@antscorp/antsomi-ui 1.7.5 → 1.7.6

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.
Files changed (24) hide show
  1. package/CHANGELOG.md +10 -2
  2. package/es/components/molecules/ShareAccess/components/GeneralAccess/GeneralAccess.js +1 -1
  3. package/es/components/molecules/ShareAccess/components/GeneralAccess/styled.js +2 -0
  4. package/es/components/organism/LeftMenu/components/common/ChildMenu/index.js +31 -19
  5. package/es/components/organism/LeftMenu/constants/variables.d.ts +8 -0
  6. package/es/components/organism/LeftMenu/constants/variables.js +8 -0
  7. package/es/components/organism/LeftMenu/hooks/useLeftMenu.js +2 -0
  8. package/es/components/organism/LeftMenu/hooks/usePermission.js +13 -0
  9. package/es/components/organism/LeftMenu/styled.js +4 -0
  10. package/es/components/organism/LeftMenu/types/index.d.ts +2 -0
  11. package/es/components/organism/LeftMenu/utils/index.d.ts +3 -1
  12. package/es/components/organism/LeftMenu/utils/index.js +36 -21
  13. package/es/components/template/Layout/Layout.js +0 -3
  14. package/es/components/template/Layout/components/RecommendationWorkspace/components/MenuMapping/components/OldLeftMenu/index.js +2 -0
  15. package/es/components/template/Layout/components/RecommendationWorkspace/components/MenuMapping/components/OldLeftMenu/styled.js +3 -0
  16. package/es/constants/queries.d.ts +1 -0
  17. package/es/constants/queries.js +1 -0
  18. package/es/models/AccountListing.d.ts +12 -0
  19. package/es/models/LeftMenu/FeatureMenuPermission.d.ts +2 -1
  20. package/es/queries/Account/useGetAccountList.d.ts +9 -4
  21. package/es/queries/Account/useGetAccountList.js +6 -1
  22. package/es/services/Account/index.d.ts +7 -5
  23. package/es/services/Account/index.js +24 -0
  24. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -4,16 +4,24 @@ All notable changes to this project will be documented in this file. Dates are d
4
4
 
5
5
  Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
6
6
 
7
- #### [v1.7.5](https://bitbucket.org/git-vn/at.packages.frontend/compare/v1.7.5..v2.0.22)
7
+ #### [v1.7.6](https://bitbucket.org/git-vn/at.packages.frontend/compare/v1.7.6..v2.0.22)
8
8
 
