@antscorp/antsomi-ui 1.3.5-beta.180 → 1.3.5-beta.181

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 (55) hide show
  1. package/es/components/molecules/AccountSelection/AccountSelection.js +1 -1
  2. package/es/components/molecules/DrawerDetail/styled.js +1 -1
  3. package/es/components/molecules/HeaderV2/HeaderV2.d.ts +6 -5
  4. package/es/components/molecules/HeaderV2/HeaderV2.js +11 -3
  5. package/es/components/organism/Help/Help.js +13 -19
  6. package/es/components/organism/Help/styled.js +3 -1
  7. package/es/components/organism/LeftMenu/components/ContentMenu/useContentMenu.js +3 -1
  8. package/es/components/organism/LeftMenu/components/HomeMenu/constants.d.ts +14 -3
  9. package/es/components/organism/LeftMenu/components/HomeMenu/constants.js +9 -4
  10. package/es/components/organism/LeftMenu/components/HomeMenu/index.js +6 -4
  11. package/es/components/organism/LeftMenu/components/HomeMenu/styled.d.ts +1 -1
  12. package/es/components/organism/LeftMenu/components/HomeMenu/styled.js +21 -7
  13. package/es/components/organism/LeftMenu/components/HomeMenu/useHomeMenu.d.ts +6 -1
  14. package/es/components/organism/LeftMenu/components/HomeMenu/useHomeMenu.js +59 -33
  15. package/es/components/organism/LeftMenu/components/InsightsMenu/useInsightsMenu.js +3 -1
  16. package/es/components/organism/LeftMenu/components/ProfilesMenu/useProfilesMenu.js +3 -2
  17. package/es/components/organism/LeftMenu/components/SettingsMenu/useSettingsMenu.js +0 -1
  18. package/es/components/organism/LeftMenu/components/TemplatesMenu/useTemplatesMenu.js +3 -2
  19. package/es/components/organism/LeftMenu/components/common/ChildMenu/index.d.ts +1 -0
  20. package/es/components/organism/LeftMenu/components/common/ChildMenu/index.js +8 -5
  21. package/es/components/organism/LeftMenu/components/common/ChildMenu/styled.js +16 -1
  22. package/es/components/organism/LeftMenu/constants/variables.d.ts +1 -0
  23. package/es/components/organism/LeftMenu/constants/variables.js +1 -0
  24. package/es/components/organism/LeftMenu/contexts/index.d.ts +2 -0
  25. package/es/components/organism/LeftMenu/contexts/index.js +1 -1
  26. package/es/components/organism/LeftMenu/hooks/useLeftMenu.d.ts +1 -1
  27. package/es/components/organism/LeftMenu/hooks/useLeftMenu.js +33 -10
  28. package/es/components/organism/LeftMenu/index.js +46 -23
  29. package/es/components/organism/LeftMenu/styled.d.ts +2 -0
  30. package/es/components/organism/LeftMenu/styled.js +44 -60
  31. package/es/components/organism/LeftMenu/utils/index.d.ts +8 -1
  32. package/es/components/organism/LeftMenu/utils/index.js +11 -27
  33. package/es/components/organism/Notification/Notification.js +10 -2
  34. package/es/components/organism/Notification/styled.js +1 -0
  35. package/es/components/template/Layout/index.d.ts +2 -0
  36. package/es/components/template/Layout/index.js +14 -10
  37. package/es/components/template/Layout/styled.d.ts +1 -0
  38. package/es/components/template/Layout/styled.js +12 -5
  39. package/es/config/index.d.ts +5 -0
  40. package/es/config/index.js +6 -0
  41. package/es/constants/api.d.ts +6 -4
  42. package/es/constants/api.js +8 -4
  43. package/es/constants/index.d.ts +1 -1
  44. package/es/constants/index.js +1 -1
  45. package/es/constants/theme.js +34 -30
  46. package/es/index.d.ts +1 -1
  47. package/es/index.js +1 -1
  48. package/es/models/LeftMenu/FeatureMenu.d.ts +1 -1
  49. package/es/providers/AppConfigProvider/contexts/index.d.ts +4 -7
  50. package/es/providers/ConfigProvider/GlobalStyle.js +3 -0
  51. package/es/services/Account/index.js +3 -3
  52. package/es/services/LeftMenu/index.js +42 -50
  53. package/es/types/config.d.ts +2 -0
  54. package/es/types/config.js +1 -0
  55. package/package.json +6 -2
