@antscorp/antsomi-ui 1.3.5-beta.455 → 1.3.5-beta.457
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/ShareAccess/ShareAccess.js +4 -1
- package/es/components/molecules/ShareAccess/actions.d.ts +8 -2
- package/es/components/molecules/ShareAccess/actions.js +2 -2
- package/es/components/molecules/ShareAccess/components/GeneralAccess/GeneralAccess.js +2 -2
- package/es/components/molecules/ShareAccess/components/ModalTransferOwnerShip/ModalTransferOwnerShip.js +1 -1
- package/es/components/molecules/ShareAccess/components/PeopleAccess/PeopleAccess.js +1 -1
- package/es/components/molecules/ShareAccess/components/SearchUser/SearchUser.js +1 -1
- package/es/components/molecules/ShareAccess/reducer.js +4 -3
- package/es/components/organism/LeftMenu/components/common/ChildMenu/index.js +1 -1
- package/es/components/organism/LeftMenu/constants/variables.d.ts +1 -0
- package/es/components/organism/LeftMenu/constants/variables.js +4 -1
- package/es/components/organism/LeftMenu/hooks/useLeftMenu.js +3 -2
- package/es/components/organism/LeftMenu/hooks/useNavigatePath.d.ts +1 -1
- package/es/components/organism/LeftMenu/hooks/useNavigatePath.js +3 -2
- package/es/components/organism/LeftMenu/hooks/usePermission.d.ts +1 -0
- package/es/components/organism/LeftMenu/hooks/usePermission.js +32 -3
- package/es/components/organism/LeftMenu/index.d.ts +1 -1
- package/es/components/organism/LeftMenu/utils/index.d.ts +1 -0
- package/es/components/organism/LeftMenu/utils/index.js +36 -15
- package/es/components/template/Layout/Layout.js +3 -2
- package/es/components/template/Layout/components/RecommendationWorkspace/components/MenuMapping/components/OldLeftMenu/index.js +2 -0
- package/es/components/template/Layout/components/RecommendationWorkspace/index.js +2 -0
- package/es/components/template/Layout/constants/menuCode.d.ts +1 -0
- package/es/components/template/Layout/constants/menuCode.js +1 -0
- package/es/components/template/Layout/constants/permission.d.ts +1 -0
- package/es/components/template/Layout/constants/permission.js +1 -0
- package/es/components/template/Layout/utils/permission.d.ts +1 -1
- package/es/components/template/Layout/utils/permission.js +9 -3
- package/package.json +1 -1
|
@@ -17,7 +17,10 @@ export const ShareAccess = (props) => {
|
|
|
17
17
|
useDeepCompareEffect(() => {
|
|
18
18
|
if (!accessInfo)
|
|
19
19
|
return;
|
|
20
|
-
dispatch(updateObjAccessInfo(
|
|
20
|
+
dispatch(updateObjAccessInfo({
|
|
21
|
+
updated: formattedAccessInfo(accessInfo),
|
|
22
|
+
triggerOut: false,
|
|
23
|
+
}));
|
|
21
24
|
}, [accessInfo]);
|
|
22
25
|
return (React.createElement(ShareAccessStateContext.Provider, { value: Object.assign(Object.assign({}, state), { excludeUserAccess, accessUserId: userId, accessUserPermission: userPermission }) },
|
|
23
26
|
React.createElement(ShareAccessDispatchContext.Provider, { value: dispatch },
|
|
@@ -3,9 +3,15 @@ export declare const TYPES: {
|
|
|
3
3
|
readonly UPDATE_OBJECT_ACCESS_INFO: "UPDATE_OBJECT_ACCESS_INFO";
|
|
4
4
|
readonly UPDATE_MODAL_TRANSTER_OWNERSHIP: "UPDATE_MODAL_TRANSTER_OWNERSHIP";
|
|
5
5
|
};
|
|
6
|
-
export declare const updateObjAccessInfo: (
|
|
6
|
+
export declare const updateObjAccessInfo: (payload: {
|
|
7
|
+
updated: ObjectAccessInfo;
|
|
8
|
+
triggerOut?: boolean;
|
|
9
|
+
}) => {
|
|
7
10
|
type: "UPDATE_OBJECT_ACCESS_INFO";
|
|
8
|
-
payload:
|
|
11
|
+
payload: {
|
|
12
|
+
updated: ObjectAccessInfo;
|
|
13
|
+
triggerOut?: boolean | undefined;
|
|
14
|
+
};
|
|
9
15
|
};
|
|
10
16
|
export declare const updateModalTransferOwnership: (modalState: Partial<ShareAccessState['modalTransferOwnership']>) => {
|
|
11
17
|
type: "UPDATE_MODAL_TRANSTER_OWNERSHIP";
|
|
@@ -2,9 +2,9 @@ export const TYPES = {
|
|
|
2
2
|
UPDATE_OBJECT_ACCESS_INFO: 'UPDATE_OBJECT_ACCESS_INFO',
|
|
3
3
|
UPDATE_MODAL_TRANSTER_OWNERSHIP: 'UPDATE_MODAL_TRANSTER_OWNERSHIP',
|
|
4
4
|
};
|
|
5
|
-
export const updateObjAccessInfo = (
|
|
5
|
+
export const updateObjAccessInfo = (payload) => ({
|
|
6
6
|
type: TYPES.UPDATE_OBJECT_ACCESS_INFO,
|
|
7
|
-
payload
|
|
7
|
+
payload,
|
|
8
8
|
});
|
|
9
9
|
export const updateModalTransferOwnership = (modalState) => ({
|
|
10
10
|
type: TYPES.UPDATE_MODAL_TRANSTER_OWNERSHIP,
|
|
@@ -22,7 +22,7 @@ export const GeneralAccess = ({ generalAccessSettings }) => {
|
|
|
22
22
|
draft.publicRole = PUBLIC_ROLE.ONLY_VIEWER;
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
|
-
dispatch(updateObjAccessInfo(updated));
|
|
25
|
+
dispatch(updateObjAccessInfo({ updated }));
|
|
26
26
|
};
|
|
27
27
|
const handleChangePublicRole = (value) => {
|
|
28
28
|
if (!accessInfo || !dispatch || !allowEdit)
|
|
@@ -30,7 +30,7 @@ export const GeneralAccess = ({ generalAccessSettings }) => {
|
|
|
30
30
|
const updated = produce(accessInfo, draft => {
|
|
31
31
|
draft.publicRole = value;
|
|
32
32
|
});
|
|
33
|
-
dispatch(updateObjAccessInfo(updated));
|
|
33
|
+
dispatch(updateObjAccessInfo({ updated }));
|
|
34
34
|
};
|
|
35
35
|
const renderDescription = () => {
|
|
36
36
|
let description = 'Only people with access can open this item';
|
|
@@ -66,7 +66,7 @@ export const SearchUser = (props) => {
|
|
|
66
66
|
const newUser = Object.assign({ userId: user.user_id, fullName: user.full_name, email: user.email, avatar: user.avatar }, defaultViewerProps);
|
|
67
67
|
draft.listAccess.push(newUser);
|
|
68
68
|
});
|
|
69
|
-
dispatch(updateObjAccessInfo(updated));
|
|
69
|
+
dispatch(updateObjAccessInfo({ updated }));
|
|
70
70
|
setUsers([]);
|
|
71
71
|
};
|
|
72
72
|
if (!allowEdit)
|
|
@@ -4,9 +4,10 @@ import { mappingOutData } from './utils';
|
|
|
4
4
|
export const shareAccessReducer = (onChange) => (state, action) => produce(state, draft => {
|
|
5
5
|
switch (action.type) {
|
|
6
6
|
case TYPES.UPDATE_OBJECT_ACCESS_INFO: {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
const { updated, triggerOut = true } = action.payload;
|
|
8
|
+
draft.accessInfo = updated;
|
|
9
|
+
if (onChange && triggerOut) {
|
|
10
|
+
onChange(mappingOutData(action.payload.updated));
|
|
10
11
|
}
|
|
11
12
|
break;
|
|
12
13
|
}
|
|
@@ -182,7 +182,7 @@ export const ChildMenu = memo(props => {
|
|
|
182
182
|
return !!icon || !!logo_url ? (React.createElement(Flex, { style: { flexShrink: 0 }, align: "center" }, !isNil(icon) ? (React.createElement(IconWrapper, null,
|
|
183
183
|
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)) : null;
|
|
184
184
|
};
|
|
185
|
-
const renderTitle = () => !menu_item_path || isRecommendation ? (renderLabel()) : isPushDifferentDomain(menu_item_domain, menu_item_path) ? (React.createElement("div", { onClick: () => navigatePath(menu_item_domain, menu_item_path), className: "menu-link" }, renderLabel())) : (React.createElement(Link, { to: getPath(menu_item_path), className: "menu-link", onClick: e => e.stopPropagation() }, renderLabel()));
|
|
185
|
+
const renderTitle = () => !menu_item_path || isRecommendation ? (renderLabel()) : isPushDifferentDomain(menu_item_domain, menu_item_path) ? (React.createElement("div", { onClick: () => navigatePath(menu_item_domain, menu_item_path), className: "menu-link" }, renderLabel())) : (React.createElement(Link, { to: getPath(menu_item_path, key), className: "menu-link", onClick: e => e.stopPropagation() }, renderLabel()));
|
|
186
186
|
return {
|
|
187
187
|
key,
|
|
188
188
|
label: (React.createElement(Flex, { gap: 10, align: "center", justify: "space-between", style: { height: '100%' } },
|
|
@@ -54,7 +54,10 @@ export const MARKETING_ROUTES = {
|
|
|
54
54
|
CHANNEL: '/gen2/:networkId/:user_id/marketing-hub/journeys/:channelId',
|
|
55
55
|
};
|
|
56
56
|
export const MARKETING_CHANNEL_KEY = { ALL_CHANNEL: 0, JOURNEY_ORCHESTRATION: 8 };
|
|
57
|
-
export const RENDER_OPTION = {
|
|
57
|
+
export const RENDER_OPTION = {
|
|
58
|
+
CHANNEL: 'destination_channel',
|
|
59
|
+
CHANNEL_GEN2: 'destination_channel_gen2',
|
|
60
|
+
};
|
|
58
61
|
/** SETTING APP */
|
|
59
62
|
export const SETTING_APP = {
|
|
60
63
|
CHANNEL_INTEGRATION: {
|
|
@@ -46,7 +46,7 @@ export const useLeftMenu = (props) => {
|
|
|
46
46
|
isShowPopover: false,
|
|
47
47
|
isExpandMenu: expandMenu || isOpenMenu,
|
|
48
48
|
});
|
|
49
|
-
const { mappingChildrenMenu, flattenMenuPermission, permissionMenu, activeItemPath } = usePermission();
|
|
49
|
+
const { mappingChildrenMenu, flattenMenuPermission, menuListPermission, permissionMenu, activeItemPath, } = usePermission();
|
|
50
50
|
const onMenuClick = useCallback((key, keyPath) => {
|
|
51
51
|
if (isRecommendation) {
|
|
52
52
|
setLeftMenuContextState({ customActiveCurrentKey: key });
|
|
@@ -200,13 +200,14 @@ export const useLeftMenu = (props) => {
|
|
|
200
200
|
useEffect(() => {
|
|
201
201
|
if (!isCustomized && !isRecommendation) {
|
|
202
202
|
// Callback function using at Layout when url change
|
|
203
|
-
onActiveMenuCodeChange === null || onActiveMenuCodeChange === void 0 ? void 0 : onActiveMenuCodeChange(activeItemPath, flattenMenuPermission);
|
|
203
|
+
onActiveMenuCodeChange === null || onActiveMenuCodeChange === void 0 ? void 0 : onActiveMenuCodeChange(activeItemPath, flattenMenuPermission, menuListPermission);
|
|
204
204
|
}
|
|
205
205
|
}, [
|
|
206
206
|
activeItemPath,
|
|
207
207
|
flattenMenuPermission,
|
|
208
208
|
isCustomized,
|
|
209
209
|
isRecommendation,
|
|
210
|
+
menuListPermission,
|
|
210
211
|
onActiveMenuCodeChange,
|
|
211
212
|
]);
|
|
212
213
|
useEffect(() => clearTimeout(timeoutPopover === null || timeoutPopover === void 0 ? void 0 : timeoutPopover.current), [timeoutPopover]);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const useNavigatePath: () => {
|
|
2
2
|
isPushDifferentDomain: (domain: string | null, path: string | null) => boolean;
|
|
3
|
-
getPath: (path: string | null) => string;
|
|
3
|
+
getPath: (path: string | null, itemKey?: string) => string;
|
|
4
4
|
navigatePath: (domain: string | null, path: string | null) => void;
|
|
5
5
|
};
|
|
@@ -10,6 +10,7 @@ import { getGeneratePath } from '../utils';
|
|
|
10
10
|
import { hasSelectAccountPermission } from '../../../template/Layout/utils';
|
|
11
11
|
// Constants
|
|
12
12
|
import { ENV } from '@antscorp/antsomi-ui/es/config';
|
|
13
|
+
import { KEEP_HASH_PATH_CODE } from '../../../template/Layout/constants';
|
|
13
14
|
// Hooks
|
|
14
15
|
import { usePermission } from './usePermission';
|
|
15
16
|
export const useNavigatePath = () => {
|
|
@@ -37,9 +38,9 @@ export const useNavigatePath = () => {
|
|
|
37
38
|
}
|
|
38
39
|
return !!customDomain && customDomain !== ((_f = window.location) === null || _f === void 0 ? void 0 : _f.origin);
|
|
39
40
|
}, [isDev]);
|
|
40
|
-
const getPath = useCallback((path) => {
|
|
41
|
+
const getPath = useCallback((path, itemKey) => {
|
|
41
42
|
var _a;
|
|
42
|
-
if (path === null || path === void 0 ? void 0 : path.includes('#')) {
|
|
43
|
+
if ((path === null || path === void 0 ? void 0 : path.includes('#')) && !KEEP_HASH_PATH_CODE.includes(`${itemKey}`)) {
|
|
43
44
|
const customPath = ((_a = path === null || path === void 0 ? void 0 : path.split('#')) === null || _a === void 0 ? void 0 : _a[1]) || '';
|
|
44
45
|
return getGeneratePath(customPath, auth);
|
|
45
46
|
}
|
|
@@ -2,5 +2,6 @@ export declare const usePermission: () => {
|
|
|
2
2
|
mappingChildrenMenu: import("@antscorp/antsomi-ui/es/models/LeftMenu").TFeatureMenu[];
|
|
3
3
|
permissionMenu: import("@antscorp/antsomi-ui/es/models/LeftMenu").TFeatureMenu[];
|
|
4
4
|
activeItemPath: import("@antscorp/antsomi-ui/es/models/LeftMenu").TFeatureMenu[];
|
|
5
|
+
menuListPermission: import("@antscorp/antsomi-ui/es/models/LeftMenu").FeatureMenuPermission[] | undefined;
|
|
5
6
|
flattenMenuPermission: import("@antscorp/antsomi-ui/es/models/LeftMenu").FeatureMenuPermission[];
|
|
6
7
|
};
|
|
@@ -58,7 +58,7 @@ export const usePermission = () => {
|
|
|
58
58
|
});
|
|
59
59
|
const { ownedDashboard = [], sharedDashboard = [] } = (dashboardData === null || dashboardData === void 0 ? void 0 : dashboardData.entries) || {};
|
|
60
60
|
const dashboardList = useMemo(() => uniqBy([...ownedDashboard, ...sharedDashboard], 'dashboardId'), [ownedDashboard, sharedDashboard]);
|
|
61
|
-
const { data:
|
|
61
|
+
const { data: destinationChannelGen2 } = useGetDestinationChannel({
|
|
62
62
|
args: {
|
|
63
63
|
auth: {
|
|
64
64
|
token: auth === null || auth === void 0 ? void 0 : auth.token,
|
|
@@ -72,6 +72,20 @@ export const usePermission = () => {
|
|
|
72
72
|
},
|
|
73
73
|
},
|
|
74
74
|
});
|
|
75
|
+
const { data: destinationChannel } = useGetDestinationChannel({
|
|
76
|
+
args: {
|
|
77
|
+
auth: {
|
|
78
|
+
token: auth === null || auth === void 0 ? void 0 : auth.token,
|
|
79
|
+
url: env ? `${CDP_API[env]}/hub` : '',
|
|
80
|
+
userId: auth === null || auth === void 0 ? void 0 : auth.userId,
|
|
81
|
+
portalId: auth === null || auth === void 0 ? void 0 : auth.portalId,
|
|
82
|
+
},
|
|
83
|
+
params: {
|
|
84
|
+
objectType: 'DESTINATION',
|
|
85
|
+
languageCode,
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
});
|
|
75
89
|
const { data: menuListPermission } = useGetListMenuPermission({
|
|
76
90
|
args: {
|
|
77
91
|
auth: {
|
|
@@ -95,8 +109,16 @@ export const usePermission = () => {
|
|
|
95
109
|
auth,
|
|
96
110
|
dashboardList,
|
|
97
111
|
destinationChannelEntries: destinationChannel === null || destinationChannel === void 0 ? void 0 : destinationChannel.entries,
|
|
112
|
+
destinationChannelGen2Entries: destinationChannelGen2 === null || destinationChannelGen2 === void 0 ? void 0 : destinationChannelGen2.entries,
|
|
113
|
+
isRecommendation,
|
|
114
|
+
}), [
|
|
115
|
+
auth,
|
|
116
|
+
dashboardList,
|
|
117
|
+
destinationChannel === null || destinationChannel === void 0 ? void 0 : destinationChannel.entries,
|
|
118
|
+
destinationChannelGen2 === null || destinationChannelGen2 === void 0 ? void 0 : destinationChannelGen2.entries,
|
|
98
119
|
isRecommendation,
|
|
99
|
-
|
|
120
|
+
permissionMenu,
|
|
121
|
+
]);
|
|
100
122
|
const activeItemPath = useMemo(() => {
|
|
101
123
|
const url = `${pathname}${hash}`;
|
|
102
124
|
const matchedCode = findLastMatchedItemByUrl({
|
|
@@ -113,6 +135,7 @@ export const usePermission = () => {
|
|
|
113
135
|
: [];
|
|
114
136
|
}, [auth, env, hash, mappingChildrenMenu, pathname]);
|
|
115
137
|
useEffect(() => setLeftMenuState({ dashboardList }), [dashboardList, setLeftMenuState]);
|
|
138
|
+
console.log({ menuList, menuListPermission, mappingChildrenMenu });
|
|
116
139
|
useEffect(() => {
|
|
117
140
|
if (!isCustomized) {
|
|
118
141
|
const receivePostMessage = (event) => {
|
|
@@ -132,5 +155,11 @@ export const usePermission = () => {
|
|
|
132
155
|
}
|
|
133
156
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
134
157
|
}, []);
|
|
135
|
-
return {
|
|
158
|
+
return {
|
|
159
|
+
mappingChildrenMenu,
|
|
160
|
+
permissionMenu,
|
|
161
|
+
activeItemPath,
|
|
162
|
+
menuListPermission,
|
|
163
|
+
flattenMenuPermission,
|
|
164
|
+
};
|
|
136
165
|
};
|
|
@@ -20,6 +20,6 @@ export interface LeftMenuProps {
|
|
|
20
20
|
expandMenu?: boolean;
|
|
21
21
|
onMenuItemClick?: (key: string, keyPath: string[]) => void;
|
|
22
22
|
};
|
|
23
|
-
onActiveMenuCodeChange?: (activeItemPath: TFeatureMenu[], flattenPermissionList?: FeatureMenuPermission[]) => void;
|
|
23
|
+
onActiveMenuCodeChange?: (activeItemPath: TFeatureMenu[], flattenPermissionList?: FeatureMenuPermission[], menuListPermission?: FeatureMenuPermission[]) => void;
|
|
24
24
|
}
|
|
25
25
|
export declare const LeftMenu: React.MemoExoticComponent<(props: LeftMenuProps) => React.JSX.Element | null>;
|
|
@@ -66,6 +66,7 @@ export declare const getMappingAppChildren: (args: {
|
|
|
66
66
|
auth?: Partial<PayloadInfo>;
|
|
67
67
|
dashboardList?: TDashboard[];
|
|
68
68
|
destinationChannelEntries?: TDestinationChannel[];
|
|
69
|
+
destinationChannelGen2Entries?: TDestinationChannel[];
|
|
69
70
|
isRecommendation?: boolean;
|
|
70
71
|
}) => TFeatureMenu[];
|
|
71
72
|
/**
|
|
@@ -13,7 +13,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
13
13
|
import { cloneDeep, isArray, isEmpty, sortBy } from 'lodash';
|
|
14
14
|
// Constants
|
|
15
15
|
import { APP_KEYS, MARKETING_CHANNEL_KEY, HOME_MENU_ITEMS, MARKETING_ROUTES, MENU_ITEM_TYPE, RENDER_OPTION, HOME_REPORT_ROUTES, SETTING_APP, } from '../constants';
|
|
16
|
-
import { MARKETING_CHANNEL_CODE } from '../../../template/Layout/constants';
|
|
16
|
+
import { MARKETING_CHANNEL_CODE, KEEP_HASH_PATH_CODE } from '../../../template/Layout/constants';
|
|
17
17
|
// Utils
|
|
18
18
|
import { handleError } from '@antscorp/antsomi-ui/es/utils';
|
|
19
19
|
import { ENV } from '@antscorp/antsomi-ui/es/config';
|
|
@@ -132,7 +132,7 @@ export const recursiveGetMenuItemByPermission = (featureMenuItem) => {
|
|
|
132
132
|
};
|
|
133
133
|
/** Map children to each App Item */
|
|
134
134
|
export const getMappingAppChildren = (args) => {
|
|
135
|
-
const { menuList, dashboardList, auth, destinationChannelEntries, isRecommendation } = args;
|
|
135
|
+
const { menuList, dashboardList, auth, destinationChannelEntries, destinationChannelGen2Entries, isRecommendation, } = args;
|
|
136
136
|
const recursiveAddRenderOption = (menuItem) => {
|
|
137
137
|
var _a;
|
|
138
138
|
const cloneMenuItem = cloneDeep(menuItem);
|
|
@@ -140,8 +140,6 @@ export const getMappingAppChildren = (args) => {
|
|
|
140
140
|
case RENDER_OPTION.CHANNEL: {
|
|
141
141
|
const path = (() => {
|
|
142
142
|
switch (menuItem.menu_item_code) {
|
|
143
|
-
case MARKETING_CHANNEL_CODE.CAMPAIGN:
|
|
144
|
-
return MARKETING_ROUTES.CHANNEL;
|
|
145
143
|
case SETTING_APP.CHANNEL_INTEGRATION.code:
|
|
146
144
|
return SETTING_APP.CHANNEL_INTEGRATION.path;
|
|
147
145
|
default:
|
|
@@ -158,6 +156,25 @@ export const getMappingAppChildren = (args) => {
|
|
|
158
156
|
}))))) || [];
|
|
159
157
|
break;
|
|
160
158
|
}
|
|
159
|
+
case RENDER_OPTION.CHANNEL_GEN2: {
|
|
160
|
+
const path = (() => {
|
|
161
|
+
switch (menuItem.menu_item_code) {
|
|
162
|
+
case MARKETING_CHANNEL_CODE.CAMPAIGN:
|
|
163
|
+
return MARKETING_ROUTES.CHANNEL;
|
|
164
|
+
default:
|
|
165
|
+
return '';
|
|
166
|
+
}
|
|
167
|
+
})();
|
|
168
|
+
cloneMenuItem.children =
|
|
169
|
+
(destinationChannelGen2Entries === null || destinationChannelGen2Entries === void 0 ? void 0 : destinationChannelGen2Entries.map(item => (Object.assign({}, getInitialFeatureMenuItem({
|
|
170
|
+
menu_item_code: item.channelCode,
|
|
171
|
+
menu_item_name: item.translateLabel,
|
|
172
|
+
logo_url: item.logoUrl,
|
|
173
|
+
menu_item_parent: menuItem.menu_item,
|
|
174
|
+
menu_item_path: getGeneratePath(path, Object.assign(Object.assign({}, auth), { channelId: item.channelId })),
|
|
175
|
+
}))))) || [];
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
161
178
|
default:
|
|
162
179
|
break;
|
|
163
180
|
}
|
|
@@ -206,9 +223,6 @@ export const getMappingAppChildren = (args) => {
|
|
|
206
223
|
default:
|
|
207
224
|
break;
|
|
208
225
|
}
|
|
209
|
-
// if (isRecommendation) {
|
|
210
|
-
// childMenuItem.permission_code = MARKETING_CHANNEL_CODE?.[childMenuItem.menu_item_code];
|
|
211
|
-
// }
|
|
212
226
|
return childMenuItem;
|
|
213
227
|
});
|
|
214
228
|
break;
|
|
@@ -237,10 +251,14 @@ export const findActiveAppCodeByUrl = (args) => {
|
|
|
237
251
|
const recursiveCheckHasActiveChild = (items) => {
|
|
238
252
|
let matchAppCode = false;
|
|
239
253
|
for (const item of items) {
|
|
240
|
-
if (
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
254
|
+
if (item === null || item === void 0 ? void 0 : item.menu_item_path) {
|
|
255
|
+
const comparePath = KEEP_HASH_PATH_CODE.includes(item.menu_item_code)
|
|
256
|
+
? getGeneratePath(item.menu_item_path, auth)
|
|
257
|
+
: getComparePath(getGeneratePath(item.menu_item_path, auth), env);
|
|
258
|
+
if (url.includes(comparePath)) {
|
|
259
|
+
matchAppCode = true;
|
|
260
|
+
break;
|
|
261
|
+
}
|
|
244
262
|
}
|
|
245
263
|
if ((item === null || item === void 0 ? void 0 : item.children) && item.children.length) {
|
|
246
264
|
matchAppCode = recursiveCheckHasActiveChild(item.children);
|
|
@@ -279,10 +297,13 @@ export const findLastMatchedItemByUrl = (args) => {
|
|
|
279
297
|
const matchedItems = [];
|
|
280
298
|
const recursiveFindActiveItem = (items, parentId) => {
|
|
281
299
|
for (const item of items) {
|
|
282
|
-
if (
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
300
|
+
if (item === null || item === void 0 ? void 0 : item.menu_item_path) {
|
|
301
|
+
const comparePath = KEEP_HASH_PATH_CODE.includes(item.menu_item_code)
|
|
302
|
+
? getGeneratePath(item.menu_item_path, auth)
|
|
303
|
+
: getComparePath(getGeneratePath(item.menu_item_path, auth), env);
|
|
304
|
+
if (url.includes(comparePath) && (!parentId || item.menu_item_parent === parentId)) {
|
|
305
|
+
matchedItems.push(item);
|
|
306
|
+
}
|
|
286
307
|
}
|
|
287
308
|
if ((item === null || item === void 0 ? void 0 : item.children) && item.children.length) {
|
|
288
309
|
recursiveFindActiveItem(item.children, String(item.menu_item));
|
|
@@ -121,12 +121,13 @@ export const Layout = memo(props => {
|
|
|
121
121
|
const _c = useDeepCompareMemo(() => merge(cloneDeep(leftMenuProps), cloneDeep(leftMenu)), [leftMenuProps, leftMenu, appConfig]), { className: leftMenuClassName, show: showLeftMenu = true } = _c, mergeLeftMenuProps = __rest(_c, ["className", "show"]);
|
|
122
122
|
const leftMenuAppConfig = useDeepCompareMemo(() => omit(Object.assign(Object.assign({}, appConfig), { permissionDomain }), ['setAppConfig']), [appConfig]);
|
|
123
123
|
const antsProcessingNotificationConfig = useMemo(() => (Object.assign({ permissionDomain, socketDomain: SOCKET_API, token, accountId: userId, userId, lang: languageCode, networkId: portalId }, processingNotificationProps)), [permissionDomain, token, userId, languageCode, portalId, processingNotificationProps]);
|
|
124
|
-
const onActiveMenuCodeChange = useCallback((activeItemPath, flattenPermissionList) => {
|
|
124
|
+
const onActiveMenuCodeChange = useCallback((activeItemPath, flattenPermissionList, menuListPermission) => {
|
|
125
125
|
var _a;
|
|
126
126
|
const activeMenuCode = (_a = activeItemPath === null || activeItemPath === void 0 ? void 0 : activeItemPath[(activeItemPath === null || activeItemPath === void 0 ? void 0 : activeItemPath.length) - 1]) === null || _a === void 0 ? void 0 : _a.menu_item_code;
|
|
127
127
|
setActiveMenuCode(activeMenuCode);
|
|
128
128
|
onActiveMenuChange === null || onActiveMenuChange === void 0 ? void 0 : onActiveMenuChange(activeMenuCode);
|
|
129
|
-
|
|
129
|
+
console.log({ activeItemPath, flattenPermissionList });
|
|
130
|
+
const hasRole = hasSelectAccountPermission(activeItemPath, flattenPermissionList, menuListPermission);
|
|
130
131
|
setShowAccountSelection(hasRole);
|
|
131
132
|
}, [onActiveMenuChange]);
|
|
132
133
|
return (React.createElement(LayoutWrapper, { showLeftMenu: !!showLeftMenu },
|
|
@@ -3,10 +3,12 @@ import React, { useLayoutEffect } from 'react';
|
|
|
3
3
|
// Components
|
|
4
4
|
import { MenuMapping, RecommendationImage } from './components';
|
|
5
5
|
import { Flex } from '../../../../atoms';
|
|
6
|
+
// Stores
|
|
6
7
|
import { useLayoutStore } from '../../stores';
|
|
7
8
|
export const RecommendationWorkspace = () => {
|
|
8
9
|
const setHeaderState = useLayoutStore(store => store.setHeaderState);
|
|
9
10
|
useLayoutEffect(() => {
|
|
11
|
+
document.title = 'Recommendation';
|
|
10
12
|
setHeaderState({
|
|
11
13
|
pageTitle: 'Recommendation',
|
|
12
14
|
});
|
|
@@ -14,4 +14,4 @@ export declare const checkingRoleScope: (args: {
|
|
|
14
14
|
scope?: number;
|
|
15
15
|
isExactly?: boolean;
|
|
16
16
|
}) => boolean;
|
|
17
|
-
export declare const hasSelectAccountPermission: (activeItemPath: TFeatureMenu[], flattenPermissionList?: FeatureMenuPermission[]) => boolean;
|
|
17
|
+
export declare const hasSelectAccountPermission: (activeItemPath: TFeatureMenu[], flattenPermissionList?: FeatureMenuPermission[], menuListPermission?: FeatureMenuPermission[]) => boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MENU_CODE, APP_ROLE_SCOPE, MENU_PERMISSIONS } from '../constants';
|
|
1
|
+
import { MENU_CODE, APP_ROLE_SCOPE, MENU_PERMISSIONS, KEEP_HASH_PATH_CODE } from '../constants';
|
|
2
2
|
import { isEmpty } from 'lodash';
|
|
3
3
|
const EDIT_ROLE = new Set(['CREATE', 'UPDATE', 'DELETE']);
|
|
4
4
|
/**
|
|
@@ -19,6 +19,7 @@ export const checkingRoleScope = (args) => {
|
|
|
19
19
|
MENU_CODE.EMAIL_TEMPLATE,
|
|
20
20
|
MENU_CODE.BATCH_STREAMING,
|
|
21
21
|
MENU_CODE.REALTIME_STREAMING,
|
|
22
|
+
MENU_CODE.DATA_SOURCE,
|
|
22
23
|
// MENU_CODE.SEGMENT,
|
|
23
24
|
// MENU_CODE.DESTINATIONS_HUB,
|
|
24
25
|
MENU_CODE.BUSINESS_OBJECT,
|
|
@@ -49,7 +50,7 @@ export const checkingRoleScope = (args) => {
|
|
|
49
50
|
}
|
|
50
51
|
return isOK;
|
|
51
52
|
};
|
|
52
|
-
export const hasSelectAccountPermission = (activeItemPath, flattenPermissionList) => {
|
|
53
|
+
export const hasSelectAccountPermission = (activeItemPath, flattenPermissionList, menuListPermission) => {
|
|
53
54
|
if (isEmpty(activeItemPath))
|
|
54
55
|
return false;
|
|
55
56
|
let roleScope = false;
|
|
@@ -70,7 +71,12 @@ export const hasSelectAccountPermission = (activeItemPath, flattenPermissionList
|
|
|
70
71
|
else {
|
|
71
72
|
permissionCode = activeItem.permission_code;
|
|
72
73
|
}
|
|
73
|
-
const menuPermission =
|
|
74
|
+
const menuPermission = (() => {
|
|
75
|
+
if (KEEP_HASH_PATH_CODE.includes(activeItem.menu_item_code)) {
|
|
76
|
+
// return;
|
|
77
|
+
}
|
|
78
|
+
return flattenPermissionList === null || flattenPermissionList === void 0 ? void 0 : flattenPermissionList.find(item => permissionCode === item.menu_code);
|
|
79
|
+
})();
|
|
74
80
|
if (menuPermission) {
|
|
75
81
|
const checkRoleScope = menuPermission
|
|
76
82
|
? checkingRoleScope({
|