@abtnode/ux 1.16.14-beta-ab7f615e → 1.16.14-beta-cb53c14b

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 (202) hide show
  1. package/es/actions.js +97 -0
  2. package/es/analytics/card.js +92 -0
  3. package/es/analytics/chart.js +96 -0
  4. package/es/analytics/cpu.js +36 -0
  5. package/es/analytics/disk.js +111 -0
  6. package/es/analytics/memory.js +72 -0
  7. package/es/analytics/runtime.js +173 -0
  8. package/es/analytics/traffic.js +259 -0
  9. package/es/blocklet/access/config-access.js +307 -0
  10. package/es/blocklet/access/index.js +216 -0
  11. package/es/blocklet/actions.js +474 -0
  12. package/es/blocklet/add-cert.js +177 -0
  13. package/es/blocklet/agreement-app.js +21 -0
  14. package/es/blocklet/agreement.js +127 -0
  15. package/es/blocklet/app-avatar.js +57 -0
  16. package/es/blocklet/audit-logs.js +259 -0
  17. package/es/blocklet/blocklet-source.js +48 -0
  18. package/es/blocklet/bundle-avatar.js +64 -0
  19. package/es/blocklet/component/add.js +1308 -0
  20. package/es/blocklet/component/configuration.js +122 -0
  21. package/es/blocklet/component/delete.js +134 -0
  22. package/es/blocklet/component/environment.js +370 -0
  23. package/es/blocklet/component/index.js +975 -0
  24. package/es/blocklet/component/line.js +20 -0
  25. package/es/blocklet/component/navigation/locale-tabs.js +225 -0
  26. package/es/blocklet/component/navigation/navigation-actions.js +112 -0
  27. package/es/blocklet/component/navigation/navigation-dialog.js +607 -0
  28. package/es/blocklet/component/navigation/navigation-preview.js +101 -0
  29. package/es/blocklet/component/navigation/simple-select.js +124 -0
  30. package/es/blocklet/component/select-store.js +155 -0
  31. package/es/blocklet/component/setting.js +109 -0
  32. package/es/blocklet/component/sortable-tree.js +126 -0
  33. package/es/blocklet/component/space-connector.js +199 -0
  34. package/es/blocklet/component/space-selector.js +178 -0
  35. package/es/blocklet/component/start.js +101 -0
  36. package/es/blocklet/component/store-blocklet-list.js +200 -0
  37. package/es/blocklet/component/switch-control.js +57 -0
  38. package/es/blocklet/config-navigation.js +331 -0
  39. package/es/blocklet/configuration.js +603 -0
  40. package/es/blocklet/disk-info.js +75 -0
  41. package/es/blocklet/icons.js +18 -0
  42. package/es/blocklet/install-from-url.js +337 -0
  43. package/es/blocklet/log.js +90 -0
  44. package/es/blocklet/migration.js +149 -0
  45. package/es/blocklet/mode.js +19 -0
  46. package/es/blocklet/notification/email.js +257 -0
  47. package/es/blocklet/notification/index.js +49 -0
  48. package/es/blocklet/oauth/auth0.js +145 -0
  49. package/es/blocklet/oauth/common-settings.js +133 -0
  50. package/es/blocklet/oauth/federated-detail-dialog.js +175 -0
  51. package/es/blocklet/oauth/federated-invite-dialog.js +83 -0
  52. package/es/blocklet/oauth/federated-join-dialog.js +111 -0
  53. package/es/blocklet/oauth/federated-site-list.js +338 -0
  54. package/es/blocklet/oauth/federated.js +81 -0
  55. package/es/blocklet/oauth/index.js +69 -0
  56. package/es/blocklet/overview.js +293 -0
  57. package/es/blocklet/page-group.js +19 -0
  58. package/es/blocklet/preferences/app-sk.js +142 -0
  59. package/es/blocklet/preferences/index.js +305 -0
  60. package/es/blocklet/purchase/common.js +95 -0
  61. package/es/blocklet/purchase/component-purchase.js +237 -0
  62. package/es/blocklet/purchase/index.js +4 -0
  63. package/es/blocklet/router/action/add-domain-alias.js +167 -0
  64. package/es/blocklet/router/action/add-rule.js +211 -0
  65. package/es/blocklet/router/action/config-routing-rule.js +232 -0
  66. package/es/blocklet/router/action/delete-domain-alias.js +99 -0
  67. package/es/blocklet/router/action/delete-rule.js +108 -0
  68. package/es/blocklet/router/action/update-rule.js +209 -0
  69. package/es/blocklet/router/domain-actions.js +64 -0
  70. package/es/blocklet/router/domain-status.js +88 -0
  71. package/es/blocklet/router/rule-actions.js +66 -0
  72. package/es/blocklet/router/rule-list.js +190 -0
  73. package/es/blocklet/router/util.js +131 -0
  74. package/es/blocklet/runtime-info.js +68 -0
  75. package/es/blocklet/status.js +91 -0
  76. package/es/blocklet/storage/action.js +134 -0
  77. package/es/blocklet/storage/backups.js +241 -0
  78. package/es/blocklet/storage/connect-to.js +373 -0
  79. package/es/blocklet/storage/connected.js +198 -0
  80. package/es/blocklet/storage/delete.js +113 -0
  81. package/es/blocklet/storage/disconnect.js +243 -0
  82. package/es/blocklet/storage/index.js +19 -0
  83. package/es/blocklet/storage/item.js +558 -0
  84. package/es/blocklet/storage/preview-nft.js +286 -0
  85. package/es/blocklet/transfer-owner.js +198 -0
  86. package/es/blocklet/types.js +18 -0
  87. package/es/blocklet/util.js +145 -0
  88. package/es/blocklet/version.js +141 -0
  89. package/es/card-selector.js +134 -0
  90. package/es/certificate.js +105 -0
  91. package/es/chain.js +13 -0
  92. package/es/click-to-copy.js +22 -0
  93. package/es/confirm.js +149 -0
  94. package/es/contexts/audit-log.js +152 -0
  95. package/es/contexts/blocklet.js +10 -0
  96. package/es/contexts/deleting-blocklets.js +70 -0
  97. package/es/contexts/node.js +17 -0
  98. package/es/contexts/session.js +8 -0
  99. package/es/contexts/team.js +10 -0
  100. package/es/delete-confirm.js +121 -0
  101. package/es/did-address.js +46 -0
  102. package/es/dot.js +14 -0
  103. package/es/exchange-passport.js +102 -0
  104. package/es/form/form-select-input.js +184 -0
  105. package/es/form/form-text-input.js +178 -0
  106. package/es/form/form-wrapper.js +88 -0
  107. package/es/form/input-triggers.js +98 -0
  108. package/es/form/required.js +8 -0
  109. package/es/hooks/blocklet.js +229 -0
  110. package/es/hooks/confirm.js +90 -0
  111. package/es/hooks/mobile-width.js +11 -0
  112. package/es/hooks/url-evaluation.js +155 -0
  113. package/es/hooks/use-app-logo.js +16 -0
  114. package/es/hooks/use-backup-progress.js +31 -0
  115. package/es/hooks/use-blocklet-info-for-connect-did-spaces.js +50 -0
  116. package/es/hooks/use-bundle-logo.js +27 -0
  117. package/es/hooks/use-navigation.js +347 -0
  118. package/es/hooks/use-passport-id.js +14 -0
  119. package/es/hooks/use-subscription.js +22 -0
  120. package/es/icons/empty-space-nft.svg +59 -0
  121. package/es/icons/empty-spaces-nft.svg +58 -0
  122. package/es/icons/long-arrow.svg +5 -0
  123. package/es/icons/space-connected.svg +3 -0
  124. package/es/icons/space-disconnect.svg +3 -0
  125. package/es/index.js +3 -0
  126. package/es/invitation/invitation-app.js +58 -0
  127. package/es/invitation/invitation-login.js +68 -0
  128. package/es/invitation/invitation-passport.js +144 -0
  129. package/es/invitation/invitation-receive.js +138 -0
  130. package/es/invitation/invitation-success.js +93 -0
  131. package/es/invitation/invitation-user.js +90 -0
  132. package/es/invitation/invitation.js +90 -0
  133. package/es/issue-passport.js +142 -0
  134. package/es/launch-blocklet/content-layout.js +58 -0
  135. package/es/launch-blocklet/page-header.js +43 -0
  136. package/es/layout/addon.js +114 -0
  137. package/es/layout/feedback.js +55 -0
  138. package/es/locales/en.js +1534 -0
  139. package/es/locales/index.js +9 -0
  140. package/es/locales/zh.js +1537 -0
  141. package/es/logs/clock.js +11 -0
  142. package/es/logs/download.js +132 -0
  143. package/es/logs/log-terminal.js +253 -0
  144. package/es/lost-passport.js +452 -0
  145. package/es/nav-logo.js +219 -0
  146. package/es/passport-tag.js +43 -0
  147. package/es/permission.js +57 -0
  148. package/es/relative-time.js +53 -0
  149. package/es/result-message.js +11 -0
  150. package/es/schema-form/color-input.js +98 -0
  151. package/es/schema-form/common-prop-types.js +13 -0
  152. package/es/schema-form/index.js +215 -0
  153. package/es/schema-form/passport-input.js +54 -0
  154. package/es/schema-form/text-input.js +57 -0
  155. package/es/store/add.js +179 -0
  156. package/es/store/delete.js +96 -0
  157. package/es/store/item.js +76 -0
  158. package/es/subscription.js +144 -0
  159. package/es/table-icons.js +34 -0
  160. package/es/table.js +52 -0
  161. package/es/tag.js +21 -0
  162. package/es/team/members/actions.js +89 -0
  163. package/es/team/members/index.js +636 -0
  164. package/es/team/members/invitations.js +188 -0
  165. package/es/team/members/invite-member.js +208 -0
  166. package/es/team/members/issue-passport.js +152 -0
  167. package/es/team/members/member.js +408 -0
  168. package/es/team/members/passport-issuances.js +155 -0
  169. package/es/team/members/passports.js +364 -0
  170. package/es/team/members/toggle-user-approval.js +122 -0
  171. package/es/team/members/transfer-node.js +256 -0
  172. package/es/team/members/util.js +14 -0
  173. package/es/team/passports/color.js +126 -0
  174. package/es/team/passports/detail.js +312 -0
  175. package/es/team/passports/index.js +282 -0
  176. package/es/team/passports/mutate-role.js +198 -0
  177. package/es/team/passports/trusted-factories.js +221 -0
  178. package/es/team/passports/trusted-factory.js +343 -0
  179. package/es/team/passports/trusted-issuer.js +296 -0
  180. package/es/team/passports/trusted-issuers.js +226 -0
  181. package/es/team/search-input.js +46 -0
  182. package/es/team/styles/dialog.js +72 -0
  183. package/es/team/styles/list-header.js +31 -0
  184. package/es/util/api.js +6 -0
  185. package/es/util/constants.js +2 -0
  186. package/es/util/index.js +598 -0
  187. package/es/util/mode.js +4 -0
  188. package/es/util/space-gateway.js +51 -0
  189. package/es/util/spaces.js +151 -0
  190. package/es/who-can-access/config.js +38 -0
  191. package/es/wrap-locale.js +15 -0
  192. package/lib/blocklet/component/space-connector.js +1 -1
  193. package/lib/blocklet/component/space-selector.js +1 -1
  194. package/lib/blocklet/storage/backups.js +1 -1
  195. package/lib/blocklet/storage/connect-to.js +1 -1
  196. package/lib/blocklet/storage/connected.js +1 -1
  197. package/lib/blocklet/storage/disconnect.js +1 -1
  198. package/lib/blocklet/storage/index.js +1 -1
  199. package/lib/blocklet/storage/item.js +1 -1
  200. package/lib/invitation/invitation-receive.js +1 -1
  201. package/lib/team/passports/trusted-factory.js +1 -1
  202. package/package.json +81 -18
