@antscorp/antsomi-ui 1.3.5-beta.492 → 1.3.5-beta.494
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/EditableName/EditableName.js +4 -1
- package/es/components/molecules/ShareAccess/ShareAccess.js +2 -2
- package/es/components/molecules/ShareAccess/types.d.ts +10 -10
- package/es/components/molecules/ShareAccess/utils.d.ts +5 -4
- package/es/components/molecules/ShareAccess/utils.js +13 -2
- package/es/components/organism/DataTable/components/Toolbar/SearchPopover.js +7 -3
- package/package.json +1 -1
|
@@ -70,6 +70,9 @@ export const EditableName = React.forwardRef((props, ref) => {
|
|
|
70
70
|
(error || requiredError) && !isLoading ? (React.createElement("div", { className: "suffix-icon-error" },
|
|
71
71
|
React.createElement(Tooltip, { title: error || requiredError },
|
|
72
72
|
React.createElement(Icon, { type: "icon-ants-warning-circle", style: { color: '#F44336', fontSize: '19.2px' } })))) : readonly ? null : (React.createElement("div", { className: "suffix-icon" },
|
|
73
|
-
React.createElement(Icon, { type: "icon-ants-pencil", style: { color: (_a = THEME.token) === null || _a === void 0 ? void 0 : _a.blue7, fontSize: '24px' }
|
|
73
|
+
React.createElement(Icon, { type: "icon-ants-pencil", style: { color: (_a = THEME.token) === null || _a === void 0 ? void 0 : _a.blue7, fontSize: '24px' }, onClick: () => {
|
|
74
|
+
var _a;
|
|
75
|
+
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
76
|
+
} }))),
|
|
74
77
|
React.createElement("span", { ref: spanRef, className: "hidden-span" })));
|
|
75
78
|
});
|
|
@@ -5,7 +5,7 @@ import { LayoutContent } from './components';
|
|
|
5
5
|
import { shareAccessReducer } from './reducer';
|
|
6
6
|
import { updateObjAccessInfo } from './actions';
|
|
7
7
|
import { useDeepCompareEffect } from '@antscorp/antsomi-ui/es/hooks/useDeepCompareEffect';
|
|
8
|
-
import {
|
|
8
|
+
import { safeParseAccessInfo } from './utils';
|
|
9
9
|
export const ShareAccess = (props) => {
|
|
10
10
|
const { accessInfo, excludeUserAccess, userId, onChange, userPermission } = props;
|
|
11
11
|
const [state, dispatch] = useReducer(shareAccessReducer(onChange), {
|
|
@@ -18,7 +18,7 @@ export const ShareAccess = (props) => {
|
|
|
18
18
|
if (!accessInfo)
|
|
19
19
|
return;
|
|
20
20
|
dispatch(updateObjAccessInfo({
|
|
21
|
-
updated:
|
|
21
|
+
updated: safeParseAccessInfo(accessInfo),
|
|
22
22
|
triggerOut: false,
|
|
23
23
|
}));
|
|
24
24
|
}, [accessInfo]);
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import { updateModalTransferOwnership, updateObjAccessInfo } from './actions';
|
|
2
2
|
import { PEOPLE_ACTION_KEYS } from './constants';
|
|
3
3
|
export type UserInfo = {
|
|
4
|
-
avatar: string;
|
|
5
|
-
full_name: string;
|
|
6
|
-
email: string;
|
|
7
4
|
user_id: number;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
avatar?: string;
|
|
6
|
+
full_name?: string;
|
|
7
|
+
email?: string;
|
|
8
|
+
user_name?: string;
|
|
9
|
+
user_type?: number;
|
|
10
|
+
ctime?: Date;
|
|
11
|
+
utime?: Date;
|
|
12
12
|
[key: string]: any;
|
|
13
13
|
};
|
|
14
14
|
export type UserAccessInfo = {
|
|
15
15
|
userId: number;
|
|
16
|
-
fullName?: string;
|
|
17
|
-
email?: string;
|
|
18
|
-
avatar?: string;
|
|
19
16
|
role: number;
|
|
20
17
|
allowView: number;
|
|
21
18
|
allowEdit: number;
|
|
22
19
|
allowComment: number;
|
|
20
|
+
fullName?: string;
|
|
21
|
+
email?: string;
|
|
22
|
+
avatar?: string;
|
|
23
23
|
[key: string]: any;
|
|
24
24
|
};
|
|
25
25
|
export type ObjectAccessInfo = {
|
|
@@ -15,6 +15,7 @@ export declare const composeObjectMenuPermissions: (params: {
|
|
|
15
15
|
edit: boolean;
|
|
16
16
|
view: boolean;
|
|
17
17
|
};
|
|
18
|
+
export declare const getOwnerIdFromAccessInfo: (accessInfo: ObjectAccessInfo) => number | undefined;
|
|
18
19
|
export declare const getActionsByUser: (args: {
|
|
19
20
|
userId?: number;
|
|
20
21
|
userPermission?: {
|
|
@@ -37,17 +38,17 @@ export declare const getActionsByUser: (args: {
|
|
|
37
38
|
readonly key: "remove_acess";
|
|
38
39
|
})[];
|
|
39
40
|
export declare const initAccessInfoDefault: (userInfo: Partial<UserInfo>) => ObjectAccessInfo;
|
|
40
|
-
export declare const
|
|
41
|
+
export declare const safeParseAccessInfo: (accessInfo: ObjectAccessInfo) => {
|
|
41
42
|
ownerId: number;
|
|
42
43
|
listAccess: {
|
|
43
44
|
userId: number;
|
|
44
|
-
fullName?: string | undefined;
|
|
45
|
-
email?: string | undefined;
|
|
46
|
-
avatar?: string | undefined;
|
|
47
45
|
role: number;
|
|
48
46
|
allowView: number;
|
|
49
47
|
allowEdit: number;
|
|
50
48
|
allowComment: number;
|
|
49
|
+
fullName?: string | undefined;
|
|
50
|
+
email?: string | undefined;
|
|
51
|
+
avatar?: string | undefined;
|
|
51
52
|
}[];
|
|
52
53
|
isPublic: number;
|
|
53
54
|
publicRole: number | null;
|
|
@@ -23,6 +23,16 @@ export const composeObjectMenuPermissions = (params) => {
|
|
|
23
23
|
view: view || (isPublic && publicRole === PUBLIC_ROLE.ONLY_VIEWER),
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
|
+
export const getOwnerIdFromAccessInfo = (accessInfo) => {
|
|
27
|
+
const { ownerId } = accessInfo;
|
|
28
|
+
if (!ownerId) {
|
|
29
|
+
const ownerInfo = accessInfo.listAccess.find(member => +member.role === ROLE_MAPPING.OWNER);
|
|
30
|
+
if (!ownerInfo)
|
|
31
|
+
return;
|
|
32
|
+
return ownerInfo.userId;
|
|
33
|
+
}
|
|
34
|
+
return ownerId;
|
|
35
|
+
};
|
|
26
36
|
export const getActionsByUser = (args) => {
|
|
27
37
|
const { userId, userPermission, updatedUserId, objectAccessInfo } = args;
|
|
28
38
|
if (!userId || !updatedUserId || !objectAccessInfo)
|
|
@@ -64,9 +74,10 @@ export const initAccessInfoDefault = (userInfo) => ({
|
|
|
64
74
|
publicRole: PUBLIC_ROLE.ONLY_VIEWER,
|
|
65
75
|
isPublic: 0,
|
|
66
76
|
});
|
|
67
|
-
export const
|
|
77
|
+
export const safeParseAccessInfo = (accessInfo) => {
|
|
68
78
|
var _a;
|
|
69
|
-
|
|
79
|
+
const ownerId = getOwnerIdFromAccessInfo(accessInfo);
|
|
80
|
+
return Object.assign(Object.assign({}, accessInfo), { ownerId: +(ownerId || -1), listAccess: (_a = accessInfo === null || accessInfo === void 0 ? void 0 : accessInfo.listAccess) === null || _a === void 0 ? void 0 : _a.map(user => (Object.assign(Object.assign({}, user), { userId: +user.userId }))) });
|
|
70
81
|
};
|
|
71
82
|
export const mappingOutData = (shareAccess) => {
|
|
72
83
|
const result = Object.assign({}, shareAccess);
|
|
@@ -9,7 +9,6 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import { Link } from 'react-router-dom';
|
|
13
12
|
import React, { useState } from 'react';
|
|
14
13
|
import styled from 'styled-components';
|
|
15
14
|
import clsx from 'clsx';
|
|
@@ -19,7 +18,7 @@ import { EmptyData } from '@antscorp/antsomi-ui/es/components/molecules';
|
|
|
19
18
|
// Constants
|
|
20
19
|
import { globalToken } from '@antscorp/antsomi-ui/es/constants';
|
|
21
20
|
// Hooks
|
|
22
|
-
import { useDeepCompareMemo } from '@antscorp/antsomi-ui/es/hooks';
|
|
21
|
+
import { useCustomRouter, useDeepCompareMemo } from '@antscorp/antsomi-ui/es/hooks';
|
|
23
22
|
// Utils
|
|
24
23
|
import { searchStringQuery } from '@antscorp/antsomi-ui/es/utils';
|
|
25
24
|
import i18nInstance from '@antscorp/antsomi-ui/es/locales/i18n';
|
|
@@ -51,6 +50,8 @@ const StyledContent = styled.div `
|
|
|
51
50
|
`;
|
|
52
51
|
export const SearchPopover = props => {
|
|
53
52
|
const { children, objectName, searchList, isClientSearch, loading, isAddFilterFromSearchItem, searchItemProps, onAddFilter = () => { }, onSearch = () => { }, onClick = () => { }, onClickSearchItem, itemSearchRender } = props, restProps = __rest(props, ["children", "objectName", "searchList", "isClientSearch", "loading", "isAddFilterFromSearchItem", "searchItemProps", "onAddFilter", "onSearch", "onClick", "onClickSearchItem", "itemSearchRender"]);
|
|
53
|
+
// Hooks
|
|
54
|
+
const { navigate } = useCustomRouter();
|
|
54
55
|
// State
|
|
55
56
|
const [state, setState] = useState({
|
|
56
57
|
searchValue: '',
|
|
@@ -73,9 +74,12 @@ export const SearchPopover = props => {
|
|
|
73
74
|
const { id, label, link, icon } = searchItem;
|
|
74
75
|
const Label = (React.createElement(React.Fragment, null,
|
|
75
76
|
icon && React.createElement(IconWrapper, null, icon),
|
|
76
|
-
React.createElement(Typography.Text, Object.assign({ ellipsis: { tooltip: label } }, searchItemProps, { className: clsx(`${link ? 'text-link' : ''}`, searchItemProps === null || searchItemProps === void 0 ? void 0 : searchItemProps.className) }),
|
|
77
|
+
React.createElement(Typography.Text, Object.assign({ ellipsis: { tooltip: label } }, searchItemProps, { className: clsx(`${link ? 'text-link' : ''}`, searchItemProps === null || searchItemProps === void 0 ? void 0 : searchItemProps.className) }), label)));
|
|
77
78
|
return (React.createElement(StyledSearchItem, { key: id, align: "center", gap: 6, onClick: () => {
|
|
78
79
|
onClick(searchItem, index);
|
|
80
|
+
if (link && !itemSearchRender && !onClickSearchItem && !isAddFilterFromSearchItem) {
|
|
81
|
+
navigate(link);
|
|
82
|
+
}
|
|
79
83
|
setState(prev => (Object.assign(Object.assign({}, prev), { isOpenPopover: false })));
|
|
80
84
|
} }, itemSearchRender ? itemSearchRender(searchItem, index, Label) : Label));
|
|
81
85
|
});
|