@@ -21,7 +21,7 @@ export const AccountSelection = props => {
21
21
  return (React.createElement(Popover, { content: React.createElement(AccountSelectionStyled, { className: className },
22
22
  React.createElement(Input, { placeholder: "Search", suffix: React.createElement(Icon, { type: "icon-ants-search-2", style: { fontSize: '24px' } }), value: searchValue, onChange: event => setSearchValue(event.target.value) }),
23
23
  React.createElement(Text, { className: "recent-text" }, "Recent"),
24
- React.createElement("ul", null, recentData === null || recentData === void 0 ? void 0 : recentData.value.map(accountId => data === null || data === void 0 ? void 0 : data.entries.find(account => account.userId === accountId)).filter(Boolean).map(account => (React.createElement(AccountItem, { key: account.userId, userName: account.userName, userId: account.userId, onClick: handleSelectAccount, isSelected: currentAccount === account.userId })))),
24
+ React.createElement("ul", null, recentData === null || recentData === void 0 ? void 0 : recentData.value.map(accountId => { var _a; return (_a = data === null || data === void 0 ? void 0 : data.entries) === null || _a === void 0 ? void 0 : _a.find(account => account.userId === accountId); }).filter(Boolean).map(account => (React.createElement(AccountItem, { key: account.userId, userName: account.userName, userId: account.userId, onClick: handleSelectAccount, isSelected: currentAccount === account.userId })))),
25
25
  React.createElement("ul", { className: "account-list" }, data === null || data === void 0 ? void 0 : data.entries.filter(account => !(recentData === null || recentData === void 0 ? void 0 : recentData.value.includes(account.userId)) &&
26
26
  searchStringQuery(account.userName, searchValue)).map(account => (React.createElement(AccountItem, { key: account.userId, userName: account.userName, userId: account.userId, onClick: handleSelectAccount, isSelected: currentAccount === account.userId })))),
27
27
  showAllAccount ? (React.createElement(Text, { className: `all-account ${currentAccount === 'ALL_ACCOUNT' ? 'is-selected' : ''}`, onClick: () => handleSelectAccount('ALL_ACCOUNT') },
@@ -72,7 +72,7 @@ export const CloseBtn = styled.div `
72
72
  export const MenuItem = styled.div `
73
73
  height: 36px;
74
74
  width: 36px;
75
- border-radius: ${token === null || token === void 0 ? void 0 : token.borderRadiusLG}px;
75
+ border-radius: ${token === null || token === void 0 ? void 0 : token.borderRadiusXL}px;
76
76
  background-color: transparent;
77
77
  display: flex;
78
78
  align-items: center;
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import { AccountSelectionProps } from '../AccountSelection';
3
3
  import { AccountSharingProps } from '../../organism';
4
4
  import { IHelpProps } from '../../organism/Help/types';
5
+ import { envType } from '@antscorp/antsomi-ui/es/types/config';
5
6
  export interface HeaderV2Props {
6
7
  className?: string;
7
8
  style?: React.CSSProperties;
@@ -20,12 +21,12 @@ export interface HeaderV2Props {
20
21
  accountSharingConfig: Pick<AccountSharingProps, 'isShowSharing' | 'isShareAccountAccess' | 'u_ogs' | 'appCode' | 'callbackLogout' | 'callbackGetInfoAccount'> & {
21
22
  show?: boolean;
22
23
  };
23
- config: {
24
- env: 'DEVELOPMENT' | 'PRODUCTION';
24
+ config?: {
25
+ env?: envType;
25
26
  language?: string;
26
- userId: number;
27
- portalId: number;
28
- token: string;
27
+ userId?: number;
28
+ portalId?: number;
29
+ token?: string;
29
30
  };
30
31
  }
31
32
  export declare const HeaderV2: React.FC<HeaderV2Props>;
@@ -10,20 +10,28 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import React, { memo, useState } from 'react';
13
- import { AccountSelection } from '../AccountSelection';
13
+ // Styled
14
14
  import { HeaderV2Styled } from './styled';
15
+ // Components
16
+ import { AccountSelection } from '../AccountSelection';
15
17
  import { AccountSharing, Help, Notification, } from '../../organism';
18
+ // Constants
16
19
  import { CDP_API, IAM_API, ISSUE_API, PERMISSION_API, PLATFORM_API, SOCKET_API, } from '@antscorp/antsomi-ui/es/constants';
20
+ import { useContextSelector } from 'use-context-selector';
21
+ import { AppConfigContext } from '../../..';
17
22
  export const HeaderV2 = memo(props => {
18
23
  var _a;
24
+ const { auth, env: envContext, languageCode, } = useContextSelector(AppConfigContext, state => state);
19
25
  const { className, style, pageTitle = 'Page Title', accountSelection = {}, helpConfig, notificationConfig = {}, accountSharingConfig, config, } = props;
20
26
  /** General config for children component */
21
- const { env, language = 'en', userId, portalId, token } = config;
27
+ 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, } = config || {};
22
28
  const { currentAccount, inputStyle = 'select', onSelectAccount } = accountSelection, accountSelectionProps = __rest(accountSelection, ["currentAccount", "inputStyle", "onSelectAccount"]);
29
+ const [selectedAccount, setSelectedAccount] = useState((_a = currentAccount !== null && currentAccount !== void 0 ? currentAccount : userId) !== null && _a !== void 0 ? _a : 'ALL_ACCOUNT');
30
+ if (!env || !language || !userId || !portalId || !token)
31
+ return null;
23
32
  const { show: showHelp = true, configs } = helpConfig, helpProps = __rest(helpConfig, ["show", "configs"]);
24
33
  const { show: showNotification = true } = notificationConfig;
25
34
  const { show: showAccountSharing = true, isShowSharing = true, isShareAccountAccess = true } = accountSharingConfig, accountSharingProps = __rest(accountSharingConfig, ["show", "isShowSharing", "isShareAccountAccess"]);
26
- const [selectedAccount, setSelectedAccount] = useState((_a = currentAccount !== null && currentAccount !== void 0 ? currentAccount : userId) !== null && _a !== void 0 ? _a : 'ALL_ACCOUNT');
27
35
  const accountSelectionApiConfig = {
28
36
  domain: CDP_API[env],
29
37
  languageCode: language,
@@ -30,7 +30,7 @@ import '@antscorp/icons/main.css';
30
30
  // Services
31
31
  import TicketService from '@antscorp/antsomi-ui/es/services/Ticket';
32
32
  // Component
33
- import { LoadingOutlined, QuestionCircleOutlined } from '@ant-design/icons';
33
+ import { LoadingOutlined } from '@ant-design/icons';
34
34
  import Icon from '@antscorp/icons';
35
35
  import { Editor } from '@tinymce/tinymce-react';
36
36
  import { Button, Spin } from 'antd';
@@ -52,7 +52,7 @@ const Loading = ({ isLoading, height, width }) => isLoading && (React.createElem
52
52
  const Help = props => {
53
53
  const { configs, triggerType, boundsDraggable, isShowResizeHover, children } = props;
54
54
  const { apiKey, domainPlatform, appCode, domain, portalId, token, userId, config, domainTicket, avatar, } = configs;
55
- const [isOpenDropdown, setIsOpenDropdown] = useState(false);
55
+ // const [isOpenDropdown, setIsOpenDropdown] = useState<boolean>(false);
56
56
  const [defaultPositionDrawActions, setDefaultPositionDrawActions] = useState(DEFAULT_POSITIONS.capture);
57
57
  const [defaultPositionRecordActions, setDefaultPositionRecordActions] = useState(DEFAULT_POSITIONS.record);
58
58
  const [isMainLoading, setIsMainLoading] = useState(false);
@@ -84,7 +84,7 @@ const Help = props => {
84
84
  });
85
85
  const [isOpenImageDrawer, setIsOpenImageDrawer] = useState(false);
86
86
  const [captureType, setCaptureType] = useState(ATTACH_KEYS.CAPTURE);
87
- const [open, setOpen] = useState(false);
87
+ // const [open, setOpen] = useState<boolean>(false);
88
88
  const [dataRecorded, setDataRecorded] = useState([]);
89
89
  const [dataListHelp, setDataListHelp] = useState([]);
90
90
  const [isMute, setIsMute] = useState(false);
@@ -155,9 +155,9 @@ const Help = props => {
155
155
  }
156
156
  return domain;
157
157
  }, [domain]);
158
- const handleCancel = () => {
159
- setOpen(false);
160
- };
158
+ // const handleCancel = () => {
159
+ // setOpen(false);
160
+ // };
161
161
  const handleClick = (data) => {
162
162
  const { key = '' } = data;
163
163
  switch (key) {
@@ -181,7 +181,7 @@ const Help = props => {
181
181
  break;
182
182
  }
183
183
  default: {
184
- setIsOpenDropdown(false);
184
+ // setIsOpenDropdown(false);
185
185
  break;
186
186
  }
187
187
  }
@@ -267,7 +267,7 @@ const Help = props => {
267
267
  setUrlImageDrawer('');
268
268
  setUrlVideoPreview('');
269
269
  setIsValidAll(true);
270
- setIsOpenDropdown(false);
270
+ // setIsOpenDropdown(false);
271
271
  setValueInput(prev => (Object.assign(Object.assign({}, prev), { message: '', title: '', files: [] })));
272
272
  setIsShowPopup(false);
273
273
  setErrFile({
@@ -382,7 +382,7 @@ const Help = props => {
382
382
  };
383
383
  setIsForceStopRecorder(false);
384
384
  setIsOpenImageDrawer(true);
385
- handleCancel();
385
+ // handleCancel();
386
386
  setIsShowPopup(false);
387
387
  }
388
388
  catch (error) {
@@ -444,7 +444,7 @@ const Help = props => {
444
444
  // passing canvas data url as screenshot preview src
445
445
  setUrlImageDrawer(canvas.toDataURL());
446
446
  setIsOpenImageDrawer(true);
447
- handleCancel();
447
+ // handleCancel();
448
448
  setIsShowPopup(false);
449
449
  });
450
450
  video.srcObject = stream; // passing capture stream data as video source object
@@ -987,15 +987,9 @@ const Help = props => {
987
987
  style: { minWidth: 250, padding: 0 },
988
988
  items: items,
989
989
  onClick: info => handleClick(info),
990
- }, onOpenChange: isOpen => setIsOpenDropdown(isOpen), trigger: triggerType, placement: "bottomRight", className: "dropdown-helps" }, children || (React.createElement(IconButtonStyled, { style: {
991
- width: 36,
992
- height: 36,
993
- borderRadius: '5px',
994
- }, icon: React.createElement(QuestionCircleOutlined, { style: {
995
- color: '#666666',
996
- fontSize: '20px',
997
- transform: 'unset',
998
- } }), className: `${isOpenDropdown ? 'antsomi-btn-default-active' : ''}`, onClick: e => e.preventDefault() }))),
990
+ },
991
+ // onOpenChange={isOpen => setIsOpenDropdown(isOpen)}
992
+ trigger: triggerType, placement: "bottomRight" }, children || React.createElement(IconButtonStyled, { icon: React.createElement(Icon, { type: "icon-ants-help" }) })),
999
993
  isShowPopup &&
1000
994
  createPortal(React.createElement(PopupDraggable, { isHiddenResizing: true, bounds: boundsDraggable, isShowResizeHover: isShowResizeHover, callback: callback, styleContainer: {
1001
995
  display: 'flex',
@@ -1,7 +1,8 @@
1
1
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3;
2
2
  // Libraries
3
- import { Dropdown, Button, Space, Typography, Tree, Input } from 'antd';
3
+ import { Dropdown, /* Button, */ Space, Typography, Tree, Input } from 'antd';
4
4
  import styled, { css } from 'styled-components';
5
+ import { Button } from '../../atoms';
5
6
  // Constants
6
7
  import { THEME } from '@antscorp/antsomi-ui/es/constants';
7
8
  // Components
@@ -267,6 +268,7 @@ export const IconButtonStyled = styled(Button) `
267
268
  background-color: transparent !important;
268
269
  color: #666666 !important;
269
270
  box-shadow: none !important;
271
+ border-radius: 10px !important;
270
272
 
271
273
  &.antsomi-dropdown-open,
272
274
  &.antsomi-popover-open {
@@ -8,5 +8,7 @@ export const useContentMenu = () => {
8
8
  const featureChildren = useContextSelector(LeftMenuContext, state => state.featureChildren);
9
9
  useEffect(() => { }, [featureChildren]);
10
10
  const customChildren = useMemo(() => featureChildren === null || featureChildren === void 0 ? void 0 : featureChildren.map(item => getMenuItem(item)), [featureChildren]);
11
- return { children: customChildren };
11
+ return {
12
+ children: customChildren,
13
+ };
12
14
  };
@@ -1,6 +1,17 @@
1
1
  import { TMenuFeatureItem } from '../../types';
2
+ export declare const HOME_REPORT_ROUTES: {
3
+ DETAIL: string;
4
+ CONFIGURE: string;
5
+ CREATE: string;
6
+ };
2
7
  export declare const CONFIG_OPTIONS: {
3
- key: string;
4
- label: string;
5
- }[];
8
+ CONFIGURE: {
9
+ key: string;
10
+ label: string;
11
+ };
12
+ REMOVE: {
13
+ key: string;
14
+ label: string;
15
+ };
16
+ };
6
17
  export declare const HOME_MENU_ITEMS: Record<string, TMenuFeatureItem>;
@@ -1,13 +1,18 @@
1
- export const CONFIG_OPTIONS = [
2
- {
1
+ export const HOME_REPORT_ROUTES = {
2
+ DETAIL: ':reportId',
3
+ CONFIGURE: ':reportId/configure',
4
+ CREATE: 'create',
5
+ };
6
+ export const CONFIG_OPTIONS = {
7
+ CONFIGURE: {
3
8
  key: 'configure',
4
9
  label: 'Configure',
5
10
  },
6
- {
11
+ REMOVE: {
7
12
  key: 'remove',
8
13
  label: 'Remove',
9
14
  },
10
- ];
15
+ };
11
16
  export const HOME_MENU_ITEMS = {
12
17
  RECENT: {
13
18
  menu_item_name: 'Recent',
@@ -3,6 +3,7 @@ import React, { memo } from 'react';
3
3
  // Components
4
4
  import { ChildMenu } from '../common';
5
5
  import { Flex } from '../../../../atoms';
6
+ // Constants
6
7
  import Icon from '@antscorp/icons';
7
8
  // Styled
8
9
  import { CreateButton, HomeMenuWrapper } from './styled';
@@ -10,11 +11,12 @@ import { CreateButton, HomeMenuWrapper } from './styled';
10
11
  import { useHomeMenu } from './useHomeMenu';
11
12
  export const HomeMenu = memo(() => {
12
13
  // Handlers
13
- const { children, onCreateNewTab } = useHomeMenu();
14
- return (React.createElement(HomeMenuWrapper, null,
15
- React.createElement(CreateButton, { type: "primary", onClick: onCreateNewTab },
14
+ const { children, onCreateNewReport, onMenuClick } = useHomeMenu();
15
+ return (React.createElement(HomeMenuWrapper, { vertical: true },
16
+ React.createElement(CreateButton, { type: "primary", onClick: onCreateNewReport },
16
17
  React.createElement(Flex, { gap: 10, align: "center" },
17
18
  React.createElement(Icon, { type: "icon-ants-plus-slim", style: { fontSize: 14 } }),
18
19
  React.createElement("span", null, "Create"))),
19
- React.createElement(ChildMenu, { items: children })));
20
+ React.createElement("div", { className: "menu-list" },
21
+ React.createElement(ChildMenu, { items: children, onMenuClick: onMenuClick }))));
20
22
  });
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- export declare const HomeMenuWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
2
+ export declare const HomeMenuWrapper: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("antd/es/flex/interface").FlexProps<import("antd/es/_util/type").AnyObject> & import("react").RefAttributes<HTMLElement>>, any, {}, never>;
3
3
  export declare const CreateButton: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("antd").ButtonProps & import("react").RefAttributes<HTMLElement>> & {
4
4
  Group: import("react").FC<import("antd/es/button").ButtonGroupProps>;
5
5
  }, any, {}, never>;
@@ -2,22 +2,36 @@ var _a;
2
2
  // Libraries
3
3
  import styled from 'styled-components';
4
4
  // Components
5
- import { Button } from '../../../../atoms';
5
+ import { Button, Flex } from '../../../../atoms';
6
6
  // Constants
7
7
  import { THEME } from '@antscorp/antsomi-ui/es/constants';
8
- export const HomeMenuWrapper = styled.div `
9
- .antsomi-menu {
10
- & > li > ul {
11
- font-weight: 400 !important;
12
- font-size: 11px !important;
8
+ export const HomeMenuWrapper = styled(Flex) `
9
+ height: 100%;
10
+
11
+ .menu-list {
12
+ width: 100%;
13
+ flex: 1 1 0%;
14
+ overflow: hidden;
15
+
16
+ .antsomi-menu {
17
+ & > li > ul {
18
+ font-weight: 400 !important;
19
+ font-size: 11px !important;
20
+ }
21
+
22
+ ::-webkit-scrollbar {
23
+ width: 13px !important;
24
+ height: 8px;
25
+ }
13
26
  }
14
27
  }
15
28
  `;
16
29
  export const CreateButton = styled(Button) `
17
30
  width: 106px;
18
31
  height: 37px !important;
19
- border-radius: ${(_a = THEME === null || THEME === void 0 ? void 0 : THEME.token) === null || _a === void 0 ? void 0 : _a.borderRadiusLG}px !important;
32
+ border-radius: ${(_a = THEME === null || THEME === void 0 ? void 0 : THEME.token) === null || _a === void 0 ? void 0 : _a.borderRadiusXL}px !important;
20
33
  box-shadow: none !important;
21
34
  font-size: 14px !important;
22
35
  margin: 10px;
36
+ flex-shrink: 0;
23
37
  `;
@@ -1,4 +1,9 @@
1
1
  export declare const useHomeMenu: () => {
2
2
  children: import("../../types").TMenuItem[];
3
- onCreateNewTab: () => void;
3
+ onCreateNewReport: () => void;
4
+ onOptionCallback: (args: {
5
+ menuItemKey: string;
6
+ optionKey: string;
7
+ }) => void;
8
+ onMenuClick: (key: string, _: any) => void;
4
9
  };
@@ -1,22 +1,22 @@
1
1
  // Libraries
2
2
  import { useCallback, useMemo } from 'react';
3
3
  import { useContextSelector } from 'use-context-selector';
4
- import { get } from 'lodash';
4
+ import { useHistory } from 'react-router-dom';
5
5
  // Queries
6
6
  import { useGetDashboard } from '@antscorp/antsomi-ui/es/queries/LeftMenu';
7
7
  // Constants
8
- import { CONFIG_OPTIONS, HOME_MENU_ITEMS } from './constants';
8
+ import { CONFIG_OPTIONS, HOME_MENU_ITEMS, HOME_REPORT_ROUTES } from './constants';
9
9
  // Utils
10
- import { generateKey, getPortalId } from '@antscorp/antsomi-ui/es/utils';
11
- import { getDefaultDashboardName } from './utils';
12
- import { getMenuItem } from '../../utils';
10
+ import { getGeneratePath, getMenuItem } from '../../utils';
13
11
  // Contexts
14
12
  import { AppConfigContext } from '@antscorp/antsomi-ui/es/providers';
15
13
  import { LeftMenuContext } from '../../contexts';
16
14
  export const useHomeMenu = () => {
15
+ // Hooks
16
+ const history = useHistory();
17
17
  // Contexts
18
18
  const appConfig = useContextSelector(AppConfigContext, state => state);
19
- const { objectId = 0, objectType = '', isGrouped = false, } = useContextSelector(LeftMenuContext, state => state);
19
+ const { activeItem, permissionMenu, objectId = 0, objectType = '', isGrouped = false, } = useContextSelector(LeftMenuContext, state => state);
20
20
  const { auth, languageCode } = appConfig;
21
21
  // Queries
22
22
  const { data: dashboardData } = useGetDashboard({
@@ -44,13 +44,27 @@ export const useHomeMenu = () => {
44
44
  });
45
45
  }, [dashboardData]);
46
46
  // Memos
47
- const listDashboardName = useMemo(() => {
48
- var _a;
49
- return ((_a = get(dashboardData, 'entries.ownedDashboard', [])) === null || _a === void 0 ? void 0 : _a.map(overview => get(overview, 'dashboardName', ''))) || [];
50
- }, [dashboardData]);
51
- const handleOptionCallback = useCallback((args) => {
52
- console.log({ args });
53
- }, []);
47
+ const homeItem = useMemo(() => permissionMenu === null || permissionMenu === void 0 ? void 0 : permissionMenu.find(item => item.menu_item_code === activeItem), [activeItem, permissionMenu]);
48
+ // const listDashboardName = useMemo(
49
+ // () =>
50
+ // get(dashboardData, 'entries.ownedDashboard', [])?.map(overview =>
51
+ // get(overview, 'dashboardName', ''),
52
+ // ) || [],
53
+ // [dashboardData],
54
+ // );
55
+ const getHomePath = useCallback((path) => `${(homeItem === null || homeItem === void 0 ? void 0 : homeItem.menu_item_path) || ''}/${path}`, [homeItem === null || homeItem === void 0 ? void 0 : homeItem.menu_item_path]);
56
+ const onOptionCallback = useCallback((args) => {
57
+ const { optionKey, menuItemKey } = args;
58
+ switch (optionKey) {
59
+ case CONFIG_OPTIONS.CONFIGURE.key:
60
+ history.push(getGeneratePath(getHomePath(HOME_REPORT_ROUTES.CONFIGURE), Object.assign(Object.assign({}, auth), { reportId: menuItemKey })));
61
+ break;
62
+ case CONFIG_OPTIONS.REMOVE.key:
63
+ break;
64
+ default:
65
+ break;
66
+ }
67
+ }, [auth, history, getHomePath]);
54
68
  const customChildren = useMemo(() => {
55
69
  var _a;
56
70
  return (_a = Object.values(HOME_MENU_ITEMS)) === null || _a === void 0 ? void 0 : _a.map(item => {
@@ -59,26 +73,38 @@ export const useHomeMenu = () => {
59
73
  menu_item_name: item.dashboardName,
60
74
  menu_item_code: String(item.dashboardId),
61
75
  icon_name: null,
62
- options: CONFIG_OPTIONS,
63
- optionCallback: handleOptionCallback,
76
+ options: Object.values(CONFIG_OPTIONS),
77
+ optionCallback: onOptionCallback,
64
78
  })) }));
65
79
  });
66
- }, [dashboardObject, handleOptionCallback]);
67
- const onCreateNewTab = useCallback(() => {
68
- const configTab = {
69
- id: generateKey(),
70
- dashboardName: getDefaultDashboardName(listDashboardName),
71
- layout: 'settings',
72
- filters: [],
73
- enableParamFilter: 1,
74
- portalId: getPortalId({}),
75
- status: 1,
76
- };
77
- console.log({ configTab });
78
- // onUpdateLoading({ isLoading: false });
79
- // props.onAddNewOverview({
80
- // configTab,
81
- // });
82
- }, [listDashboardName]);
83
- return { children: customChildren, onCreateNewTab };
80
+ }, [dashboardObject, onOptionCallback]);
81
+ // Callbacks
82
+ const onCreateNewReport = useCallback(() => {
83
+ history.push(getGeneratePath(getHomePath(HOME_REPORT_ROUTES.CREATE), auth));
84
+ }, [auth, history, getHomePath]);
85
+ const onMenuClick = useCallback((key, _) => {
86
+ history.push(getGeneratePath(getHomePath(HOME_REPORT_ROUTES.DETAIL), Object.assign(Object.assign({}, auth), { reportId: key })));
87
+ }, [auth, history, getHomePath]);
88
+ // const onCreateNewReport = useCallback(() => {
89
+ // const configTab = {
90
+ // id: generateKey(),
91
+ // dashboardName: getDefaultDashboardName(listDashboardName),
92
+ // layout: 'settings',
93
+ // filters: [],
94
+ // enableParamFilter: 1,
95
+ // portalId: getPortalId({}),
96
+ // status: 1,
97
+ // };
98
+ // // onUpdateLoading({ isLoading: false });
99
+ // // props.onAddNewOverview({
100
+ // // configTab,
101
+ // // });
102
+ // }, [listDashboardName]);
103
+ return {
104
+ children: customChildren,
105
+ /* Callbacks */
106
+ onCreateNewReport,
107
+ onOptionCallback,
108
+ onMenuClick,
109
+ };
84
110
  };
@@ -8,5 +8,7 @@ import { getMenuItem } from '../../utils';
8
8
  export const useInsightsMenu = () => {
9
9
  const featureChildren = useContextSelector(LeftMenuContext, state => state.featureChildren);
10
10
  const customChildren = useMemo(() => featureChildren === null || featureChildren === void 0 ? void 0 : featureChildren.map(item => getMenuItem(item)), [featureChildren]);
11
- return { children: customChildren };
11
+ return {
12
+ children: customChildren,
13
+ };
12
14
  };
@@ -8,6 +8,7 @@ import { getMenuItem } from '../../utils';
8
8
  export const useProfilesMenu = () => {
9
9
  const featureChildren = useContextSelector(LeftMenuContext, state => state.featureChildren);
10
10
  const customChildren = useMemo(() => featureChildren === null || featureChildren === void 0 ? void 0 : featureChildren.map(item => getMenuItem(item)), [featureChildren]);
11
- console.log('Profiles Children: ', customChildren);
12
- return { children: customChildren };
11
+ return {
12
+ children: customChildren,
13
+ };
13
14
  };
@@ -8,6 +8,5 @@ import { getMenuItem } from '../../utils';
8
8
  export const useSettingsMenu = () => {
9
9
  const featureChildren = useContextSelector(LeftMenuContext, state => state.featureChildren);
10
10
  const customChildren = useMemo(() => featureChildren === null || featureChildren === void 0 ? void 0 : featureChildren.map(item => getMenuItem(item)), [featureChildren]);
11
- console.log('Settings Children: ', customChildren);
12
11
  return { children: customChildren };
13
12
  };
@@ -8,6 +8,7 @@ import { getMenuItem } from '../../utils';
8
8
  export const useTemplatesMenu = () => {
9
9
  const featureChildren = useContextSelector(LeftMenuContext, state => state.featureChildren);
10
10
  const customChildren = useMemo(() => featureChildren === null || featureChildren === void 0 ? void 0 : featureChildren.map(item => getMenuItem(item)), [featureChildren]);
11
- console.log('Templates Children: ', customChildren);
12
- return { children: customChildren };
11
+ return {
12
+ children: customChildren,
13
+ };
13
14
  };
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import { TMenuItem } from '../../../types';
3
3
  interface ChildMenuProps {
4
4
  items?: TMenuItem[];
5
+ onMenuClick?: (key: string, keyPath: string[]) => void;
5
6
  }
6
7
  export declare const ChildMenu: React.FC<ChildMenuProps>;
7
8
  export {};
@@ -2,7 +2,7 @@
2
2
  import React, { memo, useState } from 'react';
3
3
  import Icon from '@antscorp/icons';
4
4
  import { isEmpty, isNil, isString } from 'lodash';
5
- import { generatePath, Link } from 'react-router-dom';
5
+ import { Link } from 'react-router-dom';
6
6
  import { useContextSelector } from 'use-context-selector';
7
7
  // Components
8
8
  import { Dropdown, Menu } from 'antd';
@@ -12,15 +12,18 @@ import { MenuItemImage } from './components';
12
12
  import { LabelCustom, MenuWrapper } from './styled';
13
13
  // Constants
14
14
  import { THEME } from '@antscorp/antsomi-ui/es/constants';
15
+ import { ICON_SIZE } from '../../../constants';
15
16
  // Contexts
16
17
  import { AppConfigContext } from '@antscorp/antsomi-ui/es/providers';
18
+ // Utils
19
+ import { getGeneratePath } from '../../../utils';
17
20
  export const ChildMenu = memo(props => {
18
- const { items = [] } = props;
19
- console.log({ items });
21
+ const { items = [], onMenuClick } = props;
20
22
  const userId = useContextSelector(AppConfigContext, state => { var _a; return (_a = state === null || state === void 0 ? void 0 : state.auth) === null || _a === void 0 ? void 0 : _a.userId; });
21
23
  const [current, setCurrent] = useState('1');
22
24
  const onClick = e => {
23
25
  setCurrent(e.key);
26
+ onMenuClick === null || onMenuClick === void 0 ? void 0 : onMenuClick(e.key, e.keyPath);
24
27
  };
25
28
  // Render components
26
29
  const customMenuItems = (args) => {
@@ -41,8 +44,8 @@ export const ChildMenu = memo(props => {
41
44
  React.createElement(Icon, { type: "icon-ants-three-dot-vertical", style: { marginTop: '2px' } })))) : (React.createElement(LabelCustom, { ellipsis: { tooltip: label } }, label));
42
45
  return {
43
46
  key,
44
- label: isString(menu_item_path) ? (React.createElement(Link, { to: generatePath(menu_item_path, { user_id: userId }), style: { width: '100%', height: '100%', display: 'flex', color: 'inherit' } }, labelComponent())) : (labelComponent()),
45
- icon: !isNil(icon) ? (React.createElement(Icon, { type: icon, style: { fontSize: 25 } })) : !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 })) : null,
47
+ label: isString(menu_item_path) ? (React.createElement(Link, { to: getGeneratePath(menu_item_path, { userId }), className: "menu-link" }, labelComponent())) : (labelComponent()),
48
+ icon: !isNil(icon) ? (React.createElement(Icon, { type: icon, style: { fontSize: ICON_SIZE } })) : !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 })) : null,
46
49
  children: customMenuItems({ parent: item, items: children }),
47
50
  };
48
51
  });