@@ -0,0 +1,282 @@
1
+ import React, { useContext, useState } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import styled from '@emotion/styled';
4
+ import AddIcon from '@mui/icons-material/Add';
5
+ import Box from '@mui/material/Box';
6
+ import { LocaleContext } from '@arcblock/ux/lib/Locale/context';
7
+ import Button from '@arcblock/ux/lib/Button';
8
+ import SplitButton from '@arcblock/ux/lib/SplitButton';
9
+ import Spinner from '@mui/material/CircularProgress';
10
+ import EditIcon from '@arcblock/icons/lib/EditIcon';
11
+ import LockIcon from '@arcblock/icons/lib/LockIcon';
12
+ import ExternalIssuerIcon from '@arcblock/icons/lib/ExternalIssuerIcon';
13
+ import Toast from '@arcblock/ux/lib/Toast';
14
+ import { useNodeContext } from '../../contexts/node';
15
+ import { useTeamContext } from '../../contexts/team';
16
+ import { sleep, isProtectedRole, BlockletAdminRoles } from '../../util';
17
+ import Permission from '../../permission';
18
+ import SearchInput from '../search-input';
19
+ import ListHeader from '../styles/list-header';
20
+ import Detail from './detail';
21
+ import Color from './color';
22
+ import MutateRole from './mutate-role';
23
+ import TrustedIssuers from './trusted-issuers';
24
+ import TrustedFactories from './trusted-factories';
25
+ import { jsx as _jsx } from "react/jsx-runtime";
26
+ import { jsxs as _jsxs } from "react/jsx-runtime";
27
+ import { Fragment as _Fragment } from "react/jsx-runtime";
28
+ export default function PassportList({
29
+ createPassportSvg
30
+ }) {
31
+ const {
32
+ t
33
+ } = useContext(LocaleContext);
34
+ const {
35
+ api,
36
+ inService
37
+ } = useNodeContext();
38
+ const {
39
+ roles,
40
+ teamDid,
41
+ teamIssuerDid,
42
+ teamName,
43
+ refresh: refreshTeam,
44
+ enablePassportIssuance,
45
+ passportColor,
46
+ isNodeTeam
47
+ } = useTeamContext();
48
+ const [showCreate, setShowCreate] = useState(false);
49
+ const [updateForm, setUpdateForm] = useState(false);
50
+ const [showColor, setShowColor] = useState(false);
51
+ const [showTrustedIssuers, setShowTrustedIssuers] = useState(false);
52
+ const [showTrustedFactories, setShowTrustedFactories] = useState(false);
53
+ const [search, setSearch] = useState('');
54
+ const [loading, setLoading] = useState(false);
55
+ const toggleShowIssue = async e => {
56
+ e.stopPropagation();
57
+ if (loading) {
58
+ return;
59
+ }
60
+ setLoading(true);
61
+ try {
62
+ await api.configPassportIssuance({
63
+ input: {
64
+ teamDid,
65
+ enable: !enablePassportIssuance
66
+ }
67
+ });
68
+ refreshTeam();
69
+ await sleep(800);
70
+ Toast.success(t('common.configSuccess'));
71
+ setLoading(false);
72
+ } catch (error) {
73
+ Toast.error(error.message);
74
+ setLoading(false);
75
+ }
76
+ };
77
+ const filteredRoles = roles.filter(x => !search || x.title.includes(search) || x.name.includes(search));
78
+ return /*#__PURE__*/_jsxs(Div, {
79
+ children: [/*#__PURE__*/_jsxs(ListHeader, {
80
+ children: [/*#__PURE__*/_jsx("div", {
81
+ className: "left",
82
+ children: /*#__PURE__*/_jsx(SearchInput, {
83
+ placeholder: t('team.passport.search'),
84
+ value: search,
85
+ onChange: e => setSearch(e.target.value)
86
+ })
87
+ }), /*#__PURE__*/_jsx("div", {
88
+ className: "right",
89
+ children: /*#__PURE__*/_jsxs(Permission, {
90
+ permission: inService ? '' : 'mutate_team',
91
+ role: inService ? BlockletAdminRoles : [],
92
+ children: [/*#__PURE__*/_jsx(SplitButton, {
93
+ variant: "outlined",
94
+ menuButtonProps: {
95
+ 'data-cy': 'trusted-issuers-more'
96
+ },
97
+ menu: /*#__PURE__*/_jsxs(_Fragment, {
98
+ children: [/*#__PURE__*/_jsx(SplitButton.Item, {
99
+ onClick: () => setShowTrustedFactories(true),
100
+ "data-cy": "config-show-trusted-factories",
101
+ children: /*#__PURE__*/_jsxs(Box, {
102
+ children: [t('team.passport.configFactories'), /*#__PURE__*/_jsx(Box, {
103
+ fontSize: 12,
104
+ color: "#888",
105
+ children: t('team.passport.configFactoriesTip')
106
+ })]
107
+ })
108
+ }), /*#__PURE__*/_jsx(SplitButton.Item, {
109
+ "data-cy": "config-show-issue-passport",
110
+ onClick: toggleShowIssue,
111
+ children: /*#__PURE__*/_jsxs(Box, {
112
+ display: "flex",
113
+ alignItems: "center",
114
+ children: [loading && /*#__PURE__*/_jsx(Spinner, {
115
+ size: 16,
116
+ style: {
117
+ marginRight: 8
118
+ }
119
+ }), /*#__PURE__*/_jsxs(Box, {
120
+ children: [enablePassportIssuance ? t('team.passport.disableIssuance') : t('team.passport.enableIssuance'), /*#__PURE__*/_jsx(Box, {
121
+ fontSize: 12,
122
+ color: "#888",
123
+ children: enablePassportIssuance ? t('team.passport.disableIssuanceTip') : t('team.passport.enableIssuanceTip')
124
+ })]
125
+ })]
126
+ })
127
+ }), !isNodeTeam && /*#__PURE__*/_jsx(SplitButton.Item, {
128
+ onClick: () => setShowColor(true),
129
+ "data-cy": "config-passport-color",
130
+ children: /*#__PURE__*/_jsxs(Box, {
131
+ children: [t('team.passport.configColor'), /*#__PURE__*/_jsx(Box, {
132
+ fontSize: 12,
133
+ color: "#888",
134
+ children: t('team.passport.configColorTip')
135
+ })]
136
+ })
137
+ })]
138
+ }),
139
+ children: () => /*#__PURE__*/_jsxs(Button, {
140
+ variant: "outlined",
141
+ "data-cy": "config-trusted-issuers",
142
+ onClick: () => {
143
+ setShowTrustedIssuers(true);
144
+ },
145
+ children: [/*#__PURE__*/_jsx(ExternalIssuerIcon, {
146
+ style: {
147
+ fontSize: 16,
148
+ marginRight: 4
149
+ }
150
+ }), t('team.passport.trustedPassportIssuers')]
151
+ })
152
+ }), !isNodeTeam && /*#__PURE__*/_jsxs(Button, {
153
+ style: {
154
+ marginLeft: 16
155
+ },
156
+ variant: "contained",
157
+ edge: "end",
158
+ color: "primary",
159
+ "data-cy": "create-role",
160
+ onClick: () => setShowCreate(true),
161
+ children: [/*#__PURE__*/_jsx(AddIcon, {
162
+ style: {
163
+ fontSize: 16,
164
+ marginRight: 4
165
+ }
166
+ }), t('team.add')]
167
+ })]
168
+ })
169
+ })]
170
+ }), /*#__PURE__*/_jsx(Box, {
171
+ mt: 3
172
+ }), /*#__PURE__*/_jsx(Box, {
173
+ className: "list",
174
+ children: filteredRoles.map(role => /*#__PURE__*/_jsxs(Box, {
175
+ "data-cy": `passport-${role.name}`,
176
+ className: "item",
177
+ display: "flex",
178
+ alignItems: "center",
179
+ onClick: () => setUpdateForm(role),
180
+ children: [/*#__PURE__*/_jsxs(Box, {
181
+ display: "flex",
182
+ alignItems: "center",
183
+ children: [/*#__PURE__*/_jsx("div", {
184
+ style: {
185
+ width: 150
186
+ }
187
+ // eslint-disable-next-line react/no-danger
188
+ ,
189
+ dangerouslySetInnerHTML: {
190
+ __html: createPassportSvg({
191
+ title: role.title,
192
+ issuer: teamName,
193
+ issuerDid: teamIssuerDid,
194
+ ownerName: 'Your Name',
195
+ ownerDid: teamIssuerDid,
196
+ preferredColor: passportColor,
197
+ width: '150px'
198
+ })
199
+ }
200
+ }), /*#__PURE__*/_jsx(Box, {
201
+ ml: 3,
202
+ className: "title",
203
+ children: role.title
204
+ })]
205
+ }), /*#__PURE__*/_jsx(Box, {
206
+ className: "description",
207
+ children: role.description
208
+ }), /*#__PURE__*/_jsx(Permission, {
209
+ permission: inService ? '' : 'mutate_team',
210
+ role: inService ? BlockletAdminRoles : [],
211
+ children: /*#__PURE__*/_jsx("div", {
212
+ className: "action",
213
+ children: isProtectedRole(role.name) ? /*#__PURE__*/_jsx(LockIcon, {}) : /*#__PURE__*/_jsx(EditIcon, {})
214
+ })
215
+ })]
216
+ }, role.name))
217
+ }), showCreate && /*#__PURE__*/_jsx(MutateRole, {
218
+ teamDid: teamDid,
219
+ onCancel: () => setShowCreate(false),
220
+ onSuccess: () => {
221
+ setShowCreate(false);
222
+ refreshTeam();
223
+ }
224
+ }), updateForm && /*#__PURE__*/_jsx(Detail, {
225
+ onCancel: () => setUpdateForm(false),
226
+ onSuccess: () => {
227
+ setUpdateForm(false);
228
+ refreshTeam();
229
+ },
230
+ onDelete: () => {
231
+ setUpdateForm(false);
232
+ refreshTeam();
233
+ },
234
+ mode: "update",
235
+ roleName: updateForm.name,
236
+ item: updateForm
237
+ }), showTrustedIssuers && /*#__PURE__*/_jsx(TrustedIssuers, {
238
+ onCancel: () => setShowTrustedIssuers(false)
239
+ }), showTrustedFactories && /*#__PURE__*/_jsx(TrustedFactories, {
240
+ onCancel: () => setShowTrustedFactories(false)
241
+ }), showColor && /*#__PURE__*/_jsx(Color, {
242
+ onCancel: () => setShowColor(false),
243
+ onSuccess: () => setShowColor(false)
244
+ })]
245
+ });
246
+ }
247
+ const Div = styled.div`
248
+ .list {
249
+ .item {
250
+ padding: 12px;
251
+ margin: 12px -12px;
252
+ cursor: pointer;
253
+ transition: box-shadow 0.4s;
254
+ &:hover {
255
+ box-shadow: 0 0 10px 4px rgba(0, 0, 0, 0.1);
256
+ }
257
+ }
258
+
259
+ .title {
260
+ font-weight: 400;
261
+ font-size: 18px;
262
+ width: 80px;
263
+ line-height: 21px;
264
+ color: #222222;
265
+ }
266
+
267
+ .description {
268
+ flex: 1;
269
+ margin-left: 64px;
270
+ color: #999999;
271
+ }
272
+
273
+ .action {
274
+ color: #bfbfbf;
275
+ fill: #bfbfbf;
276
+ }
277
+ }
278
+ `;
279
+ PassportList.propTypes = {
280
+ createPassportSvg: PropTypes.func.isRequired
281
+ };
282
+ PassportList.defaultProps = {};
@@ -0,0 +1,198 @@
1
+ import { useState } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import md5 from 'md5';
4
+ import Dialog from '@arcblock/ux/lib/Dialog';
5
+ import Spinner from '@mui/material/CircularProgress';
6
+ import DialogContentText from '@mui/material/DialogContentText';
7
+ import Typography from '@mui/material/Typography';
8
+ import TextField from '@mui/material/TextField';
9
+ import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
10
+ import Button from '@arcblock/ux/lib/Button';
11
+ import Alert from '@arcblock/ux/lib/Alert';
12
+ import { useNodeContext } from '../../contexts/node';
13
+ import { formatError } from '../../util';
14
+ import { jsx as _jsx } from "react/jsx-runtime";
15
+ import { jsxs as _jsxs } from "react/jsx-runtime";
16
+ import { Fragment as _Fragment } from "react/jsx-runtime";
17
+ export default function MutateRole({
18
+ teamDid,
19
+ onCancel,
20
+ onSuccess,
21
+ onError,
22
+ mode,
23
+ item
24
+ }) {
25
+ const {
26
+ api
27
+ } = useNodeContext();
28
+ const [loading, setLoading] = useState(false);
29
+ const [error, setError] = useState('');
30
+ const {
31
+ t
32
+ } = useLocaleContext();
33
+ const [title, setTitle] = useState(item.title || '');
34
+ const [description, setDescription] = useState(item.description || '');
35
+ const onCreate = async () => {
36
+ const _title = title.trim();
37
+ if (!_title) {
38
+ setError(t('team.passport.error.titleEmpty'));
39
+ return;
40
+ }
41
+ if (_title.length > 64) {
42
+ setError(t('team.passport.error.titleTooLong', {
43
+ length: 64
44
+ }));
45
+ return;
46
+ }
47
+ const desc = description.replace(/\n/g, ' ');
48
+ if (!desc) {
49
+ setError(t('team.passport.error.descriptionEmpty'));
50
+ return;
51
+ }
52
+ const name = mode === 'create' ? md5(_title) : item.name;
53
+ setError(null);
54
+ setLoading(true);
55
+ try {
56
+ if (mode === 'create') {
57
+ await api.createRole({
58
+ input: {
59
+ teamDid,
60
+ name,
61
+ title: _title,
62
+ description: desc
63
+ }
64
+ });
65
+ } else {
66
+ await api.updateRole({
67
+ input: {
68
+ teamDid,
69
+ role: {
70
+ name,
71
+ title: _title,
72
+ description: desc
73
+ }
74
+ }
75
+ });
76
+ }
77
+ onSuccess();
78
+ } catch (err) {
79
+ const errMsg = formatError(err);
80
+ setError(errMsg);
81
+ onError(err);
82
+ } finally {
83
+ setLoading(false);
84
+ }
85
+ };
86
+ const body = /*#__PURE__*/_jsxs("div", {
87
+ children: [mode === 'update' && /*#__PURE__*/_jsx(Typography, {
88
+ component: "div",
89
+ style: {
90
+ paddingTop: 24
91
+ },
92
+ children: /*#__PURE__*/_jsx(TextField, {
93
+ label: "ID",
94
+ autoComplete: "off",
95
+ variant: "outlined",
96
+ name: "url",
97
+ "data-cy": "mutate-role-input-name",
98
+ fullWidth: true,
99
+ autoFocus: true,
100
+ value: item.name,
101
+ disabled: true
102
+ })
103
+ }), /*#__PURE__*/_jsx(Typography, {
104
+ component: "div",
105
+ style: {
106
+ marginTop: 24
107
+ },
108
+ children: /*#__PURE__*/_jsx(TextField, {
109
+ label: t('common.title'),
110
+ autoComplete: "off",
111
+ variant: "outlined",
112
+ name: "title",
113
+ "data-cy": "mutate-role-input-title",
114
+ fullWidth: true,
115
+ autoFocus: true,
116
+ value: title,
117
+ onChange: e => {
118
+ setError(null);
119
+ setTitle(e.target.value);
120
+ },
121
+ disabled: mode === 'update' || loading,
122
+ helperText: t('team.passport.create.titleTip')
123
+ })
124
+ }), /*#__PURE__*/_jsx(Typography, {
125
+ component: "div",
126
+ style: {
127
+ marginTop: 24,
128
+ marginBottom: 24
129
+ },
130
+ children: /*#__PURE__*/_jsx(TextField, {
131
+ label: t('common.description'),
132
+ autoComplete: "off",
133
+ variant: "outlined",
134
+ name: "description",
135
+ "data-cy": "mutate-role-input-description",
136
+ fullWidth: true,
137
+ autoFocus: true,
138
+ value: description,
139
+ onChange: e => {
140
+ setError(null);
141
+ setDescription(e.target.value);
142
+ },
143
+ disabled: loading,
144
+ multiline: true,
145
+ rows: 3
146
+ })
147
+ })]
148
+ });
149
+ return /*#__PURE__*/_jsxs(Dialog, {
150
+ title: mode === 'create' ? t('team.passport.create.title') : '',
151
+ fullWidth: true,
152
+ open: true,
153
+ onClose: onCancel,
154
+ showCloseButton: false,
155
+ actions: /*#__PURE__*/_jsxs(_Fragment, {
156
+ children: [/*#__PURE__*/_jsx(Button, {
157
+ onClick: onCancel,
158
+ color: "inherit",
159
+ children: t('common.cancel')
160
+ }), /*#__PURE__*/_jsxs(Button, {
161
+ "data-cy": "mutate-role-confirm",
162
+ onClick: onCreate,
163
+ color: "primary",
164
+ disabled: loading,
165
+ variant: "contained",
166
+ autoFocus: true,
167
+ children: [loading && /*#__PURE__*/_jsx(Spinner, {
168
+ size: 16
169
+ }), mode === 'create' ? t('common.create') : t('common.update')]
170
+ })]
171
+ }),
172
+ children: [/*#__PURE__*/_jsx(DialogContentText, {
173
+ component: "div",
174
+ children: body
175
+ }), !!error && /*#__PURE__*/_jsx(Alert, {
176
+ type: "error",
177
+ variant: "icon",
178
+ style: {
179
+ width: '100%',
180
+ margin: 0
181
+ },
182
+ children: error
183
+ })]
184
+ });
185
+ }
186
+ MutateRole.propTypes = {
187
+ teamDid: PropTypes.string.isRequired,
188
+ onCancel: PropTypes.func.isRequired,
189
+ onSuccess: PropTypes.func.isRequired,
190
+ onError: PropTypes.func,
191
+ mode: PropTypes.oneOf(['create', 'update']),
192
+ item: PropTypes.object
193
+ };
194
+ MutateRole.defaultProps = {
195
+ onError: () => {},
196
+ mode: 'create',
197
+ item: {}
198
+ };
@@ -0,0 +1,221 @@
1
+ import React, { useState } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import styled from '@emotion/styled';
4
+ import cloneDeep from 'lodash/cloneDeep';
5
+ import Dialog from '@arcblock/ux/lib/Dialog';
6
+ import Box from '@mui/material/Box';
7
+ import AddIcon from '@mui/icons-material/Add';
8
+ import IconButton from '@mui/material/IconButton';
9
+ import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
10
+ import Button from '@arcblock/ux/lib/Button';
11
+ import Empty from '@arcblock/ux/lib/Empty';
12
+ import Tag from '@arcblock/ux/lib/Tag';
13
+ import EditIcon from '@arcblock/icons/lib/EditIcon';
14
+ import DeleteIcon from '@arcblock/icons/lib/DeleteIcon';
15
+ import Toast from '@arcblock/ux/lib/Toast';
16
+ import DidAddress from '../../did-address';
17
+ import { withPermission } from '../../permission';
18
+ import { useNodeContext } from '../../contexts/node';
19
+ import { useTeamContext } from '../../contexts/team';
20
+ import { sleep, BlockletAdminRoles } from '../../util';
21
+ import Confirm from '../../confirm';
22
+ import ListHeader from '../styles/list-header';
23
+ import SearchInput from '../search-input';
24
+ import TrustedFactory from './trusted-factory';
25
+ import { jsx as _jsx } from "react/jsx-runtime";
26
+ import { jsxs as _jsxs } from "react/jsx-runtime";
27
+ function TrustedFactories({
28
+ onCancel,
29
+ hasPermission
30
+ }) {
31
+ const {
32
+ api
33
+ } = useNodeContext();
34
+ const {
35
+ teamDid,
36
+ trustedFactories
37
+ } = useTeamContext();
38
+ const {
39
+ t
40
+ } = useLocaleContext();
41
+ const [delConfirm, setDelConfirm] = useState(null);
42
+ const [loading, setLoading] = useState(false);
43
+ const [trustedFactory, setTrustedFactory] = useState(null);
44
+ const [search, setSearch] = useState('');
45
+ const deleteTrustedFactory = async did => {
46
+ if (loading) {
47
+ return;
48
+ }
49
+ try {
50
+ setLoading(true);
51
+ await api.configTrustedFactories({
52
+ input: {
53
+ teamDid,
54
+ trustedFactories: trustedFactories.filter(x => x.factoryAddress !== did)
55
+ }
56
+ });
57
+ await sleep(800);
58
+ setLoading(false);
59
+ Toast.success(t('common.saveSuccess'));
60
+ setDelConfirm(null);
61
+ } catch (err) {
62
+ setLoading(false);
63
+ Toast.error(err.message);
64
+ }
65
+ };
66
+ const filterFactories = trustedFactories.filter(x => !search || x.factoryAddress.toLowerCase().includes(search.toLowerCase()));
67
+ return /*#__PURE__*/_jsxs(Dialog, {
68
+ title: t('team.passport.trustedFactories'),
69
+ open: true,
70
+ onClose: onCancel,
71
+ fullWidth: true,
72
+ PaperProps: {
73
+ style: {
74
+ minHeight: '80vh'
75
+ }
76
+ },
77
+ children: [/*#__PURE__*/_jsx(Div, {
78
+ children: /*#__PURE__*/_jsxs("div", {
79
+ className: "dialog-content",
80
+ children: [/*#__PURE__*/_jsx("div", {
81
+ className: "dialog-h1",
82
+ children: t('team.passport.trustedFactoriesTip')
83
+ }), /*#__PURE__*/_jsxs(Box, {
84
+ component: ListHeader,
85
+ mt: 3,
86
+ children: [/*#__PURE__*/_jsx("div", {
87
+ className: "left",
88
+ children: /*#__PURE__*/_jsx(SearchInput, {
89
+ placeholder: t('team.passport.searchFactoryAddress'),
90
+ value: search,
91
+ onChange: e => setSearch(e.target.value)
92
+ })
93
+ }), /*#__PURE__*/_jsx("div", {
94
+ className: "right",
95
+ children: hasPermission && /*#__PURE__*/_jsxs(Button, {
96
+ variant: "contained",
97
+ color: "primary",
98
+ size: "small",
99
+ "data-cy": "add-trusted-factory",
100
+ onClick: () => setTrustedFactory({
101
+ mode: 'add'
102
+ }),
103
+ children: [/*#__PURE__*/_jsx(AddIcon, {
104
+ style: {
105
+ fontSize: 16,
106
+ marginRight: 4
107
+ }
108
+ }), t('team.add')]
109
+ })
110
+ })]
111
+ }), /*#__PURE__*/_jsxs("div", {
112
+ className: "list",
113
+ children: [filterFactories.map(x => /*#__PURE__*/_jsxs(Box, {
114
+ display: "flex",
115
+ alignItems: "center",
116
+ justifyContent: "space-between",
117
+ mt: "20px",
118
+ children: [/*#__PURE__*/_jsxs(Box, {
119
+ flexGrow: 1,
120
+ children: [/*#__PURE__*/_jsx(DidAddress, {
121
+ copyable: false,
122
+ did: x.factoryAddress,
123
+ size: 16,
124
+ showDidLogo: false
125
+ }), !!x.remark && /*#__PURE__*/_jsx(Box, {
126
+ fontSize: 12,
127
+ maxWidth: "300px",
128
+ children: x.remark
129
+ })]
130
+ }), /*#__PURE__*/_jsx(Box, {
131
+ color: "gray",
132
+ mr: "24px",
133
+ children: /*#__PURE__*/_jsx(Tag, {
134
+ type: "success",
135
+ children: x.passport.role
136
+ })
137
+ }), /*#__PURE__*/_jsxs(Box, {
138
+ flexShrink: 0,
139
+ display: "flex",
140
+ alignItems: "center",
141
+ children: [/*#__PURE__*/_jsx(IconButton, {
142
+ onClick: () => setTrustedFactory({
143
+ mode: 'update',
144
+ data: cloneDeep(x)
145
+ }),
146
+ "data-cy": "edit-trusted-factory",
147
+ size: "large",
148
+ children: /*#__PURE__*/_jsx(EditIcon, {})
149
+ }), /*#__PURE__*/_jsx(IconButton, {
150
+ "data-cy": "delete-trusted-factory",
151
+ onClick: () => setDelConfirm({
152
+ title: t('common.delete'),
153
+ description: t('common.delConfirmDescription', {
154
+ data: x.factoryAddress
155
+ }),
156
+ confirm: t('common.delConfirm'),
157
+ cancel: t('common.cancel'),
158
+ onConfirm: () => deleteTrustedFactory(x.factoryAddress),
159
+ onCancel: () => {
160
+ setLoading(false);
161
+ setDelConfirm(null);
162
+ }
163
+ }),
164
+ size: "large",
165
+ children: /*#__PURE__*/_jsx(DeleteIcon, {})
166
+ })]
167
+ })]
168
+ }, x.factoryAddress)), !trustedFactories.length && /*#__PURE__*/_jsx(Empty, {
169
+ children: t('common.empty')
170
+ })]
171
+ })]
172
+ })
173
+ }), trustedFactory && /*#__PURE__*/_jsx(TrustedFactory, {
174
+ data: trustedFactory.data,
175
+ trustedFactories: cloneDeep(trustedFactories),
176
+ onCancel: () => setTrustedFactory(null),
177
+ onSuccess: () => {
178
+ setTrustedFactory(null);
179
+ }
180
+ }), delConfirm && /*#__PURE__*/_jsx(Confirm, {
181
+ title: delConfirm.title,
182
+ description: delConfirm.description,
183
+ confirm: delConfirm.confirm,
184
+ cancel: delConfirm.cancel,
185
+ params: delConfirm.params,
186
+ onConfirm: delConfirm.onConfirm,
187
+ onCancel: delConfirm.onCancel
188
+ })]
189
+ });
190
+ }
191
+ TrustedFactories.propTypes = {
192
+ onCancel: PropTypes.func.isRequired,
193
+ hasPermission: PropTypes.bool
194
+ };
195
+ TrustedFactories.defaultProps = {
196
+ hasPermission: false
197
+ };
198
+ const TrustedFactoriesInDaemon = withPermission(TrustedFactories, 'mutate_team');
199
+ const TrustedFactoriesInService = withPermission(TrustedFactories, '', BlockletAdminRoles);
200
+ export default function TrustedFactoriesWithPermission(props) {
201
+ const {
202
+ inService
203
+ } = useNodeContext();
204
+ if (inService) {
205
+ return /*#__PURE__*/_jsx(TrustedFactoriesInService, {
206
+ ...props
207
+ });
208
+ }
209
+ return /*#__PURE__*/_jsx(TrustedFactoriesInDaemon, {
210
+ ...props
211
+ });
212
+ }
213
+ const Div = styled.div`
214
+ .list {
215
+ .MuiIconButton-root {
216
+ svg {
217
+ fill: #bfbfbf;
218
+ }
219
+ }
220
+ }
221
+ `;