@antscorp/antsomi-ui 1.3.5-beta.187 → 1.3.5-beta.189

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.
@@ -0,0 +1,3 @@
1
+ export declare const MARKETING_ROUTES: {
2
+ CHANNEL: string;
3
+ };
@@ -0,0 +1,3 @@
1
+ export const MARKETING_ROUTES = {
2
+ CHANNEL: '/gen2/:networkId/:user_id/marketing-hub/journeys/:channelId/list',
3
+ };
@@ -5,10 +5,12 @@ import { isEmpty } from 'lodash';
5
5
  // Contexts
6
6
  import { LeftMenuContext } from '../../contexts';
7
7
  import { AppConfigContext } from '@antscorp/antsomi-ui/es/providers';
8
- // Querries
8
+ // Queries
9
9
  import { useGetDestinationChannel } from '@antscorp/antsomi-ui/es/queries/LeftMenu';
10
10
  // Utils
11
- import { getMenuItem } from '../../utils';
11
+ import { getGeneratePath, getMenuItem } from '../../utils';
12
+ // Constants
13
+ import { MARKETING_ROUTES } from './constants';
12
14
  export const useMarketingMenu = () => {
13
15
  // Contexts
14
16
  const appConfig = useContextSelector(AppConfigContext, state => state);
@@ -34,16 +36,27 @@ export const useMarketingMenu = () => {
34
36
  const customChildren = useMemo(() => featureChildren === null || featureChildren === void 0 ? void 0 : featureChildren.map(item => {
35
37
  var _a;
36
38
  let children = [];
39
+ switch (item.menu_item_code) {
40
+ case 'ALL_CHANNEL':
41
+ item.menu_item_path = getGeneratePath(MARKETING_ROUTES.CHANNEL, Object.assign(Object.assign({}, auth), { channelId: 0 }));
42
+ break;
43
+ case 'ORCHESTRATION':
44
+ item.menu_item_path = getGeneratePath(MARKETING_ROUTES.CHANNEL, Object.assign(Object.assign({}, auth), { channelId: 8 }));
45
+ break;
46
+ default:
47
+ break;
48
+ }
37
49
  if ((item === null || item === void 0 ? void 0 : item.render_option) === 'destination_channel') {
38
50
  children =
39
51
  ((_a = destinationChannel === null || destinationChannel === void 0 ? void 0 : destinationChannel.entries) === null || _a === void 0 ? void 0 : _a.map(item => ({
40
52
  menu_item_code: item.channelCode,
41
53
  menu_item_name: item.translateLabel,
42
54
  logo_url: item.logoUrl,
55
+ menu_item_path: getGeneratePath(MARKETING_ROUTES.CHANNEL, Object.assign(Object.assign({}, auth), { channelId: item.channelId })),
43
56
  icon_name: null,
44
57
  }))) || [];
45
58
  }
46
59
  return getMenuItem(Object.assign(Object.assign({}, item), (isEmpty(children) ? {} : { children })));
47
- }), [destinationChannel === null || destinationChannel === void 0 ? void 0 : destinationChannel.entries, featureChildren]);
60
+ }), [auth, destinationChannel === null || destinationChannel === void 0 ? void 0 : destinationChannel.entries, featureChildren]);
48
61
  return { children: customChildren };
49
62
  };
@@ -1,8 +1,8 @@
1
1
  // Libraries
2
- import React, { memo, useState } from 'react';
2
+ import React, { memo, useEffect, useState } from 'react';
3
3
  import Icon from '@antscorp/icons';
4
4
  import { isEmpty, isNil, isString } from 'lodash';
5
- import { Link } from 'react-router-dom';
5
+ import { Link, useLocation } from 'react-router-dom';
6
6
  import { useContextSelector } from 'use-context-selector';
7
7
  // Components
8
8
  import { Dropdown, Menu } from 'antd';
@@ -11,18 +11,50 @@ import { MenuItemImage } from './components';
11
11
  // Styled
12
12
  import { LabelCustom, MenuWrapper } from './styled';
13
13
  // Constants
14
- import { THEME } from '@antscorp/antsomi-ui/es/constants';
15
14
  import { ICON_SIZE } from '../../../constants';
15
+ import { ENV } from '@antscorp/antsomi-ui/es/config';
16
16
  // Contexts
17
17
  import { AppConfigContext } from '@antscorp/antsomi-ui/es/providers';
18
18
  // Utils
19
19
  import { getGeneratePath } from '../../../utils';
