@antscorp/antsomi-ui 1.3.5-beta.597 → 1.3.5-beta.599
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.
- package/es/components/molecules/HeaderV2/HeaderV2.d.ts +1 -0
- package/es/components/molecules/HeaderV2/HeaderV2.js +2 -2
- package/es/components/molecules/HeaderV2/styled.js +1 -0
- package/es/components/organism/AccountSharing/AccountSharing.js +25 -10
- package/es/components/organism/LeftMenu/LeftMenu.js +2 -2
- package/es/components/organism/LeftMenu/index.d.ts +1 -0
- package/es/components/template/Layout/Layout.js +7 -1
- package/es/utils/cookie.d.ts +10 -0
- package/es/utils/cookie.js +23 -0
- package/es/utils/index.d.ts +1 -0
- package/es/utils/index.js +1 -0
- package/package.json +1 -1
|
@@ -32,7 +32,7 @@ export const HeaderV2 = memo(props => {
|
|
|
32
32
|
const { search } = useLocation();
|
|
33
33
|
const { replace } = useCustomRouter();
|
|
34
34
|
// * Prefer to use Header in AppConfigContext
|
|
35
|
-
const { show = true, className, style, breadcrumbs, showLogo = false, rightContent, pageTitle = '', accountSelection = {}, helpConfig, notificationConfig = {}, accountSharingConfig, useURLParam, config, } = props;
|
|
35
|
+
const { show = true, className, style, breadcrumbs, showLogo = false, rightContent, pageTitle = '', accountSelection = {}, helpConfig, notificationConfig = {}, accountSharingConfig, useURLParam, config, onCLickLogo, } = props;
|
|
36
36
|
/** General config for children component */
|
|
37
37
|
const { env = envContext, language = languageCode, userId = isNaN(Number(auth === null || auth === void 0 ? void 0 : auth.userId)) ? 0 : Number(auth === null || auth === void 0 ? void 0 : auth.userId), portalId = auth === null || auth === void 0 ? void 0 : auth.portalId, token = auth === null || auth === void 0 ? void 0 : auth.token, permissionDomain = PERMISSION_API, iamDomain = IAM_API, appCode = contextAppCode, menuCode = contextMenuCode, } = config || {};
|
|
38
38
|
const { currentAccount, inputStyle = 'select', onSelectAccount } = accountSelection, accountSelectionProps = __rest(accountSelection, ["currentAccount", "inputStyle", "onSelectAccount"]);
|
|
@@ -110,7 +110,7 @@ export const HeaderV2 = memo(props => {
|
|
|
110
110
|
const QUOTE_ENTITY = React.createElement(React.Fragment, null, "\u00BB");
|
|
111
111
|
return (React.createElement(HeaderV2Styled, { "$show": show, className: className || '', style: style },
|
|
112
112
|
React.createElement("div", { className: "left-side" },
|
|
113
|
-
showLogo && (React.createElement(LogoWrapper, { className: "logo-wrapper" },
|
|
113
|
+
showLogo && (React.createElement(LogoWrapper, { className: "logo-wrapper", onClick: onCLickLogo },
|
|
114
114
|
React.createElement("img", { src: SubLogoAntsomi, alt: "Antsomi sub logo" }))),
|
|
115
115
|
React.createElement(AccountSelection, Object.assign({}, accountSelectionProps, { currentAccount: selectedAccount, apiConfig: accountSelectionApiConfig, onChange: handleChangeAccount, inputStyle: inputStyle, refreshOnSelect: true })),
|
|
116
116
|
React.createElement("div", { className: "title-container" },
|
|
@@ -19,12 +19,12 @@ import CloseIcon from './icons/close';
|
|
|
19
19
|
import SearchIcon from './icons/search';
|
|
20
20
|
import { InnerCardStyled, InputSearchStyled, PackageSharingStyled, TriggerPopoverStyled, } from './styled';
|
|
21
21
|
// Utils
|
|
22
|
-
import { formatUserId } from '@antscorp/antsomi-ui/es/utils';
|
|
22
|
+
import { formatUserId, removeAppCookieSessionSubdomain, removeAppCookieSessionSubdomainPrefix, } from '@antscorp/antsomi-ui/es/utils';
|
|
23
23
|
import { translate } from './utils';
|
|
24
24
|
import Icon from '@antscorp/icons';
|
|
25
25
|
import { useDebounce } from '@antscorp/antsomi-ui/es/hooks/useDebounceV2';
|
|
26
26
|
import { DEFAULT_TRANSLATE_DATA } from './constant';
|
|
27
|
-
import { THEME, UOGS_PREFIX } from '@antscorp/antsomi-ui/es/constants';
|
|
27
|
+
import { CDP_ROUTE, THEME, UOGS_PREFIX } from '@antscorp/antsomi-ui/es/constants';
|
|
28
28
|
import { useAppConfigContext } from '../../..';
|
|
29
29
|
// Constants
|
|
30
30
|
import { ENV } from '@antscorp/antsomi-ui/es/config';
|
|
@@ -229,18 +229,33 @@ export const AccountSharing = props => {
|
|
|
229
229
|
});
|
|
230
230
|
// const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms))
|
|
231
231
|
const onClickButtonLogout = useCallback(() => {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
232
|
+
// Handle remove cookie and redirect to login
|
|
233
|
+
removeAppCookieSessionSubdomainPrefix({ name: UOGS_PREFIX, env });
|
|
234
|
+
removeAppCookieSessionSubdomain({ name: 'c_pid', env });
|
|
235
|
+
removeAppCookieSessionSubdomain({ name: 'api_token', env });
|
|
236
|
+
removeAppCookieSessionSubdomain({ name: 'api_r_token', env });
|
|
237
|
+
removeAppCookieSessionSubdomain({ name: 'api_pid', env });
|
|
238
|
+
removeAppCookieSessionSubdomain({ name: 'user_id', env });
|
|
239
|
+
removeAppCookieSessionSubdomain({ name: 'user_logged_in_email', env });
|
|
240
|
+
removeAppCookieSessionSubdomain({ name: 'user_logged_in_full_name', env });
|
|
241
|
+
removeAppCookieSessionSubdomain({ name: 'user_logged_in_avatar', env });
|
|
242
|
+
removeAppCookieSessionSubdomain({ name: '_fe_ogs_pid', env });
|
|
243
|
+
localStorage.removeItem('cdp_decrypt_permission');
|
|
235
244
|
if (callbackLogout)
|
|
236
245
|
callbackLogout();
|
|
237
|
-
if
|
|
238
|
-
|
|
239
|
-
}
|
|
240
|
-
else {
|
|
246
|
+
// Check if env is dev
|
|
247
|
+
if (env === ENV.DEV) {
|
|
241
248
|
window.location.reload();
|
|
249
|
+
return;
|
|
242
250
|
}
|
|
243
|
-
|
|
251
|
+
// Handle logout with cdp domain
|
|
252
|
+
window.location.href = `${CDP_ROUTE[ENV.PROD]}/iam#/login`;
|
|
253
|
+
// if (urlLogout) {
|
|
254
|
+
// window.location.href = urlLogout;
|
|
255
|
+
// } else {
|
|
256
|
+
// window.location.reload();
|
|
257
|
+
// }
|
|
258
|
+
}, [callbackLogout, env]);
|
|
244
259
|
useEffect(() => {
|
|
245
260
|
const logoutEvent = (event) => {
|
|
246
261
|
const { data } = event;
|
|
@@ -18,7 +18,7 @@ import { useLeftMenuContext } from './contexts';
|
|
|
18
18
|
const SubLogoAntsomi = 'https://st-media-template.antsomi.com/icons/antsomi/antsomi.png';
|
|
19
19
|
const homePermissionCode = 'DASHBOARD';
|
|
20
20
|
export const LeftMenuComponent = memo(props => {
|
|
21
|
-
const { show = true, style, className, customization, showLogo = true } = props;
|
|
21
|
+
const { show = true, style, className, customization, showLogo = true, onClickLogo } = props;
|
|
22
22
|
const { showMenuPopover = true, showButtonExpand = true, type, items = [], onMenuItemClick, } = customization || {};
|
|
23
23
|
const appHoverMenuChildren = useLeftMenuContext(store => store.appHoverMenuChildren);
|
|
24
24
|
const customHoverMenuChildren = useLeftMenuContext(store => store.customHoverMenuChildren);
|
|
@@ -109,7 +109,7 @@ export const LeftMenuComponent = memo(props => {
|
|
|
109
109
|
return (React.createElement(LeftMenuNavWrapper, { "$show": show, style: style, "$isExpandMenu": state.isExpandMenu, className: className },
|
|
110
110
|
React.createElement(LeftMenuNav, { className: "left-menu-nav" },
|
|
111
111
|
React.createElement(FeatureMenuWrapper, { vertical: true, onMouseEnter: () => onShowPopover(), onMouseLeave: onMouseLeave },
|
|
112
|
-
showLogo && (React.createElement(NavLogoWrapper, { align: "center", justify: "center", onMouseEnter: onHoverMenuBar },
|
|
112
|
+
showLogo && (React.createElement(NavLogoWrapper, { align: "center", justify: "center", onMouseEnter: onHoverMenuBar, onClick: onClickLogo },
|
|
113
113
|
React.createElement("div", { className: "image-wrapper" },
|
|
114
114
|
React.createElement("img", { src: SubLogoAntsomi, alt: "Antsomi sub logo" })))),
|
|
115
115
|
React.createElement(FeatureMenu, { role: "menu", className: "antsomi-scroll-box" },
|
|
@@ -20,6 +20,7 @@ export interface LeftMenuProps {
|
|
|
20
20
|
defaultExpandMenu?: boolean;
|
|
21
21
|
onMenuItemClick?: (key: string, keyPath: string[]) => void;
|
|
22
22
|
};
|
|
23
|
+
onClickLogo?: () => void;
|
|
23
24
|
onActiveMenuCodeChange?: (activeItemPath: TFeatureMenu[], flattenPermissionList?: FeatureMenuPermission[], menuListPermission?: FeatureMenuPermission[]) => void;
|
|
24
25
|
}
|
|
25
26
|
export declare const LeftMenu: React.MemoExoticComponent<(props: LeftMenuProps) => React.JSX.Element | null>;
|
|
@@ -276,6 +276,12 @@ export const Layout = memo(props => {
|
|
|
276
276
|
}
|
|
277
277
|
}
|
|
278
278
|
}, [antsProcessingNotificationConfig, env]);
|
|
279
|
+
const onCLickLogo = useCallback(() => {
|
|
280
|
+
// Redirect to recommendation
|
|
281
|
+
if (env !== ENV.DEV) {
|
|
282
|
+
window.location.assign(`${CDP_ROUTE[env || 'development']}/gen2/${portalId}/dashboard/recommendation`);
|
|
283
|
+
}
|
|
284
|
+
}, [env, portalId]);
|
|
279
285
|
return (React.createElement(LayoutWrapper, { showLeftMenu: !!showLeftMenu },
|
|
280
286
|
React.createElement(Helmet, null,
|
|
281
287
|
React.createElement("meta", { charSet: "utf-8" }),
|
|
@@ -285,7 +291,7 @@ export const Layout = memo(props => {
|
|
|
285
291
|
? header === null || header === void 0 ? void 0 : header.pageTitle
|
|
286
292
|
: ''
|
|
287
293
|
: activePageTitle))),
|
|
288
|
-
React.createElement(HeaderV2, Object.assign({}, mergeHeaderProps, { show: !showOnlyContent, showLogo: !showLeftMenu })),
|
|
294
|
+
React.createElement(HeaderV2, Object.assign({}, mergeHeaderProps, { show: !showOnlyContent, showLogo: !showLeftMenu, onCLickLogo: onCLickLogo })),
|
|
289
295
|
React.createElement(Flex, { className: "layout-body" },
|
|
290
296
|
React.createElement(LeftMenu, Object.assign({ show: showLeftMenu && !showOnlyContent, className: `layout-body__menu ${leftMenuClassName}` }, mergeLeftMenuProps, { customization: Object.assign(Object.assign({}, mergeLeftMenuProps.customization), {
|
|
291
297
|
// If user has access denied, disable expandable
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TEnv } from '../types/config';
|
|
2
|
+
interface RemoveCookieSubDomain {
|
|
3
|
+
name: string;
|
|
4
|
+
env?: TEnv;
|
|
5
|
+
cookieOptions?: Record<string, any>;
|
|
6
|
+
}
|
|
7
|
+
export declare const removeCookieSubDomain: ({ name, env, cookieOptions, }: RemoveCookieSubDomain) => void;
|
|
8
|
+
export declare const removeAppCookieSessionSubdomain: (args: RemoveCookieSubDomain) => void;
|
|
9
|
+
export declare const removeAppCookieSessionSubdomainPrefix: (args: RemoveCookieSubDomain) => void;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Libraries
|
|
2
|
+
import { Cookies } from 'react-cookie';
|
|
3
|
+
import { ENV } from '../config';
|
|
4
|
+
const cookies = new Cookies();
|
|
5
|
+
export const removeCookieSubDomain = ({ name, env = 'development', cookieOptions, }) => {
|
|
6
|
+
const arrTmp = location.hostname.split('.');
|
|
7
|
+
cookies.remove(name, Object.assign(Object.assign(Object.assign({}, (env !== ENV.DEV && {
|
|
8
|
+
domain: `.${arrTmp.length < 4 ? arrTmp.slice(-2).join('.') : arrTmp.slice(-3).join('.')}`,
|
|
9
|
+
})), { path: '/', sameSite: 'none', secure: true }), cookieOptions));
|
|
10
|
+
};
|
|
11
|
+
export const removeAppCookieSessionSubdomain = (args) => {
|
|
12
|
+
removeCookieSubDomain(args);
|
|
13
|
+
if (typeof Storage !== undefined) {
|
|
14
|
+
sessionStorage.removeItem(args.name);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
export const removeAppCookieSessionSubdomainPrefix = (args) => {
|
|
18
|
+
Object.keys(cookies.getAll()).forEach(cookieName => {
|
|
19
|
+
if (cookieName.startsWith(args.name)) {
|
|
20
|
+
removeAppCookieSessionSubdomain(Object.assign(Object.assign({}, args), { name: cookieName }));
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
};
|
package/es/utils/index.d.ts
CHANGED
package/es/utils/index.js
CHANGED