@antscorp/antsomi-ui 1.3.7-beta.65 → 1.3.7-beta.67

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,6 +18,7 @@ import SearchIcon from './icons/search';
18
18
  import { InnerCardStyled, InputSearchStyled, PackageSharingStyled, TriggerPopoverStyled, } from './styled';
19
19
  // Utils
20
20
  import { formatUserId, getObjectPropSafely, removeAppCookieSessionSubdomain, removeAppCookieSessionSubdomainPrefix, setCookieSession, } from '@antscorp/antsomi-ui/es/utils';
21
+ import { createCrossSubdomainCookieOptions } from '@antscorp/antsomi-ui/es/utils/crossSubdomainCookieOptions';
21
22
  import { translate } from './utils';
22
23
  import Icon from '@antscorp/icons';
23
24
  import { useDebounce } from '@antscorp/antsomi-ui/es/hooks/useDebounceV2';
@@ -364,7 +365,6 @@ export const AccountSharing = props => {
364
365
  if (postParam.error && postParam.error !== '')
365
366
  return;
366
367
  const newUrlObj = urlDomain(selectedNetworkRef?.current?.homePage);
367
- const arrTmp = newUrlObj.hostname.split('.');
368
368
  if (postParam.action === 'ogs-authenticate') {
369
369
  const loginData = { ...postParam };
370
370
  if (loginData.full_name) {
@@ -398,34 +398,11 @@ export const AccountSharing = props => {
398
398
  prefix = u_ogs.slice(0, index);
399
399
  }
400
400
  const newU_ogs = prefix + selectedNetworkRef?.current?.networkId;
401
- if (newUrlObj.protocol !== 'https:') {
402
- if (arrTmp.length < 4) {
403
- setCookie(newU_ogs, JSON.stringify(loginData), {
404
- domain: arrTmp.slice(-2).join('.'),
405
- path: '/; samesite=None',
406
- });
407
- }
408
- else {
409
- setCookie(newU_ogs, JSON.stringify(loginData), {
410
- domain: arrTmp.slice(-3).join('.'),
411
- path: '/; samesite=None',
412
- });
413
- }
414
- }
415
- else {
416
- if (arrTmp.length < 4) {
417
- setCookie(newU_ogs, JSON.stringify(loginData), {
418
- domain: arrTmp.slice(-2).join('.'),
419
- path: '/; samesite=None; secure',
420
- });
421
- }
422
- else {
423
- setCookie(newU_ogs, JSON.stringify(loginData), {
424
- domain: arrTmp.slice(-3).join('.'),
425
- path: '/; samesite=None; secure',
426
- });
427
- }
428
- }
401
+ const cookieOptions = createCrossSubdomainCookieOptions({
402
+ hostname: newUrlObj.hostname,
403
+ protocol: newUrlObj.protocol,
404
+ });
405
+ setCookie(newU_ogs, JSON.stringify(loginData), cookieOptions);
429
406
  }
430
407
  }
431
408
  if (portalRedirectUrl) {
@@ -59,21 +59,21 @@ export const LeftMenuComponent = memo(props => {
59
59
  const isActive = activeAppCode === menu_item_code;
60
60
  const isHover = state.hoverItem === menu_item_code;
61
61
  let Label = null;
62
- Label = (_jsxs("li", { role: "menuitem", className: classNames({ isActive, isHover }), children: [renderMenuIcon(component_icon_name || icon_name || ''), _jsx(Typography.Text, { children: menu_item_name }), showMenuPopover && _jsx("div", { className: "popup-triangle" })] }));
62
+ Label = (_jsxs("li", { role: "menuitem", className: classNames('menu_item', { isActive, isHover }), children: [renderMenuIcon(component_icon_name || icon_name || ''), _jsx(Typography.Text, { ellipsis: { tooltip: menu_item_name }, children: menu_item_name }), showMenuPopover && _jsx("div", { className: "popup-triangle" })] }));
63
63
  return (_jsx(FeatureMenuItem, { onClick: () => onClickFeatureMenuItem(item), onMouseEnter: () => onMouseEnter(menu_item_code), children: Label }, menu_item));
64
64
  }, [activeAppCode, state.hoverItem, showMenuPopover, onMouseEnter, onClickFeatureMenuItem]);
65
65
  const renderRecommendationMenuItem = useCallback((item) => {
66
66
  const { menu_item_name, menu_item, component_icon_name, icon_name, permission_code } = item;
67
67
  const isActive = customActiveAppKey === permission_code;
68
68
  const isHover = state.hoverItem === permission_code;
69
- const renderLabel = () => (_jsxs("li", { role: "menuitem", className: classNames({ isActive, isHover }), onClick: () => onMenuItemClick?.(permission_code || 'null', [permission_code || 'null']), children: [renderMenuIcon(component_icon_name || icon_name || ''), _jsx(Typography.Text, { children: menu_item_name })] }));
69
+ const renderLabel = () => (_jsxs("li", { role: "menuitem", className: classNames('menu_item', { isActive, isHover }), onClick: () => onMenuItemClick?.(permission_code || 'null', [permission_code || 'null']), children: [renderMenuIcon(component_icon_name || icon_name || ''), _jsx(Typography.Text, { ellipsis: { tooltip: menu_item_name }, children: menu_item_name })] }));
70
70
  return (_jsx(FeatureMenuItem, { onMouseEnter: () => onMouseEnter(permission_code || 'null'), children: renderLabel() }, menu_item));
71
71
  }, [customActiveAppKey, onMenuItemClick, onMouseEnter, state.hoverItem]);
72
72
  const renderCustomizedMenuItems = useCallback((items) => items?.map(item => {
73
73
  const { key, icon, label } = item;
74
74
  const isActive = key === customActiveAppKey;
75
75
  const isHover = key === state.hoverItem;
76
- return (_jsx(FeatureMenuItem, { onClick: () => onMenuItemClick?.(key, [key]), onMouseEnter: () => onMouseEnter(key), children: _jsxs("li", { role: "menuitem", className: classNames({ isActive, isHover }), children: [renderMenuIcon(icon || ''), _jsx(Typography.Text, { children: label }), showMenuPopover && _jsx("div", { className: "popup-triangle" })] }) }, key));
76
+ return (_jsx(FeatureMenuItem, { onClick: () => onMenuItemClick?.(key, [key]), onMouseEnter: () => onMouseEnter(key), children: _jsxs("li", { role: "menuitem", className: classNames('menu_item', { isActive, isHover }), children: [renderMenuIcon(icon || ''), _jsx(Typography.Text, { ellipsis: { tooltip: label }, children: label }), showMenuPopover && _jsx("div", { className: "popup-triangle" })] }) }, key));
77
77
  }), [customActiveAppKey, state.hoverItem, showMenuPopover, onMenuItemClick, onMouseEnter]);
78
78
  const renderAppMenuItems = useCallback(() => type === 'customization'
79
79
  ? renderCustomizedMenuItems(items)
@@ -163,6 +163,8 @@ export const FeatureMenuItem = styled.div `
163
163
  font-size: 11px !important;
164
164
  font-weight: 500;
165
165
  color: inherit;
166
+ width: 100%;
167
+ text-align: center;
166
168
  }
167
169
 
168
170
  .menu-item__icon {
@@ -17,6 +17,7 @@ import { LoginSelectPortal, LoginWithGG, SignIn, VerifyAccount, SetupGGAuthentic
17
17
  import { useContainerDimensions } from './hooks';
18
18
  // Utils
19
19
  import { checkURL, navigateTo } from './utils';
20
+ import { createCrossSubdomainCookieOptions } from '@antscorp/antsomi-ui/es/utils/crossSubdomainCookieOptions';
20
21
  import { LOGIN_METHODS, STEPS } from './constants';
21
22
  import { LoginBannerZone, LoginMain, WrapperLogin } from './styled';
22
23
  export const Login = props => {
@@ -439,7 +440,6 @@ export const Login = props => {
439
440
  if (postParam.error && postParam.error !== '') {
440
441
  }
441
442
  else {
442
- const arrTmp = window.location.hostname.split('.');
443
443
  if (postParam.action === 'ogs-authenticate') {
444
444
  const loginData = { ...postParam, type: 'all_account' };
445
445
  if (loginData.hasOwnProperty('full_name')) {
@@ -463,38 +463,12 @@ export const Login = props => {
463
463
  ? u_ogs
464
464
  : `${u_ogs}_${selectedNetworkRef.current?.networkId}`;
465
465
  const maxAge = 30 * 24 * 3600;
466
- if (window.location.protocol !== 'https:') {
467
- if (arrTmp.length < 4) {
468
- setCookie(cookieKey, JSON.stringify(loginData), {
469
- domain: arrTmp.slice(-2).join('.'),
470
- path: '/; samesite=None',
471
- maxAge,
472
- });
473
- }
474
- else {
475
- setCookie(cookieKey, JSON.stringify(loginData), {
476
- domain: arrTmp.slice(-3).join('.'),
477
- path: '/; samesite=None',
478
- maxAge,
479
- });
480
- }
481
- }
482
- else {
483
- if (arrTmp.length < 4) {
484
- setCookie(cookieKey, JSON.stringify(loginData), {
485
- domain: arrTmp.slice(-2).join('.'),
486
- path: '/; samesite=None; secure',
487
- maxAge,
488
- });
489
- }
490
- else {
491
- setCookie(cookieKey, JSON.stringify(loginData), {
492
- domain: arrTmp.slice(-3).join('.'),
493
- path: '/; samesite=None; secure',
494
- maxAge,
495
- });
496
- }
497
- }
466
+ const cookieOptions = createCrossSubdomainCookieOptions({
467
+ hostname: window.location.hostname,
468
+ protocol: window.location.protocol,
469
+ maxAge,
470
+ });
471
+ setCookie(cookieKey, JSON.stringify(loginData), cookieOptions);
498
472
  }
499
473
  }
500
474
  if (doPostEvent) {
@@ -0,0 +1,14 @@
1
+ interface CrossSubdomainCookieOptionsInput {
2
+ hostname: string;
3
+ protocol: string;
4
+ maxAge?: number;
5
+ }
6
+ export interface CrossSubdomainCookieOptions {
7
+ domain: string;
8
+ path: '/';
9
+ sameSite: 'none';
10
+ secure?: true;
11
+ maxAge?: number;
12
+ }
13
+ export declare function createCrossSubdomainCookieOptions({ hostname, protocol, maxAge, }: CrossSubdomainCookieOptionsInput): CrossSubdomainCookieOptions;
14
+ export {};
@@ -0,0 +1,12 @@
1
+ export function createCrossSubdomainCookieOptions({ hostname, protocol, maxAge, }) {
2
+ const hostnameParts = hostname.split('.');
3
+ return {
4
+ domain: hostnameParts.length < 4
5
+ ? hostnameParts.slice(-2).join('.')
6
+ : hostnameParts.slice(-3).join('.'),
7
+ path: '/',
8
+ sameSite: 'none',
9
+ ...(protocol === 'https:' && { secure: true }),
10
+ ...(maxAge !== undefined && { maxAge }),
11
+ };
12
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.3.7-beta.65",
3
+ "version": "1.3.7-beta.67",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",