@@ -7,18 +7,25 @@ import { Typography } from '../../../../../atoms';
7
7
  import { THEME } from '@antscorp/antsomi-ui/es/constants';
8
8
  export const MenuWrapper = styled.div `
9
9
  width: 100%;
10
+ height: 100%;
10
11
  background-color: transparent !important;
11
12
  color: 12px !important;
12
13
  font-weight: bold !important;
13
14
  padding: 5px !important;
14
15
  border-right: none !important;
15
16
 
17
+ & > ul {
18
+ height: 100%;
19
+ overflow: auto;
20
+ }
21
+
16
22
  [role='menu'] {
17
23
  background-color: transparent !important;
24
+ border: none !important;
18
25
  }
19
26
 
20
27
  [role='menuitem'] {
21
- border-radius: ${(_a = THEME === null || THEME === void 0 ? void 0 : THEME.token) === null || _a === void 0 ? void 0 : _a.borderRadiusLG}px !important;
28
+ border-radius: ${(_a = THEME === null || THEME === void 0 ? void 0 : THEME.token) === null || _a === void 0 ? void 0 : _a.borderRadiusXL}px !important;
22
29
  padding-right: 10px !important;
23
30
  }
24
31
 
@@ -30,6 +37,14 @@ export const MenuWrapper = styled.div `
30
37
  .antsomi-menu-submenu-title:hover {
31
38
  background-color: #f2f9ff !important;
32
39
  }
