@antscorp/antsomi-ui 1.3.3-beta.68 → 1.3.3-beta.69
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/ShareAccess/components/GeneralAccess/GeneralAccess.js +13 -3
- package/es/components/molecules/ShareAccess/components/LayoutContent/LayoutContent.d.ts +1 -1
- package/es/components/molecules/ShareAccess/components/LayoutContent/LayoutContent.js +5 -0
- package/es/components/molecules/ShareAccess/constants.d.ts +0 -8
- package/es/components/molecules/ShareAccess/constants.js +0 -10
- package/es/components/molecules/ShareAccess/hooks/useShareAccess.js +5 -3
- package/es/components/molecules/ShareAccess/index.d.ts +3 -2
- package/es/components/molecules/ShareAccess/index.js +3 -2
- package/es/components/molecules/ShareAccess/types.d.ts +1 -1
- package/es/components/molecules/ShareAccess/utils.d.ts +2 -0
- package/es/components/molecules/ShareAccess/utils.js +12 -7
- package/package.json +3 -3
|
@@ -3,7 +3,7 @@ import { Dropdown } from 'antd';
|
|
|
3
3
|
import produce from 'immer';
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { updateObjAccessInfo } from '../../actions';
|
|
6
|
-
import { GENERAL_ACCESS,
|
|
6
|
+
import { GENERAL_ACCESS, PUBLIC_ROLE, ROLE_ACCESS_LABEL } from '../../constants';
|
|
7
7
|
import { useShareAccess } from '../../hooks';
|
|
8
8
|
import { StyledGeneralAccessRoot } from './styled';
|
|
9
9
|
export const GeneralAccess = () => {
|
|
@@ -31,6 +31,16 @@ export const GeneralAccess = () => {
|
|
|
31
31
|
});
|
|
32
32
|
dispatch(updateObjAccessInfo(updated));
|
|
33
33
|
};
|
|
34
|
+
const renderDescription = () => {
|
|
35
|
+
let description = 'Only people with access can open this item.';
|
|
36
|
+
if (isPublic && publicRole === PUBLIC_ROLE.ONLY_VIEWER) {
|
|
37
|
+
description = 'Anyone on the portal can view this item.';
|
|
38
|
+
}
|
|
39
|
+
if (isPublic && publicRole === PUBLIC_ROLE.ONLY_EDITOR) {
|
|
40
|
+
description = 'Anyone on the portal can edit this item.';
|
|
41
|
+
}
|
|
42
|
+
return description;
|
|
43
|
+
};
|
|
34
44
|
return (React.createElement(StyledGeneralAccessRoot, null,
|
|
35
45
|
React.createElement("div", { className: "title" }, "General access"),
|
|
36
46
|
React.createElement("div", { className: "setting" },
|
|
@@ -47,8 +57,8 @@ export const GeneralAccess = () => {
|
|
|
47
57
|
React.createElement("div", { className: "general-dropdown-wrapper" },
|
|
48
58
|
React.createElement("div", { className: "accessable-title" }, isPublic ? 'Public' : 'Restricted'),
|
|
49
59
|
allowEdit && React.createElement(Icon, { className: "icon-angle", type: "icon-ants-angle-down" }))),
|
|
50
|
-
React.createElement("div", { className: "description" },
|
|
51
|
-
!!isPublic && (React.createElement(Dropdown, { placement: "bottomLeft", trigger: ['click'], destroyPopupOnHide: true, disabled: !allowEdit, menu: {
|
|
60
|
+
React.createElement("div", { className: "description" }, renderDescription())),
|
|
61
|
+
!!isPublic && publicRole && (React.createElement(Dropdown, { placement: "bottomLeft", trigger: ['click'], destroyPopupOnHide: true, disabled: !allowEdit, menu: {
|
|
52
62
|
items: [
|
|
53
63
|
publicRole === PUBLIC_ROLE.ONLY_VIEWER
|
|
54
64
|
? {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { useShareAccess } from '../../hooks';
|
|
2
3
|
import { GeneralAccess } from '../GeneralAccess';
|
|
3
4
|
import { ModalTransferOwnership } from '../ModalTransferOwnerShip/ModalTransferOwnerShip';
|
|
4
5
|
import { PeopleAccess } from '../PeopleAccess';
|
|
@@ -6,6 +7,10 @@ import { SearchUser } from '../SearchUser';
|
|
|
6
7
|
import { StyledLayoutContentRoot } from './styled';
|
|
7
8
|
export const LayoutContent = (props) => {
|
|
8
9
|
const { getUserInfo, allowChangeOnwership = true } = props;
|
|
10
|
+
const { state } = useShareAccess();
|
|
11
|
+
const { allowEdit, allowView } = state;
|
|
12
|
+
if (!allowEdit && !allowView)
|
|
13
|
+
return null;
|
|
9
14
|
return (React.createElement(StyledLayoutContentRoot, null,
|
|
10
15
|
React.createElement(SearchUser, { getUserInfo: getUserInfo }),
|
|
11
16
|
React.createElement(PeopleAccess, { allowChangeOnwership: allowChangeOnwership }),
|
|
@@ -59,14 +59,6 @@ export declare const GENERAL_ACTIONS: {
|
|
|
59
59
|
readonly label: "Restricted";
|
|
60
60
|
};
|
|
61
61
|
};
|
|
62
|
-
export declare const GENERATE_DESCRIPTION: {
|
|
63
|
-
1: {
|
|
64
|
-
[x: number]: string;
|
|
65
|
-
};
|
|
66
|
-
0: {
|
|
67
|
-
[x: number]: string;
|
|
68
|
-
};
|
|
69
|
-
};
|
|
70
62
|
export declare const MENU_PERMISSION: {
|
|
71
63
|
readonly NONE: 1;
|
|
72
64
|
readonly CREATED_BY_USER: 2;
|
|
@@ -77,16 +77,6 @@ export const GENERAL_ACTIONS = {
|
|
|
77
77
|
label: 'Restricted',
|
|
78
78
|
},
|
|
79
79
|
};
|
|
80
|
-
export const GENERATE_DESCRIPTION = {
|
|
81
|
-
[GENERAL_ACCESS.PUBLIC]: {
|
|
82
|
-
[PUBLIC_ROLE.ONLY_EDITOR]: 'Anyone on the portal can edit this item.',
|
|
83
|
-
[PUBLIC_ROLE.ONLY_VIEWER]: 'Anyone on the portal can view this item.',
|
|
84
|
-
},
|
|
85
|
-
[GENERAL_ACCESS.RESTRICTED]: {
|
|
86
|
-
[PUBLIC_ROLE.ONLY_EDITOR]: 'Only people with access can open this item.',
|
|
87
|
-
[PUBLIC_ROLE.ONLY_VIEWER]: 'Only people with access can open this item.',
|
|
88
|
-
},
|
|
89
|
-
};
|
|
90
80
|
export const MENU_PERMISSION = {
|
|
91
81
|
NONE: 1,
|
|
92
82
|
CREATED_BY_USER: 2,
|
|
@@ -3,7 +3,7 @@ import { MENU_PERMISSION } from '../constants';
|
|
|
3
3
|
import { ShareAccessDispatchContext, ShareAccessStateContext } from '../context';
|
|
4
4
|
import { composeObjectMenuPermissions } from '../utils';
|
|
5
5
|
export const useShareAccess = () => {
|
|
6
|
-
var _a, _b, _c;
|
|
6
|
+
var _a, _b, _c, _d, _e;
|
|
7
7
|
const state = useContext(ShareAccessStateContext);
|
|
8
8
|
const dispatch = useContext(ShareAccessDispatchContext);
|
|
9
9
|
if (!state) {
|
|
@@ -11,9 +11,11 @@ export const useShareAccess = () => {
|
|
|
11
11
|
}
|
|
12
12
|
const userAccess = useMemo(() => { var _a; return (_a = state.accessInfo) === null || _a === void 0 ? void 0 : _a.listAccess.find(access => access.userId === state.accessUserId); }, [state.accessUserId, (_a = state.accessInfo) === null || _a === void 0 ? void 0 : _a.listAccess]);
|
|
13
13
|
const { edit: allowEdit, view: allowView } = composeObjectMenuPermissions({
|
|
14
|
+
isPublic: !!((_b = state.accessInfo) === null || _b === void 0 ? void 0 : _b.isPublic),
|
|
15
|
+
publicRole: ((_c = state.accessInfo) === null || _c === void 0 ? void 0 : _c.publicRole) || null,
|
|
14
16
|
menuPermission: {
|
|
15
|
-
view: ((
|
|
16
|
-
edit: ((
|
|
17
|
+
view: ((_d = state.accessUserPermission) === null || _d === void 0 ? void 0 : _d.view) || MENU_PERMISSION.NONE,
|
|
18
|
+
edit: ((_e = state.accessUserPermission) === null || _e === void 0 ? void 0 : _e.edit) || MENU_PERMISSION.NONE,
|
|
17
19
|
},
|
|
18
20
|
objectPermission: {
|
|
19
21
|
edit: !!(userAccess === null || userAccess === void 0 ? void 0 : userAccess.allowEdit),
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ObjectAccessInfo } from './types';
|
|
2
2
|
export declare const mergePermission: (objectPermissionAllow: boolean, menuPermissionValue: number) => boolean;
|
|
3
3
|
export declare const composeObjectMenuPermissions: (params: {
|
|
4
|
+
isPublic: boolean;
|
|
5
|
+
publicRole: number | null;
|
|
4
6
|
objectPermission: {
|
|
5
7
|
edit: boolean;
|
|
6
8
|
view: boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MENU_PERMISSION, PEOPLE_ACTIONS, PEOPLE_ACTION_KEYS, ROLE_MAPPING } from './constants';
|
|
1
|
+
import { MENU_PERMISSION, PEOPLE_ACTIONS, PEOPLE_ACTION_KEYS, PUBLIC_ROLE, ROLE_MAPPING, } from './constants';
|
|
2
2
|
import { remove } from 'lodash';
|
|
3
3
|
export const mergePermission = (objectPermissionAllow, menuPermissionValue) => {
|
|
4
4
|
const valueMapping = {
|
|
@@ -14,19 +14,24 @@ export const mergePermission = (objectPermissionAllow, menuPermissionValue) => {
|
|
|
14
14
|
return !!valueMapping[`${menuPermissionValue}_${objectPermissionAllow}`];
|
|
15
15
|
};
|
|
16
16
|
export const composeObjectMenuPermissions = (params) => {
|
|
17
|
-
const { menuPermission, objectPermission } = params;
|
|
17
|
+
const { menuPermission, objectPermission, isPublic, publicRole } = params;
|
|
18
18
|
const edit = mergePermission(objectPermission.edit, menuPermission.edit);
|
|
19
19
|
const view = mergePermission(objectPermission.view, menuPermission.view);
|
|
20
|
-
return {
|
|
20
|
+
return {
|
|
21
|
+
edit: edit || (isPublic && publicRole === PUBLIC_ROLE.ONLY_EDITOR),
|
|
22
|
+
view: view || (isPublic && publicRole === PUBLIC_ROLE.ONLY_VIEWER),
|
|
23
|
+
};
|
|
21
24
|
};
|
|
22
25
|
export const getActionsByUser = (args) => {
|
|
23
26
|
const { userId, userPermission, updatedUserId, objectAccessInfo } = args;
|
|
24
27
|
if (!userId || !updatedUserId || !objectAccessInfo)
|
|
25
28
|
return [];
|
|
26
|
-
const { ownerId } = objectAccessInfo;
|
|
27
|
-
const user =
|
|
28
|
-
const updatedUser =
|
|
29
|
+
const { ownerId, listAccess, publicRole, isPublic } = objectAccessInfo;
|
|
30
|
+
const user = listAccess.find(access => access.userId === userId);
|
|
31
|
+
const updatedUser = listAccess.find(access => access.userId === updatedUserId);
|
|
29
32
|
const { edit: allowEdit } = composeObjectMenuPermissions({
|
|
33
|
+
isPublic: !!isPublic,
|
|
34
|
+
publicRole,
|
|
30
35
|
objectPermission: {
|
|
31
36
|
view: !!(user === null || user === void 0 ? void 0 : user.allowView),
|
|
32
37
|
edit: !!(user === null || user === void 0 ? void 0 : user.allowEdit),
|
|
@@ -36,7 +41,7 @@ export const getActionsByUser = (args) => {
|
|
|
36
41
|
edit: (userPermission === null || userPermission === void 0 ? void 0 : userPermission.edit) || MENU_PERMISSION.NONE,
|
|
37
42
|
},
|
|
38
43
|
});
|
|
39
|
-
if (!user || !updatedUser || !allowEdit || updatedUser.userId === ownerId)
|
|
44
|
+
if ((!user && !isPublic) || !updatedUser || !allowEdit || updatedUser.userId === ownerId)
|
|
40
45
|
return [];
|
|
41
46
|
const actions = Object.values(PEOPLE_ACTION_KEYS);
|
|
42
47
|
if (userId !== ownerId) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antscorp/antsomi-ui",
|
|
3
|
-
"version": "1.3.3-beta.
|
|
3
|
+
"version": "1.3.3-beta.69",
|
|
4
4
|
"description": "An enterprise-class UI design language and React UI library.",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"dist/*",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"not op_mini all"
|
|
58
58
|
],
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@antscorp/icons": "0.27.
|
|
60
|
+
"@antscorp/icons": "0.27.6",
|
|
61
61
|
"@antscorp/image-editor": "1.0.2",
|
|
62
62
|
"@emotion/react": "^11.11.1",
|
|
63
63
|
"@fortawesome/fontawesome-svg-core": "6.1.1",
|
|
@@ -75,9 +75,9 @@
|
|
|
75
75
|
"html-entities": "^2.0.2",
|
|
76
76
|
"html-to-image": "^1.11.11",
|
|
77
77
|
"html2canvas": "^1.4.1",
|
|
78
|
-
"immer": "3.0.0",
|
|
79
78
|
"i18next": "21.6.16",
|
|
80
79
|
"i18next-browser-languagedetector": "6.1.2",
|
|
80
|
+
"immer": "3.0.0",
|
|
81
81
|
"lodash": "^4.17.21",
|
|
82
82
|
"moment": "2.29.2",
|
|
83
83
|
"qs": "6.10.3",
|