@antscorp/antsomi-ui 1.3.5-beta.362 → 1.3.5-beta.364

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.
@@ -3,13 +3,21 @@ import { useMemo } from 'react';
3
3
  // Queries
4
4
  import { useGetAccountList, useGetPermissionAccountList, useGetRecentAccount, } from '@antscorp/antsomi-ui/es/queries';
5
5
  // Constant
6
- import { PORTALS_IDS } from '@antscorp/antsomi-ui/es/constants';
6
+ import { APP_CODES } from '@antscorp/antsomi-ui/es/constants';
7
+ const { APP_ANTALYSER, DATAFLOWS } = APP_CODES;
8
+ // NOTES: Just define for account selection
9
+ const isUsePermissionAccount = (appCode) => {
10
+ if ([APP_ANTALYSER, DATAFLOWS].includes(appCode)) {
11
+ return true;
12
+ }
13
+ return false;
14
+ };
7
15
  export const useAccountSelection = (apiConfig) => {
8
- const { domain, token, userId, appCode, menuCode, portalId } = apiConfig;
16
+ const { domain, token, userId, appCode, menuCode } = apiConfig;
9
17
  const { data } = useGetAccountList({
10
18
  apiConfig,
11
19
  options: {
12
- enabled: portalId !== PORTALS_IDS.SANDBOX_76753,
20
+ enabled: !isUsePermissionAccount(appCode || ''),
13
21
  },
14
22
  });
15
23
  const { data: permissionAccountList } = useGetPermissionAccountList({
@@ -24,18 +32,18 @@ export const useAccountSelection = (apiConfig) => {
24
32
  menuCode: menuCode || appCode || '',
25
33
  },
26
34
  options: {
27
- enabled: portalId === PORTALS_IDS.SANDBOX_76753,
35
+ enabled: isUsePermissionAccount(appCode || ''),
28
36
  },
29
37
  });
30
38
  const { data: recentData } = useGetRecentAccount({
31
39
  apiConfig,
32
40
  options: {
33
- enabled: portalId !== PORTALS_IDS.SANDBOX_76753,
41
+ enabled: !isUsePermissionAccount(appCode || ''),
34
42
  },
35
43
  });
36
44
  // Memos
37
45
  const accountData = useMemo(() => {
38
- if (portalId === PORTALS_IDS.SANDBOX_76753) {
46
+ if (isUsePermissionAccount(appCode || '')) {
39
47
  return ((permissionAccountList === null || permissionAccountList === void 0 ? void 0 : permissionAccountList.map(account => ({
40
48
  email: account.email,
41
49
  userId: account.user_id,
@@ -44,6 +52,6 @@ export const useAccountSelection = (apiConfig) => {
44
52
  }))) || []);
45
53
  }
46
54
  return (data === null || data === void 0 ? void 0 : data.entries) || [];
47
- }, [data === null || data === void 0 ? void 0 : data.entries, permissionAccountList, portalId]);
55
+ }, [appCode, data === null || data === void 0 ? void 0 : data.entries, permissionAccountList]);
48
56
  return { recentData, accountData };
49
57
  };
@@ -1 +1 @@
1
- export * from './NumOfDaysRanges';
1
+ export { NumOfDaysRanges } from './NumOfDaysRanges';
@@ -1 +1 @@
1
- export * from './NumOfDaysRanges';
1
+ export { NumOfDaysRanges } from './NumOfDaysRanges';
@@ -1,12 +1,39 @@
1
1
  import React, { useRef } from 'react';
2
+ import { List, Menu } from 'antd';
2
3
  import Icon from '@antscorp/icons';
4
+ import styled from 'styled-components';
3
5
  import { Popover } from '@antscorp/antsomi-ui/es/components/atoms';
4
6
  import classNames from 'classnames';
5
7
  import { useCalendarSelectionContext } from '../../../../hooks';
6
8
  import { changeRangeType } from '../../../../actions';
7
9
  import { rangeInfoToStringType } from '../../../../utils';
