@abtnode/ux 1.16.42 → 1.16.43-beta-20250419-231352-c78ac93d

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.
Files changed (45) hide show
  1. package/lib/blocklet/access-key/component.js +29 -14
  2. package/lib/blocklet/access-key/create.js +2 -2
  3. package/lib/blocklet/access-key/detail.js +12 -7
  4. package/lib/blocklet/access-key/index.js +15 -8
  5. package/lib/blocklet/access-key/update.js +19 -9
  6. package/lib/blocklet/audit-log-cell.js +19 -3
  7. package/lib/blocklet/audit-logs.js +4 -2
  8. package/lib/blocklet/branding.js +146 -402
  9. package/lib/blocklet/component/add-component/add-component-core.js +1 -1
  10. package/lib/blocklet/component/domain-action-card.js +19 -3
  11. package/lib/blocklet/component/domain-list.js +80 -37
  12. package/lib/blocklet/domains.js +8 -3
  13. package/lib/blocklet/logo-uploader.js +4 -4
  14. package/lib/blocklet/router/action/add-domain-alias.js +11 -5
  15. package/lib/blocklet/router/action/delete-domain-alias.js +7 -3
  16. package/lib/blocklet/router/domain-actions.js +8 -3
  17. package/lib/blocklet/status.js +39 -38
  18. package/lib/hooks/blocklet.js +23 -1
  19. package/lib/hooks/url-evaluation.js +18 -7
  20. package/lib/icons/app-logo.svg +14 -21
  21. package/lib/icons/favicon.svg +7 -8
  22. package/lib/icons/header-logo.svg +57 -80
  23. package/lib/locales/ar.js +3 -3
  24. package/lib/locales/de.js +3 -3
  25. package/lib/locales/en.js +3 -3
  26. package/lib/locales/es.js +3 -3
  27. package/lib/locales/fr.js +3 -3
  28. package/lib/locales/hi.js +3 -3
  29. package/lib/locales/i18n.db +0 -0
  30. package/lib/locales/id.js +3 -3
  31. package/lib/locales/ja.js +3 -3
  32. package/lib/locales/ko.js +3 -3
  33. package/lib/locales/pt.js +3 -3
  34. package/lib/locales/ru.js +3 -3
  35. package/lib/locales/th.js +3 -3
  36. package/lib/locales/vi.js +3 -3
  37. package/lib/locales/zh-tw.js +4 -4
  38. package/lib/locales/zh.js +4 -4
  39. package/lib/notifications/pages/index.js +8 -2
  40. package/lib/notifications/pages/list.js +7 -6
  41. package/lib/team/members/index.js +14 -11
  42. package/lib/team/members/member.js +18 -38
  43. package/lib/team/passports/new/passport-item.js +60 -27
  44. package/lib/util/extract-markdown-links.js +18 -0
  45. package/package.json +25 -25
@@ -1,9 +1,12 @@
1
1
  import PropTypes from 'prop-types';
2
- import Tooltip from '@mui/material/Tooltip';
3
2
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
4
- import { format } from 'timeago.js';
3
+ import RelativeTime from '@arcblock/ux/lib/RelativeTime';
4
+ import { RBAC_CONFIG, ROLES } from '@abtnode/constant';
5
+ import { uniqBy } from 'lodash';
5
6
  import { formatToDatetime } from '../../util';
