@antscorp/antsomi-ui 1.3.5-beta.560 → 1.3.5-beta.562
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/components/molecules/RequestAccess/RequestAccess.d.ts +15 -0
- package/es/components/molecules/RequestAccess/RequestAccess.js +42 -0
- package/es/components/molecules/RequestAccess/index.d.ts +1 -0
- package/es/components/molecules/RequestAccess/index.js +1 -0
- package/es/components/molecules/RequestAccess/styled.d.ts +1 -0
- package/es/components/molecules/RequestAccess/styled.js +34 -0
- package/es/components/organism/LeftMenu/hooks/usePermission.js +2 -1
- package/es/locales/en/translation.json +9 -0
- package/es/locales/i18n.d.ts +18 -0
- package/es/locales/translations.d.ts +9 -0
- package/es/locales/vi/translation.json +9 -0
- package/es/utils/common.d.ts +10 -0
- package/es/utils/common.js +13 -0
- package/package.json +5 -5
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface RequestAccessProps {
|
|
3
|
+
className?: string;
|
|
4
|
+
placeholder?: string;
|
|
5
|
+
deniedTitle?: string;
|
|
6
|
+
deniedSubTitle?: string;
|
|
7
|
+
sentTitle?: string;
|
|
8
|
+
sentSubTitle?: string;
|
|
9
|
+
requestText?: string;
|
|
10
|
+
switchAccountText?: string;
|
|
11
|
+
onRequest?: (message: string) => Promise<void>;
|
|
12
|
+
onSwitchAccount?: () => void;
|
|
13
|
+
}
|
|
14
|
+
export declare const RequestAccess: React.FC<RequestAccessProps>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React, { useRef, useState } from 'react';
|
|
2
|
+
import { Button, Flex, TextArea, Typography } from '@antscorp/antsomi-ui/es/components';
|
|
3
|
+
// Styled
|
|
4
|
+
import { RequestAccessStyled } from './styled';
|
|
5
|
+
// Translate
|
|
6
|
+
import i18nInstance from '@antscorp/antsomi-ui/es/locales/i18n';
|
|
7
|
+
import { translations } from '@antscorp/antsomi-ui/es/locales/translations';
|
|
8
|
+
const { t } = i18nInstance;
|
|
9
|
+
export const RequestAccess = props => {
|
|
10
|
+
const { className, placeholder = t(translations.requestAccess.placeholder), deniedTitle = t(translations.requestAccess.deniedTitle), deniedSubTitle = t(translations.requestAccess.deniedSubTitle), sentTitle = t(translations.requestAccess.sentTitle), sentSubTitle = t(translations.requestAccess.sentSubTitle), requestText = t(translations.requestAccess.requestText), switchAccountText = t(translations.requestAccess.switchAccountText), onRequest, onSwitchAccount, } = props;
|
|
11
|
+
const [isSentRequest, setIsSentRequest] = useState(false);
|
|
12
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
13
|
+
const messageRef = useRef(null);
|
|
14
|
+
const handleClickRequest = () => {
|
|
15
|
+
var _a, _b;
|
|
16
|
+
const message = ((_b = (_a = messageRef.current) === null || _a === void 0 ? void 0 : _a.resizableTextArea) === null || _b === void 0 ? void 0 : _b.textArea.value) || '';
|
|
17
|
+
if (onRequest) {
|
|
18
|
+
try {
|
|
19
|
+
setIsLoading(true);
|
|
20
|
+
onRequest(message)
|
|
21
|
+
.then(() => setIsSentRequest(true))
|
|
22
|
+
.finally(() => setIsLoading(false));
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
setIsSentRequest(true);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const handleSwitchAccount = () => {
|
|
30
|
+
if (onSwitchAccount)
|
|
31
|
+
onSwitchAccount();
|
|
32
|
+
};
|
|
33
|
+
return (React.createElement(RequestAccessStyled, { className: `antsomi-request-access ${className || ''}` },
|
|
34
|
+
React.createElement(Flex, { vertical: true, gap: 20 },
|
|
35
|
+
React.createElement(Flex, { vertical: true, gap: 5 },
|
|
36
|
+
React.createElement(Typography.Text, { className: "denied-title" }, isSentRequest ? sentTitle : deniedTitle),
|
|
37
|
+
React.createElement(Typography.Text, { className: "denied-sub-title" }, isSentRequest ? sentSubTitle : deniedSubTitle)),
|
|
38
|
+
!isSentRequest ? (React.createElement(TextArea, { style: { resize: 'none' }, placeholder: placeholder, ref: messageRef })) : null,
|
|
39
|
+
React.createElement(Flex, { className: "action-buttons", gap: 10 },
|
|
40
|
+
isSentRequest ? null : (React.createElement(Button, { onClick: handleClickRequest, type: "primary", loading: isLoading }, requestText)),
|
|
41
|
+
React.createElement(Button, { onClick: handleSwitchAccount }, switchAccountText)))));
|
|
42
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { RequestAccess } from './RequestAccess';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { RequestAccess } from './RequestAccess';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const RequestAccessStyled: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { globalToken } from '@antscorp/antsomi-ui/es/constants';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
export const RequestAccessStyled = styled.div `
|
|
4
|
+
box-sizing: border-box;
|
|
5
|
+
width: 100%;
|
|
6
|
+
height: 100%;
|
|
7
|
+
|
|
8
|
+
display: flex;
|
|
9
|
+
justify-content: center;
|
|
10
|
+
align-items: center;
|
|
11
|
+
|
|
12
|
+
& > div {
|
|
13
|
+
width: 350px;
|
|
14
|
+
|
|
15
|
+
.denied-title {
|
|
16
|
+
font-size: 20px;
|
|
17
|
+
line-height: 24px;
|
|
18
|
+
font-weight: 700;
|
|
19
|
+
color: ${globalToken === null || globalToken === void 0 ? void 0 : globalToken.orange6};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.denied-sub-title {
|
|
23
|
+
line-height: 14px;
|
|
24
|
+
color: ${globalToken === null || globalToken === void 0 ? void 0 : globalToken.bw8};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.antsomi-input {
|
|
28
|
+
height: 150px;
|
|
29
|
+
border: 1px solid ${globalToken === null || globalToken === void 0 ? void 0 : globalToken.blue1} !important;
|
|
30
|
+
border-radius: ${globalToken === null || globalToken === void 0 ? void 0 : globalToken.borderRadius}px;
|
|
31
|
+
padding: 10px;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
`;
|
|
@@ -11,6 +11,7 @@ import { ENV } from '@antscorp/antsomi-ui/es/config';
|
|
|
11
11
|
// Utils
|
|
12
12
|
import { findLastMatchedItemByUrl, findPathOfActiveItem, flattenMenuArray, getMappingAppChildren, recursivePermissionMenu, } from '../utils';
|
|
13
13
|
import { useCheckUserPermission } from '@antscorp/antsomi-ui/es/queries';
|
|
14
|
+
import { recursiveSortBy } from '@antscorp/antsomi-ui/es/utils';
|
|
14
15
|
const { DEV, SANDBOX, SANDBOX_CDP } = ENV;
|
|
15
16
|
export const usePermission = () => {
|
|
16
17
|
const appConfig = useLeftMenuContext(store => store.appConfig);
|
|
@@ -135,7 +136,7 @@ export const usePermission = () => {
|
|
|
135
136
|
userPermission,
|
|
136
137
|
]);
|
|
137
138
|
const mappingChildrenMenuWithNoPermission = useMemo(() => getMappingAppChildren({
|
|
138
|
-
menuList: (menuList === null || menuList === void 0 ? void 0 : menuList.rows) || [],
|
|
139
|
+
menuList: recursiveSortBy((menuList === null || menuList === void 0 ? void 0 : menuList.rows) || [], 'children', ['level_position']) || [],
|
|
139
140
|
auth,
|
|
140
141
|
dashboardList,
|
|
141
142
|
destinationChannelEntries: destinationChannel === null || destinationChannel === void 0 ? void 0 : destinationChannel.entries,
|
|
@@ -665,5 +665,14 @@
|
|
|
665
665
|
"description": "Ask for permission or switch to an account with access",
|
|
666
666
|
"requestAccess": "Request access",
|
|
667
667
|
"switchAccount": "Switch account"
|
|
668
|
+
},
|
|
669
|
+
"requestAccess": {
|
|
670
|
+
"placeholder": "Message (optional)",
|
|
671
|
+
"deniedTitle": "Access Denied",
|
|
672
|
+
"deniedSubTitle": "Ask for permission or switch to an account with access",
|
|
673
|
+
"sentTitle": "Request sent",
|
|
674
|
+
"sentSubTitle": "You’ll receive an email once your request is approved or denied",
|
|
675
|
+
"requestText": "Request Access",
|
|
676
|
+
"switchAccountText": "Switch account"
|
|
668
677
|
}
|
|
669
678
|
}
|
package/es/locales/i18n.d.ts
CHANGED
|
@@ -668,6 +668,15 @@ export declare const translationsJson: {
|
|
|
668
668
|
requestAccess: string;
|
|
669
669
|
switchAccount: string;
|
|
670
670
|
};
|
|
671
|
+
requestAccess: {
|
|
672
|
+
placeholder: string;
|
|
673
|
+
deniedTitle: string;
|
|
674
|
+
deniedSubTitle: string;
|
|
675
|
+
sentTitle: string;
|
|
676
|
+
sentSubTitle: string;
|
|
677
|
+
requestText: string;
|
|
678
|
+
switchAccountText: string;
|
|
679
|
+
};
|
|
671
680
|
};
|
|
672
681
|
};
|
|
673
682
|
vi: {
|
|
@@ -889,6 +898,15 @@ export declare const translationsJson: {
|
|
|
889
898
|
requestAccess: string;
|
|
890
899
|
switchAccount: string;
|
|
891
900
|
};
|
|
901
|
+
requestAccess: {
|
|
902
|
+
placeholder: string;
|
|
903
|
+
deniedTitle: string;
|
|
904
|
+
deniedSubTitle: string;
|
|
905
|
+
sentTitle: string;
|
|
906
|
+
sentSubTitle: string;
|
|
907
|
+
requestText: string;
|
|
908
|
+
switchAccountText: string;
|
|
909
|
+
};
|
|
892
910
|
};
|
|
893
911
|
};
|
|
894
912
|
};
|
|
@@ -668,6 +668,15 @@ export declare const convertLanguageJsonToObject: (json: any, objToConvertTo?: C
|
|
|
668
668
|
requestAccess: string;
|
|
669
669
|
switchAccount: string;
|
|
670
670
|
};
|
|
671
|
+
requestAccess: {
|
|
672
|
+
placeholder: string;
|
|
673
|
+
deniedTitle: string;
|
|
674
|
+
deniedSubTitle: string;
|
|
675
|
+
sentTitle: string;
|
|
676
|
+
sentSubTitle: string;
|
|
677
|
+
requestText: string;
|
|
678
|
+
switchAccountText: string;
|
|
679
|
+
};
|
|
671
680
|
}>, current?: string) => void;
|
|
672
681
|
export declare const t: (id: string, ...rest: any[]) => [string, ...any[]];
|
|
673
682
|
export declare const getTranslateMessage: (id: string, defaultMessage?: string, value?: Record<string, unknown>) => string;
|
|
@@ -215,5 +215,14 @@
|
|
|
215
215
|
"description": "Hãy yêu cầu quyền truy cập hoặc chuyển sang tài khoản có quyền",
|
|
216
216
|
"requestAccess": "Yêu cầu truy cập",
|
|
217
217
|
"switchAccount": "Đổi tài khoản"
|
|
218
|
+
},
|
|
219
|
+
"requestAccess": {
|
|
220
|
+
"placeholder": "Lời nhắn (Không bắt buộc)",
|
|
221
|
+
"deniedTitle": "Truy cập bị từ chối",
|
|
222
|
+
"deniedSubTitle": "Hãy yêu cầu cấp quyền hoặc chuyển sang tài khoản có quyền truy cập",
|
|
223
|
+
"sentTitle": "Đã gửi yêu cầu",
|
|
224
|
+
"sentSubTitle": "Bạn sẽ nhận được email sau khi yêu cầu của bạn được chấp thuận hoặc bị từ chối",
|
|
225
|
+
"requestText": "Yêu cầu truy cập",
|
|
226
|
+
"switchAccountText": "Đổi tài khoản"
|
|
218
227
|
}
|
|
219
228
|
}
|
package/es/utils/common.d.ts
CHANGED
|
@@ -137,3 +137,13 @@ export declare function splitTextByNewline(text?: string): string[];
|
|
|
137
137
|
* @returns {any | null} The parsed JSON object if successful, or `null` if the parsing fails or the key does not exist.
|
|
138
138
|
*/
|
|
139
139
|
export declare function parseJSONFromLocalStorage<T = any>(key: string): T | null;
|
|
140
|
+
/**
|
|
141
|
+
* Recursively sorts an array of objects by specified keys and also sorts their nested children arrays.
|
|
142
|
+
*
|
|
143
|
+
* @template T - The type of the objects within the array.
|
|
144
|
+
* @param {T[]} arr - The array of objects to be sorted.
|
|
145
|
+
* @param {keyof T} [childrenKey='children'] - The key used to identify the children array in each object.
|
|
146
|
+
* @param {Array<keyof T>} [sortByKeys=[]] - The keys used to sort the objects.
|
|
147
|
+
* @returns {T[]} - The sorted array with each object’s children arrays also sorted recursively.
|
|
148
|
+
*/
|
|
149
|
+
export declare const recursiveSortBy: <T = any>(arr: T[], childrenKey?: keyof T, sortByKeys?: (keyof T)[]) => T[];
|
package/es/utils/common.js
CHANGED
|
@@ -6,6 +6,7 @@ import uniqid from 'uniqid';
|
|
|
6
6
|
import { MESSAGES, PORTAL_KEYS } from '@antscorp/antsomi-ui/es/services/constants';
|
|
7
7
|
// Utils
|
|
8
8
|
import { handleError } from './handleError';
|
|
9
|
+
import { sortBy } from 'lodash';
|
|
9
10
|
const PATH = 'src/utils/common.ts';
|
|
10
11
|
/**
|
|
11
12
|
* Function to reorder list
|
|
@@ -607,3 +608,15 @@ export function parseJSONFromLocalStorage(key) {
|
|
|
607
608
|
return null;
|
|
608
609
|
}
|
|
609
610
|
}
|
|
611
|
+
/**
|
|
612
|
+
* Recursively sorts an array of objects by specified keys and also sorts their nested children arrays.
|
|
613
|
+
*
|
|
614
|
+
* @template T - The type of the objects within the array.
|
|
615
|
+
* @param {T[]} arr - The array of objects to be sorted.
|
|
616
|
+
* @param {keyof T} [childrenKey='children'] - The key used to identify the children array in each object.
|
|
617
|
+
* @param {Array<keyof T>} [sortByKeys=[]] - The keys used to sort the objects.
|
|
618
|
+
* @returns {T[]} - The sorted array with each object’s children arrays also sorted recursively.
|
|
619
|
+
*/
|
|
620
|
+
export const recursiveSortBy = (arr, childrenKey = 'children', sortByKeys = []) => sortBy(arr, [...sortByKeys]).map(item => (Object.assign(Object.assign({}, item), (item[childrenKey] && {
|
|
621
|
+
[childrenKey]: recursiveSortBy(item[childrenKey], childrenKey, sortByKeys),
|
|
622
|
+
}))));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antscorp/antsomi-ui",
|
|
3
|
-
"version": "1.3.5-beta.
|
|
3
|
+
"version": "1.3.5-beta.562",
|
|
4
4
|
"description": "An enterprise-class UI design language and React UI library.",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"dist/*",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"ts-compile": "tsc -p tsconfig.esm.json",
|
|
41
41
|
"copy-files": "copyfiles -u 1 src/**/*.json src/**/*.svg src/**/*.scss src/**/*.png es",
|
|
42
42
|
"icons:add": "tsx scripts/add-icons.ts",
|
|
43
|
-
"icons:export": "
|
|
44
|
-
"icons:format": "prettier --write \"src/components/icons/*.tsx\"",
|
|
43
|
+
"icons:export": "sh -e scripts/generate-export-icon.sh",
|
|
44
|
+
"icons:format": "prettier --loglevel warn --write \"src/components/icons/*.tsx\"",
|
|
45
45
|
"icons:update": "sh -e scripts/update-icons.sh"
|
|
46
46
|
},
|
|
47
47
|
"husky": {
|
|
@@ -200,7 +200,7 @@
|
|
|
200
200
|
"eslint-config-prettier": "^8.8.0",
|
|
201
201
|
"eslint-plugin-import": "^2.27.5",
|
|
202
202
|
"eslint-plugin-jsx-a11y": "^6.7.1",
|
|
203
|
-
"eslint-plugin-prettier": "^
|
|
203
|
+
"eslint-plugin-prettier": "^5.2.1",
|
|
204
204
|
"eslint-plugin-react": "^7.32.2",
|
|
205
205
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
206
206
|
"eslint-plugin-storybook": "^0.8.0",
|
|
@@ -212,7 +212,7 @@
|
|
|
212
212
|
"mini-css-extract-plugin": "^2.7.5",
|
|
213
213
|
"postcss": "^8.4.21",
|
|
214
214
|
"postcss-loader": "^7.1.0",
|
|
215
|
-
"prettier": "^
|
|
215
|
+
"prettier": "^3.3.3",
|
|
216
216
|
"react": "18.2.0",
|
|
217
217
|
"react-dom": "18.2.0",
|
|
218
218
|
"react-fast-compare": "^3.2.1",
|