@antscorp/antsomi-ui 1.3.5-beta.415 → 1.3.5-beta.416
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/HeaderV2/styled.js +4 -1
- package/es/components/molecules/ModalSelect/Card.js +26 -6
- package/es/components/molecules/ModalSelect/styled.js +6 -0
- package/es/components/molecules/ModalSelect/types.d.ts +2 -0
- package/es/components/molecules/ShareAccess/constants.d.ts +1 -1
- package/es/components/molecules/ShareAccess/constants.js +0 -12
- package/es/components/molecules/ShareAccess/reducer.js +2 -1
- package/es/components/molecules/ShareAccess/types.d.ts +3 -7
- package/es/components/molecules/ShareAccess/utils.d.ts +10 -8
- package/es/components/molecules/ShareAccess/utils.js +15 -4
- package/package.json +1 -1
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
var _a, _b, _c;
|
|
2
|
+
// Libraries
|
|
2
3
|
import styled from 'styled-components';
|
|
3
|
-
|
|
4
|
+
// Constants
|
|
5
|
+
import { THEME, globalToken } from '@antscorp/antsomi-ui/es/constants';
|
|
4
6
|
export const HeaderV2Styled = styled.div `
|
|
5
7
|
height: ${(_a = THEME.token) === null || _a === void 0 ? void 0 : _a.headerHeight};
|
|
6
8
|
background-color: #f6f8fc;
|
|
@@ -42,6 +44,7 @@ export const HeaderV2Styled = styled.div `
|
|
|
42
44
|
font-size: 20px;
|
|
43
45
|
line-height: 23px;
|
|
44
46
|
font-weight: bold;
|
|
47
|
+
color: ${globalToken === null || globalToken === void 0 ? void 0 : globalToken.colorTextBase};
|
|
45
48
|
}
|
|
46
49
|
`;
|
|
47
50
|
export const LogoWrapper = styled.div `
|
|
@@ -9,9 +9,9 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import React from 'react';
|
|
12
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
13
13
|
import { CardDefinationContainer, CardRecommendedContainer, RecommendItem, StyledCard, } from './styled';
|
|
14
|
-
import { Typography } from 'antd';
|
|
14
|
+
import { Tooltip, Typography } from 'antd';
|
|
15
15
|
import clsx from 'clsx';
|
|
16
16
|
import { globalToken } from '@antscorp/antsomi-ui/es/constants';
|
|
17
17
|
const { Text, Paragraph } = Typography;
|
|
@@ -20,22 +20,42 @@ export const Card = (props) => {
|
|
|
20
20
|
return (React.createElement(StyledCard, Object.assign({ bordered: bordered }, rest), children));
|
|
21
21
|
};
|
|
22
22
|
export const CardDefination = (props) => {
|
|
23
|
+
const refreshKey = useRef(0);
|
|
24
|
+
const [isExpanded, setIsExpanded] = useState(false);
|
|
25
|
+
const [expandable, setExpandable] = useState(true);
|
|
23
26
|
const { title, description, descriptionEllipsis = {
|
|
24
27
|
rows: 3,
|
|
25
28
|
symbol: 'Learn more',
|
|
26
|
-
expandable: true,
|
|
27
29
|
tooltip: true,
|
|
28
30
|
}, } = props;
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (!expandable) {
|
|
33
|
+
setExpandable(true);
|
|
34
|
+
}
|
|
35
|
+
}, [expandable]);
|
|
36
|
+
const handleCollapse = () => {
|
|
37
|
+
refreshKey.current += 1;
|
|
38
|
+
setExpandable(false);
|
|
39
|
+
};
|
|
29
40
|
return (React.createElement(CardDefinationContainer, null,
|
|
30
41
|
title && React.createElement(Text, { className: "title" }, title),
|
|
31
|
-
description && (React.createElement(Paragraph, { ellipsis: descriptionEllipsis, className: "description" },
|
|
42
|
+
description && (React.createElement(Paragraph, { key: refreshKey.current, ellipsis: Object.assign(Object.assign({}, descriptionEllipsis), { expandable, onExpand: () => setIsExpanded(true) }), className: "description" },
|
|
43
|
+
description,
|
|
44
|
+
isExpanded && (React.createElement("span", { className: "antsomi-typography-collapse", onClick: handleCollapse }, "View less"))))));
|
|
32
45
|
};
|
|
33
46
|
export const CardRecommended = (props) => {
|
|
34
47
|
const { title, recomendations = [] } = props;
|
|
35
48
|
return (React.createElement(CardRecommendedContainer, null,
|
|
36
49
|
title && React.createElement(Text, { className: "title" }, title),
|
|
37
50
|
React.createElement("div", { className: "recomendations" }, recomendations.map(i => {
|
|
38
|
-
const { className, color = globalToken === null || globalToken === void 0 ? void 0 : globalToken.blue2, bordered = false } = i;
|
|
39
|
-
|
|
51
|
+
const { description, className, color = globalToken === null || globalToken === void 0 ? void 0 : globalToken.blue2, bordered = false } = i;
|
|
52
|
+
const item = (React.createElement(RecommendItem, Object.assign({}, i, { key: i.key, color: color, bordered: bordered, className: clsx('item', className) })));
|
|
53
|
+
if (typeof description === 'string') {
|
|
54
|
+
return (React.createElement(Tooltip, { title: description, placement: "top" }, item));
|
|
55
|
+
}
|
|
56
|
+
if (description) {
|
|
57
|
+
return React.createElement(Tooltip, Object.assign({}, description), item);
|
|
58
|
+
}
|
|
59
|
+
return item;
|
|
40
60
|
}))));
|
|
41
61
|
};
|
|
@@ -125,6 +125,12 @@ export const CardDefinationContainer = styled.div `
|
|
|
125
125
|
.antsomi-typography-expand {
|
|
126
126
|
font-weight: 500;
|
|
127
127
|
}
|
|
128
|
+
|
|
129
|
+
.antsomi-typography-collapse {
|
|
130
|
+
font-weight: 500;
|
|
131
|
+
color: ${globalToken === null || globalToken === void 0 ? void 0 : globalToken.colorPrimary};
|
|
132
|
+
cursor: pointer;
|
|
133
|
+
}
|
|
128
134
|
}
|
|
129
135
|
`;
|
|
130
136
|
export const CardRecommendedContainer = styled.div `
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { RefCallback } from 'react';
|
|
2
2
|
import { MenuProps, ModalProps, TagProps } from 'antd';
|
|
3
3
|
import { EllipsisConfig } from 'antd/es/typography/Base';
|
|
4
|
+
import { TooltipProps } from 'antd/lib';
|
|
4
5
|
export type ModalSelectProps = {
|
|
5
6
|
open?: boolean;
|
|
6
7
|
value?: string;
|
|
@@ -23,5 +24,6 @@ export type CardRecommendedProps = {
|
|
|
23
24
|
title?: string;
|
|
24
25
|
recomendations?: (TagProps & {
|
|
25
26
|
key?: React.Key;
|
|
27
|
+
description?: string | TooltipProps;
|
|
26
28
|
})[];
|
|
27
29
|
};
|
|
@@ -17,7 +17,7 @@ export declare const ROLE_ACCESS_LABEL: {
|
|
|
17
17
|
2: string;
|
|
18
18
|
3: string;
|
|
19
19
|
};
|
|
20
|
-
export declare const ACCESS_PROPERTIES_BY_ROLE: Record<AccessRole, Pick<UserAccessInfo, 'role' | 'allowView' | 'allowEdit' | 'allowComment'
|
|
20
|
+
export declare const ACCESS_PROPERTIES_BY_ROLE: Record<AccessRole, Pick<UserAccessInfo, 'role' | 'allowView' | 'allowEdit' | 'allowComment'>>;
|
|
21
21
|
export declare const PEOPLE_ACTION_KEYS: {
|
|
22
22
|
readonly TO_VIEWER: "to_viewer";
|
|
23
23
|
readonly TO_EDITOR: "to_editor";
|
|
@@ -22,30 +22,18 @@ export const ACCESS_PROPERTIES_BY_ROLE = {
|
|
|
22
22
|
allowView: 1,
|
|
23
23
|
allowEdit: 1,
|
|
24
24
|
allowComment: 1,
|
|
25
|
-
accessType: {
|
|
26
|
-
label: ROLE_ACCESS_LABEL[ROLE_MAPPING.OWNER],
|
|
27
|
-
value: ROLE_ACCESS_LABEL[ROLE_MAPPING.OWNER].toLowerCase(),
|
|
28
|
-
},
|
|
29
25
|
},
|
|
30
26
|
[ROLE_MAPPING.EDITOR]: {
|
|
31
27
|
role: ROLE_MAPPING.EDITOR,
|
|
32
28
|
allowView: 1,
|
|
33
29
|
allowEdit: 1,
|
|
34
30
|
allowComment: 1,
|
|
35
|
-
accessType: {
|
|
36
|
-
label: ROLE_ACCESS_LABEL[ROLE_MAPPING.EDITOR],
|
|
37
|
-
value: ROLE_ACCESS_LABEL[ROLE_MAPPING.EDITOR].toLowerCase(),
|
|
38
|
-
},
|
|
39
31
|
},
|
|
40
32
|
[ROLE_MAPPING.VIEWER]: {
|
|
41
33
|
role: ROLE_MAPPING.VIEWER,
|
|
42
34
|
allowView: 1,
|
|
43
35
|
allowEdit: 0,
|
|
44
36
|
allowComment: 0,
|
|
45
|
-
accessType: {
|
|
46
|
-
label: ROLE_ACCESS_LABEL[ROLE_MAPPING.VIEWER],
|
|
47
|
-
value: ROLE_ACCESS_LABEL[ROLE_MAPPING.VIEWER].toLowerCase(),
|
|
48
|
-
},
|
|
49
37
|
},
|
|
50
38
|
};
|
|
51
39
|
export const PEOPLE_ACTION_KEYS = {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import produce from 'immer';
|
|
2
2
|
import { TYPES } from './actions';
|
|
3
|
+
import { mappingOutData } from './utils';
|
|
3
4
|
export const shareAccessReducer = (onChange) => (state, action) => produce(state, draft => {
|
|
4
5
|
switch (action.type) {
|
|
5
6
|
case TYPES.UPDATE_OBJECT_ACCESS_INFO: {
|
|
6
7
|
draft.accessInfo = action.payload;
|
|
7
8
|
if (onChange) {
|
|
8
|
-
onChange(action.payload);
|
|
9
|
+
onChange(mappingOutData(action.payload));
|
|
9
10
|
}
|
|
10
11
|
break;
|
|
11
12
|
}
|
|
@@ -13,17 +13,13 @@ export type UserInfo = {
|
|
|
13
13
|
};
|
|
14
14
|
export type UserAccessInfo = {
|
|
15
15
|
userId: number;
|
|
16
|
-
fullName
|
|
17
|
-
email
|
|
18
|
-
avatar
|
|
16
|
+
fullName?: string;
|
|
17
|
+
email?: string;
|
|
18
|
+
avatar?: string;
|
|
19
19
|
role: number;
|
|
20
20
|
allowView: number;
|
|
21
21
|
allowEdit: number;
|
|
22
22
|
allowComment: number;
|
|
23
|
-
accessType: {
|
|
24
|
-
label: string;
|
|
25
|
-
value: string;
|
|
26
|
-
};
|
|
27
23
|
[key: string]: any;
|
|
28
24
|
};
|
|
29
25
|
export type ObjectAccessInfo = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ObjectAccessInfo, UserInfo } from './types';
|
|
1
|
+
import { ObjectAccessInfo, UserAccessInfo, UserInfo } from './types';
|
|
2
2
|
export declare const mergePermission: (objectPermissionAllow: boolean, menuPermissionValue: number) => boolean;
|
|
3
3
|
export declare const composeObjectMenuPermissions: (params: {
|
|
4
4
|
isPublic: boolean;
|
|
@@ -41,18 +41,20 @@ export declare const formattedAccessInfo: (accessInfo: ObjectAccessInfo) => {
|
|
|
41
41
|
ownerId: number;
|
|
42
42
|
listAccess: {
|
|
43
43
|
userId: number;
|
|
44
|
-
fullName
|
|
45
|
-
email
|
|
46
|
-
avatar
|
|
44
|
+
fullName?: string | undefined;
|
|
45
|
+
email?: string | undefined;
|
|
46
|
+
avatar?: string | undefined;
|
|
47
47
|
role: number;
|
|
48
48
|
allowView: number;
|
|
49
49
|
allowEdit: number;
|
|
50
50
|
allowComment: number;
|
|
51
|
-
accessType: {
|
|
52
|
-
label: string;
|
|
53
|
-
value: string;
|
|
54
|
-
};
|
|
55
51
|
}[];
|
|
56
52
|
isPublic: number;
|
|
57
53
|
publicRole: number | null;
|
|
58
54
|
};
|
|
55
|
+
export declare const mappingOutData: (shareAccess: ObjectAccessInfo) => {
|
|
56
|
+
isPublic: number;
|
|
57
|
+
publicRole: number | null;
|
|
58
|
+
ownerId: number;
|
|
59
|
+
listAccess: UserAccessInfo[];
|
|
60
|
+
};
|
|
@@ -59,10 +59,7 @@ export const getActionsByUser = (args) => {
|
|
|
59
59
|
export const initAccessInfoDefault = (userInfo) => ({
|
|
60
60
|
ownerId: +(userInfo === null || userInfo === void 0 ? void 0 : userInfo.user_id),
|
|
61
61
|
listAccess: [
|
|
62
|
-
Object.assign(Object.assign({}, snakeCaseToCamelCase(userInfo)), { role: ROLE_MAPPING.OWNER, allowView: 1, allowEdit: 1, allowComment: 1,
|
|
63
|
-
label: ROLE_ACCESS_LABEL[ROLE_MAPPING.OWNER],
|
|
64
|
-
value: ROLE_ACCESS_LABEL[ROLE_MAPPING.OWNER].toLowerCase(),
|
|
65
|
-
} }),
|
|
62
|
+
Object.assign(Object.assign({}, snakeCaseToCamelCase(userInfo)), { role: ROLE_MAPPING.OWNER, allowView: 1, allowEdit: 1, allowComment: 1 }),
|
|
66
63
|
],
|
|
67
64
|
publicRole: PUBLIC_ROLE.ONLY_VIEWER,
|
|
68
65
|
isPublic: 0,
|
|
@@ -71,3 +68,17 @@ export const formattedAccessInfo = (accessInfo) => {
|
|
|
71
68
|
var _a;
|
|
72
69
|
return (Object.assign(Object.assign({}, accessInfo), { ownerId: +((accessInfo === null || accessInfo === void 0 ? void 0 : accessInfo.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 }))) }));
|
|
73
70
|
};
|
|
71
|
+
export const mappingOutData = (shareAccess) => {
|
|
72
|
+
const result = Object.assign({}, shareAccess);
|
|
73
|
+
result.listAccess = result.listAccess.map(accessInfo => {
|
|
74
|
+
const roleLabel = ROLE_ACCESS_LABEL[accessInfo.role];
|
|
75
|
+
if (typeof roleLabel === 'string') {
|
|
76
|
+
accessInfo.accessType = {
|
|
77
|
+
label: roleLabel,
|
|
78
|
+
value: roleLabel.toLowerCase(),
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
return accessInfo;
|
|
82
|
+
});
|
|
83
|
+
return result;
|
|
84
|
+
};
|