8
- import { StyledMenu } from './styled';
9
- import { List } from 'antd';
10
+ const StyledMenu = styled(Menu) `
11
+ &.antsomi-menu-root {
12
+ .antsomi-menu-item {
13
+ position: relative;
14
+ color: black;
15
+ height: 32px;
16
+ line-height: 32px;
17
+ border-radius: 0;
18
+ width: 100%;
19
+ margin: 0;
20
+
21
+ &.antsomi-menu-item-selected {
22
+ font-weight: bold;
23
+
24
+ &:after {
25
+ content: '';
26
+ position: absolute;
27
+ left: 0;
28
+ top: 0;
29
+ width: 4px;
30
+ height: 100%;
31
+ background-color: #005fb8;
32
+ }
33
+ }
34
+ }
35
+ }
36
+ `;
10
37
  export const Option = props => {
11
38
  const itemRef = useRef(null);
12
39
  const { label = '', options = [], type } = props;
@@ -1,2 +1,2 @@
1
- export * from './Option';
2
- export * from './NumOfDaysRanges';
1
+ export { Option } from './Option';
2
+ export { NumOfDaysRanges } from './NumOfDaysRanges';
@@ -1,2 +1,2 @@
1
- export * from './Option';
2
- export * from './NumOfDaysRanges';
1
+ export { Option } from './Option';
2
+ export { NumOfDaysRanges } from './NumOfDaysRanges';
@@ -21,5 +21,10 @@ export declare const CalendarSelectionConstants: {
21
21
  readonly days_up_to_today: "days_up_to_today";
22
22
  readonly days_up_to_yesterday: "days_up_to_yesterday";
23
23
  };
24
+ AUTO_UPDATE_TO_KEY: {
25
+ readonly today: "today";
26
+ readonly yesterday: "yesterday";
27
+ readonly fixed: "fixed";
28
+ };
24
29
  };
25
30
  export type { TriggerOutInfo, CalendarSelectionValue } from './types';
@@ -1,6 +1,7 @@
1
- import { TRIGGER_OUT_MODE, SELECTION_KEY } from './constants';
1
+ import { TRIGGER_OUT_MODE, SELECTION_KEY, AUTO_UPDATE_TO_KEY } from './constants';
2
2
  export { CalendarSelection } from './CalendarSelection';
3
3
  export const CalendarSelectionConstants = {
4
4
  TRIGGER_OUT_MODE,
5
5
  SELECTION_KEY,
6
+ AUTO_UPDATE_TO_KEY,
6
7
  };
@@ -7,7 +7,7 @@ import quarterOfYear from 'dayjs/plugin/quarterOfYear';
7
7
  import isSameOrBefore from 'dayjs/plugin/isSameOrBefore';
8
8
  import { AUTO_UPDATE_TO_KEY, DEFAULT_NUM_UP_TO, MAP_TITLE, RANGE_LIMIT, SELECTION_KEY, } from './constants';
9
9
  import { last } from 'lodash';
10
- import { asssertCannotReach } from '@antscorp/antsomi-ui/es/utils/common';
10
+ import { asssertCannotReach } from '@antscorp/antsomi-ui/es/utils';
11
11
  dayjs.extend(utc);
12
12
  dayjs.extend(timezone);
13
13
  dayjs.extend(isoWeek);
