@abtnode/ux 1.8.26 → 1.8.28

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