@antscorp/antsomi-ui 1.3.5-beta.227 → 1.3.5-beta.229
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.js +4 -4
- package/es/components/organism/AlgorithmsSetting/index.js +0 -1
- package/es/components/organism/LeftMenu/components/HomeMenu/useHomeMenu.js +1 -5
- package/es/components/organism/LeftMenu/components/common/ChildMenu/index.js +5 -10
- package/es/components/organism/LeftMenu/components/common/ChildMenu/utils.js +3 -2
- package/es/components/organism/LeftMenu/constants/sampleData.d.ts +2 -5
- package/es/components/organism/LeftMenu/hooks/useLeftMenu.js +14 -23
- package/es/components/organism/LeftMenu/hooks/useNavigatePath.d.ts +1 -1
- package/es/components/organism/LeftMenu/hooks/useNavigatePath.js +11 -8
- package/es/components/organism/LeftMenu/index.d.ts +6 -0
- package/es/components/organism/LeftMenu/index.js +10 -5
- package/es/components/organism/LeftMenu/stores/index.d.ts +2 -0
- package/es/components/organism/LeftMenu/utils/index.d.ts +5 -0
- package/es/components/organism/LeftMenu/utils/index.js +17 -3
- package/es/components/template/Layout/Layout.js +4 -3
- package/package.json +1 -1
|
@@ -41,12 +41,12 @@ export const HeaderV2 = memo(props => {
|
|
|
41
41
|
if (!oidParam) {
|
|
42
42
|
// urlParams.append('oid', 'ALL_ACCOUNT');
|
|
43
43
|
// urlParams.append('oid', `${currentAccount ?? userId ?? 'ALL_ACCOUNT'}`);
|
|
44
|
-
const newUrl = `${window.location.pathname}?${urlParams.toString()}${window.location.hash}`;
|
|
45
|
-
window.history.replaceState(null, '', newUrl);
|
|
44
|
+
// const newUrl = `${window.location.pathname}?${urlParams.toString()}${window.location.hash}`;
|
|
45
|
+
// window.history.replaceState(null, '', newUrl);
|
|
46
46
|
}
|
|
47
47
|
else {
|
|
48
|
-
const newUrl = `${window.location.pathname}?${urlParams.toString()}${window.location.hash}`;
|
|
49
|
-
window.history.replaceState(null, '', newUrl);
|
|
48
|
+
// const newUrl = `${window.location.pathname}?${urlParams.toString()}${window.location.hash}`;
|
|
49
|
+
// window.history.replaceState(null, '', newUrl);
|
|
50
50
|
}
|
|
51
51
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
52
52
|
}, [oidParam, useURLParam, userId]);
|
|
@@ -730,7 +730,6 @@ export const AlgorithmsSetting = (props) => {
|
|
|
730
730
|
rowGap: '20px',
|
|
731
731
|
columnGap: '40px',
|
|
732
732
|
alignItems: 'center',
|
|
733
|
-
padding: '0px 8px 8px',
|
|
734
733
|
} },
|
|
735
734
|
React.createElement(Text, { color: isCDP ? (_b = THEME.token) === null || _b === void 0 ? void 0 : _b.colorText : undefined, style: { fontWeight: 'bold' } }, itemTypeName === ITEM_TYPE_NAME.ARTICLE ? 'Article Filters' : 'Product Filters'),
|
|
736
735
|
React.createElement(Text, { color: isCDP ? (_c = THEME.token) === null || _c === void 0 ? void 0 : _c.colorText : undefined, style: { fontWeight: 'bold' } }, "Hide"),
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
// Libraries
|
|
2
2
|
import { useCallback, useMemo } from 'react';
|
|
3
|
-
import { useContextSelector } from 'use-context-selector';
|
|
4
3
|
import { useHistory, useLocation } from 'react-router-dom';
|
|
5
4
|
// Constants
|
|
6
5
|
import { CONFIG_OPTIONS } from './constants';
|
|
7
6
|
import { HOME_REPORT_ROUTES } from '../../constants';
|
|
8
7
|
// Utils
|
|
9
8
|
import { getGeneratePath, getMenuItem } from '../../utils';
|
|
10
|
-
// Contexts
|
|
11
|
-
import { AppConfigContext } from '@antscorp/antsomi-ui/es/providers';
|
|
12
9
|
// Types
|
|
13
10
|
import { useLeftMenuStore } from '../../stores';
|
|
14
11
|
export const useHomeMenu = () => {
|
|
@@ -16,8 +13,7 @@ export const useHomeMenu = () => {
|
|
|
16
13
|
const { pathname } = useLocation();
|
|
17
14
|
const history = useHistory();
|
|
18
15
|
const appMenuChildren = useLeftMenuStore(store => store.state.appMenuChildren);
|
|
19
|
-
|
|
20
|
-
const auth = useContextSelector(AppConfigContext, state => state === null || state === void 0 ? void 0 : state.auth);
|
|
16
|
+
const auth = useLeftMenuStore(store => { var _a; return (_a = store.state.appConfig) === null || _a === void 0 ? void 0 : _a.auth; });
|
|
21
17
|
// Memos
|
|
22
18
|
const onOptionCallback = useCallback((args) => {
|
|
23
19
|
const { optionKey, menuItemKey } = args;
|
|
@@ -3,8 +3,7 @@ import React, { memo, useEffect, useState } from 'react';
|
|
|
3
3
|
import Icon from '@antscorp/icons';
|
|
4
4
|
import { isEmpty, isNil, uniq } from 'lodash';
|
|
5
5
|
import classNames from 'classnames';
|
|
6
|
-
import { Link
|
|
7
|
-
import { useContextSelector } from 'use-context-selector';
|
|
6
|
+
import { Link } from 'react-router-dom';
|
|
8
7
|
// Components
|
|
9
8
|
import { Dropdown, Menu } from 'antd';
|
|
10
9
|
import { Flex } from '../../../../../atoms';
|
|
@@ -14,8 +13,6 @@ import { LabelCustom, MenuWrapper } from './styled';
|
|
|
14
13
|
import { IconWrapper } from '../../../styled';
|
|
15
14
|
// Constants
|
|
16
15
|
import { ICON_SIZE } from '../../../constants';
|
|
17
|
-
// Contexts
|
|
18
|
-
import { AppConfigContext } from '@antscorp/antsomi-ui/es/providers';
|
|
19
16
|
// Utils
|
|
20
17
|
import { findActiveAppCodeByUrl, findLastMatchedItemByUrl } from '../../../utils';
|
|
21
18
|
import { recursiveFindParentOfActiveItem } from './utils';
|
|
@@ -25,9 +22,8 @@ import { useLeftMenuStore } from '../../../stores';
|
|
|
25
22
|
import { useNavigatePath } from '../../../hooks/useNavigatePath';
|
|
26
23
|
export const ChildMenu = memo(props => {
|
|
27
24
|
const { items = [], parentKey, onMenuClick } = props;
|
|
28
|
-
// Contexts
|
|
29
|
-
const auth = useContextSelector(AppConfigContext, state => state === null || state === void 0 ? void 0 : state.auth);
|
|
30
25
|
// Stores
|
|
26
|
+
const auth = useLeftMenuStore(store => { var _a; return (_a = store.state.appConfig) === null || _a === void 0 ? void 0 : _a.auth; });
|
|
31
27
|
const activeAppCode = useLeftMenuStore(store => store.state.activeAppCode);
|
|
32
28
|
const menuItems = useLeftMenuStore(store => store.state.menuItems);
|
|
33
29
|
const setLeftMenuState = useLeftMenuStore(store => store.setState);
|
|
@@ -37,12 +33,12 @@ export const ChildMenu = memo(props => {
|
|
|
37
33
|
// Variables
|
|
38
34
|
const randomMenuWrapperId = random(10);
|
|
39
35
|
// Hooks
|
|
40
|
-
const { pathname, hash
|
|
36
|
+
const { pathname, hash } = window.location;
|
|
41
37
|
const { isPushDifferentDomain, getPath, navigatePath } = useNavigatePath();
|
|
42
38
|
// Side Effects
|
|
43
39
|
useEffect(() => {
|
|
44
40
|
var _a;
|
|
45
|
-
const url = `${pathname}${hash}
|
|
41
|
+
const url = `${pathname}${hash}`;
|
|
46
42
|
/** Active menu item by current url */
|
|
47
43
|
const activeMenuItem = (_a = findLastMatchedItemByUrl({ url, menuItems, auth })) === null || _a === void 0 ? void 0 : _a.menu_item_code;
|
|
48
44
|
if (activeMenuItem && activeMenuItem !== currentActiveItem) {
|
|
@@ -64,7 +60,6 @@ export const ChildMenu = memo(props => {
|
|
|
64
60
|
hash,
|
|
65
61
|
items,
|
|
66
62
|
pathname,
|
|
67
|
-
search,
|
|
68
63
|
parentKey,
|
|
69
64
|
activeAppCode,
|
|
70
65
|
menuItems,
|
|
@@ -93,7 +88,7 @@ export const ChildMenu = memo(props => {
|
|
|
93
88
|
React.createElement(Icon, { className: "child-menu-item-icon", type: "icon-ants-three-dot-vertical", style: { marginTop: '2px', zIndex: 1000 } })))) : (React.createElement(LabelCustom, { ellipsis: { tooltip: label } }, label));
|
|
94
89
|
return {
|
|
95
90
|
key,
|
|
96
|
-
label: !menu_item_path ? (labelComponent()) : isPushDifferentDomain(menu_item_domain, menu_item_path) ? (React.createElement("div", { onClick: () => navigatePath(menu_item_domain, menu_item_path), className: "menu-link" }, labelComponent())) : (React.createElement(Link, { to: getPath(
|
|
91
|
+
label: !menu_item_path ? (labelComponent()) : isPushDifferentDomain(menu_item_domain, menu_item_path) ? (React.createElement("div", { onClick: () => navigatePath(menu_item_domain, menu_item_path), className: "menu-link" }, labelComponent())) : (React.createElement(Link, { to: getPath(menu_item_path), className: "menu-link" }, labelComponent())),
|
|
97
92
|
icon: !isNil(icon) ? (React.createElement(IconWrapper, null,
|
|
98
93
|
React.createElement(Icon, { type: icon }))) : !isNil(logo_url) ? (React.createElement(MenuItemImage, { imageUrl: logo_url, fallbackIcon: (_a = args === null || args === void 0 ? void 0 : args.parent) === null || _a === void 0 ? void 0 : _a.icon, className: classNames({ isActive: currentActiveItem === key }) })) : null,
|
|
99
94
|
children: customMenuItems({ parent: item, items: children }),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Utils
|
|
2
|
-
import { getGeneratePath } from '../../../utils';
|
|
2
|
+
import { getComparePath, getGeneratePath } from '../../../utils';
|
|
3
3
|
import { handleError } from '@antscorp/antsomi-ui/es/utils';
|
|
4
4
|
const PATH = 'src/components/organism/LeftMenu/components/common/ChildMenu/utils.ts';
|
|
5
5
|
/**
|
|
@@ -22,7 +22,8 @@ export const findActiveMenuItemByUrl = (args) => {
|
|
|
22
22
|
const recursiveFindActiveItem = (items) => {
|
|
23
23
|
let activeItem;
|
|
24
24
|
for (const item of items) {
|
|
25
|
-
if (!!(item === null || item === void 0 ? void 0 : item.menu_item_path) &&
|
|
25
|
+
if (!!(item === null || item === void 0 ? void 0 : item.menu_item_path) &&
|
|
26
|
+
url.includes(getComparePath(getGeneratePath(item.menu_item_path, auth)))) {
|
|
26
27
|
activeItem = item === null || item === void 0 ? void 0 : item.menu_item_code;
|
|
27
28
|
break;
|
|
28
29
|
}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import { TFeatureMenu } from '@antscorp/antsomi-ui/es/models/LeftMenu';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
label: string;
|
|
5
|
-
icon: string;
|
|
6
|
-
}[];
|
|
2
|
+
import { TMenuItem } from '../types';
|
|
3
|
+
export declare const MENU_ITEMS: TMenuItem[];
|
|
7
4
|
export declare const MENU_SAMPLE: TFeatureMenu[];
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
// Libraries
|
|
2
2
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
3
|
-
import { useContextSelector } from 'use-context-selector';
|
|
4
3
|
import { isArray, sortBy } from 'lodash';
|
|
5
|
-
import { useLocation } from 'react-router-dom';
|
|
6
|
-
// Contexts
|
|
7
|
-
import { AppConfigContext } from '@antscorp/antsomi-ui/es/providers';
|
|
8
4
|
// Queries
|
|
9
5
|
import { useGetDashboard, useGetDestinationChannel, useGetListMenu, useGetListMenuPermission, } from '@antscorp/antsomi-ui/es/queries/LeftMenu';
|
|
10
6
|
// Utils
|
|
@@ -18,16 +14,15 @@ const initialState = {
|
|
|
18
14
|
};
|
|
19
15
|
export const useLeftMenu = (props) => {
|
|
20
16
|
// Props
|
|
21
|
-
const { objectType = 'OVERVIEW', objectId = 1, isGrouped = true, onActiveMenuCodeChange } = props;
|
|
17
|
+
const { objectType = 'OVERVIEW', objectId = 1, isGrouped = true, appConfig, onActiveMenuCodeChange, } = props;
|
|
22
18
|
// Hooks
|
|
23
|
-
const { pathname, hash
|
|
24
|
-
|
|
25
|
-
const appConfig = useContextSelector(AppConfigContext, state => state);
|
|
19
|
+
const { pathname, hash } = window.location;
|
|
20
|
+
console.log({ pathname, hash, locationWindow: window.location });
|
|
26
21
|
// Stores
|
|
27
22
|
const activeAppCode = useLeftMenuStore(store => store.state.activeAppCode);
|
|
28
23
|
const setLeftMenuState = useLeftMenuStore(store => store.setState);
|
|
29
24
|
// Destructuring variables
|
|
30
|
-
const { auth, languageCode } = appConfig;
|
|
25
|
+
const { auth, languageCode } = appConfig || {};
|
|
31
26
|
// State
|
|
32
27
|
const [state, setState] = useState(initialState);
|
|
33
28
|
// Queries
|
|
@@ -101,7 +96,7 @@ export const useLeftMenu = (props) => {
|
|
|
101
96
|
dashboardData,
|
|
102
97
|
destinationChannelEntries: destinationChannel === null || destinationChannel === void 0 ? void 0 : destinationChannel.entries,
|
|
103
98
|
}), [auth, dashboardData, destinationChannel === null || destinationChannel === void 0 ? void 0 : destinationChannel.entries, permissionMenu]);
|
|
104
|
-
/*
|
|
99
|
+
/* Handlers */
|
|
105
100
|
const receivePostMessage = (event) => {
|
|
106
101
|
const { data } = event;
|
|
107
102
|
const { type } = data || {};
|
|
@@ -119,7 +114,12 @@ export const useLeftMenu = (props) => {
|
|
|
119
114
|
useEffect(() => {
|
|
120
115
|
window.addEventListener('message', receivePostMessage);
|
|
121
116
|
return () => window.removeEventListener('message', receivePostMessage);
|
|
117
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
122
118
|
}, []);
|
|
119
|
+
useEffect(() => {
|
|
120
|
+
if (appConfig)
|
|
121
|
+
setLeftMenuState({ appConfig });
|
|
122
|
+
}, [appConfig, setLeftMenuState]);
|
|
123
123
|
/**
|
|
124
124
|
* Change list menu children when hovering or activating items, giving priority to hovering items
|
|
125
125
|
*/
|
|
@@ -137,20 +137,19 @@ export const useLeftMenu = (props) => {
|
|
|
137
137
|
* Active App Item having code matching url
|
|
138
138
|
*/
|
|
139
139
|
useEffect(() => {
|
|
140
|
-
const url = `${pathname}${hash}
|
|
140
|
+
const url = `${pathname}${hash}`;
|
|
141
141
|
const matchAppCode = findActiveAppCodeByUrl({ url, menuItems: mappingChildrenMenu, auth });
|
|
142
142
|
if (matchAppCode && matchAppCode !== activeAppCode) {
|
|
143
143
|
setLeftMenuState({ activeAppCode: matchAppCode });
|
|
144
144
|
}
|
|
145
145
|
}, [
|
|
146
146
|
activeAppCode,
|
|
147
|
-
appConfig.auth,
|
|
147
|
+
appConfig === null || appConfig === void 0 ? void 0 : appConfig.auth,
|
|
148
148
|
auth,
|
|
149
149
|
hash,
|
|
150
150
|
mappingChildrenMenu,
|
|
151
151
|
pathname,
|
|
152
152
|
permissionMenu,
|
|
153
|
-
search,
|
|
154
153
|
setLeftMenuState,
|
|
155
154
|
]);
|
|
156
155
|
/**
|
|
@@ -158,7 +157,7 @@ export const useLeftMenu = (props) => {
|
|
|
158
157
|
*/
|
|
159
158
|
useEffect(() => {
|
|
160
159
|
var _a;
|
|
161
|
-
const url = `${pathname}${hash}
|
|
160
|
+
const url = `${pathname}${hash}`;
|
|
162
161
|
const matchedCode = (_a = findLastMatchedItemByUrl({
|
|
163
162
|
url,
|
|
164
163
|
menuItems: mappingChildrenMenu,
|
|
@@ -171,15 +170,7 @@ export const useLeftMenu = (props) => {
|
|
|
171
170
|
})
|
|
172
171
|
: [];
|
|
173
172
|
onActiveMenuCodeChange === null || onActiveMenuCodeChange === void 0 ? void 0 : onActiveMenuCodeChange(activeItemPath, flattenMenuPermission);
|
|
174
|
-
}, [
|
|
175
|
-
auth,
|
|
176
|
-
flattenMenuPermission,
|
|
177
|
-
hash,
|
|
178
|
-
mappingChildrenMenu,
|
|
179
|
-
onActiveMenuCodeChange,
|
|
180
|
-
pathname,
|
|
181
|
-
search,
|
|
182
|
-
]);
|
|
173
|
+
}, [auth, flattenMenuPermission, hash, mappingChildrenMenu, onActiveMenuCodeChange, pathname]);
|
|
183
174
|
/* Callbacks */
|
|
184
175
|
const onToggleChildMenu = useCallback(() => {
|
|
185
176
|
setState(prev => (Object.assign(Object.assign({}, prev), { isExpandMenu: !prev.isExpandMenu })));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const useNavigatePath: () => {
|
|
2
2
|
isPushDifferentDomain: (domain: string | null, path: string | null) => boolean;
|
|
3
|
-
getPath: (
|
|
3
|
+
getPath: (path: string | null) => string;
|
|
4
4
|
navigatePath: (domain: string | null, path: string | null) => void;
|
|
5
5
|
};
|
|
@@ -13,11 +13,12 @@ export const useNavigatePath = () => {
|
|
|
13
13
|
// Contexts
|
|
14
14
|
const { auth, env } = useContextSelector(AppConfigContext, state => state);
|
|
15
15
|
const { search } = useLocation();
|
|
16
|
-
const searchParams = search === '?' ? '' : search;
|
|
16
|
+
const searchParams = search === '?' || !search ? '' : search;
|
|
17
|
+
const isDev = env === ENV.DEV;
|
|
17
18
|
// Callbacks
|
|
18
19
|
const isPushDifferentDomain = useCallback((domain, path) => {
|
|
19
20
|
var _a, _b, _c, _d, _e, _f;
|
|
20
|
-
if (
|
|
21
|
+
if (isDev)
|
|
21
22
|
return false;
|
|
22
23
|
const customDomain = domain !== null && domain !== void 0 ? domain : '';
|
|
23
24
|
const splitNextPath = (path === null || path === void 0 ? void 0 : path.split('#')) || ['', ''];
|
|
@@ -29,18 +30,20 @@ export const useNavigatePath = () => {
|
|
|
29
30
|
return currentRoute !== nextRoute;
|
|
30
31
|
}
|
|
31
32
|
return !!customDomain && customDomain !== ((_f = window.location) === null || _f === void 0 ? void 0 : _f.origin);
|
|
32
|
-
}, [
|
|
33
|
-
const getPath = useCallback((
|
|
33
|
+
}, [isDev]);
|
|
34
|
+
const getPath = useCallback((path) => {
|
|
34
35
|
var _a;
|
|
35
|
-
if (
|
|
36
|
+
if (path === null || path === void 0 ? void 0 : path.includes('#')) {
|
|
36
37
|
const customPath = ((_a = path === null || path === void 0 ? void 0 : path.split('#')) === null || _a === void 0 ? void 0 : _a[1]) || '';
|
|
37
38
|
return getGeneratePath(customPath, auth);
|
|
38
39
|
}
|
|
39
|
-
return getGeneratePath(
|
|
40
|
-
|
|
40
|
+
return `${getGeneratePath(path !== null && path !== void 0 ? path : '', auth)}`;
|
|
41
|
+
// return `${getGeneratePath(path ?? '', auth)}${searchParams}`;
|
|
42
|
+
}, [auth, searchParams]);
|
|
41
43
|
const navigatePath = useCallback((domain, path) => {
|
|
42
44
|
const newDomain = isNil(domain) || env === ENV.DEV ? '' : domain;
|
|
43
|
-
window.location.assign(getGeneratePath(`${newDomain}${path}
|
|
45
|
+
window.location.assign(`${getGeneratePath(`${newDomain}${path}`, auth)}`);
|
|
46
|
+
// window.location.assign(`${getGeneratePath(`${newDomain}${path}`, auth)}${searchParams}`);
|
|
44
47
|
}, [auth, env, searchParams]);
|
|
45
48
|
return { isPushDifferentDomain, getPath, navigatePath };
|
|
46
49
|
};
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { TFeatureMenu } from '@antscorp/antsomi-ui/es/models/LeftMenu/FeatureMenu';
|
|
3
3
|
import { FeatureMenuPermission } from '@antscorp/antsomi-ui/es/models/LeftMenu';
|
|
4
|
+
import { AppConfigProviderProps } from '../../..';
|
|
5
|
+
import { TMenuItem } from './types';
|
|
4
6
|
export interface LeftMenuProps {
|
|
7
|
+
appConfig?: AppConfigProviderProps;
|
|
5
8
|
objectType?: string;
|
|
6
9
|
objectId?: number;
|
|
7
10
|
isGrouped?: boolean;
|
|
8
11
|
style?: React.CSSProperties;
|
|
9
12
|
className?: string;
|
|
13
|
+
isExpandable?: boolean;
|
|
14
|
+
items?: TMenuItem[];
|
|
15
|
+
isCustomized?: boolean;
|
|
10
16
|
onActiveMenuCodeChange?: (activeItemPath: TFeatureMenu[], flattenPermissionList?: FeatureMenuPermission[]) => void;
|
|
11
17
|
}
|
|
12
18
|
export declare const LeftMenu: React.FC<LeftMenuProps>;
|
|
@@ -18,7 +18,7 @@ import { useLeftMenu } from './hooks';
|
|
|
18
18
|
import { useNavigatePath } from './hooks/useNavigatePath';
|
|
19
19
|
export const LeftMenu = memo(props => {
|
|
20
20
|
var _a;
|
|
21
|
-
const { style, className } = props;
|
|
21
|
+
const { style, className, isExpandable = true, isCustomized = false } = props;
|
|
22
22
|
// Hooks
|
|
23
23
|
const {
|
|
24
24
|
/* State */
|
|
@@ -71,8 +71,13 @@ export const LeftMenu = memo(props => {
|
|
|
71
71
|
React.createElement("div", { className: "icon-wrapper" }, isNil(icon_name) ? null : React.createElement(Icon, { type: icon_name, style: { fontSize: ICON_SIZE } })),
|
|
72
72
|
React.createElement(Typography.Text, null, menu_item_name),
|
|
73
73
|
React.createElement("div", { className: "popup-triangle" })));
|
|
74
|
-
return (React.createElement(FeatureMenuItem, { key: menu_item, onMouseEnter: () => onMouseEnter(menu_item_code) }, isString(menu_item_path) ? (isPushDifferentDomain(menu_item_domain, menu_item_path) ? (React.createElement("div", { onClick: () => navigatePath(menu_item_domain, menu_item_path) }, labelComponent())) : (React.createElement(Link, { to: getPath(
|
|
74
|
+
return (React.createElement(FeatureMenuItem, { key: menu_item, onMouseEnter: () => onMouseEnter(menu_item_code) }, isString(menu_item_path) ? (isPushDifferentDomain(menu_item_domain, menu_item_path) ? (React.createElement("div", { onClick: () => navigatePath(menu_item_domain, menu_item_path) }, labelComponent())) : (React.createElement(Link, { to: getPath(menu_item_path), className: "menu-link" }, labelComponent()))) : (labelComponent())));
|
|
75
75
|
};
|
|
76
|
+
// const renderCustomizedMenuItems = (items: TMenuItem) => {
|
|
77
|
+
// return items?.map(item => {
|
|
78
|
+
// return <FeatureMenuItem key={menu_item} onMouseEnter={() => onMouseEnter(menu_item_code)} />;
|
|
79
|
+
// });
|
|
80
|
+
// };
|
|
76
81
|
return (React.createElement(LeftMenuNavWrapper, { style: style, className: className },
|
|
77
82
|
React.createElement(LeftMenuNav, null,
|
|
78
83
|
React.createElement(FeatureMenuWrapper, { isExpandMenu: state.isExpandMenu, vertical: true },
|
|
@@ -88,12 +93,12 @@ export const LeftMenu = memo(props => {
|
|
|
88
93
|
const settingFeature = permissionMenu === null || permissionMenu === void 0 ? void 0 : permissionMenu.find(item => item.menu_item_code === APP_KEYS.SETTINGS);
|
|
89
94
|
return settingFeature ? renderFeatureMenuItems(settingFeature) : null;
|
|
90
95
|
})())),
|
|
91
|
-
React.createElement(ExpandWrapper, { onMouseEnter: onMouseLeave },
|
|
96
|
+
isExpandable && (React.createElement(ExpandWrapper, { onMouseEnter: onMouseLeave },
|
|
92
97
|
React.createElement(Icon, { type: "icon-ants-expand-more", style: {
|
|
93
98
|
cursor: 'pointer',
|
|
94
99
|
fontSize: '20px',
|
|
95
100
|
transform: `rotate(${state.isExpandMenu ? '90deg' : '270deg'})`,
|
|
96
|
-
}, onClick: onToggleChildMenu }))),
|
|
97
|
-
React.createElement(ChildMenuWrapper, { isExpand: state.isExpandMenu, className: "antsomi-scroll-box" },
|
|
101
|
+
}, onClick: onToggleChildMenu })))),
|
|
102
|
+
React.createElement(ChildMenuWrapper, { isExpand: state.isExpandMenu && isExpandable, className: "antsomi-scroll-box" },
|
|
98
103
|
React.createElement("div", { className: "scroll-content" }, childMenu))));
|
|
99
104
|
});
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { TFeatureMenu } from '@antscorp/antsomi-ui/es/models/LeftMenu';
|
|
2
|
+
import { AppConfigProviderProps } from '@antscorp/antsomi-ui/es/providers';
|
|
2
3
|
export interface LeftMenuState {
|
|
3
4
|
activeAppCode: string;
|
|
4
5
|
menuItems: TFeatureMenu[];
|
|
5
6
|
appMenuChildren: TFeatureMenu[];
|
|
7
|
+
appConfig?: AppConfigProviderProps;
|
|
6
8
|
}
|
|
7
9
|
interface LeftMenuStore {
|
|
8
10
|
state: LeftMenuState;
|
|
@@ -28,6 +28,11 @@ export declare const getGeneratePath: (path: string, params?: Partial<PayloadInf
|
|
|
28
28
|
dashboardId?: string;
|
|
29
29
|
channelId?: number;
|
|
30
30
|
}) => string;
|
|
31
|
+
/**
|
|
32
|
+
* This is used to delete the hash of the path returned from the api,
|
|
33
|
+
* the purpose of which is to compare with the url to activate the app
|
|
34
|
+
*/
|
|
35
|
+
export declare const getComparePath: (path: string) => string;
|
|
31
36
|
/**
|
|
32
37
|
* Creates an initial feature menu item object with default values.
|
|
33
38
|
* @param {Partial<TFeatureMenu>} featureMenuItem - The partial feature menu item object.
|
|
@@ -87,6 +87,18 @@ export const getGeneratePath = (path, params) => {
|
|
|
87
87
|
return '';
|
|
88
88
|
}
|
|
89
89
|
};
|
|
90
|
+
/**
|
|
91
|
+
* This is used to delete the hash of the path returned from the api,
|
|
92
|
+
* the purpose of which is to compare with the url to activate the app
|
|
93
|
+
*/
|
|
94
|
+
export const getComparePath = (path) => {
|
|
95
|
+
var _a;
|
|
96
|
+
if (path === null || path === void 0 ? void 0 : path.includes('#')) {
|
|
97
|
+
const customPath = ((_a = path === null || path === void 0 ? void 0 : path.split('#')) === null || _a === void 0 ? void 0 : _a[1]) || '';
|
|
98
|
+
return customPath;
|
|
99
|
+
}
|
|
100
|
+
return path;
|
|
101
|
+
};
|
|
90
102
|
/**
|
|
91
103
|
* Creates an initial feature menu item object with default values.
|
|
92
104
|
* @param {Partial<TFeatureMenu>} featureMenuItem - The partial feature menu item object.
|
|
@@ -167,7 +179,8 @@ export const findActiveAppCodeByUrl = (args) => {
|
|
|
167
179
|
const recursiveCheckHasActiveChild = (items) => {
|
|
168
180
|
let matchAppCode = false;
|
|
169
181
|
for (const item of items) {
|
|
170
|
-
if (!!(item === null || item === void 0 ? void 0 : item.menu_item_path) &&
|
|
182
|
+
if (!!(item === null || item === void 0 ? void 0 : item.menu_item_path) &&
|
|
183
|
+
url.includes(getComparePath(getGeneratePath(item.menu_item_path, auth)))) {
|
|
171
184
|
matchAppCode = true;
|
|
172
185
|
break;
|
|
173
186
|
}
|
|
@@ -182,7 +195,7 @@ export const findActiveAppCodeByUrl = (args) => {
|
|
|
182
195
|
};
|
|
183
196
|
for (const menuItem of menuItems) {
|
|
184
197
|
if (!!(menuItem === null || menuItem === void 0 ? void 0 : menuItem.menu_item_path) &&
|
|
185
|
-
url.includes(getGeneratePath(menuItem.menu_item_path, auth))) {
|
|
198
|
+
url.includes(getComparePath(getGeneratePath(menuItem.menu_item_path, auth)))) {
|
|
186
199
|
matchAppCode = menuItem.menu_item_code;
|
|
187
200
|
break;
|
|
188
201
|
}
|
|
@@ -208,7 +221,8 @@ export const findLastMatchedItemByUrl = (args) => {
|
|
|
208
221
|
const matchedItems = [];
|
|
209
222
|
const recursiveFindActiveItem = (items) => {
|
|
210
223
|
for (const item of items) {
|
|
211
|
-
if (!!(item === null || item === void 0 ? void 0 : item.menu_item_path) &&
|
|
224
|
+
if (!!(item === null || item === void 0 ? void 0 : item.menu_item_path) &&
|
|
225
|
+
url.includes(getComparePath(getGeneratePath(item.menu_item_path, auth)))) {
|
|
212
226
|
matchedItems.push(item);
|
|
213
227
|
}
|
|
214
228
|
if ((item === null || item === void 0 ? void 0 : item.children) && item.children.length) {
|
|
@@ -36,7 +36,8 @@ export const Layout = memo(props => {
|
|
|
36
36
|
const _a = leftMenuProps || {}, { className = '' } = _a, restOfLeftMenuProps = __rest(_a, ["className"]);
|
|
37
37
|
const _b = workspaceProps || {}, { workspaceContentProps } = _b, restOfWorkspaceProps = __rest(_b, ["workspaceContentProps"]);
|
|
38
38
|
// Selectors
|
|
39
|
-
const
|
|
39
|
+
const appConfig = useContextSelector(AppConfigContext, state => state);
|
|
40
|
+
const { auth, languageCode, appCode, env } = appConfig;
|
|
40
41
|
const { token, userId, portalId } = auth || {};
|
|
41
42
|
const headerStore = useLayoutStore(store => store.state.header);
|
|
42
43
|
const [showAccountSelection, setShowAccountSelection] = useState(false);
|
|
@@ -81,7 +82,7 @@ export const Layout = memo(props => {
|
|
|
81
82
|
embeddedData: {},
|
|
82
83
|
INSIGHT_U_OGS: 'uogs',
|
|
83
84
|
} }) }), accountSharingConfig: Object.assign(Object.assign({}, headerProps === null || headerProps === void 0 ? void 0 : headerProps.accountSharingConfig), { u_ogs: 'uogs', appCode: 'APP_CUSTOMER_360' }), accountSelection: Object.assign(Object.assign({}, headerProps === null || headerProps === void 0 ? void 0 : headerProps.accountSelection), { show: !!((_b = headerProps === null || headerProps === void 0 ? void 0 : headerProps.accountSelection) === null || _b === void 0 ? void 0 : _b.show) && showAccountSelection }) }));
|
|
84
|
-
}, [headerProps, permissionDomain, showAccountSelection]);
|
|
85
|
+
}, [headerProps, iamDomain, permissionDomain, showAccountSelection]);
|
|
85
86
|
const mergeHeaderProps = useMemo(() => merge(initialHeaderProps, headerStore), [initialHeaderProps, headerStore]);
|
|
86
87
|
const antsProcessingNotificationConfig = useMemo(() => (Object.assign({ permissionDomain, socketDomain: SOCKET_API, token, accountId: userId, userId, lang: languageCode, networkId: portalId }, processingNotificationProps)), [permissionDomain, token, userId, languageCode, portalId, processingNotificationProps]);
|
|
87
88
|
const onActiveMenuCodeChange = useCallback((activeItemPath, flattenPermissionList) => {
|
|
@@ -129,7 +130,7 @@ export const Layout = memo(props => {
|
|
|
129
130
|
return (React.createElement(LayoutWrapper, null,
|
|
130
131
|
React.createElement(HeaderV2, Object.assign({}, mergeHeaderProps)),
|
|
131
132
|
React.createElement(Flex, { className: "layout-body" },
|
|
132
|
-
React.createElement(LeftMenu, Object.assign({ className: `layout-body__menu ${className}
|
|
133
|
+
React.createElement(LeftMenu, Object.assign({ className: `layout-body__menu ${className}`, appConfig: appConfig }, restOfLeftMenuProps, { onActiveMenuCodeChange: onActiveMenuCodeChange })),
|
|
133
134
|
React.createElement(ContentWrapper, null,
|
|
134
135
|
React.createElement("div", Object.assign({}, restOfWorkspaceProps, { className: `layout-body__content ${(workspaceProps === null || workspaceProps === void 0 ? void 0 : workspaceProps.className) || ''}` }),
|
|
135
136
|
React.createElement(NotificationWrapper, null,
|