@@ -13,7 +13,7 @@ export const usePermission = () => {
13
13
  const appConfig = useLeftMenuStore(store => store.state.appConfig);
14
14
  const isCustomized = useLeftMenuStore(store => store.state.isCustomized);
15
15
  const { isGrouped, objectId, objectType } = useLeftMenuStore(store => store.state.dashboardParams);
16
- const { auth, languageCode = 'en', env = 'development' } = appConfig || {};
16
+ const { auth, languageCode = 'en', env = 'development', permissionDomain } = appConfig || {};
17
17
  const { pathname, hash } = window.location;
18
18
  const { data: menuList } = useGetListMenu({
19
19
  args: {
@@ -63,7 +63,7 @@ export const usePermission = () => {
63
63
  args: {
64
64
  auth: {
65
65
  token: auth === null || auth === void 0 ? void 0 : auth.token,
66
- url: PERMISSION_API,
66
+ url: permissionDomain || PERMISSION_API,
67
67
  userId: auth === null || auth === void 0 ? void 0 : auth.userId,
68
68
  accountId: auth === null || auth === void 0 ? void 0 : auth.userId,
69
69
  },
@@ -36,7 +36,7 @@ export const Layout = memo(props => {
36
36
  const _a = leftMenuProps || {}, { className = '' } = _a, restOfLeftMenuProps = __rest(_a, ["className"]);
37
37
  const _b = workspaceProps || {}, { workspaceContentProps } = _b, restOfWorkspaceProps = __rest(_b, ["workspaceContentProps"]);
38
38
  const appConfig = useContextSelector(AppConfigContext, state => state);
39
- const { auth, languageCode, appCode, env } = appConfig;
39
+ const { auth, languageCode, appCode, permissionDomain: configPermissionDomain, env } = appConfig;
40
40
  const { token, userId, portalId } = auth || {};
41
41
  const showLeftMenu = useLayoutStore(store => store.state.leftMenu.show);
42
42
  const header = useLayoutStore(store => store.state.header);
@@ -63,6 +63,12 @@ export const Layout = memo(props => {
63
63
  // Memo
64
64
  const permissionDomain = useMemo(() => {
65
65
  var _a;
66
+ /**
67
+ * Priority for permission domain
68
+ */
69
+ if (configPermissionDomain) {
70
+ return configPermissionDomain;
71
+ }
66
72
  /**
67
73
  * Check if appCode not exist and portalId is SANDBOX
68
74
  * then return production permission api
@@ -76,7 +82,7 @@ export const Layout = memo(props => {
76
82
  default:
77
83
  return PERMISSION_API;
78
84
  }
79
- }, [appCode, env, portalId]);
85
+ }, [appCode, configPermissionDomain, env, portalId]);
80
86
  const iamDomain = useMemo(() => {
81
87
  var _a;
82
88
  /**
@@ -2,10 +2,12 @@
2
2
  import styled from 'styled-components';
3
3
  // Components
4
4
  import { Flex } from '../../../../atoms';
5
+ // Constants
6
+ import { globalToken } from '@antscorp/antsomi-ui/es/constants';
5
7
  export const BlankTemplateWrapper = styled(Flex) `
6
8
  box-sizing: border-box;
7
9
  border: 1px solid #b8cfe6;
8
- border-radius: 5px;
10
+ border-radius: ${globalToken === null || globalToken === void 0 ? void 0 : globalToken.borderRadius}px;
9
11
  cursor: pointer;
10
12
 
11
13
  .add-blank-btn {
@@ -8,6 +8,8 @@ export interface AppConfigProps {
8
8
  menuCode?: string;
9
9
  languageCode?: string;
10
10
  urlLogout?: string;
11
+ /** Domain */
12
+ permissionDomain?: string;
11
13
  setAppConfig: React.Dispatch<React.SetStateAction<AppConfigProviderProps>>;
12
14
  }
13
15
  export interface AppConfigProviderProps extends Omit<AppConfigProps, 'setAppConfig'> {
@@ -63,7 +63,6 @@ export declare const isEmail: (email: string) => boolean;
63
63
  */
64
64
  export declare function mapNumberToOrdinalText(num: number): string;
65
65
  export declare const searchParamsToObject: (searchParams?: string) => Record<string, unknown>;
66
- export declare function asssertCannotReach(x: never): void;
67
66
  export declare const getShuffleArray: <T>(array: T[]) => T[];
68
67
  export declare const snakeCaseToCamelCase: <T = Record<string, any>>(object: Record<string, any> | Record<string, any>[], recursive?: boolean) => T;
69
68
  export declare const camelCaseToSnakeCase: <T = Record<string, any>>(object: Record<string, any>, recursive?: boolean) => T;
@@ -86,3 +85,4 @@ export declare const searchStringQuery: (str: string, queryStr: string) => boole
86
85
  export declare const isExistedImage: (imageUrl: string) => boolean;
87
86
  export declare const getUrlNoCache: (url?: string, cacheValue?: number | string) => string;
88
87
  export declare const safeParseJson: (json?: string | null, defaultValue?: any) => any;
88
+ export declare function asssertCannotReach(x: never): void;
@@ -387,9 +387,6 @@ export function mapNumberToOrdinalText(num) {
387
387
  }
388
388
  }
389
389
  export const searchParamsToObject = (searchParams = '') => Object.fromEntries(new URLSearchParams(searchParams));
390
- export function asssertCannotReach(x) {
391
- throw new Error('cannot reach this place in the code!');
392
- }
393
390
  export const getShuffleArray = (array) => {
394
391
  for (let i = array.length - 1; i > 0; i--) {
395
392
  /* Choose a random position from 0 to i */
@@ -502,3 +499,6 @@ export const safeParseJson = (json, defaultValue) => {
502
499
  return defaultValue;
503
500
  }
504
501
  };
502
+ export function asssertCannotReach(x) {
503
+ throw new Error('cannot reach this place in the code!');
504
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.3.5-beta.362",
3
+ "version": "1.3.5-beta.364",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",
@@ -1,29 +0,0 @@
1
- import { Menu } from 'antd';
2
- import styled from 'styled-components';
3
- export const StyledMenu = styled(Menu) `
4
- &.antsomi-menu-root {
5
- .antsomi-menu-item {
6
- position: relative;
7
- color: black;
8
- height: 32px;
9
- line-height: 32px;
10
- border-radius: 0;
11
- width: 100%;
12
- margin: 0;
13
-
14
- &.antsomi-menu-item-selected {
15
- font-weight: bold;
16
-
17
- &:after {
18
- content: '';
19
- position: absolute;
20
- left: 0;
21
- top: 0;
22
- width: 4px;
23
- height: 100%;
24
- background-color: #005fb8;
25
- }
26
- }
27
- }
28
- }
29
- `;