6
- import { jsx as _jsx } from "react/jsx-runtime";
7
+ import { useNodeContext } from '../../contexts/node';
8
+ import { useTeamContext } from '../../contexts/team';
9
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
7
10
  function ExpiredAt({
8
11
  value
9
12
  }) {
@@ -14,21 +17,33 @@ function ExpiredAt({
14
17
  const now = new Date();
15
18
  const expiredAt = new Date(value);
16
19
  const isExpired = expiredAt < now;
17
- return /*#__PURE__*/_jsx(Tooltip, {
18
- title: isExpired ? formatToDatetime(value, locale) : '',
19
- children: isExpired ? /*#__PURE__*/_jsx("span", {
20
+ if (isExpired) {
21
+ return /*#__PURE__*/_jsxs("span", {
20
22
  style: {
21
23
  color: 'red'
22
24
  },
23
- children: `${t('setting.accessKey.expired', {
24
- time: format(new Date(value).getTime(), locale)
25
- })}`
26
- }) : formatToDatetime(value, locale)
27
- });
25
+ children: [/*#__PURE__*/_jsx(RelativeTime, {
26
+ value: value,
27
+ locale: locale
28
+ }), `${t('setting.accessKey.expired', {
29
+ time: ''
30
+ })}`]
31
+ });
32
+ }
33
+ return formatToDatetime(value, locale);
28
34
  }
29
35
  ExpiredAt.propTypes = {
30
36
  value: PropTypes.string.isRequired
31
37
  };
32
-
33
- // eslint-disable-next-line import/prefer-default-export
34
- export { ExpiredAt };
38
+ const useRoles = () => {
39
+ const SERVER_ROLES = RBAC_CONFIG.roles.filter(x => x.passport);
40
+ const {
41
+ inService
42
+ } = useNodeContext();
43
+ const {
44
+ roles: teamRoles
45
+ } = useTeamContext();
46
+ const roles = uniqBy([...SERVER_ROLES, ...(inService ? teamRoles : [])], 'name').filter(x => x.name !== ROLES.OWNER);
47
+ return roles;
48
+ };
49
+ export { ExpiredAt, useRoles };
@@ -11,11 +11,11 @@ import FormControl from '@mui/material/FormControl';
11
11
  import Box from '@mui/material/Box';
12
12
  import Button from '@arcblock/ux/lib/Button';
13
13
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
14
- import { RBAC_CONFIG, ROLES } from '@abtnode/constant';
15
14
  import TimeSelect from '../../team/members/time-select';
16
15
  import Confirm from '../../../lib/confirm';
17
16
  import { useNodeContext } from '../../contexts/node';
18
17
  import { useTeamContext } from '../../contexts/team';
18
+ import { useRoles } from './component';
19
19
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
20
20
  export default function CreateAccessKey(props) {
21
21
  const {
@@ -33,7 +33,7 @@ export default function CreateAccessKey(props) {
33
33
  } = useLocaleContext();
34
34
  const [loading, setLoading] = useState(false);
35
35
  const [confirmSetting, setConfirmSetting] = useState(null);
36
- const roles = RBAC_CONFIG.roles.filter(x => x.passport && x.name !== ROLES.OWNER);
36
+ const roles = useRoles();
37
37
  const onCancel = () => {
38
38
  setLoading(false);
39
39
  setConfirmSetting(null);
@@ -21,7 +21,7 @@ import { formatToDatetime } from '../../util';
21
21
  import { useTeamContext } from '../../contexts/team';
22
22
  import { useNodeContext } from '../../contexts/node';
23
23
  import { useBlockletContext } from '../../contexts/blocklet';
24
- import { ExpiredAt } from './component';
24
+ import { ExpiredAt, useRoles } from './component';
25
25
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
26
26
  export default function AccessKeyDetail({
27
27
  accessKey,
@@ -76,6 +76,7 @@ function BaseInfo({
76
76
  const {
77
77
  blocklet
78
78
  } = useBlockletContext();
79
+ const roles = useRoles();
79
80
  const getUser = useCallback(async did => {
80
81
  if (!did) return null;
81
82
  const response = await client.getUser({
@@ -91,6 +92,8 @@ function BaseInfo({
91
92
  const user = useRequest(() => getUser(accessKey.createdBy), {});
92
93
  const currentComponent = (blocklet?.children || []).find(child => child?.meta?.did === accessKey.componentDid);
93
94
  const avatar = useMemo(() => parseAvatar(user?.data?.avatar, teamDid, true), [user?.data?.avatar, teamDid]);
95
+ const p = roles.find(x => x.name === accessKey.passport);
96
+ const passportName = p ? p.title : accessKey.passport;
94
97
  const infoGroups = [{
95
98
  title: t('common.baseInfo'),
96
99
  items: [{
@@ -102,7 +105,7 @@ function BaseInfo({
102
105
  }, {
103
106
  label: t('common.role'),
104
107
  content: /*#__PURE__*/_jsx(Box, {
105
- children: renderRole((accessKey.passport || '').toLowerCase())
108
+ children: renderRole(passportName, accessKey.passport)
106
109
  })
107
110
  }, {
108
111
  label: t('common.createdVia'),
@@ -118,14 +121,18 @@ function BaseInfo({
118
121
  height: 32
119
122
  }
120
123
  },
121
- children: /*#__PURE__*/_jsx(Card, {
124
+ children: /*#__PURE__*/_jsx(UserCard, {
122
125
  user: {
123
126
  ...user.data,
124
127
  avatar
125
128
  },
126
129
  showDid: true,
127
130
  cardType: CardType.Detailed,
128
- infoType: InfoType.Minimal
131
+ infoType: InfoType.Minimal,
132
+ sx: {
133
+ border: 0,
134
+ padding: 0
135
+ }
129
136
  })
130
137
  }) : accessKey.createdBy ? /*#__PURE__*/_jsx(DidAddress, {
131
138
  did: accessKey.createdBy,
@@ -196,7 +203,7 @@ function BaseInfo({
196
203
  children: /*#__PURE__*/_jsx(Box, {
197
204
  className: "info-area",
198
205
  children: infoGroups.map(group => /*#__PURE__*/_jsxs(Box, {
199
- mb: 2,
206
+ mb: 3,
200
207
  children: [/*#__PURE__*/_jsx(Typography, {
201
208
  variant: "h6",
202
209
  sx: {
@@ -226,7 +233,6 @@ function BaseInfo({
226
233
  BaseInfo.propTypes = {
227
234
  accessKey: PropTypes.object.isRequired
228
235
  };
229
- const Card = styled(UserCard)``;
230
236
  const StyledDiv = styled(Stack)`
231
237
  .info-card {
232
238
  margin-bottom: 24px;
@@ -254,7 +260,6 @@ const StyledDiv = styled(Stack)`
254
260
  flex: 1;
255
261
  display: flex;
256
262
  flex-direction: column;
257
- gap: 16px;
258
263
  }
259
264
 
260
265
  .info-header {
@@ -5,9 +5,8 @@ import { useAsyncRetry } from 'react-use';
5
5
  import { Box, Alert, Typography, Tooltip } from '@mui/material';
6
6
  import DidAddress from '@arcblock/did-connect/lib/Address';
7
7
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
8
- import { RBAC_CONFIG } from '@abtnode/constant';
9
8
  import Datatable, { getDurableData } from '@arcblock/ux/lib/Datatable';
10
- import { format } from 'timeago.js';
9
+ import RelativeTime from '@arcblock/ux/lib/RelativeTime';
11
10
  import { renderRole } from '../../team/passports/new/passport-item';
12
11
  import { formatError, formatToDatetime } from '../../util';
13
12
  import { useNodeContext } from '../../contexts/node';
@@ -18,7 +17,7 @@ import DeleteAccessKey from './delete';
18
17
  import UpdateAccessKey from './update';
19
18
  import Permission from '../../permission';
20
19
  import AccessKeyDetail from './detail';
21
- import { ExpiredAt } from './component';
20
+ import { ExpiredAt, useRoles } from './component';
22
21
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
23
22
  export default function AccessKey() {
24
23
  const {
@@ -34,6 +33,7 @@ export default function AccessKey() {
34
33
  } = useTeamContext();
35
34
  const [confirmInfo, setConfirmInfo] = useState({});
36
35
  const [accessKey, setAccessKeyDialog] = useState(null);
36
+ const roles = useRoles();
37
37
  const datatableRef = useRef(null);
38
38
  const durableKey = `access-keys-${teamDid}`;
39
39
  const tableDurableData = getDurableData(durableKey);
@@ -91,9 +91,10 @@ export default function AccessKey() {
91
91
  name: 'passport',
92
92
  options: {
93
93
  customBodyRender: value => {
94
- const p = RBAC_CONFIG.roles.find(x => x.name === value);
94
+ const p = roles.find(x => x.name === value);
95
+ const passport = p ? p.title : value;
95
96
  return /*#__PURE__*/_jsx(Box, {
96
- children: renderRole((p ? p.title : value).toLowerCase())
97
+ children: renderRole(passport, value)
97
98
  });
98
99
  }
99
100
  }
@@ -114,7 +115,10 @@ export default function AccessKey() {
114
115
  customBodyRender: value => {
115
116
  return /*#__PURE__*/_jsx(Tooltip, {
116
117
  title: formatToDatetime(value, locale),
117
- children: value ? format(new Date(value).getTime(), locale === 'tw' ? 'zh' : locale) : '-'
118
+ children: value ? /*#__PURE__*/_jsx(RelativeTime, {
119
+ value: value,
120
+ locale: locale
121
+ }) : '-'
118
122
  });
119
123
  }
120
124
  }
@@ -125,7 +129,10 @@ export default function AccessKey() {
125
129
  customBodyRender: value => {
126
130
  return /*#__PURE__*/_jsx(Tooltip, {
127
131
  title: formatToDatetime(value, locale),
128
- children: value ? format(new Date(value).getTime(), locale === 'tw' ? 'zh' : locale) : '-'
132
+ children: value ? /*#__PURE__*/_jsx(RelativeTime, {
133
+ value: value,
134
+ locale: locale
135
+ }) : '-'
129
136
  });
130
137
  }
131
138
  }
@@ -166,7 +173,7 @@ export default function AccessKey() {
166
173
  });
167
174
  }
168
175
  }
169
- }], [list, locale, t, state.retry]);
176
+ }], [list, locale, t, state.retry, roles]);
170
177
  const onTableChange = ({
171
178
  page,
172
179
  rowsPerPage,
@@ -5,16 +5,17 @@ import Spinner from '@mui/material/CircularProgress';
5
5
  import Stack from '@mui/material/Stack';
6
6
  import TextField from '@mui/material/TextField';
7
7
  import MenuItem from '@mui/material/MenuItem';
8
+ import Box from '@mui/material/Box';
8
9
  import Select from '@mui/material/Select';
9
10
  import InputLabel from '@mui/material/InputLabel';
10
11
  import FormControl from '@mui/material/FormControl';
11
12
  import Button from '@arcblock/ux/lib/Button';
12
13
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
13
- import { RBAC_CONFIG, ROLES } from '@abtnode/constant';
14
14
  import TimeSelect from '../../team/members/time-select';
15
15
  import Confirm from '../../../lib/confirm';
16
16
  import { useNodeContext } from '../../contexts/node';
17
17
  import { useTeamContext } from '../../contexts/team';
18
+ import { useRoles } from './component';
18
19
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
19
20
  export default function UpdateAccessKey(props) {
20
21
  const {
@@ -24,18 +25,18 @@ export default function UpdateAccessKey(props) {
24
25
  passport,
25
26
  expireAt
26
27
  } = props;
27
- const {
28
- t
29
- } = useLocaleContext();
30
- const [loading, setLoading] = useState(false);
31
- const [confirmSetting, setConfirmSetting] = useState(null);
32
28
  const {
33
29
  api
34
30
  } = useNodeContext();
35
31
  const {
36
32
  teamDid
37
33
  } = useTeamContext();
38
- const roles = RBAC_CONFIG.roles.filter(x => x.passport && x.name !== ROLES.OWNER);
34
+ const {
35
+ t
36
+ } = useLocaleContext();
37
+ const [loading, setLoading] = useState(false);
38
+ const [confirmSetting, setConfirmSetting] = useState(null);
39
+ const roles = useRoles();
39
40
  const onCancel = () => {
40
41
  setLoading(false);
41
42
  setConfirmSetting(null);
@@ -123,8 +124,17 @@ export default function UpdateAccessKey(props) {
123
124
  children: roles.map(r => /*#__PURE__*/_jsx(MenuItem, {
124
125
  value: r.name,
125
126
  "data-cy": `update-access-key-passport-option-${r.name}`,
126
- children: /*#__PURE__*/_jsx("span", {
127
- children: r.title || r.name
127
+ children: /*#__PURE__*/_jsxs(Box, {
128
+ children: [/*#__PURE__*/_jsx("span", {
129
+ children: r.title || r.name
130
+ }), /*#__PURE__*/_jsx(Box, {
131
+ maxWidth: 440,
132
+ fontSize: 12,
133
+ color: "#999",
134
+ whiteSpace: "normal",
135
+ textAlign: "justify",
136
+ children: r.description
137
+ })]
128
138
  })
129
139
  }, r.name))
130
140
  })]
@@ -11,8 +11,10 @@ import UnfoldMoreIcon from '@mui/icons-material/UnfoldMore';
11
11
  import CloseFullscreenIcon from '@mui/icons-material/CloseFullscreen';
12
12
  import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined';
13
13
  import debounce from 'lodash/debounce';
14
+ import { WELLKNOWN_SERVICE_PATH_PREFIX } from '@abtnode/constant';
14
15
  import RelativeTime from '../relative-time';
15
16
  import ShortenLabel from './component/shorten-label';
17
+ import extractMarkdownLinks from '../util/extract-markdown-links';
16
18
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
17
19
  const blockletServerLogo = `
18
20
  <svg style="width:38px;height:38px;" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">
@@ -41,7 +43,8 @@ export default function AuditLogCell({
41
43
  content,
42
44
  isLast,
43
45
  titleLink,
44
- avatarUrl
46
+ avatarUrl,
47
+ inService
45
48
  }) {
46
49
  const [isExpanded, setIsExpanded] = useState(false);
47
50
  const [isOverflowing, setIsOverflowing] = useState(false);
@@ -71,6 +74,19 @@ export default function AuditLogCell({
71
74
  };
72
75
  }).filter(v => !!v.value);
73
76
  }, [titleInfo]);
77
+ const fixLinksContent = useMemo(() => {
78
+ let nextContent = content;
79
+ if (inService) {
80
+ const links = extractMarkdownLinks(content);
81
+ links.forEach(link => {
82
+ // 如果包含 `如果是 blocklets 的 members` 链接,应该根据场景来替换跳转的路径
83
+ if (/^(?:\/[^/]+)*\/blocklets\/[^/]+\/members$/.test(link.url)) {
84
+ nextContent = nextContent.replace(link.url, `${WELLKNOWN_SERVICE_PATH_PREFIX}/admin/did-connect/members`);
85
+ }
86
+ });
87
+ }
88
+ return nextContent;
89
+ }, [content, inService]);
74
90
  return /*#__PURE__*/_jsx(Box, {
75
91
  "data-cy": "log-entry",
76
92
  sx: {
@@ -185,7 +201,7 @@ export default function AuditLogCell({
185
201
  "data-color-mode": "light",
186
202
  gutterBottom: true,
187
203
  children: /*#__PURE__*/_jsx(MarkdownPreview, {
188
- source: content,
204
+ source: fixLinksContent,
189
205
  rehypePlugins: [[rehypeExternalLinks, {
190
206
  target: '_blank'
191
207
  }]]
@@ -206,7 +222,7 @@ export default function AuditLogCell({
206
222
  },
207
223
  children: /*#__PURE__*/_jsx(MarkdownPreview, {
208
224
  ref: textRef,
209
- source: content,
225
+ source: fixLinksContent,
210
226
  rehypePlugins: [[rehypeExternalLinks, {
211
227
  target: '_blank'
212
228
  }]]
@@ -11,6 +11,7 @@ import InputLabel from '@mui/material/InputLabel';
11
11
  import FormControl from '@mui/material/FormControl';
12
12
  import TablePagination from '@mui/material/TablePagination';
13
13
  import styled from '@emotion/styled';
14
+ import { get } from 'lodash';
14
15
  import { parseAvatar } from '../team/members/util';
15
16
  import { useAuditLogContext, AuditLogProvider } from '../contexts/audit-log';
16
17
  import AuditLogCell from './audit-log-cell';
@@ -75,10 +76,11 @@ function AuditLog({
75
76
  subTitle: log.actor.role ? log.actor.role : t('common.unrecordedRole'),
76
77
  content: log.content,
77
78
  action: log.action,
79
+ inService: inService,
78
80
  titleInfo: {
79
81
  IP: log.ip,
80
- OS: `${log.env?.os?.name}${log.env?.os?.version ? ` ${log.env?.os?.version}` : ''}`,
81
- Client: `${log.env?.browser?.name}${log.env?.browser?.Version ? ` ${log.env?.browser?.Version}` : ''}`
82
+ OS: `${get(log, 'env.os.name', '')}${get(log, 'env.os.version', '')}`,
83
+ Client: `${get(log, 'env.browser.name', '')}${get(log, 'env.browser.Version', '')}`
82
84
  },
83
85
  createdAt: log.createdAt
84
86
  });