@antscorp/antsomi-ui 1.3.5-beta.76 → 1.3.5-beta.77
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/ShareAccess.js +2 -2
- package/es/components/molecules/ShareAccess/components/LayoutContent/LayoutContent.js +2 -2
- package/es/components/molecules/ShareAccess/components/PeopleAccess/PeopleAccess.d.ts +1 -1
- package/es/components/molecules/ShareAccess/components/PeopleAccess/PeopleAccess.js +6 -5
- package/es/components/molecules/ShareAccess/hooks/useShareAccess.d.ts +1 -0
- package/es/components/molecules/ShareAccess/types.d.ts +4 -1
- package/package.json +1 -1
|
@@ -5,7 +5,7 @@ import { LayoutContent } from './components';
|
|
|
5
5
|
import { shareAccessReducer } from './reducer';
|
|
6
6
|
import { updateObjAccessInfo } from './actions';
|
|
7
7
|
export const ShareAccess = (props) => {
|
|
8
|
-
const { accessInfo, userId, onChange, userPermission } = props;
|
|
8
|
+
const { accessInfo, excludeUserAccess, userId, onChange, userPermission } = props;
|
|
9
9
|
const [state, dispatch] = useReducer(shareAccessReducer(onChange), {
|
|
10
10
|
modalTransferOwnership: {
|
|
11
11
|
open: false,
|
|
@@ -17,7 +17,7 @@ export const ShareAccess = (props) => {
|
|
|
17
17
|
return;
|
|
18
18
|
dispatch(updateObjAccessInfo(accessInfo));
|
|
19
19
|
}, [accessInfo]);
|
|
20
|
-
return (React.createElement(ShareAccessStateContext.Provider, { value: Object.assign(Object.assign({}, state), { accessUserId: userId, accessUserPermission: userPermission }) },
|
|
20
|
+
return (React.createElement(ShareAccessStateContext.Provider, { value: Object.assign(Object.assign({}, state), { excludeUserAccess, accessUserId: userId, accessUserPermission: userPermission }) },
|
|
21
21
|
React.createElement(ShareAccessDispatchContext.Provider, { value: dispatch },
|
|
22
22
|
React.createElement(LayoutContent, Object.assign({}, props)))));
|
|
23
23
|
};
|
|
@@ -6,14 +6,14 @@ import { PeopleAccess } from '../PeopleAccess';
|
|
|
6
6
|
import { SearchUser } from '../SearchUser';
|
|
7
7
|
import { StyledLayoutContentRoot } from './styled';
|
|
8
8
|
export const LayoutContent = (props) => {
|
|
9
|
-
const { getUserInfo,
|
|
9
|
+
const { getUserInfo, excludeUserAccess, allowAddUser = true } = props;
|
|
10
10
|
const { state } = useShareAccess();
|
|
11
11
|
const { allowEdit, allowView } = state;
|
|
12
12
|
if (!allowEdit && !allowView)
|
|
13
13
|
return null;
|
|
14
14
|
return (React.createElement(StyledLayoutContentRoot, null,
|
|
15
15
|
allowAddUser && React.createElement(SearchUser, { getUserInfo: getUserInfo }),
|
|
16
|
-
React.createElement(PeopleAccess, {
|
|
16
|
+
React.createElement(PeopleAccess, { excludeUserAccess: excludeUserAccess }),
|
|
17
17
|
React.createElement(GeneralAccess, null),
|
|
18
18
|
React.createElement(ModalTransferOwnership, null)));
|
|
19
19
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ShareAccessProps } from '../../types';
|
|
3
|
-
type PeopleAccessProps = Pick<ShareAccessProps, '
|
|
3
|
+
type PeopleAccessProps = Pick<ShareAccessProps, 'excludeUserAccess'>;
|
|
4
4
|
export declare const PeopleAccess: (props: PeopleAccessProps) => React.JSX.Element | null;
|
|
5
5
|
export {};
|
|
@@ -14,7 +14,7 @@ const ROLE_BY_ACTIONS = {
|
|
|
14
14
|
[PEOPLE_ACTION_KEYS.TO_VIEWER]: ROLE_MAPPING.VIEWER,
|
|
15
15
|
};
|
|
16
16
|
export const PeopleAccess = (props) => {
|
|
17
|
-
const {
|
|
17
|
+
const { excludeUserAccess } = props;
|
|
18
18
|
const { state, dispatch } = useShareAccess();
|
|
19
19
|
const { accessInfo, accessUserId, accessUserPermission } = state;
|
|
20
20
|
const handleClickAction = (actKey, updatedUserId) => {
|
|
@@ -54,9 +54,10 @@ export const PeopleAccess = (props) => {
|
|
|
54
54
|
};
|
|
55
55
|
const renderActionItems = (actions) => {
|
|
56
56
|
let hasDivider = false;
|
|
57
|
-
return actions.flatMap(act => {
|
|
57
|
+
return actions.flatMap((act, idx) => {
|
|
58
58
|
const items = [];
|
|
59
|
-
const needDivider = PEOPLE_ACTION_KEYS.REMOVE_ACCESS === act.key || PEOPLE_ACTION_KEYS.TO_OWNER === act.key
|
|
59
|
+
const needDivider = (PEOPLE_ACTION_KEYS.REMOVE_ACCESS === act.key || PEOPLE_ACTION_KEYS.TO_OWNER === act.key) &&
|
|
60
|
+
actions[idx - 1];
|
|
60
61
|
if (needDivider && !hasDivider) {
|
|
61
62
|
items.push({ type: 'divider' });
|
|
62
63
|
items.push({ key: act.key, label: act.label });
|
|
@@ -78,8 +79,8 @@ export const PeopleAccess = (props) => {
|
|
|
78
79
|
objectAccessInfo: accessInfo,
|
|
79
80
|
userPermission: accessUserPermission,
|
|
80
81
|
});
|
|
81
|
-
if (
|
|
82
|
-
remove(actions, act => act.key
|
|
82
|
+
if (excludeUserAccess) {
|
|
83
|
+
remove(actions, act => excludeUserAccess.includes(act.key));
|
|
83
84
|
}
|
|
84
85
|
return (React.createElement(List.Item, null,
|
|
85
86
|
React.createElement(Avatar, { src: access.avatar }),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { updateModalTransferOwnership, updateObjAccessInfo } from './actions';
|
|
2
|
+
import { PEOPLE_ACTION_KEYS } from './constants';
|
|
2
3
|
export type UserInfo = {
|
|
3
4
|
avatar: string;
|
|
4
5
|
full_name: string;
|
|
@@ -27,6 +28,7 @@ export type ObjectAccessInfo = {
|
|
|
27
28
|
ownerId: number;
|
|
28
29
|
listAccess: UserAccessInfo[];
|
|
29
30
|
};
|
|
31
|
+
export type ExcludeUserAccess = Array<(typeof PEOPLE_ACTION_KEYS)[keyof typeof PEOPLE_ACTION_KEYS]>;
|
|
30
32
|
export type ShareAccessProps = {
|
|
31
33
|
userId?: number;
|
|
32
34
|
userPermission?: {
|
|
@@ -35,7 +37,7 @@ export type ShareAccessProps = {
|
|
|
35
37
|
};
|
|
36
38
|
accessInfo?: ObjectAccessInfo;
|
|
37
39
|
allowAddUser?: boolean;
|
|
38
|
-
|
|
40
|
+
excludeUserAccess?: ExcludeUserAccess;
|
|
39
41
|
getUserInfo?(search: string, signal: AbortSignal): Promise<UserInfo[]> | UserInfo[];
|
|
40
42
|
onChange?: (accessInfo: ObjectAccessInfo) => void;
|
|
41
43
|
};
|
|
@@ -46,6 +48,7 @@ export type ShareAccessState = {
|
|
|
46
48
|
view: number;
|
|
47
49
|
edit: number;
|
|
48
50
|
};
|
|
51
|
+
excludeUserAccess?: ExcludeUserAccess;
|
|
49
52
|
modalTransferOwnership: {
|
|
50
53
|
open: boolean;
|
|
51
54
|
userToOwnerShipId: number;
|