20
20
  export const ChildMenu = memo(props => {
21
21
  const { items = [], onMenuClick } = props;
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; });
23
- const [current, setCurrent] = useState('1');
22
+ // Selectors
23
+ const auth = useContextSelector(AppConfigContext, state => state === null || state === void 0 ? void 0 : state.auth);
24
+ const env = useContextSelector(AppConfigContext, state => state === null || state === void 0 ? void 0 : state.env);
25
+ // States
26
+ const [currentActiveItem, setCurrentActiveItem] = useState('');
27
+ // Hooks
28
+ const { pathname, hash, search } = useLocation();
29
+ // Side Effects
30
+ useEffect(() => {
31
+ var _a;
32
+ const url = `${pathname}${hash}${search}`;
33
+ const recursiveFindActiveItem = (items) => {
34
+ let activeItem;
35
+ for (const item of items) {
36
+ if (!isNil(item === null || item === void 0 ? void 0 : item.menu_item_path) &&
37
+ url.includes(getGeneratePath(item.menu_item_path, auth))) {
38
+ activeItem = item;
39
+ break;
40
+ }
41
+ if ((item === null || item === void 0 ? void 0 : item.children) && item.children.length) {
42
+ const childActiveItem = recursiveFindActiveItem(item.children);
43
+ if (childActiveItem) {
44
+ activeItem = childActiveItem;
45
+ break;
46
+ }
47
+ }
48
+ }
49
+ return activeItem;
50
+ };
51
+ const activeItem = (_a = recursiveFindActiveItem(items)) === null || _a === void 0 ? void 0 : _a.key;
52
+ if (activeItem && activeItem !== currentActiveItem) {
53
+ setCurrentActiveItem(activeItem);
54
+ }
55
+ }, [auth, currentActiveItem, hash, items, pathname, search]);
56
+ // Handlers
24
57
  const onClick = e => {
25
- setCurrent(e.key);
26
58
  onMenuClick === null || onMenuClick === void 0 ? void 0 : onMenuClick(e.key, e.keyPath);
27
59
  };
28
60
  // Render components
@@ -30,8 +62,9 @@ export const ChildMenu = memo(props => {
30
62
  var _a;
31
63
  return (_a = args === null || args === void 0 ? void 0 : args.items) === null || _a === void 0 ? void 0 : _a.map(item => {
32
64
  var _a;
33
- const { key, label, children, icon, logo_url, menu_item_path, options, optionCallback } = item;
34
- const labelComponent = () => (!children || isEmpty(children)) && !isEmpty(options) ? (React.createElement(Flex, { gap: 10, align: "center", justify: "space-between", style: { width: '100%' } },
65
+ const { key, label, children, icon, logo_url, menu_item_path, menu_item_domain, options, optionCallback, } = item;
66
+ const domain = !isNil(menu_item_domain) && env === ENV.DEV ? menu_item_domain : '';
67
+ const labelComponent = () => (!children || isEmpty(children)) && !isEmpty(options) ? (React.createElement(Flex, { gap: 10, align: "center", justify: "space-between", style: { width: '100%' }, className: "child-menu-label" },
35
68
  React.createElement(LabelCustom, { ellipsis: { tooltip: label } }, label),
36
69
  React.createElement(Dropdown, { menu: {
37
70
  items: options,
@@ -40,23 +73,21 @@ export const ChildMenu = memo(props => {
40
73
  e.domEvent.preventDefault();
41
74
  optionCallback === null || optionCallback === void 0 ? void 0 : optionCallback({ menuItemKey: key, optionKey: e.key });
42
75
  },
43
- } },
44
- React.createElement(Icon, { type: "icon-ants-three-dot-vertical", style: { marginTop: '2px' } })))) : (React.createElement(LabelCustom, { ellipsis: { tooltip: label } }, label));
76
+ }, trigger: ['click'] },
77
+ React.createElement(Icon, { type: "icon-ants-three-dot-vertical", style: { marginTop: '2px', zIndex: 1000 } })))) : (React.createElement(LabelCustom, { ellipsis: { tooltip: label } }, label));
45
78
  return {
46
79
  key,
47
- label: isString(menu_item_path) ? (React.createElement(Link, { to: getGeneratePath(menu_item_path, { userId }), className: "menu-link" }, labelComponent())) : (labelComponent()),
80
+ label: isString(menu_item_path) ? (React.createElement(Link, { to: getGeneratePath(`${domain}${menu_item_path}`, auth), className: "menu-link" }, labelComponent())) : (labelComponent()),
48
81
  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,
49
82
  children: customMenuItems({ parent: item, items: children }),
50
83
  };
51
84
  });
52
85
  };
