@abtnode/ux 1.8.26 → 1.8.27

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 (62) hide show
  1. package/lib/actions.js +137 -0
  2. package/lib/blocklet/actions.js +501 -0
  3. package/lib/blocklet/audit-logs.js +226 -0
  4. package/lib/blocklet/avatar.js +123 -0
  5. package/lib/blocklet/blocklet-source.js +69 -0
  6. package/lib/blocklet/component/configuration.js +150 -0
  7. package/lib/blocklet/component/delete.js +138 -0
  8. package/lib/blocklet/component/environment.js +334 -0
  9. package/lib/blocklet/component/index.js +837 -0
  10. package/lib/blocklet/component/setting.js +174 -0
  11. package/lib/blocklet/configuration.js +531 -0
  12. package/lib/blocklet/disk-info.js +115 -0
  13. package/lib/blocklet/icons.js +36 -0
  14. package/lib/blocklet/log.js +70 -0
  15. package/lib/blocklet/mode.js +47 -0
  16. package/lib/blocklet/overview.js +218 -0
  17. package/lib/blocklet/runtime-info.js +111 -0
  18. package/lib/blocklet/status.js +125 -0
  19. package/lib/blocklet/util.js +141 -0
  20. package/lib/blocklet/version.js +216 -0
  21. package/lib/click-to-copy.js +51 -0
  22. package/lib/confirm.js +175 -0
  23. package/lib/contexts/audit-log.js +155 -0
  24. package/lib/contexts/deleting-blocklets.js +91 -0
  25. package/lib/contexts/node.js +34 -0
  26. package/lib/contexts/session.js +22 -0
  27. package/lib/contexts/team.js +22 -0
  28. package/lib/did-address.js +95 -0
  29. package/lib/dot.js +25 -0
  30. package/lib/hooks/mobile-width.js +24 -0
  31. package/lib/icons/long-arrow.svg +5 -0
  32. package/lib/locales/en.js +1046 -38
  33. package/lib/locales/zh.js +1049 -36
  34. package/lib/logs/clock.js +25 -0
  35. package/lib/logs/log-terminal.js +198 -0
  36. package/lib/passport-tag.js +58 -0
  37. package/lib/permission.js +84 -0
  38. package/lib/relative-time.js +74 -0
  39. package/lib/table-icons.js +59 -0
  40. package/lib/table.js +19 -0
  41. package/lib/tag.js +48 -0
  42. package/lib/team/members/actions.js +115 -0
  43. package/lib/team/members/index.js +544 -0
  44. package/lib/team/members/invitations.js +229 -0
  45. package/lib/team/members/invite-member.js +241 -0
  46. package/lib/team/members/issue-passport.js +178 -0
  47. package/lib/team/members/member.js +336 -0
  48. package/lib/team/members/passport-issuances.js +181 -0
  49. package/lib/team/members/passports.js +377 -0
  50. package/lib/team/members/toggle-user-approval.js +154 -0
  51. package/lib/team/members/transfer-node.js +295 -0
  52. package/lib/team/members/util.js +27 -0
  53. package/lib/team/passports/detail.js +304 -0
  54. package/lib/team/passports/index.js +256 -0
  55. package/lib/team/passports/mutate-role.js +230 -0
  56. package/lib/team/passports/trusted-issuer.js +339 -0
  57. package/lib/team/passports/trusted-issuers.js +284 -0
  58. package/lib/team/search-input.js +51 -0
  59. package/lib/team/styles/dialog.js +19 -0
  60. package/lib/team/styles/list-header.js +19 -0
  61. package/lib/util/index.js +642 -6
  62. package/package.json +32 -9
