@antscorp/antsomi-ui 1.3.5-beta.469 → 1.3.5-beta.470
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/organism/LeftMenu/hooks/useNavigatePath.js +1 -1
- package/es/components/template/Layout/Layout.js +6 -1
- package/es/components/template/Layout/constants/menuCode.d.ts +1 -1
- package/es/components/template/Layout/constants/menuCode.js +1 -1
- package/es/components/template/Layout/utils/permission.d.ts +6 -1
- package/es/components/template/Layout/utils/permission.js +17 -3
- package/package.json +1 -1
|
@@ -19,7 +19,7 @@ export const useNavigatePath = () => {
|
|
|
19
19
|
const { search } = useLocation();
|
|
20
20
|
const isDev = env === ENV.DEV;
|
|
21
21
|
const { activeItemPath, flattenMenuPermission } = usePermission();
|
|
22
|
-
const hasRole = useDeepCompareMemo(() => hasSelectAccountPermission(activeItemPath, flattenMenuPermission), [activeItemPath, flattenMenuPermission]);
|
|
22
|
+
const hasRole = useDeepCompareMemo(() => hasSelectAccountPermission({ activeItemPath, flattenPermissionList: flattenMenuPermission }), [activeItemPath, flattenMenuPermission]);
|
|
23
23
|
const urlParams = useMemo(() => new URLSearchParams(search), [search]);
|
|
24
24
|
const oidParam = hasRole ? urlParams.get('oid') : null;
|
|
25
25
|
const searchParams = oidParam ? `?oid=${oidParam}` : '';
|
|
@@ -126,7 +126,12 @@ export const Layout = memo(props => {
|
|
|
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
|
-
const hasRole = hasSelectAccountPermission(
|
|
129
|
+
const hasRole = hasSelectAccountPermission({
|
|
130
|
+
activeItemPath: cloneDeep(activeItemPath),
|
|
131
|
+
flattenPermissionList,
|
|
132
|
+
menuListPermission,
|
|
133
|
+
appItem: activeItemPath[0],
|
|
134
|
+
});
|
|
130
135
|
setShowAccountSelection(hasRole);
|
|
131
136
|
}, [onActiveMenuChange]);
|
|
132
137
|
return (React.createElement(LayoutWrapper, { showLeftMenu: !!showLeftMenu },
|
|
@@ -14,4 +14,9 @@ export declare const checkingRoleScope: (args: {
|
|
|
14
14
|
scope?: number;
|
|
15
15
|
isExactly?: boolean;
|
|
16
16
|
}) => boolean;
|
|
17
|
-
export declare const hasSelectAccountPermission: (
|
|
17
|
+
export declare const hasSelectAccountPermission: (args: {
|
|
18
|
+
activeItemPath: TFeatureMenu[];
|
|
19
|
+
flattenPermissionList?: FeatureMenuPermission[];
|
|
20
|
+
menuListPermission?: FeatureMenuPermission[];
|
|
21
|
+
appItem?: TFeatureMenu;
|
|
22
|
+
}) => boolean;
|
|
@@ -19,7 +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.
|
|
22
|
+
MENU_CODE.DATASOURCES,
|
|
23
23
|
// MENU_CODE.SEGMENT,
|
|
24
24
|
// MENU_CODE.DESTINATIONS_HUB,
|
|
25
25
|
MENU_CODE.BUSINESS_OBJECT,
|
|
@@ -50,7 +50,8 @@ export const checkingRoleScope = (args) => {
|
|
|
50
50
|
}
|
|
51
51
|
return isOK;
|
|
52
52
|
};
|
|
53
|
-
export const hasSelectAccountPermission = (
|
|
53
|
+
export const hasSelectAccountPermission = (args) => {
|
|
54
|
+
const { activeItemPath, flattenPermissionList, menuListPermission, appItem } = args;
|
|
54
55
|
if (isEmpty(activeItemPath))
|
|
55
56
|
return false;
|
|
56
57
|
let roleScope = false;
|
|
@@ -72,8 +73,21 @@ export const hasSelectAccountPermission = (activeItemPath, flattenPermissionList
|
|
|
72
73
|
permissionCode = activeItem.permission_code;
|
|
73
74
|
}
|
|
74
75
|
const menuPermission = (() => {
|
|
76
|
+
var _a;
|
|
75
77
|
if (KEEP_HASH_PATH_CODE.includes(activeItem.menu_item_code)) {
|
|
76
|
-
|
|
78
|
+
if (appItem) {
|
|
79
|
+
const appPermission = (() => {
|
|
80
|
+
switch (appItem === null || appItem === void 0 ? void 0 : appItem.permission_code) {
|
|
81
|
+
case 'SQL_WORKSPACE':
|
|
82
|
+
return 'APP_ANTALYSER';
|
|
83
|
+
default:
|
|
84
|
+
return appItem === null || appItem === void 0 ? void 0 : appItem.permission_code;
|
|
85
|
+
}
|
|
86
|
+
})();
|
|
87
|
+
const parentMenu = menuListPermission === null || menuListPermission === void 0 ? void 0 : menuListPermission.find(item => item.app_code === appPermission);
|
|
88
|
+
return (_a = parentMenu === null || parentMenu === void 0 ? void 0 : parentMenu.childs) === null || _a === void 0 ? void 0 : _a.find(item => item.menu_code === permissionCode);
|
|
89
|
+
}
|
|
90
|
+
return;
|
|
77
91
|
}
|
|
78
92
|
return flattenPermissionList === null || flattenPermissionList === void 0 ? void 0 : flattenPermissionList.find(item => permissionCode === item.menu_code);
|
|
79
93
|
})();
|