53
- return (React.createElement(MenuWrapper, null,
54
- React.createElement(Menu, { onClick: onClick, selectedKeys: [current], mode: "inline", items: customMenuItems({ items }), inlineIndent: 10, expandIcon: ({ isOpen }) => {
55
- var _a;
56
- return (React.createElement(Icon, { type: "icon-ants-expand-more", style: {
57
- fontSize: ICON_SIZE,
58
- color: (_a = THEME.token) === null || _a === void 0 ? void 0 : _a.bw8,
59
- transform: `rotate(${isOpen ? '180deg' : '0deg'})`,
60
- } }));
61
- } })));
86
+ return (React.createElement(MenuWrapper, { className: "child-menu" },
87
+ React.createElement(Menu, { selectedKeys: [currentActiveItem], defaultOpenKeys: [currentActiveItem], mode: "inline", items: customMenuItems({ items }), inlineIndent: 10, expandIcon: ({ isOpen }) => (React.createElement(Icon, { type: "icon-ants-expand-more", style: {
88
+ fontSize: ICON_SIZE,
89
+ color: 'inherit',
90
+ // color: THEME.token?.bw8,
91
+ transform: `rotate(${isOpen ? '180deg' : '0deg'})`,
92
+ } })), onClick: onClick })));
62
93
  });