@@ -0,0 +1,174 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = ComponentSettingWithPermission;
7
+
8
+ var _react = require("react");
9
+
10
+ var _styled = _interopRequireDefault(require("@emotion/styled"));
11
+
12
+ var _propTypes = _interopRequireDefault(require("prop-types"));
13
+
14
+ var _Box = _interopRequireDefault(require("@mui/material/Box"));
15
+
16
+ var _context = require("@arcblock/ux/lib/Locale/context");
17
+
18
+ var _toast = _interopRequireDefault(require("../../toast"));
19
+
20
+ var _formTextInput = _interopRequireDefault(require("../../form/form-text-input"));
21
+
22
+ var _node = require("../../contexts/node");
23
+
24
+ var _permission = require("../../permission");
25
+
26
+ var _util = require("../../util");
27
+
28
+ var _jsxRuntime = require("react/jsx-runtime");
29
+
30
+ var _templateObject;
31
+
32
+ const _excluded = ["blocklet", "ancestors", "hasPermission"];
33
+
34
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
35
+
36
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
37
+
38
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
39
+
40
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
41
+
42
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
43
+
44
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
45
+
46
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
47
+
48
+ function ComponentSetting(_ref) {
49
+ let {
50
+ blocklet,
51
+ ancestors,
52
+ hasPermission
53
+ } = _ref,
54
+ rest = _objectWithoutProperties(_ref, _excluded);
55
+
56
+ const {
57
+ t
58
+ } = (0, _context.useLocaleContext)();
59
+ const {
60
+ api
61
+ } = (0, _node.useNodeContext)();
62
+ const rootDid = ancestors.map(x => x.meta.did)[0];
63
+ const [loading, setLoading] = (0, _react.useState)('');
64
+ const isDev = (0, _util.isBlockletDev)(blocklet);
65
+ const disabled = isDev || loading || !hasPermission;
66
+
67
+ if (!rootDid) {
68
+ return null;
69
+ }
70
+
71
+ if (blocklet.status === 'unknown' && (0, _util.isInstalling)(blocklet.status)) {
72
+ return null;
73
+ }
74
+
75
+ const onSubmitTitle = async value => {
76
+ setLoading(true);
77
+
78
+ try {
79
+ setLoading(false);
80
+ await api.updateComponentTitle({
81
+ input: {
82
+ rootDid,
83
+ did: blocklet.meta.did,
84
+ title: value
85
+ }
86
+ });
87
+ } catch (err) {
88
+ setLoading(false);
89
+ err.message = (0, _util.formatError)(err);
90
+
91
+ _toast.default.error(err.message);
92
+
93
+ throw err;
94
+ }
95
+ };
96
+
97
+ const onSubmitMountPoint = async value => {
98
+ setLoading(true);
99
+
100
+ try {
101
+ await api.updateComponentMountPoint({
102
+ input: {
103
+ rootDid,
104
+ did: blocklet.meta.did,
105
+ mountPoint: value
106
+ }
107
+ });
108
+ setLoading(false);
109
+ } catch (err) {
110
+ setLoading(false);
111
+ err.message = (0, _util.formatError)(err);
112
+
113
+ _toast.default.error(err.message);
114
+
115
+ throw err;
116
+ }
117
+ };
118
+
119
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(Div, _objectSpread(_objectSpread({
120
+ component: "div"
121
+ }, rest), {}, {
122
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
123
+ mt: 3,
124
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_formTextInput.default, {
125
+ label: t('common.title'),
126
+ style: {
127
+ marginTop: -24
128
+ },
129
+ disabled: loading || disabled,
130
+ loading: loading,
131
+ required: true,
132
+ initialValue: blocklet.meta.title,
133
+ onSubmit: onSubmitTitle
134
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_formTextInput.default, {
135
+ label: t('blocklet.component.mountPoint'),
136
+ style: {
137
+ marginTop: -24
138
+ },
139
+ disabled: loading || disabled,
140
+ loading: loading,
141
+ required: true,
142
+ initialValue: blocklet.mountPoint,
143
+ onSubmit: onSubmitMountPoint
144
+ })]
145
+ })
146
+ }));
147
+ }
148
+
149
+ const ComponentSettingInDaemon = (0, _permission.withPermission)(ComponentSetting, 'mutate_blocklet');
150
+ const ComponentSettingInService = (0, _permission.withPermission)(ComponentSetting, '', _util.BlockletAdminRoles);
151
+
152
+ function ComponentSettingWithPermission(props) {
153
+ const {
154
+ inService
155
+ } = (0, _node.useNodeContext)();
156
+
157
+ if (inService) {
158
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(ComponentSettingInService, _objectSpread({}, props));
159
+ }
160
+
161
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(ComponentSettingInDaemon, _objectSpread({}, props));
162
+ }
163
+
164
+ ComponentSetting.propTypes = {
165
+ blocklet: _propTypes.default.object.isRequired,
166
+ ancestors: _propTypes.default.array,
167
+ hasPermission: _propTypes.default.bool
168
+ };
169
+ ComponentSetting.defaultProps = {
170
+ ancestors: [],
171
+ hasPermission: false
172
+ };
173
+
174
+ const Div = _styled.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral([""])));
@@ -0,0 +1,531 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = BlockletEnvironmentWithPermission;
7
+
8
+ var _react = require("react");
9
+
10
+ var _styled = _interopRequireDefault(require("@emotion/styled"));
11
+
12
+ var _propTypes = _interopRequireDefault(require("prop-types"));
13
+
14
+ var _get = _interopRequireDefault(require("lodash/get"));
15
+
16
+ var _omit = _interopRequireDefault(require("lodash/omit"));
17
+
18
+ var _TextField = _interopRequireDefault(require("@mui/material/TextField"));
19
+
20
+ var _Box = _interopRequireDefault(require("@mui/material/Box"));
21
+
22
+ var _MenuItem = _interopRequireDefault(require("@mui/material/MenuItem"));
23
+
24
+ var _useTheme = _interopRequireDefault(require("@mui/material/styles/useTheme"));
25
+
26
+ var _Switch = _interopRequireDefault(require("@mui/material/Switch"));
27
+
28
+ var _Divider = _interopRequireDefault(require("@mui/material/Divider"));
29
+
30
+ var _context = require("@arcblock/ux/lib/Locale/context");
31
+
32
+ var _constant = require("@blocklet/constant");
33
+
34
+ var _util = require("@blocklet/meta/lib/util");
35
+
36
+ var _toast = _interopRequireDefault(require("../toast"));
37
+
38
+ var _schemaForm = _interopRequireDefault(require("../schema-form"));
39
+
40
+ var _config = _interopRequireDefault(require("../who-can-access/config"));
41
+
42
+ var _node = require("../contexts/node");
43
+
44
+ var _util2 = require("../util");
45
+
46
+ var _permission = require("../permission");
47
+
48
+ var _jsxRuntime = require("react/jsx-runtime");
49
+
50
+ var _templateObject, _templateObject2;
51
+
52
+ const _excluded = ["blocklet", "onUpdate", "hasPermission"],
53
+ _excluded2 = ["value"];
54
+
55
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
56
+
57
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
58
+
59
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
60
+
61
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
62
+
63
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
64
+
65
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
66
+
67
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
68
+
69
+ function BlockletEnvironment(_ref) {
70
+ var _blocklet$settings;
71
+
72
+ let {
73
+ blocklet,
74
+ onUpdate,
75
+ hasPermission
76
+ } = _ref,
77
+ rest = _objectWithoutProperties(_ref, _excluded);
78
+
79
+ const node = (0, _node.useNodeContext)();
80
+ const {
81
+ t,
82
+ locale
83
+ } = (0, _react.useContext)(_context.LocaleContext);
84
+ const [cpuCores, setCpuCores] = (0, _react.useState)('');
85
+ const [loading, setLoading] = (0, _react.useState)('');
86
+ const whoCanAccess = (0, _util.getWhoCanAccess)(blocklet);
87
+ const publicToStore = blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$settings = blocklet.settings) === null || _blocklet$settings === void 0 ? void 0 : _blocklet$settings.publicToStore;
88
+ const theme = (0, _useTheme.default)();
89
+ const [editingItem, setEditingItem] = (0, _react.useState)(null);
90
+ const disabled = loading || !hasPermission;
91
+ const {
92
+ inService,
93
+ ws: {
94
+ useSubscription
95
+ }
96
+ } = node;
97
+ const clusterMode = (0, _get.default)(blocklet.meta, 'capabilities.clusterMode', false);
98
+ useSubscription('system.info', res => {
99
+ if (clusterMode) {
100
+ setCpuCores((0, _get.default)(res, 'cpu.cores', ''));
101
+ }
102
+ });
103
+
104
+ if ((0, _util2.isInstalling)(blocklet.status)) {
105
+ return null;
106
+ }
107
+
108
+ const WalletTypes = [{
109
+ label: 'DID',
110
+ value: 'default'
111
+ }, {
112
+ label: 'ETH',
113
+ value: 'eth'
114
+ }]; // configurable blocklet environment
115
+
116
+ const customType = blocklet.environments.find(x => x.key === 'BLOCKLET_WALLET_TYPE');
117
+ const customDelete = blocklet.environments.find(x => x.key === 'BLOCKLET_DELETABLE');
118
+ const deletable = !customDelete || customDelete.value === 'yes';
119
+ const customColor = blocklet.environments.find(x => x.key === 'BLOCKLET_PASSPORT_COLOR');
120
+ const customUrl = blocklet.environments.find(x => x.key === 'BLOCKLET_APP_URL');
121
+ const customLogo = blocklet.environments.find(x => x.key === 'BLOCKLET_APP_LOGO');
122
+ const configurableEnvs = [{
123
+ key: _constant.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_NAME,
124
+ description: t('blocklet.config.name'),
125
+ value: blocklet.environments.find(x => x.key === 'BLOCKLET_APP_NAME').value
126
+ }, {
127
+ key: _constant.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_DESCRIPTION,
128
+ description: t('blocklet.config.description'),
129
+ value: blocklet.environments.find(x => x.key === 'BLOCKLET_APP_DESCRIPTION').value
130
+ }, {
131
+ key: _constant.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_PASSPORT_COLOR,
132
+ description: t('blocklet.config.passportColor'),
133
+ value: customColor ? customColor.value : 'auto',
134
+ componentType: 'passport',
135
+ componentProps: {
136
+ blocklet
137
+ }
138
+ }, {
139
+ key: _constant.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_URL,
140
+ description: t('blocklet.config.appUrl'),
141
+ value: customUrl ? customUrl.value : ''
142
+ }, {
143
+ key: _constant.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_LOGO,
144
+ description: t('blocklet.config.logo'),
145
+ value: customLogo ? customLogo.value : ''
146
+ }];
147
+
148
+ if (clusterMode) {
149
+ const exist = blocklet.configs.find(x => x.key === _constant.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_CLUSTER_SIZE);
150
+ const value = exist ? exist.value : cpuCores;
151
+ configurableEnvs.push({
152
+ key: _constant.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_CLUSTER_SIZE,
153
+ description: t('blocklet.config.clusterSize'),
154
+ value,
155
+ cpuCores
156
+ });
157
+ }
158
+
159
+ const defaultValue = {};
160
+ const schemaList = configurableEnvs.map(item => {
161
+ const {
162
+ value
163
+ } = item,
164
+ props = _objectWithoutProperties(item, _excluded2);
165
+
166
+ defaultValue[item.key] = value;
167
+ return _objectSpread({}, props);
168
+ });
169
+
170
+ const onWhoCanAccessChange = async e => {
171
+ if (loading) {
172
+ return;
173
+ }
174
+
175
+ setLoading(true);
176
+
177
+ try {
178
+ const {
179
+ value
180
+ } = e.target;
181
+ const {
182
+ blocklet: data
183
+ } = await node.api.updateWhoCanAccess({
184
+ input: {
185
+ did: blocklet.meta.did,
186
+ whoCanAccess: value
187
+ }
188
+ });
189
+ onUpdate(data);
190
+ } catch (err) {
191
+ _toast.default.error(err.message);
192
+ } finally {
193
+ setLoading(false);
194
+ }
195
+ };
196
+
197
+ const onPublicToStoreChange = async e => {
198
+ if (loading) {
199
+ return;
200
+ }
201
+
202
+ setLoading(true);
203
+
204
+ try {
205
+ const {
206
+ checked
207
+ } = e.target;
208
+ const {
209
+ blocklet: data
210
+ } = await node.api.configPublicToStore({
211
+ input: {
212
+ did: blocklet.meta.did,
213
+ publicToStore: checked
214
+ }
215
+ });
216
+ onUpdate(data);
217
+ } catch (err) {
218
+ _toast.default.error(err.message);
219
+ } finally {
220
+ setLoading(false);
221
+ }
222
+ };
223
+
224
+ const iconStyle = {
225
+ marginRight: 4,
226
+ fontSize: 18,
227
+ verticalAlign: 'text-bottom',
228
+ color: theme.palette.text.secondary
229
+ };
230
+
231
+ const onSubmitConfig = async value => {
232
+ if (value.key === _constant.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_CLUSTER_SIZE) {
233
+ const errMessage = (0, _util2.isValidClusterSize)(value);
234
+
235
+ if (errMessage) {
236
+ _toast.default.error(errMessage);
237
+
238
+ return;
239
+ }
240
+ }
241
+
242
+ const params = [_objectSpread(_objectSpread({}, (0, _omit.default)(editingItem, ['childDid', 'componentType', 'componentProps'])), {}, {
243
+ value,
244
+ custom: true
245
+ })];
246
+
247
+ try {
248
+ setLoading(true);
249
+ const {
250
+ blocklet: data
251
+ } = await node.api.configBlocklet({
252
+ input: {
253
+ did: blocklet.meta.did,
254
+ configs: params
255
+ }
256
+ });
257
+ onUpdate(data);
258
+ } catch (err) {
259
+ _toast.default.error(err.message);
260
+ } finally {
261
+ setLoading(false);
262
+ }
263
+ };
264
+
265
+ const onDeletableChange = async e => {
266
+ if (loading) {
267
+ return;
268
+ }
269
+
270
+ setLoading(true);
271
+
272
+ try {
273
+ const {
274
+ checked
275
+ } = e.target;
276
+ const {
277
+ blocklet: data
278
+ } = await node.api.configBlocklet({
279
+ input: {
280
+ did: blocklet.meta.did,
281
+ configs: [{
282
+ key: _constant.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_DELETABLE,
283
+ value: checked ? 'no' : 'yes',
284
+ custom: true
285
+ }]
286
+ }
287
+ });
288
+ onUpdate(data);
289
+ } catch (err) {
290
+ _toast.default.error(err.message);
291
+ } finally {
292
+ setLoading(false);
293
+ }
294
+ };
295
+
296
+ const onWalletTypeChange = async e => {
297
+ if (loading) {
298
+ return;
299
+ }
300
+
301
+ setLoading(true);
302
+
303
+ try {
304
+ const {
305
+ value
306
+ } = e.target;
307
+ const {
308
+ blocklet: data
309
+ } = await node.api.configBlocklet({
310
+ input: {
311
+ did: blocklet.meta.did,
312
+ configs: [{
313
+ key: _constant.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_WALLET_TYPE,
314
+ value,
315
+ custom: true
316
+ }]
317
+ }
318
+ });
319
+ onUpdate(data);
320
+ } catch (err) {
321
+ _toast.default.error(err.message);
322
+ } finally {
323
+ setLoading(false);
324
+ }
325
+ };
326
+
327
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Div, _objectSpread(_objectSpread({}, rest), {}, {
328
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_schemaForm.default, {
329
+ disabled: disabled,
330
+ style: {
331
+ marginTop: -24
332
+ },
333
+ loading: loading,
334
+ schema: schemaList,
335
+ defaultValue: defaultValue,
336
+ onChange: (changeValue, _ref2) => {
337
+ let {
338
+ action,
339
+ currentItem
340
+ } = _ref2;
341
+
342
+ if (action === 'edit') {
343
+ setEditingItem(currentItem);
344
+ } else if (['cancel', 'confirm'].includes(action)) {
345
+ setEditingItem(null);
346
+ }
347
+
348
+ if (action === 'confirm') {
349
+ onSubmitConfig(changeValue[currentItem.key]);
350
+ }
351
+ }
352
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
353
+ className: "config-form",
354
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
355
+ className: "config-item",
356
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
357
+ className: "config-label",
358
+ children: [t('blocklet.config.access.title'), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
359
+ className: "config-desc",
360
+ children: t('blocklet.config.access.description')
361
+ })]
362
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_TextField.default, {
363
+ disabled: disabled,
364
+ select: true,
365
+ size: "small",
366
+ value: whoCanAccess,
367
+ onChange: onWhoCanAccessChange,
368
+ SelectProps: {
369
+ renderValue: selected => {
370
+ const d = _config.default.find(x => x.value === selected);
371
+
372
+ return d ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
373
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(d.icon, {
374
+ style: iconStyle
375
+ }), d.title[locale]]
376
+ }) : null;
377
+ }
378
+ },
379
+ children: _config.default.map(d => {
380
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(StyledMenuItem, {
381
+ value: d.value,
382
+ sx: {
383
+ display: 'block'
384
+ },
385
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
386
+ display: "flex",
387
+ alignItems: "center",
388
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(d.icon, {
389
+ style: iconStyle
390
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
391
+ children: d.title[locale]
392
+ })]
393
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
394
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
395
+ className: "tip",
396
+ children: d.description[locale]
397
+ })
398
+ })]
399
+ });
400
+ })
401
+ })]
402
+ }), whoCanAccess === 'all' && blocklet.source === 'registry' && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
403
+ className: "config-item",
404
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
405
+ className: "config-label",
406
+ children: [t('blocklet.config.access.publicToStore'), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
407
+ className: "config-desc",
408
+ children: t('blocklet.config.access.publicInstanceTip')
409
+ })]
410
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Switch.default, {
411
+ disabled: disabled,
412
+ checked: publicToStore,
413
+ defaultChecked: true,
414
+ onChange: onPublicToStoreChange
415
+ })]
416
+ }), !inService && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
417
+ className: "config-item",
418
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
419
+ className: "config-label",
420
+ children: [t('blocklet.config.deletable.name'), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
421
+ className: "config-desc",
422
+ children: deletable ? t('blocklet.config.deletable.disable') : t('blocklet.config.deletable.enable')
423
+ })]
424
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Switch.default, {
425
+ disabled: disabled,
426
+ checked: !deletable,
427
+ defaultChecked: true,
428
+ onChange: onDeletableChange
429
+ })]
430
+ })]
431
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
432
+ className: "config-form",
433
+ component: _Divider.default,
434
+ my: 3
435
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
436
+ className: "config-form",
437
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
438
+ className: "config-item",
439
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
440
+ className: "config-label",
441
+ children: [t('blocklet.config.walletType.name'), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
442
+ className: "config-desc",
443
+ children: t('blocklet.config.walletType.description')
444
+ })]
445
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_TextField.default, {
446
+ disabled: disabled,
447
+ select: true,
448
+ size: "small",
449
+ value: (customType === null || customType === void 0 ? void 0 : customType.value) || 'default',
450
+ onChange: onWalletTypeChange,
451
+ children: WalletTypes.map(type => {
452
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledMenuItem, {
453
+ value: type.value,
454
+ sx: {
455
+ display: 'block'
456
+ },
457
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
458
+ display: "flex",
459
+ alignItems: "center",
460
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
461
+ children: type.label
462
+ })
463
+ })
464
+ });
465
+ })
466
+ })]
467
+ })
468
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_schemaForm.default, {
469
+ disabled: disabled,
470
+ style: {
471
+ marginTop: 0
472
+ },
473
+ loading: loading,
474
+ schema: [{
475
+ key: _constant.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_SK,
476
+ description: t('blocklet.config.sk'),
477
+ value: blocklet.environments.find(x => x.key === 'BLOCKLET_APP_SK').value,
478
+ custom: true,
479
+ secure: true
480
+ }],
481
+ defaultValue: {
482
+ [_constant.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_SK]: blocklet.environments.find(x => x.key === 'BLOCKLET_APP_SK').value
483
+ },
484
+ onChange: (changeValue, _ref3) => {
485
+ let {
486
+ action,
487
+ currentItem
488
+ } = _ref3;
489
+
490
+ if (action === 'edit') {
491
+ setEditingItem(currentItem);
492
+ } else if (['cancel', 'confirm'].includes(action)) {
493
+ setEditingItem(null);
494
+ }
495
+
496
+ if (action === 'confirm') {
497
+ onSubmitConfig(changeValue[currentItem.key]);
498
+ }
499
+ }
500
+ })]
501
+ }));
502
+ }
503
+
504
+ const BlockletEnvironmentInDaemon = (0, _permission.withPermission)(BlockletEnvironment, 'mutate_blocklet');
505
+ const BlockletEnvironmentInService = (0, _permission.withPermission)(BlockletEnvironment, '', _util2.BlockletAdminRoles);
506
+
507
+ function BlockletEnvironmentWithPermission(props) {
508
+ const {
509
+ inService
510
+ } = (0, _node.useNodeContext)();
511
+
512
+ if (inService) {
513
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(BlockletEnvironmentInService, _objectSpread({}, props));
514
+ }
515
+
516
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(BlockletEnvironmentInDaemon, _objectSpread({}, props));
517
+ }
518
+
519
+ BlockletEnvironment.propTypes = {
520
+ blocklet: _propTypes.default.object.isRequired,
521
+ onUpdate: _propTypes.default.func,
522
+ hasPermission: _propTypes.default.bool
523
+ };
524
+ BlockletEnvironment.defaultProps = {
525
+ onUpdate: () => {},
526
+ hasPermission: false
527
+ };
528
+
529
+ const Div = _styled.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .config-form {\n width: 80%;\n flex-grow: 1;\n overflow-y: auto;\n ", " {\n width: 100%;\n flex-shrink: 0;\n padding: 0 24px;\n transform: translate(0, 0);\n max-height: 60vh;\n }\n }\n\n .config-item {\n display: flex;\n align-items: center;\n justify-content: space-between;\n margin: 16px 0;\n }\n\n .config-label {\n font-weight: bold;\n }\n\n .config-desc {\n font-weight: normal;\n font-size: 12px;\n color: #666;\n }\n"])), props => props.theme.breakpoints.down('md'));
530
+
531
+ const StyledMenuItem = (0, _styled.default)(_MenuItem.default)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n .tip {\n font-size: 12px;\n color: ", ";\n }\n"])), props => props.theme.palette.text.secondary);