9
9
  - chore: update storybook version [`d13f194`](https://bitbucket.org/git-vn/at.packages.frontend/commits/d13f19462c2fe117934df7fe2e09fd0aa95a0167)
10
10
  - feat: update input width when in view [`f27b982`](https://bitbucket.org/git-vn/at.packages.frontend/commits/f27b982a4427c414a1b5d5538641516a3d35aa6e)
11
11
  - chore: update datatable components [`d38cf96`](https://bitbucket.org/git-vn/at.packages.frontend/commits/d38cf9687b2a6fd03396247d04c6ef37a6b030f1)
12
12
 
13
- ### [v2.0.22](https://bitbucket.org/git-vn/at.packages.frontend/compare/v2.0.22..v1.7.4)
13
+ ### [v2.0.22](https://bitbucket.org/git-vn/at.packages.frontend/compare/v2.0.22..v1.7.5)
14
14
 
15
15
  > 19 January 2023
16
16
 
17
+ #### [v1.7.5](https://bitbucket.org/git-vn/at.packages.frontend/compare/v1.7.5..v1.7.4)
18
+
19
+ > 11 July 2024
20
+
21
+ - feat(compoents): add component AccountProfile [`e504187`](https://bitbucket.org/git-vn/at.packages.frontend/commits/e5041873fa3236acf35312801754240a7542b8dd)
22
+ - chore(component): remove unuse common folder [`5123bac`](https://bitbucket.org/git-vn/at.packages.frontend/commits/5123bac8005db98661ca48c500aab56ac42b1feb)
23
+ - chore: update formatFitlerValue for useTablisting hook [`2b173a0`](https://bitbucket.org/git-vn/at.packages.frontend/commits/2b173a02ab8fb24a8cd3b6d1c8403c111e831eb4)
24
+
17
25
  #### [v1.7.4](https://bitbucket.org/git-vn/at.packages.frontend/compare/v1.7.4..v1.3.5-beta.446)
18
26
 
19
27
  > 5 July 2024
@@ -59,7 +59,7 @@ export const GeneralAccess = ({ generalAccessSettings }) => {
59
59
  React.createElement("div", { className: "accessable-title" }, isPublic ? 'Public' : 'Restricted'),
60
60
  allowEdit && (React.createElement(Icon, { className: "icon-angle", type: "icon-ants-expand-more", style: { fontSize: 20 } })))),
61
61
  React.createElement("div", { className: "description" }, renderDescription())),
62
- !!isPublic && publicRole && (React.createElement(Dropdown, { placement: "bottomLeft", trigger: ['click'], destroyPopupOnHide: true, disabled: !allowEdit || isShowOnlyText, overlayStyle: { zIndex: 3002 }, menu: {
62
+ !!isPublic && publicRole && (React.createElement(Dropdown, { placement: "bottomRight", trigger: ['click'], destroyPopupOnHide: true, disabled: !allowEdit || isShowOnlyText, overlayStyle: { zIndex: 3002 }, menu: {
63
63
  items: [
64
64
  publicRole === PUBLIC_ROLE.ONLY_VIEWER
65
65
  ? {
@@ -11,6 +11,7 @@ export const StyledGeneralAccessRoot = styled.div `
11
11
 
12
12
  .setting {
13
13
  display: flex;
14
+ align-items: center;
14
15
  justify-content: space-between;
15
16
  border: 1px solid #e6e6e6;
16
17
  border-radius: ${(_a = THEME.token) === null || _a === void 0 ? void 0 : _a.borderRadius}px;
@@ -53,6 +54,7 @@ export const StyledGeneralAccessRoot = styled.div `
53
54
  display: flex;
54
55
  align-items: center;
55
56
  gap: 4px;
57
+ cursor: pointer;
56
58
  }
57
59
  }
58
60
  `;
@@ -1,3 +1,4 @@
1
+ var _a;
1
2
  // Libraries
2
3
  import React, { memo, useState } from 'react';
3
4
  import Icon from '@antscorp/icons';
@@ -21,11 +22,13 @@ import { useNavigatePath } from '../../../hooks';
21
22
  import { useDeepCompareEffect } from '@antscorp/antsomi-ui/es/hooks';
22
23
  // Contexts
23
24
  import { useLeftMenuContext } from '../../../contexts';
25
+ import { THEME } from '@antscorp/antsomi-ui/es/constants';
24
26
  const noDashboardItem = {
25
27
  key: 'no_dashboard',
26
- label: 'No dashboard available',
28
+ label: 'Click Create to make a dashboard',
27
29
  disabled: true,
28
30
  icon: null,
31
+ style: { fontSize: '10px', color: (_a = THEME === null || THEME === void 0 ? void 0 : THEME.token) === null || _a === void 0 ? void 0 : _a.bw8 },
29
32
  };
30
33
  const styles = {
31
34
  dropdownMenu: { width: '130px', padding: '8px 0' },
@@ -51,6 +54,9 @@ export const ChildMenu = memo(props => {
51
54
  const [openKeys, setOpenKeys] = useState([]);
52
55
  const { pathname, hash } = window.location;
53
56
  const { isPushDifferentDomain, getPath, navigatePath } = useNavigatePath();
57
+ useDeepCompareEffect(() => {
58
+ setOpenKeys((items === null || items === void 0 ? void 0 : items.map(item => item.key)) || []);
59
+ }, [items]);
54
60
  useDeepCompareEffect(() => {
55
61
  switch (true) {
56
62
  case isCustomized: {
@@ -129,25 +135,31 @@ export const ChildMenu = memo(props => {
129
135
  env,
130
136
  ]);
131
137
  const onClick = e => {
132
- var _a;
133
138
  if (isRecommendation) {
134
- const permissionCode = (_a = recursiveFindItemByKey({
135
- activeKey: e.key,
136
- menuItems: items || [],
137
- })) === null || _a === void 0 ? void 0 : _a.permission_code;
138
- const permissionCodePath = (() => {
139
+ const [permissionCode, permissionCodePath] = (() => {
139
140
  var _a;
140
- const array = [];
141
- (_a = e.keyPath) === null || _a === void 0 ? void 0 : _a.forEach(item => {
141
+ if (e.key === 'WEB_PERSONALIZE') {
142
+ return ['WEB_PERSONALIZE-JOURNEY', ['WEB_PERSONALIZE-JOURNEY']];
143
+ }
144
+ const permissionCode = (_a = recursiveFindItemByKey({
145
+ activeKey: e.key,
146
+ menuItems: items || [],
147
+ })) === null || _a === void 0 ? void 0 : _a.permission_code;
148
+ const permissionCodePath = (() => {
142
149
  var _a;
143
- const permissionCode = (_a = recursiveFindItemByKey({
144
- activeKey: item,
145
- menuItems: items || [],
146
- })) === null || _a === void 0 ? void 0 : _a.permission_code;
147
- if (permissionCode)
148
- array.push(permissionCode);
149
- });
150
- return uniq(array);
150
+ const array = [];
151
+ (_a = e.keyPath) === null || _a === void 0 ? void 0 : _a.forEach(item => {
152
+ var _a;
153
+ const permissionCode = (_a = recursiveFindItemByKey({
154
+ activeKey: item,
155
+ menuItems: items || [],
156
+ })) === null || _a === void 0 ? void 0 : _a.permission_code;
157
+ if (permissionCode)
158
+ array.push(permissionCode);
159
+ });
160
+ return uniq(array);
161
+ })();
162
+ return [permissionCode, permissionCodePath];
151
163
  })();
152
164
  if (permissionCode)
153
165
  onMenuClick === null || onMenuClick === void 0 ? void 0 : onMenuClick(permissionCode, permissionCodePath);
@@ -160,9 +172,9 @@ export const ChildMenu = memo(props => {
160
172
  const customMenuItems = (args) => {
161
173
  var _a;
162
174
  return (_a = args === null || args === void 0 ? void 0 : args.items) === null || _a === void 0 ? void 0 : _a.map(item => {
163
- const { key, label, children, icon, logo_url, menu_item_path = null, menu_item_domain = null, options, disabled, optionCallback, } = item;
175
+ const { key, label, children, icon, logo_url, menu_item_path = null, menu_item_domain = null, options, disabled, style, optionCallback, } = item;
164
176
  const isOwnerDashboardKey = key === HOME_MENU_ITEMS.DASHBOARD.menu_item_code;
165
- const renderLabel = () => (React.createElement(LabelWrapper, { gap: 10, align: "center", justify: "space-between" },
177
+ const renderLabel = () => (React.createElement(LabelWrapper, { gap: 10, align: "center", justify: "space-between", style: style },
166
178
  React.createElement(LabelCustom, { ellipsis: { tooltip: label } }, label),
167
179
  (options === null || options === void 0 ? void 0 : options.length) && !isRecommendation && (React.createElement(OptionDropdownWrapper, { align: "center" },
168
180
  React.createElement(Dropdown, { menu: {
@@ -8,6 +8,7 @@ export declare const APP_KEYS: {
8
8
  DATA: string;
9
9
  INSIGHTS: string;
10
10
  SETTINGS: string;
11
+ SHARE_ACCESS: string;
11
12
  };
12
13
  export declare const MENU_ITEM_TYPE: {
13
14
  APP: number;
@@ -40,3 +41,10 @@ export declare const SETTING_APP: {
40
41
  path: string;
41
42
  };
42
43
  };
44
+ /** Some app in old menu permission is deprecated then we should remove */
45
+ export declare const APP_EXCLUDED_KEYS: string[];
46
+ /** Some app need to map app code to check duplicate permission_code */
47
+ export declare const MAP_MENU_TO_PARENT_APP_CODE: {
48
+ DATA_SOURCE: string;
49
+ DF_DATA_SOURCE: string;
50
+ };
@@ -7,6 +7,7 @@ export const APP_KEYS = {
7
7
  DATA: 'DATA',
8
8
  INSIGHTS: 'INSIGHT',
9
9
  SETTINGS: 'SETTING',
10
+ SHARE_ACCESS: 'SHARE_ACCESS',
10
11
  };
11
12
  export const MENU_ITEM_TYPE = {
12
13
  APP: 1,
@@ -52,3 +53,10 @@ export const SETTING_APP = {
52
53
  path: '/gen2/:networkId/:user_id/marketing-hub/destinations/:channelId',
53
54
  },
54
55
  };
56
+ /** Some app in old menu permission is deprecated then we should remove */
57
+ export const APP_EXCLUDED_KEYS = [APP_KEYS.SHARE_ACCESS];
58
+ /** Some app need to map app code to check duplicate permission_code */
59
+ export const MAP_MENU_TO_PARENT_APP_CODE = {
60
+ DATA_SOURCE: 'APP_ANTALYSER',
61
+ DF_DATA_SOURCE: 'DATAFLOWS',
62
+ };
@@ -28,6 +28,8 @@ export const useLeftMenu = (props) => {
28
28
  return 'SQL_WORKSPACE';
29
29
  case 'DATASOURCES-APP_ANTALYSER':
30
30
  return 'DATASOURCES-SQL_WORKSPACE';
31
+ case 'WEB_PERSONALIZE-JOURNEY':
32
+ return 'WEB_PERSONALIZE';
31
33
  default:
32
34
  return activeKey;
33
35
  }
@@ -10,6 +10,7 @@ import { CDP_API, PERMISSION_API, POST_MESSAGE_TYPES } from '@antscorp/antsomi-u
10
10
  import { ENV } from '@antscorp/antsomi-ui/es/config';
11
11
  // Utils
12
12
  import { findLastMatchedItemByUrl, findPathOfActiveItem, flattenMenuArray, getMappingAppChildren, recursivePermissionMenu, } from '../utils';
13
+ import { useCheckUserPermission } from '@antscorp/antsomi-ui/es/queries';
13
14
  const { DEV, SANDBOX, SANDBOX_CDP } = ENV;
14
15
  export const usePermission = () => {
15
16
  const appConfig = useLeftMenuContext(store => store.appConfig);
@@ -42,6 +43,16 @@ export const usePermission = () => {
42
43
  enabled: !!(auth === null || auth === void 0 ? void 0 : auth.userId) && !!auth.portalId,
43
44
  },
44
45
  });
46
+ const { data: userPermission } = useCheckUserPermission({
47
+ apiConfig: {
48
+ userId: +((auth === null || auth === void 0 ? void 0 : auth.userId) || 0),
49
+ accountId: +((auth === null || auth === void 0 ? void 0 : auth.accountId) || 0),
50
+ portalId: auth === null || auth === void 0 ? void 0 : auth.portalId,
51
+ token: auth === null || auth === void 0 ? void 0 : auth.token,
52
+ languageCode,
53
+ domain: 'https://sandbox-app.cdp.asia',
54
+ },
55
+ });
45
56
  const { data: dashboardData, refetch: refetchDashboard } = useGetDashboard({
46
57
  args: {
47
58
  auth: {
@@ -113,6 +124,7 @@ export const usePermission = () => {
113
124
  destinationChannelEntries: destinationChannel === null || destinationChannel === void 0 ? void 0 : destinationChannel.entries,
114
125
  destinationChannelGen2Entries: destinationChannelGen2 === null || destinationChannelGen2 === void 0 ? void 0 : destinationChannelGen2.entries,
115
126
  isRecommendation,
127
+ userPermission,
116
128
  }), [
117
129
  auth,
118
130
  dashboardList,
@@ -120,6 +132,7 @@ export const usePermission = () => {
120
132
  destinationChannelGen2 === null || destinationChannelGen2 === void 0 ? void 0 : destinationChannelGen2.entries,
121
133
  isRecommendation,
122
134
  permissionMenu,
135
+ userPermission,
123
136
  ]);
124
137
  const activeItemPath = useMemo(() => {
125
138
  const url = `${pathname}${hash}`;
@@ -116,6 +116,10 @@ export const FeatureMenu = styled.ul `
116
116
 
117
117
  .menu-content {
118
118
  flex-shrink: 0;
119
+
120
+ &.scroll-content {
121
+ margin-right: 0px !important;
122
+ }
119
123
  }
120
124
 
121
125
  .nav-blank {
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { TFeatureMenu } from '@antscorp/antsomi-ui/es/models/LeftMenu';
2
3
  export type TMenuItem = Omit<Partial<TFeatureMenu>, 'children' | keyof TRequireMenuItemKey> & {
3
4
  key: string;
@@ -5,6 +6,7 @@ export type TMenuItem = Omit<Partial<TFeatureMenu>, 'children' | keyof TRequireM
5
6
  icon: string | null;
6
7
  disabled?: boolean;
7
8
  children?: TMenuItem[];
9
+ style?: React.CSSProperties;
8
10
  } & TOption;
9
11
  export type TMenuFeatureItem = Omit<Partial<TFeatureMenu>, 'children'> & TRequireMenuItemKey & TOption & {
10
12
  children?: TMenuFeatureItem[];
@@ -2,6 +2,7 @@ import { FeatureMenuPermission, TDashboard, TDestinationChannel, TFeatureMenu }
2
2
  import { PayloadInfo } from '@antscorp/antsomi-ui/es/types';
3
3
  import { TMenuFeatureItem, TMenuItem } from '../types';
4
4
  import { TEnv } from '@antscorp/antsomi-ui/es/types/config';
5
+ import { TAccountPermission } from '@antscorp/antsomi-ui/es/models/AccountListing';
5
6
  /**
6
7
  * Converts a feature menu item to a menu item suitable for rendering in the UI.
7
8
  * @param {TMenuFeatureItem} featureMenu - The feature menu item to convert.
@@ -15,7 +16,7 @@ export declare const getMenuItem: (featureMenu: TMenuFeatureItem) => TMenuItem;
15
16
  * @param {string} childKey - The key representing the children array in each menu item.
16
17
  * @returns {T[]} The flattened array of menu items.
17
18
  */
18
- export declare const flattenMenuArray: <T>(menuItems: T[], childKey: string) => T[];
19
+ export declare const flattenMenuArray: (menuItems: FeatureMenuPermission[], childKey: string, parentAppCode?: FeatureMenuPermission['parent_app_code']) => FeatureMenuPermission[];
19
20
  /**
20
21
  * Recursively filters menu items based on permissions.
21
22
  * check permission if menu item has menu_type of @alias MENU_ITEM_TYPE.MENU
@@ -70,6 +71,7 @@ export declare const getMappingAppChildren: (args: {
70
71
  destinationChannelEntries?: TDestinationChannel[];
71
72
  destinationChannelGen2Entries?: TDestinationChannel[];
72
73
  isRecommendation?: boolean;
74
+ userPermission?: TAccountPermission;
73
75
  }) => TFeatureMenu[];
74
76
  /**
75
77
  * Finds the app code of the active menu item based on the provided URL within the given menu items.
@@ -12,7 +12,7 @@ var __rest = (this && this.__rest) || function (s, e) {
12
12
  // Libraries
13
13
  import { cloneDeep, isArray, isEmpty, sortBy } from 'lodash';
14
14
  // Constants
15
- import { APP_KEYS, MARKETING_CHANNEL_KEY, HOME_MENU_ITEMS, MARKETING_ROUTES, MENU_ITEM_TYPE, RENDER_OPTION, HOME_REPORT_ROUTES, SETTING_APP, } from '../constants';
15
+ import { APP_KEYS, MARKETING_CHANNEL_KEY, HOME_MENU_ITEMS, MARKETING_ROUTES, MENU_ITEM_TYPE, RENDER_OPTION, HOME_REPORT_ROUTES, SETTING_APP, APP_EXCLUDED_KEYS, MAP_MENU_TO_PARENT_APP_CODE, } from '../constants';
16
16
  import { MARKETING_CHANNEL_CODE, KEEP_HASH_PATH_DEV } from '../../../template/Layout/constants';
17
17
  // Utils
18
18
  import { handleError } from '@antscorp/antsomi-ui/es/utils';
@@ -35,15 +35,19 @@ export const getMenuItem = (featureMenu) => {
35
35
  * @param {string} childKey - The key representing the children array in each menu item.
36
36
  * @returns {T[]} The flattened array of menu items.
37
37
  */
38
- export const flattenMenuArray = (menuItems, childKey) => {
38
+ export const flattenMenuArray = (menuItems, childKey, parentAppCode) => {
39
39
  let result = [];
40
- menuItems.forEach(item => {
40
+ for (const item of menuItems) {
41
+ // If item has app_code and the app code is in the excluded list, skip it
42
+ if (!!item.app_code && APP_EXCLUDED_KEYS.includes(item.app_code)) {
43
+ continue;
44
+ }
41
45
  const children = (item === null || item === void 0 ? void 0 : item[childKey]) || [];
42
- result.push(Object.assign(Object.assign({}, item), { [childKey]: [] }));
46
+ result.push(Object.assign(Object.assign(Object.assign({}, item), (parentAppCode ? { parent_app_code: parentAppCode } : {})), { [childKey]: [] }));
43
47
  if (children.length > 0) {
44
- result = [...result, ...flattenMenuArray(children, childKey)];
48
+ result = [...result, ...flattenMenuArray(children, childKey, item.app_code)];
45
49
  }
46
- });
50
+ }
47
51
  return result;
48
52
  };
49
53
  /**
@@ -52,11 +56,22 @@ export const flattenMenuArray = (menuItems, childKey) => {
52
56
  */
53
57
  export const recursivePermissionMenu = (menuItems, menuPermissions) => {
54
58
  var _a, _b;
55
- const menu = (_b = (_a = menuItems === null || menuItems === void 0 ? void 0 : menuItems.filter(({ permission_code, menu_item_type }) => {
59
+ const menu = (_b = (_a = menuItems === null || menuItems === void 0 ? void 0 : menuItems.filter(({ permission_code, menu_item_type, menu_item_code }) => {
56
60
  if (Number(menu_item_type) !== MENU_ITEM_TYPE.MENU) {
57
61
  return true;
58
62
  }
59
- return !!(menuPermissions === null || menuPermissions === void 0 ? void 0 : menuPermissions.find(({ menu_code = '' }) => !!permission_code && [menu_code].includes(permission_code)));
63
+ return !!(menuPermissions === null || menuPermissions === void 0 ? void 0 : menuPermissions.find(({ menu_code = '', parent_app_code }) => {
64
+ if (permission_code) {
65
+ const parentAppCode = MAP_MENU_TO_PARENT_APP_CODE[menu_item_code];
66
+ // If parent app code is exist in the MAP_MENU_TO_PARENT_APP_CODE then check with parent app code
67
+ if (parentAppCode && parent_app_code) {
68
+ return parentAppCode === parent_app_code && [menu_code].includes(permission_code);
69
+ }
70
+ // Else just check with menu_code
71
+ return [menu_code].includes(permission_code);
72
+ }
73
+ return false;
74
+ }));
60
75
  })) === null || _a === void 0 ? void 0 : _a.map(item => (Object.assign(Object.assign({}, item), (isArray(item.children)
61
76
  ? {
62
77
  children: recursivePermissionMenu(sortBy(item.children || [], ['level_position']), menuPermissions),
@@ -71,13 +86,6 @@ export const recursivePermissionMenu = (menuItems, menuPermissions) => {
71
86
  export const getGeneratePath = (path, params) => {
72
87
  try {
73
88
  const { portalId, userId, dashboardId, channelId } = params || {};
74
- // return generatePath(path, {
75
- // user_id: userId ?? '-1',
76
- // networkId: portalId ?? -1,
77
- // portalId: portalId ?? -1,
78
- // dashboardId: dashboardId ?? '-1',
79
- // channelId: channelId ?? -1,
80
- // });
81
89
  const paramsObjects = {
82
90
  user_id: userId !== null && userId !== void 0 ? userId : '-1',
83
91
  networkId: portalId !== null && portalId !== void 0 ? portalId : -1,
@@ -124,7 +132,7 @@ export const recursiveGetInitialFeatureMenuItem = (featureMenuItem) => (Object.a
124
132
  export const recursiveGetMenuItemByPermission = (featureMenuItem) => {
125
133
  var _a;
126
134
  return ({
127
- key: featureMenuItem.permission_code || 'null',
135
+ key: featureMenuItem.permission_code || featureMenuItem.menu_item_code || 'null',
128
136
  label: featureMenuItem.menu_item_name,
129
137
  icon: featureMenuItem.icon_name,
130
138
  logo_url: featureMenuItem.logo_url,
@@ -133,7 +141,7 @@ export const recursiveGetMenuItemByPermission = (featureMenuItem) => {
133
141
  };
134
142
  /** Map children to each App Item */
135
143
  export const getMappingAppChildren = (args) => {
136
- const { menuList, dashboardList, auth, destinationChannelEntries, destinationChannelGen2Entries, isRecommendation, } = args;
144
+ const { menuList, dashboardList, auth, destinationChannelEntries, destinationChannelGen2Entries, isRecommendation, userPermission, } = args;
137
145
  const recursiveAddRenderOption = (menuItem) => {
138
146
  var _a;
139
147
  const cloneMenuItem = cloneDeep(menuItem);
@@ -207,10 +215,17 @@ export const getMappingAppChildren = (args) => {
207
215
  })), { children: (_a = dashboardObject === null || dashboardObject === void 0 ? void 0 : dashboardObject[childMenuItem.menu_item_code]) === null || _a === void 0 ? void 0 : _a.map(item => {
208
216
  const { shareAccess } = item || {};
209
217
  const dashboardEditable = (() => {
210
- var _a, _b;
211
- if (isEmpty(shareAccess))
212
- return true;
213
- return (((_b = (_a = shareAccess === null || shareAccess === void 0 ? void 0 : shareAccess.list_access) === null || _a === void 0 ? void 0 : _a.find(item => item.user_id === (auth === null || auth === void 0 ? void 0 : auth.userId))) === null || _b === void 0 ? void 0 : _b.allow_edit) === FEATURE_PERMISSIONS.EVERYTHING);
218
+ var _a, _b, _c;
219
+ switch ((_a = userPermission === null || userPermission === void 0 ? void 0 : userPermission.permissions) === null || _a === void 0 ? void 0 : _a.edit) {
220
+ case 'EVERYTHING':
221
+ return true;
222
+ case 'NONE':
223
+ return false;
224
+ default:
225
+ if (isEmpty(shareAccess))
226
+ return true;
227
+ return (((_c = (_b = shareAccess === null || shareAccess === void 0 ? void 0 : shareAccess.list_access) === null || _b === void 0 ? void 0 : _b.find(item => item.user_id === (auth === null || auth === void 0 ? void 0 : auth.userId))) === null || _c === void 0 ? void 0 : _c.allow_edit) === FEATURE_PERMISSIONS.EVERYTHING);
228
+ }
214
229
  })();
215
230
  return Object.assign({}, getInitialFeatureMenuItem({
216
231
  menu_item: String(item.dashboardId),
@@ -51,9 +51,7 @@ export const Layout = memo(props => {
51
51
  const [noSpaceTopContent, setNoSpaceTopContent] = useState(false);
52
52
  const [activeMenuCode, setActiveMenuCode] = useState('');
53
53
  const [activePageTitle, setActivePageTitle] = useState('');
54
- // Refs
55
54
  const notificationWrapperRef = useRef(null);
56
- // Hooks
57
55
  useMutationObserver(() => {
58
56
  if (notificationWrapperRef.current) {
59
57
  const child = notificationWrapperRef.current.querySelector('div');
@@ -67,7 +65,6 @@ export const Layout = memo(props => {
67
65
  attributeOldValue: true,
68
66
  characterDataOldValue: true,
69
67
  });
70
- // Memo
71
68
  const permissionDomain = useDeepCompareMemo(() => {
72
69
  var _a;
73
70
  /**
@@ -31,6 +31,8 @@ export const OldLeftMenu = memo(props => {
31
31
  return 'DATASOURCES-APP_ANTALYSER';
32
32
  case 'EXPLORERS':
33
33
  return 'ANALYSIS';
34
+ case 'WEB_PERSONALIZE-JOURNEY':
35
+ return 'JOURNEY';
34
36
  default:
35
37
  return activeKey;
36
38
  }
@@ -21,6 +21,9 @@ export const MenuWrapper = styled.div `
21
21
  height: 100%;
22
22
  max-height: 100%;
23
23
  overflow: auto;
24
+ &::-webkit-scrollbar {
25
+ display: none !important;
26
+ }
24
27
 
25
28
  li {
26
29
  min-height: 40px !important;
@@ -25,6 +25,7 @@ export declare const QUERY_KEYS: {
25
25
  GET_ACCOUNT_LISTING: string;
26
26
  GET_PERMISSION_ACCOUNT_LISTING: string;
27
27
  GET_RECENT_ACCOUNT: string;
28
+ CHECK_ACCOUNT_PERMISSION: string;
28
29
  GET_ABSTRACT_USERS: string;
29
30
  GET_COLUMN_METRICS: string;
30
31
  GET_DATA_TABLE_LISTING: string;
@@ -36,6 +36,7 @@ export const QUERY_KEYS = {
36
36
  GET_ACCOUNT_LISTING: 'GET_ACCOUNT_LISTING',
37
37
  GET_PERMISSION_ACCOUNT_LISTING: 'GET_PERMISSION_ACCOUNT_LISTING',
38
38
  GET_RECENT_ACCOUNT: 'GET_RECENT_ACCOUNT',
39
+ CHECK_ACCOUNT_PERMISSION: 'CHECK_ACCOUNT_PERMISSION',
39
40
  // ABSTRACT
40
41
  GET_ABSTRACT_USERS: 'GET_ABSTRACT_USERS',
41
42
  // DATA TABLE
@@ -13,3 +13,15 @@ export interface AccountRecent {
13
13
  userId: number;
14
14
  value: number[];
15
15
  }
16
+ export type TAccountPermission = {
17
+ objectType?: number;
18
+ isView?: boolean;
19
+ isEdit?: boolean;
20
+ isExist?: boolean;
21
+ permissions?: {
22
+ view: string;
23
+ edit: string;
24
+ loginView: string;
25
+ loginEdit: string;
26
+ };
27
+ };
@@ -1,5 +1,5 @@
1
1
  export type FeatureMenuPermission = {
2
- app_id?: number;
2
+ app_id?: string | number;
3
3
  app_name?: string;
4
4
  app_code?: string | null;
5
5
  path?: string;
@@ -12,6 +12,7 @@ export type FeatureMenuPermission = {
12
12
  menu_code?: string | null;
13
13
  menu_name?: string;
14
14
  menu_parent?: number | null;
15
+ parent_app_code?: string | null;
15
16
  menu_order?: number;
16
17
  icon?: string;
17
18
  menu_path?: string;
@@ -1,15 +1,20 @@
1
1
  import { UseQueryOptions } from '@tanstack/react-query';
2
- import { GetAccountList } from '../../services/Account';
3
- import { AccountListing, AccountRecent } from '../../models/AccountListing';
2
+ import { TAccountParams } from '../../services/Account';
3
+ import { AccountListing, AccountRecent, TAccountPermission } from '../../models/AccountListing';
4
4
  type OptionHasDefault = 'queryKey' | 'queryFn';
5
5
  type GetAccountListProps = {
6
- apiConfig: GetAccountList;
6
+ apiConfig: TAccountParams;
7
7
  options?: Omit<UseQueryOptions<AccountListing, any, AccountListing, any[]>, OptionHasDefault>;
8
8
  };
9
9
  type GetRecentAccountProps = {
10
- apiConfig: GetAccountList;
10
+ apiConfig: TAccountParams;
11
11
  options?: Omit<UseQueryOptions<any, any, AccountRecent, any[]>, OptionHasDefault>;
12
12
  };
13
+ type TCheckUserPermissionProps = {
14
+ apiConfig: TAccountParams;
15
+ options?: Omit<UseQueryOptions<any, any, TAccountPermission | undefined, any[]>, OptionHasDefault>;
16
+ };
13
17
  export declare const useGetAccountList: (props: GetAccountListProps) => import("@tanstack/react-query").UseQueryResult<AccountListing, any>;
14
18
  export declare const useGetRecentAccount: (props: GetRecentAccountProps) => import("@tanstack/react-query").UseQueryResult<AccountRecent, any>;
19
+ export declare const useCheckUserPermission: (props: TCheckUserPermissionProps) => import("@tanstack/react-query").UseQueryResult<TAccountPermission | undefined, any>;
15
20
  export {};
@@ -4,7 +4,7 @@ import { useQuery } from '@tanstack/react-query';
4
4
  import { accountService } from '../../services/Account';
5
5
  // Constants
6
6
  import { QUERY_KEYS } from '../../constants/queries';
7
- const { getList, getRecentAccount } = accountService;
7
+ const { getList, getRecentAccount, checkPermission } = accountService;
8
8
  export const useGetAccountList = (props) => {
9
9
  const { apiConfig, options } = props;
10
10
  return useQuery(Object.assign({ queryKey: [QUERY_KEYS.GET_ACCOUNT_LISTING, apiConfig], queryFn: () => getList(apiConfig) }, options));
@@ -13,3 +13,8 @@ export const useGetRecentAccount = (props) => {
13
13
  const { apiConfig, options } = props;
14
14
  return useQuery(Object.assign({ queryKey: [QUERY_KEYS.GET_RECENT_ACCOUNT], queryFn: () => getRecentAccount(apiConfig) }, options));
15
15
  };
16
+ export const useCheckUserPermission = (props) => {
17
+ const { apiConfig, options } = props;
18
+ const { languageCode, userId, portalId } = apiConfig;
19
+ return useQuery(Object.assign({ queryKey: [QUERY_KEYS.CHECK_ACCOUNT_PERMISSION, languageCode, userId, portalId], queryFn: () => checkPermission(apiConfig) }, options));
20
+ };
@@ -1,12 +1,14 @@
1
- import { AccountListing, AccountRecent } from '../../models/AccountListing';
2
- export type GetAccountList = {
1
+ import { AccountListing, AccountRecent, TAccountPermission } from '../../models/AccountListing';
2
+ export type TAccountParams = {
3
3
  domain: string;
4
4
  portalId?: number;
5
5
  languageCode?: string;
6
6
  userId?: number;
7
- token: string;
7
+ accountId?: number;
8
+ token?: string;
8
9
  };
9
10
  export declare const accountService: {
10
- getList: (config: GetAccountList) => Promise<AccountListing>;
11
- getRecentAccount: (config: GetAccountList) => Promise<AccountRecent | undefined>;
11
+ getList: (config: TAccountParams) => Promise<AccountListing>;
12
+ getRecentAccount: (config: TAccountParams) => Promise<AccountRecent | undefined>;
13
+ checkPermission: (config: TAccountParams) => Promise<TAccountPermission>;
12
14
  };
@@ -62,4 +62,28 @@ export const accountService = {
62
62
  return Promise.reject(error);
63
63
  }
64
64
  }),
65
+ checkPermission: (config) => __awaiter(void 0, void 0, void 0, function* () {
66
+ var _g, _h, _j;
67
+ const { domain, languageCode = 'en', portalId = 33167, userId, token, accountId } = config;
68
+ try {
69
+ const response = yield axios({
70
+ method: 'POST',
71
+ url: `${domain}/hub/toolkit/v2.0/operate/check-permission`,
72
+ params: {
73
+ portalId,
74
+ languageCode,
75
+ _user_id: userId,
76
+ _owner_id: accountId,
77
+ },
78
+ data: { objects: [{ objectType: 1 }] },
79
+ headers: {
80
+ Token: token,
81
+ },
82
+ });
83
+ return ((_j = (_h = (_g = response === null || response === void 0 ? void 0 : response.data) === null || _g === void 0 ? void 0 : _g.data) === null || _h === void 0 ? void 0 : _h.entries) === null || _j === void 0 ? void 0 : _j[0]) || {};
84
+ }
85
+ catch (error) {
86
+ return Promise.reject(error);
87
+ }
88
+ }),
65
89
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.7.5",
3
+ "version": "1.7.6",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",