@@ -31,7 +31,6 @@ export const LeftMenu = memo(props => {
31
31
  permissionMenu, appConfig,
32
32
  /* Callbacks */
33
33
  onToggleChildMenu, onMouseEnter, onMouseLeave, } = useLeftMenu();
34
- const { userId, portalId } = (appConfig === null || appConfig === void 0 ? void 0 : appConfig.auth) || {};
35
34
  // Memo
36
35
  const childMenu = useMemo(() => {
37
36
  const selectedFeatureKey = state.hoverItem || state.activeItem;
@@ -74,10 +73,7 @@ export const LeftMenu = memo(props => {
74
73
  React.createElement("div", { className: "icon-wrapper" }, isNil(icon_name) ? null : React.createElement(Icon, { type: icon_name, style: { fontSize: ICON_SIZE } })),
75
74
  React.createElement(Typography.Text, null, menu_item_name),
76
75
  React.createElement("div", { className: "popup-triangle" })));
77
- return (React.createElement(FeatureMenuItem, { key: menu_item, onMouseEnter: () => onMouseEnter(menu_item_code, children) }, isString(menu_item_path) ? (React.createElement(Link, { to: getGeneratePath(`${domain}${menu_item_path}`, {
78
- userId,
79
- portalId,
80
- }), className: "menu-link" }, labelComponent())) : (labelComponent())));
76
+ return (React.createElement(FeatureMenuItem, { key: menu_item, onMouseEnter: () => onMouseEnter(menu_item_code, children) }, isString(menu_item_path) ? (React.createElement(Link, { to: getGeneratePath(`${domain}${menu_item_path}`, appConfig === null || appConfig === void 0 ? void 0 : appConfig.auth), className: "menu-link" }, labelComponent())) : (labelComponent())));
81
77
  };
82
78
  return (React.createElement(LeftMenuProvider, { value: {
83
79
  activeItem: state.activeItem,
@@ -96,7 +92,7 @@ export const LeftMenu = memo(props => {
96
92
  React.createElement(FeatureMenu, { role: "menu", className: "antsomi-scroll-box", onMouseLeave: onMouseLeave },
97
93
  React.createElement("div", { className: "menu-content scroll-content" }, (_a = permissionMenu === null || permissionMenu === void 0 ? void 0 : permissionMenu.filter(item => item.menu_item_code !== FEATURE_KEYS.SETTINGS)) === null || _a === void 0 ? void 0 : _a.map(item => renderFeatureMenuItems(item))),
98
94
  React.createElement("div", { className: "nav-blank", onMouseEnter: () => onMouseEnter(state.activeItem) }),
99
- React.createElement(PopoverWrapper, { className: "antsomi-scroll-box", onMouseLeave: onMouseLeave },
95
+ React.createElement(PopoverWrapper, { className: "antsomi-scroll-box antsomi-child-menu-popover", onMouseLeave: onMouseLeave },
100
96
  React.createElement("div", { className: "scroll-content" }, childMenu))),
101
97
  React.createElement("div", { style: { flexShrink: 0 } }, (() => {
102
98
  const settingFeature = permissionMenu === null || permissionMenu === void 0 ? void 0 : permissionMenu.find(item => item.menu_item_code === FEATURE_KEYS.SETTINGS);
@@ -1,6 +1,6 @@
1
1
  import { FeatureMenuPermission, TFeatureMenu } from '@antscorp/antsomi-ui/es/models/LeftMenu';
2
- import { TMenuFeatureItem, TMenuItem } from '../types';
3
2
  import { PayloadInfo } from '@antscorp/antsomi-ui/es/types';
3
+ import { TMenuFeatureItem, TMenuItem } from '../types';
4
4
  export declare const getMenuItem: (featureMenu: TMenuFeatureItem) => TMenuItem;
5
5
  export declare const flattenMenuArray: <T>(menuItems: T[], childKey: string) => T[];
6
6
  /**
@@ -10,4 +10,5 @@ export declare const flattenMenuArray: <T>(menuItems: T[], childKey: string) =>
10
10
  export declare const recursivePermissionMenu: (menuItems: TFeatureMenu[], MenuPermissions: FeatureMenuPermission[]) => TFeatureMenu[];
11
11
  export declare const getGeneratePath: (path: string, params?: Omit<PayloadInfo & {
12
12
  reportId?: string;
13
+ channelId?: number;
13
14
  }, 'url'>) => string;
@@ -14,6 +14,9 @@ import { isArray, isEmpty, isNil } from 'lodash';
14
14
  import { generatePath } from 'react-router-dom';
15
15
  // Constants
16
16
  import { MENU_ITEM_TYPE } from '../constants';
17
+ // Utils
18
+ import { handleError } from '@antscorp/antsomi-ui/es/utils';
19
+ const PATH = 'src/components/organism/LeftMenu/utils/index.ts';
17
20
  export const getMenuItem = (featureMenu) => {
18
21
  const { menu_item_code, menu_item_name, children, icon_name } = featureMenu, restOfFeatureMenu = __rest(featureMenu, ["menu_item_code", "menu_item_name", "children", "icon_name"]);
19
22
  return Object.assign({ key: menu_item_code, label: menu_item_name, icon: icon_name, children: children === null || children === void 0 ? void 0 : children.map(item => getMenuItem(item)) }, restOfFeatureMenu);
@@ -45,9 +48,22 @@ export const recursivePermissionMenu = (menuItems, MenuPermissions) => {
45
48
  : {}))))) === null || _b === void 0 ? void 0 : _b.filter(item => !(isArray(item.children) && isEmpty(item.children)));
46
49
  return menu;
47
50
  };
48
- export const getGeneratePath = (path, params) => generatePath(path.replace('#', `/${params === null || params === void 0 ? void 0 : params.portalId}#`), {
49
- user_id: params === null || params === void 0 ? void 0 : params.userId,
50
- networkId: params === null || params === void 0 ? void 0 : params.portalId,
51
- portalId: params === null || params === void 0 ? void 0 : params.portalId,
52
- reportId: params === null || params === void 0 ? void 0 : params.reportId,
53
- });
51
+ export const getGeneratePath = (path, params) => {
52
+ try {
53
+ return generatePath(path.replace('#', `/${params === null || params === void 0 ? void 0 : params.portalId}#`), {
54
+ user_id: (params === null || params === void 0 ? void 0 : params.userId) || '',
55
+ networkId: (params === null || params === void 0 ? void 0 : params.portalId) || -1,
56
+ portalId: (params === null || params === void 0 ? void 0 : params.portalId) || -1,
57
+ reportId: (params === null || params === void 0 ? void 0 : params.reportId) || '',
58
+ channelId: (params === null || params === void 0 ? void 0 : params.channelId) || -1,
59
+ });
60
+ }
61
+ catch (error) {
62
+ handleError(error, {
63
+ path: PATH,
64
+ name: getGeneratePath.name,
65
+ args: { path, params },
66
+ });
67
+ return '';
68
+ }
69
+ };
@@ -1,6 +1,7 @@
1
1
  import React, { PropsWithChildren } from 'react';
2
2
  import { LeftMenuProps } from '../../organism';
3
3
  import { HeaderV2Props } from '../../molecules';
4
+ import '@antscorp/processing-notification/dist/index.css';
4
5
  interface LayoutProps {
5
6
  headerProps?: Partial<HeaderV2Props>;
6
7
  leftMenuProps?: LeftMenuProps;
@@ -23,6 +23,8 @@ import { HeaderV2 } from '../../molecules';
23
23
  import { AppConfigContext } from '../../..';
24
24
  // Constants
25
25
  import { PERMISSION_API, SOCKET_API } from '../../../constants';
26
+ // Css
27
+ import '@antscorp/processing-notification/dist/index.css';
26
28
  export const Layout = memo(props => {
27
29
  var _a;
28
30
  const { leftMenuProps, headerProps, workspaceProps, children } = props;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.3.5-beta.187",
3
+ "version": "1.3.5-beta.189",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",
@@ -60,7 +60,6 @@
60
60
  "not op_mini all"
61
61
  ],
62
62
  "dependencies": {
63
- "@antscorp/antsomi-ui": "file:.yalc/@antscorp/antsomi-ui",
64
63
  "@antscorp/icons": "^0.27.14",
65
64
  "@antscorp/image-editor": "1.0.2",
66
65
  "@antscorp/processing-notification": "^1.0.0",