40
+
41
+ .menu-link {
42
+ width: 100% !important;
43
+ height: 100% !important;
44
+ display: flex !important;
45
+ color: inherit !important;
46
+ text-decoration: none !important;
47
+ }
33
48
  `;
34
49
  export const LabelCustom = styled(Typography.Text) `
35
50
  font-size: inherit !important;
@@ -13,3 +13,4 @@ export declare const MENU_ITEM_TYPE: {
13
13
  MENU: number;
14
14
  GROUP_MENU: number;
15
15
  };
16
+ export declare const ICON_SIZE = 20;
@@ -13,3 +13,4 @@ export const MENU_ITEM_TYPE = {
13
13
  MENU: 2,
14
14
  GROUP_MENU: 3,
15
15
  };
16
+ export const ICON_SIZE = 20;
@@ -5,6 +5,8 @@ export interface TLeftMenuContext {
5
5
  objectType?: string;
6
6
  objectId?: number;
7
7
  isGrouped?: boolean;
8
+ activeItem?: string;
9
+ permissionMenu: TFeatureMenu[];
8
10
  }
9
11
  declare const LeftMenuContext: import("use-context-selector").Context<TLeftMenuContext>;
10
12
  declare const LeftMenuProvider: React.FC<React.PropsWithChildren<{
@@ -1,7 +1,7 @@
1
1
  // Libraries
2
2
  import React from 'react';
3
3
  import { createContext } from 'use-context-selector';
4
- const initialContext = { featureChildren: [] };
4
+ const initialContext = { featureChildren: [], permissionMenu: [] };
5
5
  const LeftMenuContext = createContext(initialContext);
6
6
  const LeftMenuProvider = props => {
7
7
  const { value = initialContext, children } = props;