@abtnode/ux 1.16.38 → 1.16.39-beta-20250209-032436-5ceca2cb
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/lib/blocklet/audit-log-cell.js +237 -0
- package/lib/blocklet/audit-logs.js +123 -170
- package/lib/blocklet/component/switch-control.js +12 -2
- package/lib/contexts/audit-log.js +21 -5
- package/lib/invitation/invitation-receive.js +1 -1
- package/lib/locales/ar.js +23 -9
- package/lib/locales/de.js +23 -9
- package/lib/locales/en.js +23 -9
- package/lib/locales/es.js +23 -9
- package/lib/locales/fr.js +23 -9
- package/lib/locales/hi.js +23 -9
- package/lib/locales/i18n.db +0 -0
- package/lib/locales/id.js +23 -9
- package/lib/locales/ja.js +23 -9
- package/lib/locales/ko.js +23 -9
- package/lib/locales/pt.js +23 -9
- package/lib/locales/ru.js +23 -9
- package/lib/locales/th.js +23 -9
- package/lib/locales/vi.js +23 -9
- package/lib/locales/zh-tw.js +23 -9
- package/lib/locales/zh.js +23 -9
- package/package.json +9 -9
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
/* eslint-disable react/prop-types */
|
|
2
|
+
import { useMemo, useState, useRef, useEffect } from 'react';
|
|
3
|
+
import { Link } from 'react-router-dom';
|
|
4
|
+
import MarkdownPreview from '@uiw/react-markdown-preview';
|
|
5
|
+
import rehypeExternalLinks from 'rehype-external-links';
|
|
6
|
+
import Box from '@mui/material/Box';
|
|
7
|
+
import Typography from '@mui/material/Typography';
|
|
8
|
+
import { Avatar, IconButton, Tooltip } from '@mui/material';
|
|
9
|
+
import { CopyButton } from '@arcblock/ux/lib/ClickToCopy';
|
|
10
|
+
import UnfoldMoreIcon from '@mui/icons-material/UnfoldMore';
|
|
11
|
+
import CloseFullscreenIcon from '@mui/icons-material/CloseFullscreen';
|
|
12
|
+
import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined';
|
|
13
|
+
import { debounce } from 'lodash';
|
|
14
|
+
import RelativeTime from '../relative-time';
|
|
15
|
+
import ShortenLabel from './component/shorten-label';
|
|
16
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
|
+
const blockletServerLogo = `
|
|
18
|
+
<svg style="width:38px;height:38px;" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
19
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M50.152 10.6417L31.72 0L13.288 10.6417V24.7942L1 31.8887V53.1722L19.432 63.8139L31.6902 56.7366L31.72 56.7538L31.7498 56.7366L44.008 63.8139L62.44 53.1722V31.8887L50.152 24.7942V10.6417ZM60.52 32.9972L48.232 25.9027V11.7502L31.72 2.21703L15.208 11.7502V25.9028L2.92 32.9972V52.0636L19.432 61.5968L31.6902 54.5196L31.72 54.5368L31.7498 54.5196L44.008 61.5968L60.52 52.0636V32.9972Z" fill="url(#paint0_linear_606_96)"/>
|
|
20
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M50.1521 24.8307L31.7201 14.189L13.2881 24.8307V46.1141L31.7201 56.7558L50.1521 46.1141V24.8307ZM15.2081 25.9392L31.7201 16.406L48.2321 25.9392V45.0056L31.7201 54.5388L15.2081 45.0056V25.9392ZM28.5464 23.0464C28.6641 22.6342 29.0408 22.3501 29.4695 22.3501H33.9707C34.3993 22.3501 34.776 22.6342 34.8938 23.0464L35.7504 26.0447L37.8696 27.2681L40.8945 26.5109C41.3103 26.4068 41.7447 26.591 41.959 26.9622L44.2096 30.8604C44.424 31.2316 44.3662 31.6998 44.0682 32.0079L41.8999 34.2489V36.6959L44.0682 38.9369C44.3662 39.245 44.424 39.7133 44.2096 40.0845L41.959 43.9827C41.7447 44.3539 41.3103 44.538 40.8945 44.4339L37.8696 43.6767L35.7504 44.9002L34.8938 47.8984C34.776 48.3106 34.3993 48.5947 33.9707 48.5947H29.4695C29.0408 48.5947 28.6641 48.3106 28.5464 47.8984L27.6897 44.9002L25.5706 43.6767L22.5457 44.4339C22.1299 44.538 21.6955 44.3539 21.4812 43.9827L19.2305 40.0845C19.0162 39.7133 19.0739 39.245 19.372 38.9369L21.5402 36.6959V34.2489L19.372 32.0079C19.0739 31.6998 19.0162 31.2316 19.2305 30.8604L21.4812 26.9622C21.6955 26.591 22.1299 26.4068 22.5457 26.5109L25.5706 27.2681L27.6897 26.0447L28.5464 23.0464ZM28.9861 27.5132C29.2018 27.3887 29.3607 27.1851 29.4292 26.9456L30.1936 24.2701H33.2466L34.011 26.9456C34.0794 27.1851 34.2383 27.3887 34.4541 27.5132L37.2459 29.1251C37.4617 29.2497 37.7174 29.2855 37.9591 29.225L40.6583 28.5493L42.1848 31.1932L40.25 33.193C40.0768 33.372 39.9799 33.6114 39.9799 33.8605V37.0843C39.9799 37.3334 40.0768 37.5728 40.25 37.7518L42.1848 39.7516L40.6583 42.3955L37.9591 41.7198C37.7174 41.6593 37.4617 41.6951 37.2459 41.8197L34.4541 43.4316C34.2383 43.5561 34.0794 43.7597 34.011 43.9992L33.2466 46.6747H30.1936L29.4292 43.9992C29.3607 43.7597 29.2018 43.5561 28.9861 43.4316L26.1942 41.8197C25.9785 41.6951 25.7228 41.6593 25.4811 41.7198L22.7819 42.3955L21.2554 39.7516L23.1902 37.7518C23.3634 37.5728 23.4602 37.3334 23.4602 37.0843V33.8605C23.4602 33.6114 23.3634 33.372 23.1902 33.193L21.2554 31.1932L22.7819 28.5493L25.4811 29.225C25.7228 29.2855 25.9785 29.2497 26.1942 29.1251L28.9861 27.5132ZM31.7201 41.6407C28.3134 41.6407 25.5517 38.8791 25.5517 35.4724C25.5517 32.0657 28.3134 29.3041 31.7201 29.3041C35.1268 29.3041 37.8884 32.0657 37.8884 35.4724C37.8884 38.8791 35.1268 41.6407 31.7201 41.6407ZM35.9684 35.4724C35.9684 37.8187 34.0664 39.7207 31.7201 39.7207C29.3738 39.7207 27.4717 37.8187 27.4717 35.4724C27.4717 33.1261 29.3738 31.2241 31.7201 31.2241C34.0664 31.2241 35.9684 33.1261 35.9684 35.4724Z" fill="url(#paint1_linear_606_96)"/>
|
|
21
|
+
<defs>
|
|
22
|
+
<linearGradient id="paint0_linear_606_96" x1="31.72" y1="95.7208" x2="95.488" y2="34.3249" gradientUnits="userSpaceOnUse">
|
|
23
|
+
<stop stop-color="#0FA4B7"/>
|
|
24
|
+
<stop offset="0.494757" stop-color="#1DC1C7"/>
|
|
25
|
+
<stop offset="1" stop-color="#2BE0D7"/>
|
|
26
|
+
</linearGradient>
|
|
27
|
+
<linearGradient id="paint1_linear_606_96" x1="28.4374" y1="99.2464" x2="98.7613" y2="44.9372" gradientUnits="userSpaceOnUse">
|
|
28
|
+
<stop stop-color="#0FA4B7"/>
|
|
29
|
+
<stop offset="0.494757" stop-color="#1DC1C7"/>
|
|
30
|
+
<stop offset="1" stop-color="#2BE0D7"/>
|
|
31
|
+
</linearGradient>
|
|
32
|
+
</defs>
|
|
33
|
+
</svg>
|
|
34
|
+
`;
|
|
35
|
+
export default function AuditLogCell({
|
|
36
|
+
title,
|
|
37
|
+
subTitle,
|
|
38
|
+
titleInfo,
|
|
39
|
+
action,
|
|
40
|
+
createdAt,
|
|
41
|
+
content,
|
|
42
|
+
isLast,
|
|
43
|
+
titleLink,
|
|
44
|
+
avatarUrl
|
|
45
|
+
}) {
|
|
46
|
+
const [isExpanded, setIsExpanded] = useState(false);
|
|
47
|
+
const [isOverflowing, setIsOverflowing] = useState(false);
|
|
48
|
+
const [windowWidth, setWindowWidth] = useState(window.innerWidth);
|
|
49
|
+
const textRef = useRef(null);
|
|
50
|
+
const checkOverflow = () => {
|
|
51
|
+
const current = textRef.current?.mdp?.current;
|
|
52
|
+
if (current) {
|
|
53
|
+
setIsOverflowing(current.scrollHeight > current.offsetHeight);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
const handleResize = debounce(() => {
|
|
58
|
+
setWindowWidth(window.innerWidth);
|
|
59
|
+
}, 100);
|
|
60
|
+
window.addEventListener('resize', handleResize);
|
|
61
|
+
return () => window.removeEventListener('resize', handleResize);
|
|
62
|
+
}, []);
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
checkOverflow();
|
|
65
|
+
}, [windowWidth, content]);
|
|
66
|
+
const infoList = useMemo(() => {
|
|
67
|
+
return Object.entries(titleInfo).map(([key, value]) => {
|
|
68
|
+
return {
|
|
69
|
+
key,
|
|
70
|
+
value
|
|
71
|
+
};
|
|
72
|
+
}).filter(v => !!v.value);
|
|
73
|
+
}, [titleInfo]);
|
|
74
|
+
return /*#__PURE__*/_jsx(Box, {
|
|
75
|
+
"data-cy": "log-entry",
|
|
76
|
+
sx: {
|
|
77
|
+
borderBottom: isLast ? 'none' : '1px solid #ddd',
|
|
78
|
+
padding: 2
|
|
79
|
+
},
|
|
80
|
+
children: /*#__PURE__*/_jsxs(Box, {
|
|
81
|
+
sx: {
|
|
82
|
+
display: 'flex',
|
|
83
|
+
flexDirection: 'row',
|
|
84
|
+
flexWrap: 'wrap',
|
|
85
|
+
gap: 2,
|
|
86
|
+
width: '100%'
|
|
87
|
+
},
|
|
88
|
+
children: [/*#__PURE__*/_jsx(Box, {
|
|
89
|
+
sx: {
|
|
90
|
+
mt: 0.5
|
|
91
|
+
},
|
|
92
|
+
className: "log-author",
|
|
93
|
+
children: avatarUrl ? /*#__PURE__*/_jsx(Avatar, {
|
|
94
|
+
src: avatarUrl,
|
|
95
|
+
size: 36,
|
|
96
|
+
shape: "circle"
|
|
97
|
+
}) : /*#__PURE__*/_jsx("div", {
|
|
98
|
+
dangerouslySetInnerHTML: {
|
|
99
|
+
__html: blockletServerLogo
|
|
100
|
+
}
|
|
101
|
+
})
|
|
102
|
+
}), /*#__PURE__*/_jsxs(Box, {
|
|
103
|
+
sx: {
|
|
104
|
+
width: 240
|
|
105
|
+
},
|
|
106
|
+
children: [/*#__PURE__*/_jsx(Typography, {
|
|
107
|
+
color: "textSecondary",
|
|
108
|
+
component: "p",
|
|
109
|
+
display: "flex",
|
|
110
|
+
children: titleLink ? /*#__PURE__*/_jsx(Link, {
|
|
111
|
+
to: titleLink,
|
|
112
|
+
target: "_blank",
|
|
113
|
+
children: /*#__PURE__*/_jsx(ShortenLabel, {
|
|
114
|
+
maxLength: 26,
|
|
115
|
+
children: title
|
|
116
|
+
})
|
|
117
|
+
}) : /*#__PURE__*/_jsx(ShortenLabel, {
|
|
118
|
+
maxLength: 26,
|
|
119
|
+
children: title
|
|
120
|
+
})
|
|
121
|
+
}), /*#__PURE__*/_jsx(Tooltip, {
|
|
122
|
+
"aria-label": "Audit device info",
|
|
123
|
+
title: /*#__PURE__*/_jsx(Box, {
|
|
124
|
+
sx: {
|
|
125
|
+
color: '#fff',
|
|
126
|
+
display: 'flex',
|
|
127
|
+
flexDirection: 'column',
|
|
128
|
+
fontSize: 12
|
|
129
|
+
},
|
|
130
|
+
children: infoList?.map(item => {
|
|
131
|
+
return /*#__PURE__*/_jsx(Typography, {
|
|
132
|
+
sx: {
|
|
133
|
+
color: '#fff'
|
|
134
|
+
},
|
|
135
|
+
fontSize: 12,
|
|
136
|
+
children: `${item.key}: ${item.value}`
|
|
137
|
+
}, item.key);
|
|
138
|
+
})
|
|
139
|
+
}),
|
|
140
|
+
children: /*#__PURE__*/_jsxs(Typography, {
|
|
141
|
+
component: "span",
|
|
142
|
+
color: "textSecondary",
|
|
143
|
+
fontSize: 13,
|
|
144
|
+
children: [subTitle, /*#__PURE__*/_jsx(InfoOutlinedIcon, {
|
|
145
|
+
sx: {
|
|
146
|
+
ml: 0.5,
|
|
147
|
+
fontSize: 12,
|
|
148
|
+
verticalAlign: 'middle'
|
|
149
|
+
}
|
|
150
|
+
})]
|
|
151
|
+
})
|
|
152
|
+
})]
|
|
153
|
+
}), /*#__PURE__*/_jsxs(Box, {
|
|
154
|
+
sx: {
|
|
155
|
+
width: 200
|
|
156
|
+
},
|
|
157
|
+
children: [/*#__PURE__*/_jsx(Typography, {
|
|
158
|
+
sx: {
|
|
159
|
+
fontSize: '16px',
|
|
160
|
+
color: 'rgb(36, 41, 47)',
|
|
161
|
+
backgroundColor: '#fff',
|
|
162
|
+
fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji'"
|
|
163
|
+
},
|
|
164
|
+
children: action
|
|
165
|
+
}), /*#__PURE__*/_jsx(Typography, {
|
|
166
|
+
component: "span",
|
|
167
|
+
color: "textSecondary",
|
|
168
|
+
fontSize: 13,
|
|
169
|
+
children: /*#__PURE__*/_jsx(RelativeTime, {
|
|
170
|
+
value: createdAt
|
|
171
|
+
})
|
|
172
|
+
})]
|
|
173
|
+
}), /*#__PURE__*/_jsx(Box, {
|
|
174
|
+
sx: {
|
|
175
|
+
flex: 1
|
|
176
|
+
},
|
|
177
|
+
children: isOverflowing && isExpanded ? /*#__PURE__*/_jsx(Typography, {
|
|
178
|
+
className: "log-content",
|
|
179
|
+
maxWidth: "lg",
|
|
180
|
+
color: "textPrimary",
|
|
181
|
+
component: "div",
|
|
182
|
+
"data-color-mode": "light",
|
|
183
|
+
gutterBottom: true,
|
|
184
|
+
children: /*#__PURE__*/_jsx(MarkdownPreview, {
|
|
185
|
+
source: content,
|
|
186
|
+
rehypePlugins: [[rehypeExternalLinks, {
|
|
187
|
+
target: '_blank'
|
|
188
|
+
}]]
|
|
189
|
+
})
|
|
190
|
+
}) : /*#__PURE__*/_jsx(Typography, {
|
|
191
|
+
className: "log-content",
|
|
192
|
+
maxWidth: "lg",
|
|
193
|
+
color: "textPrimary",
|
|
194
|
+
component: "div",
|
|
195
|
+
"data-color-mode": "light",
|
|
196
|
+
gutterBottom: true,
|
|
197
|
+
sx: {
|
|
198
|
+
display: isExpanded ? 'block' : '-webkit-box',
|
|
199
|
+
WebkitLineClamp: isExpanded ? 'none' : 2,
|
|
200
|
+
WebkitBoxOrient: 'vertical',
|
|
201
|
+
overflow: isExpanded ? 'visible' : 'hidden',
|
|
202
|
+
wordBreak: 'break-word'
|
|
203
|
+
},
|
|
204
|
+
children: /*#__PURE__*/_jsx(MarkdownPreview, {
|
|
205
|
+
ref: textRef,
|
|
206
|
+
source: content,
|
|
207
|
+
rehypePlugins: [[rehypeExternalLinks, {
|
|
208
|
+
target: '_blank'
|
|
209
|
+
}]]
|
|
210
|
+
})
|
|
211
|
+
})
|
|
212
|
+
}), /*#__PURE__*/_jsxs(Box, {
|
|
213
|
+
children: [isOverflowing && /*#__PURE__*/_jsx(IconButton, {
|
|
214
|
+
size: "small",
|
|
215
|
+
onClick: () => setIsExpanded(!isExpanded),
|
|
216
|
+
children: isExpanded ? /*#__PURE__*/_jsx(CloseFullscreenIcon, {
|
|
217
|
+
sx: {
|
|
218
|
+
fontSize: 22
|
|
219
|
+
}
|
|
220
|
+
}) : /*#__PURE__*/_jsx(UnfoldMoreIcon, {
|
|
221
|
+
sx: {
|
|
222
|
+
fontSize: 22
|
|
223
|
+
}
|
|
224
|
+
})
|
|
225
|
+
}), /*#__PURE__*/_jsx(IconButton, {
|
|
226
|
+
size: "small",
|
|
227
|
+
children: /*#__PURE__*/_jsx(CopyButton, {
|
|
228
|
+
sx: {
|
|
229
|
+
fontSize: 22
|
|
230
|
+
},
|
|
231
|
+
content: content
|
|
232
|
+
})
|
|
233
|
+
})]
|
|
234
|
+
})]
|
|
235
|
+
})
|
|
236
|
+
});
|
|
237
|
+
}
|
|
@@ -1,24 +1,20 @@
|
|
|
1
1
|
/* eslint-disable react/prop-types */
|
|
2
|
-
import styled from '@emotion/styled';
|
|
3
|
-
import { Link } from 'react-router-dom';
|
|
4
|
-
import MarkdownPreview from '@uiw/react-markdown-preview';
|
|
5
|
-
import rehypeExternalLinks from 'rehype-external-links';
|
|
6
|
-
import DidAvatar from '@arcblock/did-connect/lib/Avatar';
|
|
7
2
|
import Spinner from '@mui/material/CircularProgress';
|
|
8
3
|
import Empty from '@arcblock/ux/lib/Empty';
|
|
9
4
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
10
5
|
import { WELLKNOWN_BLOCKLET_ADMIN_PATH } from '@abtnode/constant';
|
|
6
|
+
import TableSearch from '@arcblock/ux/lib/Datatable/TableSearch';
|
|
11
7
|
import Box from '@mui/material/Box';
|
|
12
|
-
import Typography from '@mui/material/Typography';
|
|
13
|
-
import Pagination from '@mui/lab/Pagination';
|
|
14
8
|
import MenuItem from '@mui/material/MenuItem';
|
|
15
9
|
import Select from '@mui/material/Select';
|
|
16
10
|
import InputLabel from '@mui/material/InputLabel';
|
|
17
11
|
import FormControl from '@mui/material/FormControl';
|
|
18
|
-
import
|
|
12
|
+
import TablePagination from '@mui/material/TablePagination';
|
|
13
|
+
import { parseAvatar } from '../team/members/util';
|
|
19
14
|
import { useAuditLogContext, AuditLogProvider } from '../contexts/audit-log';
|
|
15
|
+
import AuditLogCell from './audit-log-cell';
|
|
20
16
|
import { useNodeContext } from '../contexts/node';
|
|
21
|
-
import
|
|
17
|
+
import { useTeamContext } from '../contexts/team';
|
|
22
18
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
23
19
|
const getUserLink = ({
|
|
24
20
|
log,
|
|
@@ -35,12 +31,19 @@ const getUserLink = ({
|
|
|
35
31
|
return `/blocklets/${log.scope}/members?did=${log.actor.did}`;
|
|
36
32
|
};
|
|
37
33
|
function AuditLog({
|
|
38
|
-
log
|
|
34
|
+
log,
|
|
35
|
+
isLast
|
|
39
36
|
}) {
|
|
40
37
|
const {
|
|
41
38
|
inService,
|
|
42
39
|
info
|
|
43
40
|
} = useNodeContext();
|
|
41
|
+
const {
|
|
42
|
+
t
|
|
43
|
+
} = useLocaleContext();
|
|
44
|
+
const {
|
|
45
|
+
teamDid
|
|
46
|
+
} = useTeamContext();
|
|
44
47
|
const {
|
|
45
48
|
showScope,
|
|
46
49
|
scopeFormatter = x => x
|
|
@@ -51,89 +54,32 @@ function AuditLog({
|
|
|
51
54
|
|
|
52
55
|
// HACK: blocklet 类型会在存储前被强制置为 `''`,所以需要增加空字符串判断
|
|
53
56
|
const isUser = !['blocklet', ''].includes(log.actor.role);
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
marginRight: 8
|
|
81
|
-
},
|
|
82
|
-
children: scopeFormatter(log.scope)
|
|
83
|
-
})
|
|
84
|
-
}), isUser ? /*#__PURE__*/_jsxs(Link, {
|
|
85
|
-
to: getUserLink({
|
|
86
|
-
log,
|
|
87
|
-
inService,
|
|
88
|
-
info
|
|
89
|
-
}),
|
|
90
|
-
target: "_blank",
|
|
91
|
-
children: [log.actor.fullName, log.actor.role ? `(${log.actor.role})` : '']
|
|
92
|
-
}) : /*#__PURE__*/_jsxs("span", {
|
|
93
|
-
children: [log.actor.fullName, log.actor.role ? `(${log.actor.role})` : '']
|
|
94
|
-
}), ' ', /*#__PURE__*/_jsx("span", {
|
|
95
|
-
style: {
|
|
96
|
-
margin: '0 4px'
|
|
97
|
-
},
|
|
98
|
-
children: "-"
|
|
99
|
-
}), " ", log.action]
|
|
100
|
-
}), /*#__PURE__*/_jsx(Typography, {
|
|
101
|
-
className: "log-content",
|
|
102
|
-
maxWidth: "lg",
|
|
103
|
-
color: "textPrimary",
|
|
104
|
-
component: "div",
|
|
105
|
-
"data-color-mode": "light",
|
|
106
|
-
gutterBottom: true,
|
|
107
|
-
children: /*#__PURE__*/_jsx(MarkdownPreview, {
|
|
108
|
-
source: log.content,
|
|
109
|
-
rehypePlugins: [[rehypeExternalLinks, {
|
|
110
|
-
target: '_blank'
|
|
111
|
-
}]]
|
|
112
|
-
})
|
|
113
|
-
}), /*#__PURE__*/_jsxs(Box, {
|
|
114
|
-
className: "log-meta",
|
|
115
|
-
variant: "body2",
|
|
116
|
-
children: [!!log.ip && /*#__PURE__*/_jsx(Typography, {
|
|
117
|
-
component: "span",
|
|
118
|
-
color: "textSecondary",
|
|
119
|
-
children: `IP: ${log.ip}`
|
|
120
|
-
}), !!log.env.os?.name && /*#__PURE__*/_jsxs(Typography, {
|
|
121
|
-
component: "span",
|
|
122
|
-
color: "textSecondary",
|
|
123
|
-
children: [log.env.os.name, "(", log.env.os.version, ")"]
|
|
124
|
-
}), !!log.env.browser?.name && /*#__PURE__*/_jsxs(Typography, {
|
|
125
|
-
component: "span",
|
|
126
|
-
color: "textSecondary",
|
|
127
|
-
children: [log.env.browser.name, "(", log.env.browser.version, ")"]
|
|
128
|
-
}), /*#__PURE__*/_jsx(Typography, {
|
|
129
|
-
component: "span",
|
|
130
|
-
color: "textSecondary",
|
|
131
|
-
children: /*#__PURE__*/_jsx(RelativeTime, {
|
|
132
|
-
value: log.createdAt
|
|
133
|
-
})
|
|
134
|
-
})]
|
|
135
|
-
})]
|
|
136
|
-
})]
|
|
57
|
+
let title = log.actor.fullName;
|
|
58
|
+
if (showScope) {
|
|
59
|
+
title = log.actor.fullName ? `${title} - ${scopeFormatter(log.scope)}` : scopeFormatter(log.scope);
|
|
60
|
+
}
|
|
61
|
+
const titleLink = showScope ? log.link : getUserLink({
|
|
62
|
+
log,
|
|
63
|
+
inService,
|
|
64
|
+
info
|
|
65
|
+
});
|
|
66
|
+
const avatarUrl = log.actor.avatar ? parseAvatar(log.actor.avatar, teamDid, inService) : '';
|
|
67
|
+
return /*#__PURE__*/_jsx(AuditLogCell, {
|
|
68
|
+
isLast: isLast,
|
|
69
|
+
isUser: isUser,
|
|
70
|
+
avatarDid: log.actor.did,
|
|
71
|
+
avatarUrl: avatarUrl,
|
|
72
|
+
title: title || t('common.unrecordedUser'),
|
|
73
|
+
titleLink: titleLink,
|
|
74
|
+
subTitle: log.actor.role ? log.actor.role : t('common.unrecordedRole'),
|
|
75
|
+
content: log.content,
|
|
76
|
+
action: log.action,
|
|
77
|
+
titleInfo: {
|
|
78
|
+
IP: log.ip,
|
|
79
|
+
OS: `${log.env.os?.name}${log.env.os?.version ? ` ${log.env.os?.version}` : ''}`,
|
|
80
|
+
Client: `${log.env.browser?.name}${log.env.browser?.Version ? ` ${log.env.browser?.Version}` : ''}`
|
|
81
|
+
},
|
|
82
|
+
createdAt: log.createdAt
|
|
137
83
|
});
|
|
138
84
|
}
|
|
139
85
|
function AuditLogs() {
|
|
@@ -144,11 +90,35 @@ function AuditLogs() {
|
|
|
144
90
|
data,
|
|
145
91
|
loading,
|
|
146
92
|
paging,
|
|
93
|
+
setPaging,
|
|
147
94
|
filter,
|
|
148
95
|
categories,
|
|
149
96
|
setCategory,
|
|
150
|
-
fetch
|
|
97
|
+
fetch,
|
|
98
|
+
actionOrContent,
|
|
99
|
+
setActionOrContent
|
|
151
100
|
} = useAuditLogContext();
|
|
101
|
+
const handleRowsPerPageChange = e => {
|
|
102
|
+
const pageSize = Number(e.target.value);
|
|
103
|
+
setPaging({
|
|
104
|
+
...paging,
|
|
105
|
+
pageSize
|
|
106
|
+
});
|
|
107
|
+
fetch({
|
|
108
|
+
page: 1,
|
|
109
|
+
pageSize
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
const handlePageChange = page => {
|
|
113
|
+
setPaging({
|
|
114
|
+
...paging,
|
|
115
|
+
page: page + 1
|
|
116
|
+
});
|
|
117
|
+
fetch({
|
|
118
|
+
page: page + 1,
|
|
119
|
+
pageSize: paging.pageSize
|
|
120
|
+
});
|
|
121
|
+
};
|
|
152
122
|
if (loading) {
|
|
153
123
|
return /*#__PURE__*/_jsx("div", {
|
|
154
124
|
style: {
|
|
@@ -158,11 +128,16 @@ function AuditLogs() {
|
|
|
158
128
|
children: /*#__PURE__*/_jsx(Spinner, {})
|
|
159
129
|
});
|
|
160
130
|
}
|
|
161
|
-
return /*#__PURE__*/_jsxs(
|
|
131
|
+
return /*#__PURE__*/_jsxs(Box, {
|
|
162
132
|
"data-cy": "audit-logs",
|
|
163
|
-
children: [/*#__PURE__*/
|
|
164
|
-
|
|
165
|
-
|
|
133
|
+
children: [/*#__PURE__*/_jsxs(Box, {
|
|
134
|
+
sx: {
|
|
135
|
+
display: 'flex',
|
|
136
|
+
flexDirection: 'row',
|
|
137
|
+
gap: 2,
|
|
138
|
+
alignItems: 'center'
|
|
139
|
+
},
|
|
140
|
+
children: [/*#__PURE__*/_jsxs(FormControl, {
|
|
166
141
|
style: {
|
|
167
142
|
width: '240px'
|
|
168
143
|
},
|
|
@@ -174,6 +149,9 @@ function AuditLogs() {
|
|
|
174
149
|
value: filter.category,
|
|
175
150
|
onChange: e => setCategory(e.target.value),
|
|
176
151
|
fullWidth: true,
|
|
152
|
+
sx: {
|
|
153
|
+
borderRadius: 1
|
|
154
|
+
},
|
|
177
155
|
label: t('common.category'),
|
|
178
156
|
disabled: loading,
|
|
179
157
|
children: categories.map(x => /*#__PURE__*/_jsx(MenuItem, {
|
|
@@ -186,19 +164,54 @@ function AuditLogs() {
|
|
|
186
164
|
})
|
|
187
165
|
}, x.label))
|
|
188
166
|
})]
|
|
189
|
-
})
|
|
167
|
+
}), /*#__PURE__*/_jsx(Box, {
|
|
168
|
+
sx: {
|
|
169
|
+
flex: 1
|
|
170
|
+
}
|
|
171
|
+
}), /*#__PURE__*/_jsx(TableSearch, {
|
|
172
|
+
options: {
|
|
173
|
+
searchPlaceholder: t('common.auditLogsSearch'),
|
|
174
|
+
searchDebounceTime: 600
|
|
175
|
+
},
|
|
176
|
+
search: actionOrContent,
|
|
177
|
+
searchText: actionOrContent,
|
|
178
|
+
searchTextUpdate: setActionOrContent,
|
|
179
|
+
searchClose: () => setActionOrContent(''),
|
|
180
|
+
onSearchOpen: () => {}
|
|
181
|
+
})]
|
|
190
182
|
}), data.length === 0 && /*#__PURE__*/_jsx(Empty, {
|
|
191
183
|
children: t('common.empty')
|
|
192
|
-
}),
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
184
|
+
}), /*#__PURE__*/_jsx(Box, {
|
|
185
|
+
sx: {
|
|
186
|
+
mt: 2,
|
|
187
|
+
border: data?.length > 0 ? '1px solid #ddd' : 'none',
|
|
188
|
+
borderRadius: 1
|
|
189
|
+
},
|
|
190
|
+
children: data.length > 0 && data.map((x, index) => /*#__PURE__*/_jsx(AuditLog, {
|
|
191
|
+
log: x,
|
|
192
|
+
isLast: index === data.length - 1
|
|
193
|
+
}, x.id))
|
|
194
|
+
}), /*#__PURE__*/_jsx(Box, {
|
|
195
|
+
sx: {
|
|
196
|
+
display: 'flex',
|
|
197
|
+
justifyContent: 'flex-end',
|
|
198
|
+
mt: 2
|
|
199
|
+
},
|
|
200
|
+
children: /*#__PURE__*/_jsx(TablePagination, {
|
|
201
|
+
disabled: loading,
|
|
202
|
+
page: paging.page - 1,
|
|
203
|
+
count: paging.total,
|
|
204
|
+
rowsPerPage: paging.pageSize,
|
|
205
|
+
rowsPerPageOptions: [10, 20, 50, 100],
|
|
206
|
+
labelRowsPerPage: t('pagination.rowsPerPage'),
|
|
207
|
+
labelDisplayedRows: ({
|
|
208
|
+
from,
|
|
209
|
+
to,
|
|
210
|
+
count
|
|
211
|
+
}) => `${from}–${to} / ${count !== -1 ? count : `${t()}more than ${to}`}`,
|
|
212
|
+
onPageChange: (_, page) => handlePageChange(page),
|
|
213
|
+
onRowsPerPageChange: handleRowsPerPageChange
|
|
214
|
+
})
|
|
202
215
|
})]
|
|
203
216
|
});
|
|
204
217
|
}
|
|
@@ -215,64 +228,4 @@ export default function WrappedAuditLogs({
|
|
|
215
228
|
scopeFormatter: scopeFormatter,
|
|
216
229
|
children: /*#__PURE__*/_jsx(AuditLogs, {})
|
|
217
230
|
});
|
|
218
|
-
}
|
|
219
|
-
const Div = styled.div`
|
|
220
|
-
.log-controls {
|
|
221
|
-
display: flex;
|
|
222
|
-
justify-content: space-between;
|
|
223
|
-
}
|
|
224
|
-
.log-entry {
|
|
225
|
-
display: flex;
|
|
226
|
-
margin: 16px 0;
|
|
227
|
-
|
|
228
|
-
.log-author {
|
|
229
|
-
margin-right: 8px;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
.log-body {
|
|
233
|
-
flex: 1;
|
|
234
|
-
|
|
235
|
-
a {
|
|
236
|
-
color: ${({
|
|
237
|
-
theme
|
|
238
|
-
}) => theme.palette.primary.main};
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
.log-header {
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
.log-content {
|
|
245
|
-
p {
|
|
246
|
-
margin-bottom: 4px;
|
|
247
|
-
}
|
|
248
|
-
ul,
|
|
249
|
-
ol {
|
|
250
|
-
padding-left: 2rem;
|
|
251
|
-
}
|
|
252
|
-
li {
|
|
253
|
-
list-style-type: disc;
|
|
254
|
-
}
|
|
255
|
-
code.code-highlight {
|
|
256
|
-
max-height: 300px;
|
|
257
|
-
overflow: auto;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
.log-meta {
|
|
262
|
-
margin-top: 4px;
|
|
263
|
-
|
|
264
|
-
span {
|
|
265
|
-
font-size: 0.8rem;
|
|
266
|
-
display: inline-block;
|
|
267
|
-
margin-right: 8px;
|
|
268
|
-
padding-right: 8px;
|
|
269
|
-
border-right: 1px solid #ccc;
|
|
270
|
-
|
|
271
|
-
&:last-of-type {
|
|
272
|
-
border-right: none;
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
`;
|
|
231
|
+
}
|
|
@@ -31,6 +31,7 @@ function SwitchControl({
|
|
|
31
31
|
return /*#__PURE__*/_jsx(Root, {
|
|
32
32
|
className: className,
|
|
33
33
|
style: style,
|
|
34
|
+
labelPlacement: labelProps?.labelPlacement,
|
|
34
35
|
children: /*#__PURE__*/_jsx(IOSSwitch, {
|
|
35
36
|
labelProps: _labelProps,
|
|
36
37
|
...rest
|
|
@@ -40,14 +41,23 @@ function SwitchControl({
|
|
|
40
41
|
SwitchControl.propTypes = IOSSwitch.propTypes;
|
|
41
42
|
SwitchControl.defaultProps = IOSSwitch.defaultProps;
|
|
42
43
|
const Root = styled.div`
|
|
43
|
-
max-width:
|
|
44
|
+
max-width: ${({
|
|
45
|
+
labelPlacement
|
|
46
|
+
}) => labelPlacement === 'end' ? '100%' : '300px'};
|
|
44
47
|
> label {
|
|
45
48
|
display: flex;
|
|
46
|
-
justify-content:
|
|
49
|
+
justify-content: ${({
|
|
50
|
+
labelPlacement
|
|
51
|
+
}) => labelPlacement === 'end' ? 'flex-start' : 'space-between'};
|
|
47
52
|
width: 100%;
|
|
48
53
|
margin-left: 0;
|
|
49
54
|
margin-right: 0;
|
|
50
55
|
}
|
|
56
|
+
.MuiFormControlLabel-labelPlacementEnd {
|
|
57
|
+
.MuiSwitch-root {
|
|
58
|
+
margin-right: 8px;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
51
61
|
${({
|
|
52
62
|
theme
|
|
53
63
|
}) => theme.breakpoints.down('sm')} {
|