@antscorp/antsomi-ui 1.8.3 → 1.8.5
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/icons/ExpandMoreIcon.d.ts +3 -0
- package/es/components/icons/ExpandMoreIcon.js +7 -0
- package/es/components/icons/index.d.ts +1 -0
- package/es/components/icons/index.js +1 -0
- package/es/components/molecules/AccountSelection/styled.js +1 -0
- package/es/components/molecules/Dropdown/Dropdown.d.ts +1 -0
- package/es/components/molecules/Dropdown/Dropdown.js +1 -1
- 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/molecules/ShareAccess/components/PeopleAccess/PeopleAccess.js +7 -3
- package/es/components/molecules/ShareAccess/constants.d.ts +1 -0
- package/es/components/molecules/ShareAccess/constants.js +1 -0
- package/es/components/molecules/ShareAccess/utils.d.ts +1 -13
- package/es/components/molecules/ShareAccess/utils.js +4 -2
- package/es/components/organism/AccountSharing/AccountSharing.d.ts +1 -0
- package/es/components/organism/AccountSharing/AccountSharing.js +110 -14
- package/es/components/organism/LeftMenu/LeftMenu.js +2 -2
- package/es/components/organism/LeftMenu/hooks/useLeftMenu.js +5 -14
- package/es/components/organism/LeftMenu/index.d.ts +1 -0
- package/es/components/template/Layout/Layout.js +7 -1
- package/es/providers/ConfigProvider/GlobalStyle.js +24 -4
- package/es/utils/cookie.d.ts +11 -0
- package/es/utils/cookie.js +33 -0
- package/es/utils/index.d.ts +1 -0
- package/es/utils/index.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import { useIcon } from './hooks/useIcon';
|
|
3
|
+
export const ExpandMoreIcon = forwardRef((props, ref) => {
|
|
4
|
+
const { width, height } = useIcon(props);
|
|
5
|
+
return (React.createElement("svg", Object.assign({ viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, props, { ref: ref, width: width, height: height }),
|
|
6
|
+
React.createElement("path", { d: "M16.5938 8.57812L18 9.98438L12 15.9844L6 9.98438L7.40625 8.57812L12 13.1719L16.5938 8.57812Z", fill: "currentColor" })));
|
|
7
|
+
});
|
|
@@ -14,7 +14,7 @@ import { Space, Typography } from 'antd';
|
|
|
14
14
|
import Icon from '@antscorp/icons';
|
|
15
15
|
import { StyledInputDropdownRoot } from './styled';
|
|
16
16
|
import clsx from 'clsx';
|
|
17
|
-
|
|
17
|
+
import './style.scss';
|
|
18
18
|
export { Dropdown } from 'antd';
|
|
19
19
|
const DefaultExpandIcon = React.createElement(Icon, { type: "icon-ants-expand-more" });
|
|
20
20
|
export const InputDropdown = (props) => {
|
|
@@ -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" },
|
|
@@ -3,12 +3,13 @@ import produce from 'immer';
|
|
|
3
3
|
import { Avatar, Dropdown, List } from 'antd';
|
|
4
4
|
import { remove, cloneDeep } from 'lodash';
|
|
5
5
|
import React, { useMemo } from 'react';
|
|
6
|
-
import { ACCESS_PROPERTIES_BY_ROLE, PEOPLE_ACTION_KEYS, ROLE_ACCESS_LABEL, ROLE_MAPPING, } from '../../constants';
|
|
6
|
+
import { ACCESS_PROPERTIES_BY_ROLE, PEOPLE_ACTION_KEYS, REGEX_REMOVE_NAME, ROLE_ACCESS_LABEL, ROLE_MAPPING, } from '../../constants';
|
|
7
7
|
import { useShareAccess } from '../../hooks';
|
|
8
8
|
import { getActionsByUser } from '../../utils';
|
|
9
9
|
import { StyledPeopleAccessRoot } from './styled';
|
|
10
10
|
import { updateModalTransferOwnership, updateObjAccessInfo } from '../../actions';
|
|
11
11
|
import { Spin } from '@antscorp/antsomi-ui/es/components/atoms';
|
|
12
|
+
import { globalToken } from '@antscorp/antsomi-ui/es/constants';
|
|
12
13
|
const ROLE_BY_ACTIONS = {
|
|
13
14
|
[PEOPLE_ACTION_KEYS.TO_OWNER]: ROLE_MAPPING.OWNER,
|
|
14
15
|
[PEOPLE_ACTION_KEYS.TO_EDITOR]: ROLE_MAPPING.EDITOR,
|
|
@@ -84,6 +85,7 @@ export const PeopleAccess = (props) => {
|
|
|
84
85
|
return (React.createElement(StyledPeopleAccessRoot, null,
|
|
85
86
|
React.createElement("div", { className: "title" }, "People with access"),
|
|
86
87
|
React.createElement(List, { dataSource: dataSourceSorted, loading: { spinning: dataSourceSorted.length === 0, indicator: React.createElement(Spin, null) }, renderItem: access => {
|
|
88
|
+
var _a;
|
|
87
89
|
const actions = getActionsByUser({
|
|
88
90
|
userId: accessUserId,
|
|
89
91
|
updatedUserId: access.userId,
|
|
@@ -97,8 +99,10 @@ export const PeopleAccess = (props) => {
|
|
|
97
99
|
return (React.createElement(List.Item, null,
|
|
98
100
|
React.createElement(Avatar, { src: access.avatar }),
|
|
99
101
|
React.createElement("div", { className: "info" },
|
|
100
|
-
React.createElement("div", { className: "name" },
|
|
101
|
-
|
|
102
|
+
React.createElement("div", { className: "name" },
|
|
103
|
+
REGEX_REMOVE_NAME.test(access.email || '') && (React.createElement("span", { style: { color: globalToken === null || globalToken === void 0 ? void 0 : globalToken.red6 } }, "[Deleted account]\u00A0")),
|
|
104
|
+
access.fullName || (access === null || access === void 0 ? void 0 : access.name)),
|
|
105
|
+
React.createElement("div", { className: "email" }, (_a = access.email) === null || _a === void 0 ? void 0 : _a.replace(REGEX_REMOVE_NAME, ''))),
|
|
102
106
|
React.createElement(Dropdown, { trigger: ['click'], disabled: !actions.length, overlayStyle: { zIndex: 3002 }, menu: {
|
|
103
107
|
items: renderActionItems(actions),
|
|
104
108
|
onClick: e => handleClickAction(e.key, access.userId),
|
|
@@ -26,19 +26,7 @@ export declare const getActionsByUser: (args: {
|
|
|
26
26
|
updatedUserId?: number;
|
|
27
27
|
objectAccessInfo?: ObjectAccessInfo;
|
|
28
28
|
omit?: Array<(typeof PEOPLE_ACTION_KEYS)[keyof typeof PEOPLE_ACTION_KEYS]>;
|
|
29
|
-
}) =>
|
|
30
|
-
readonly label: "Viewer";
|
|
31
|
-
readonly key: "to_viewer";
|
|
32
|
-
} | {
|
|
33
|
-
readonly label: "Editor";
|
|
34
|
-
readonly key: "to_editor";
|
|
35
|
-
} | {
|
|
36
|
-
readonly label: "Transfer ownership";
|
|
37
|
-
readonly key: "to_owner";
|
|
38
|
-
} | {
|
|
39
|
-
readonly label: "Remove Access";
|
|
40
|
-
readonly key: "remove_acess";
|
|
41
|
-
})[];
|
|
29
|
+
}) => any[];
|
|
42
30
|
export declare const initAccessInfoDefault: (userInfo: Partial<UserInfo>) => ObjectAccessInfo;
|
|
43
31
|
export declare const safeParseAccessInfo: (accessInfo: ObjectAccessInfo) => {
|
|
44
32
|
ownerId: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MENU_PERMISSION, PEOPLE_ACTIONS, PEOPLE_ACTION_KEYS, PUBLIC_ROLE, ROLE_ACCESS_LABEL, ROLE_MAPPING, } from './constants';
|
|
1
|
+
import { MENU_PERMISSION, PEOPLE_ACTIONS, PEOPLE_ACTION_KEYS, PUBLIC_ROLE, REGEX_REMOVE_NAME, ROLE_ACCESS_LABEL, ROLE_MAPPING, } from './constants';
|
|
2
2
|
import { remove } from 'lodash';
|
|
3
3
|
import { snakeCaseToCamelCase } from '@antscorp/antsomi-ui/es/utils';
|
|
4
4
|
export const mergePermission = (objectPermissionAllow, menuPermissionValue) => {
|
|
@@ -54,7 +54,9 @@ export const getActionsByUser = (args) => {
|
|
|
54
54
|
});
|
|
55
55
|
if ((!user && !isPublic) || !updatedUser || !allowEdit || updatedUser.userId === ownerId)
|
|
56
56
|
return [];
|
|
57
|
-
const actions =
|
|
57
|
+
const actions = REGEX_REMOVE_NAME.test(updatedUser.email || '')
|
|
58
|
+
? ['remove_acess']
|
|
59
|
+
: Object.values(PEOPLE_ACTION_KEYS);
|
|
58
60
|
if (userId !== ownerId || (omit === null || omit === void 0 ? void 0 : omit.includes('to_owner'))) {
|
|
59
61
|
remove(actions, actKey => actKey === PEOPLE_ACTION_KEYS.TO_OWNER);
|
|
60
62
|
}
|
|
@@ -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, getObjectPropSafely, 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';
|
|
@@ -40,7 +40,7 @@ const InputSearch = props => {
|
|
|
40
40
|
};
|
|
41
41
|
export const AccountSharing = props => {
|
|
42
42
|
var _a;
|
|
43
|
-
const { permissionDomain = '', iamDomain = '', token = '', accountId = 0, networkId = 0, appCode = '', lang = 'en', translateData = DEFAULT_TRANSLATE_DATA, urlEditProfile = '', callbackGetInfoAccount, urlLogout = '', isShowSharing = false, isShareAccountAccess = false, u_ogs = '', callbackLogout, } = props;
|
|
43
|
+
const { permissionDomain = '', iamDomain = '', token = '', accountId = 0, networkId = 0, appCode = '', lang = 'en', translateData = DEFAULT_TRANSLATE_DATA, urlEditProfile = '', callbackGetInfoAccount, urlLogout = '', isShowSharing = false, isShareAccountAccess = false, u_ogs = '', callbackLogout, usePrivilege = true, } = props;
|
|
44
44
|
const { appConfig } = useAppConfigContext();
|
|
45
45
|
const { env } = appConfig;
|
|
46
46
|
const selectedNetworkRef = useRef();
|
|
@@ -60,7 +60,7 @@ export const AccountSharing = props => {
|
|
|
60
60
|
const [serverTranslateData, setServerTranslateData] = useState({});
|
|
61
61
|
const [language, setLanguage] = useState(lang || 'en');
|
|
62
62
|
const debounceSearch = useDebounce(accountSearch, 500);
|
|
63
|
-
const [
|
|
63
|
+
const [, setCookie] = useCookies();
|
|
64
64
|
const domain = iamDomain.charAt(iamDomain.length - 1) === '/' ? iamDomain : `${iamDomain}/`;
|
|
65
65
|
const translateLang = useMemo(() => translate(translateData, serverTranslateData, language), [serverTranslateData, language, translateData]);
|
|
66
66
|
const getInfoAccount = () => {
|
|
@@ -120,6 +120,77 @@ export const AccountSharing = props => {
|
|
|
120
120
|
}
|
|
121
121
|
});
|
|
122
122
|
};
|
|
123
|
+
const getMenuUrl = (menu, userId = '') => {
|
|
124
|
+
if (!menu || !menu.menu_path) {
|
|
125
|
+
return '';
|
|
126
|
+
}
|
|
127
|
+
const { app_domain: appDomain, app_path: appPath, menu_path: menuPath } = menu;
|
|
128
|
+
return (appDomain + appPath + menuPath).replaceAll(':user_id', userId);
|
|
129
|
+
};
|
|
130
|
+
const redirectFirstMenu = (data, redirectAccountId) => {
|
|
131
|
+
if (!Array.isArray(data)) {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
const arrMenus = getObjectPropSafely(() => [...data].sort((first, second) => first.app_order - second.app_order)[0].childs) || [];
|
|
135
|
+
if (arrMenus && arrMenus.length) {
|
|
136
|
+
const firstMenu = arrMenus
|
|
137
|
+
.filter(menu => +menu.show_hide)
|
|
138
|
+
.sort((first, second) => first.menu_order - second.menu_order)[0];
|
|
139
|
+
if (firstMenu) {
|
|
140
|
+
const redirectUrl = getMenuUrl(firstMenu, redirectAccountId);
|
|
141
|
+
window.location.href = redirectUrl;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
const buildListAppMenus = (data, userId) => {
|
|
146
|
+
if (!Array.isArray(data) || !data.length) {
|
|
147
|
+
return [];
|
|
148
|
+
}
|
|
149
|
+
let arrMenus = [];
|
|
150
|
+
data.forEach(item => {
|
|
151
|
+
if (item.menu_id) {
|
|
152
|
+
arrMenus.push(getMenuUrl(item, userId));
|
|
153
|
+
}
|
|
154
|
+
if (item.childs && item.childs.length) {
|
|
155
|
+
arrMenus = arrMenus.concat(buildListAppMenus(item.childs, userId));
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
return arrMenus;
|
|
159
|
+
};
|
|
160
|
+
const checkRedirectHomePage = (homePage, data, userId) => {
|
|
161
|
+
const convertedHomePage = String(homePage).replace(/:user_id/g, userId);
|
|
162
|
+
if (!Array.isArray(data) || !data.length) {
|
|
163
|
+
window.location.href = convertedHomePage;
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
const arrMenus = buildListAppMenus(data, userId);
|
|
167
|
+
if (!arrMenus.some(url => convertedHomePage.includes(url))) {
|
|
168
|
+
return redirectFirstMenu(data, userId);
|
|
169
|
+
}
|
|
170
|
+
window.location.href = convertedHomePage;
|
|
171
|
+
};
|
|
172
|
+
const getAppsMenus = ({ token, userId, accountId, homePage }) => {
|
|
173
|
+
if (permissionDomain && token && userId && accountId) {
|
|
174
|
+
const apiUrl = permissionDomain + (usePrivilege ? '/api/privilege/index' : '/api/permission/index');
|
|
175
|
+
return axios({
|
|
176
|
+
url: apiUrl,
|
|
177
|
+
params: {
|
|
178
|
+
type: 'list-app',
|
|
179
|
+
_token: token,
|
|
180
|
+
_user_id: userId,
|
|
181
|
+
_account_id: accountId,
|
|
182
|
+
_lang: 'en',
|
|
183
|
+
hasChild: true,
|
|
184
|
+
from: 'login',
|
|
185
|
+
},
|
|
186
|
+
}).then(res => {
|
|
187
|
+
if (res && res.data) {
|
|
188
|
+
checkRedirectHomePage(homePage, res.data.data, userId);
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
return null;
|
|
193
|
+
};
|
|
123
194
|
const getListAccountSharing = () => {
|
|
124
195
|
if (isShareAccountAccess) {
|
|
125
196
|
const params = {
|
|
@@ -208,7 +279,11 @@ export const AccountSharing = props => {
|
|
|
208
279
|
});
|
|
209
280
|
}
|
|
210
281
|
}, [limitAccount]);
|
|
211
|
-
const filterListNetwork = useMemo(() => listNetworks.filter((netWork) => netWork.networkName.toLocaleLowerCase().indexOf(portalSearch.toLocaleLowerCase()) !==
|
|
282
|
+
const filterListNetwork = useMemo(() => listNetworks.filter((netWork) => netWork.networkName.toLocaleLowerCase().indexOf(portalSearch.toLocaleLowerCase()) !==
|
|
283
|
+
-1 ||
|
|
284
|
+
String(netWork.networkId)
|
|
285
|
+
.toLocaleLowerCase()
|
|
286
|
+
.indexOf(portalSearch.toLocaleLowerCase()) !== -1), [listNetworks, portalSearch]);
|
|
212
287
|
const logAccountSwitch = (switchAccountId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
213
288
|
// setIsShowLoading(true)
|
|
214
289
|
if (switchAccountId && isShareAccountAccess) {
|
|
@@ -229,18 +304,33 @@ export const AccountSharing = props => {
|
|
|
229
304
|
});
|
|
230
305
|
// const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms))
|
|
231
306
|
const onClickButtonLogout = useCallback(() => {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
307
|
+
// Handle remove cookie and redirect to login
|
|
308
|
+
removeAppCookieSessionSubdomainPrefix({ name: UOGS_PREFIX, env });
|
|
309
|
+
removeAppCookieSessionSubdomain({ name: 'c_pid', env });
|
|
310
|
+
removeAppCookieSessionSubdomain({ name: 'api_token', env });
|
|
311
|
+
removeAppCookieSessionSubdomain({ name: 'api_r_token', env });
|
|
312
|
+
removeAppCookieSessionSubdomain({ name: 'api_pid', env });
|
|
313
|
+
removeAppCookieSessionSubdomain({ name: 'user_id', env });
|
|
314
|
+
removeAppCookieSessionSubdomain({ name: 'user_logged_in_email', env });
|
|
315
|
+
removeAppCookieSessionSubdomain({ name: 'user_logged_in_full_name', env });
|
|
316
|
+
removeAppCookieSessionSubdomain({ name: 'user_logged_in_avatar', env });
|
|
317
|
+
removeAppCookieSessionSubdomain({ name: '_fe_ogs_pid', env });
|
|
318
|
+
localStorage.removeItem('cdp_decrypt_permission');
|
|
235
319
|
if (callbackLogout)
|
|
236
320
|
callbackLogout();
|
|
237
|
-
if
|
|
238
|
-
|
|
239
|
-
}
|
|
240
|
-
else {
|
|
321
|
+
// Check if env is dev
|
|
322
|
+
if (env === ENV.DEV) {
|
|
241
323
|
window.location.reload();
|
|
324
|
+
return;
|
|
242
325
|
}
|
|
243
|
-
|
|
326
|
+
// Handle logout with cdp domain
|
|
327
|
+
window.location.href = `${CDP_ROUTE[ENV.PROD]}/iam#/login`;
|
|
328
|
+
// if (urlLogout) {
|
|
329
|
+
// window.location.href = urlLogout;
|
|
330
|
+
// } else {
|
|
331
|
+
// window.location.reload();
|
|
332
|
+
// }
|
|
333
|
+
}, [callbackLogout, env]);
|
|
244
334
|
useEffect(() => {
|
|
245
335
|
const logoutEvent = (event) => {
|
|
246
336
|
const { data } = event;
|
|
@@ -328,7 +418,13 @@ export const AccountSharing = props => {
|
|
|
328
418
|
}
|
|
329
419
|
}
|
|
330
420
|
if (selectedNetworkRef.current && selectedNetworkRef.current.homePage) {
|
|
331
|
-
|
|
421
|
+
getAppsMenus({
|
|
422
|
+
token: postParam.token,
|
|
423
|
+
userId: accountId,
|
|
424
|
+
accountId,
|
|
425
|
+
homePage: selectedNetworkRef.current.homePage,
|
|
426
|
+
});
|
|
427
|
+
// window.location.href = selectedNetworkRef.current.homePage.replaceAll(':user_id', accountId);
|
|
332
428
|
}
|
|
333
429
|
};
|
|
334
430
|
const handleLoginData = (data = null) => {
|
|
@@ -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" },
|
|
@@ -13,8 +13,8 @@ import { DASHBOARD_MODULE_CONFIG } from '../../../template/Layout/constants';
|
|
|
13
13
|
import { usePermission } from './usePermission';
|
|
14
14
|
import { useCustomRouter, useDeepCompareEffect } from '@antscorp/antsomi-ui/es/hooks';
|
|
15
15
|
import { useNavigatePath } from './useNavigatePath';
|
|
16
|
+
const cookies = new ReactCookies();
|
|
16
17
|
export const useLeftMenu = (props) => {
|
|
17
|
-
// Props
|
|
18
18
|
const { objectType = DASHBOARD_MODULE_CONFIG.objectType, objectId = DASHBOARD_MODULE_CONFIG.objectId, isGrouped = DASHBOARD_MODULE_CONFIG.isGrouped, appConfig, customization, onActiveMenuCodeChange, } = props;
|
|
19
19
|
const { defaultExpandMenu, type, items, activeKey, onMenuItemClick } = customization || {};
|
|
20
20
|
const mappedActiveKey = useMemo(() => {
|
|
@@ -36,7 +36,6 @@ export const useLeftMenu = (props) => {
|
|
|
36
36
|
return activeKey;
|
|
37
37
|
}
|
|
38
38
|
}, [activeKey, type]);
|
|
39
|
-
const cookies = new ReactCookies();
|
|
40
39
|
const { pathname, hash, origin } = window.location;
|
|
41
40
|
const { navigate } = useCustomRouter();
|
|
42
41
|
const { isPushDifferentDomain, getPath, navigatePath } = useNavigatePath();
|
|
@@ -46,21 +45,13 @@ export const useLeftMenu = (props) => {
|
|
|
46
45
|
const { auth, env } = appConfig || {};
|
|
47
46
|
const timeoutPopover = useRef(null);
|
|
48
47
|
const openLeftMenuCookies = cookies.get('_leftmenu_state');
|
|
49
|
-
const isOpenMenu = !isNil(openLeftMenuCookies) ? Boolean(openLeftMenuCookies) :
|
|
48
|
+
const isOpenMenu = !isNil(openLeftMenuCookies) ? Boolean(openLeftMenuCookies) : false;
|
|
50
49
|
const [state, setState] = useState({
|
|
51
50
|
hoverItem: '',
|
|
52
51
|
isShowPopover: false,
|
|
53
|
-
isExpandMenu:
|
|
52
|
+
isExpandMenu: isBoolean(defaultExpandMenu) ? defaultExpandMenu : isOpenMenu,
|
|
54
53
|
});
|
|
55
54
|
const { mappingChildrenMenu, flattenMenuPermission, menuListPermission, permissionMenu, activeItemPath, } = usePermission();
|
|
56
|
-
useEffect(() => {
|
|
57
|
-
if (isBoolean(defaultExpandMenu)) {
|
|
58
|
-
setState(prev => (Object.assign(Object.assign({}, prev), { isExpandMenu: defaultExpandMenu })));
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
setState(prev => (Object.assign(Object.assign({}, prev), { isExpandMenu: isOpenMenu })));
|
|
62
|
-
}
|
|
63
|
-
}, [defaultExpandMenu, isOpenMenu]);
|
|
64
55
|
const onMenuClick = useCallback((key, keyPath) => {
|
|
65
56
|
if (type === 'recommendation') {
|
|
66
57
|
setLeftMenuContextState({ customActiveCurrentKey: key });
|
|
@@ -68,7 +59,7 @@ export const useLeftMenu = (props) => {
|
|
|
68
59
|
onMenuItemClick === null || onMenuItemClick === void 0 ? void 0 : onMenuItemClick(key, [...keyPath, customActiveAppKey]);
|
|
69
60
|
}, [customActiveAppKey, onMenuItemClick, setLeftMenuContextState, type]);
|
|
70
61
|
useDeepCompareEffect(() => {
|
|
71
|
-
if (
|
|
62
|
+
if (defaultExpandMenu === undefined) {
|
|
72
63
|
cookies.set('_leftmenu_state', state.isExpandMenu ? 1 : 0, {
|
|
73
64
|
domain: `.${origin.split('.').splice(-2).join('.')}`,
|
|
74
65
|
path: '/',
|
|
@@ -76,7 +67,7 @@ export const useLeftMenu = (props) => {
|
|
|
76
67
|
secure: true,
|
|
77
68
|
});
|
|
78
69
|
}
|
|
79
|
-
}, [
|
|
70
|
+
}, [cookies, defaultExpandMenu, origin, state.isExpandMenu]);
|
|
80
71
|
useDeepCompareEffect(() => {
|
|
81
72
|
setLeftMenuContextState({
|
|
82
73
|
appConfig,
|
|
@@ -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
|
|
@@ -186,14 +186,34 @@ export const GlobalStyle = () => {
|
|
|
186
186
|
|
|
187
187
|
// NOTE: Just hot fix for easy looking
|
|
188
188
|
.antsomi-btn-primary.antsomi-btn-compact-item.antsomi-btn-compact-first-item {
|
|
189
|
-
padding-right:
|
|
189
|
+
padding-right: 6px !important;
|
|
190
190
|
}
|
|
191
191
|
.antsomi-btn-compact-item.antsomi-btn-primary.antsomi-btn-compact-last-item {
|
|
192
192
|
width: fit-content;
|
|
193
|
-
padding: 0px !important;
|
|
194
|
-
padding
|
|
193
|
+
//padding: 0px !important;
|
|
194
|
+
padding: 0px 4px !important;
|
|
195
195
|
&::before {
|
|
196
|
-
|
|
196
|
+
content: '';
|
|
197
|
+
position: absolute;
|
|
198
|
+
left: 0px;
|
|
199
|
+
background-color: ${globalToken === null || globalToken === void 0 ? void 0 : globalToken.blue5} !important;
|
|
200
|
+
top: auto !important;
|
|
201
|
+
height: 80% !important;
|
|
202
|
+
width: 1px !important;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
&:disabled {
|
|
206
|
+
&::before {
|
|
207
|
+
background-color: ${globalToken === null || globalToken === void 0 ? void 0 : globalToken.bw4} !important;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
&:not(:disabled) {
|
|
212
|
+
&:hover {
|
|
213
|
+
&:: before {
|
|
214
|
+
opacity: 0;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
197
217
|
}
|
|
198
218
|
}
|
|
199
219
|
|
|
@@ -0,0 +1,11 @@
|
|
|
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 removeAppCookieSession: (args: RemoveCookieSubDomain) => void;
|
|
10
|
+
export declare const removeAppCookieSessionSubdomainPrefix: (args: RemoveCookieSubDomain) => void;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Libraries
|
|
2
|
+
import { Cookies } from 'react-cookie';
|
|
3
|
+
import { ENV } from '../config';
|
|
4
|
+
const cookies = new Cookies(null, {
|
|
5
|
+
path: '/',
|
|
6
|
+
sameSite: 'none',
|
|
7
|
+
secure: true,
|
|
8
|
+
});
|
|
9
|
+
export const removeCookieSubDomain = ({ name, env = 'development', cookieOptions, }) => {
|
|
10
|
+
const arrTmp = location.hostname.split('.');
|
|
11
|
+
cookies.remove(name, Object.assign(Object.assign(Object.assign({}, (env !== ENV.DEV && {
|
|
12
|
+
domain: `.${arrTmp.length < 4 ? arrTmp.slice(-2).join('.') : arrTmp.slice(-3).join('.')}`,
|
|
13
|
+
})), { path: '/', sameSite: 'none', secure: true }), cookieOptions));
|
|
14
|
+
};
|
|
15
|
+
export const removeAppCookieSessionSubdomain = (args) => {
|
|
16
|
+
removeCookieSubDomain(args);
|
|
17
|
+
if (typeof Storage !== undefined) {
|
|
18
|
+
sessionStorage.removeItem(args.name);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
export const removeAppCookieSession = (args) => {
|
|
22
|
+
cookies.remove(args === null || args === void 0 ? void 0 : args.name, args === null || args === void 0 ? void 0 : args.cookieOptions);
|
|
23
|
+
if (typeof Storage !== undefined) {
|
|
24
|
+
sessionStorage.removeItem(args.name);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
export const removeAppCookieSessionSubdomainPrefix = (args) => {
|
|
28
|
+
Object.keys(cookies.getAll()).forEach(cookieName => {
|
|
29
|
+
if (cookieName.startsWith(args.name)) {
|
|
30
|
+
removeAppCookieSessionSubdomain(Object.assign(Object.assign({}, args), { name: cookieName }));
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
};
|
package/es/utils/index.d.ts
CHANGED
package/es/utils/index.js
CHANGED