@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,277 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = ComponentEnvironment;
7
+ var _react = require("react");
8
+ var _styled = _interopRequireDefault(require("@emotion/styled"));
9
+ var _propTypes = _interopRequireDefault(require("prop-types"));
10
+ var _core = _interopRequireDefault(require("@material-table/core"));
11
+ var _TextField = _interopRequireDefault(require("@mui/material/TextField"));
12
+ var _Alert = _interopRequireDefault(require("@mui/material/Alert"));
13
+ var _constant = require("@blocklet/constant");
14
+ var _util = require("@blocklet/meta/lib/util");
15
+ var _context = require("@arcblock/ux/lib/Locale/context");
16
+ var _clickToCopy = _interopRequireDefault(require("../../click-to-copy"));
17
+ var _toast = _interopRequireDefault(require("../../toast"));
18
+ var _node = require("../../contexts/node");
19
+ var _tableIcons = _interopRequireDefault(require("../../table-icons"));
20
+ var _table = _interopRequireDefault(require("../../table"));
21
+ var _permission = _interopRequireDefault(require("../../permission"));
22
+ var _util2 = require("../../util");
23
+ var _icons = _interopRequireDefault(require("../icons"));
24
+ var _jsxRuntime = require("react/jsx-runtime");
25
+ var _templateObject, _templateObject2;
26
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
28
+ 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; }
29
+ 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; }
30
+ 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; }
31
+ function ComponentEnvironment(_ref) {
32
+ let {
33
+ blocklet,
34
+ ancestors
35
+ } = _ref;
36
+ const node = (0, _node.useNodeContext)();
37
+ const {
38
+ inService
39
+ } = node;
40
+ const {
41
+ t
42
+ } = (0, _react.useContext)(_context.LocaleContext);
43
+ const dids = [...ancestors.map(x => x.meta.did), blocklet.meta.did];
44
+ const onConfigChanged = () => _toast.default.success(t('blocklet.config.changedTip'));
45
+ const isConfigEditable = x => x.custom;
46
+ if ((0, _util2.isInstalling)(blocklet.status)) {
47
+ return null;
48
+ }
49
+ if (blocklet.status === 'unknown' && (0, _util2.isInstalling)(blocklet.status)) {
50
+ return null;
51
+ }
52
+ const onAddConfig = async data => {
53
+ if (!data.key.trim() || !data.value.trim()) {
54
+ _toast.default.error(t('blocklet.config.environment.keyValueRequired'));
55
+ return;
56
+ }
57
+ if (data.key.startsWith('BLOCKLET_')) {
58
+ _toast.default.error(t('blocklet.config.environment.invalidKey'));
59
+ return;
60
+ }
61
+ data.custom = true;
62
+ const result = await node.api.configBlocklet({
63
+ input: {
64
+ did: dids,
65
+ configs: [data]
66
+ }
67
+ });
68
+ if (result.code === 'ok') {
69
+ onConfigChanged(result.blocklet);
70
+ }
71
+ };
72
+ const onEditConfig = async (newData, oldData) => {
73
+ // only required field can't be empty
74
+ if (newData.required && (!newData.key.trim() || !newData.value.trim())) {
75
+ _toast.default.error(t('blocklet.config.environment.keyValueRequired'));
76
+ return;
77
+ }
78
+ if (newData.key.startsWith('BLOCKLET_') && !_constant.BLOCKLET_CONFIGURABLE_KEY[newData.key]) {
79
+ _toast.default.error(t('blocklet.config.environment.invalidKey'));
80
+ return;
81
+ }
82
+ if (newData.key === _constant.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_CLUSTER_SIZE) {
83
+ const errMessage = (0, _util2.isValidClusterSize)(newData);
84
+ if (errMessage) {
85
+ _toast.default.error(errMessage);
86
+ return;
87
+ }
88
+ }
89
+ const configs = [newData];
90
+ if (newData.key !== oldData.key) {
91
+ configs.push({
92
+ key: oldData.key
93
+ });
94
+ }
95
+ try {
96
+ const result = await node.api.configBlocklet({
97
+ input: {
98
+ did: dids,
99
+ configs
100
+ }
101
+ });
102
+ if (result.code === 'ok') {
103
+ onConfigChanged(result.blocklet);
104
+ }
105
+ } catch (err) {
106
+ _toast.default.error((0, _util2.formatError)(err));
107
+ }
108
+ };
109
+ const onDeleteConfig = async data => {
110
+ if (data.required) {
111
+ _toast.default.error(t('blocklet.config.environment.deleteForbidden'));
112
+ return;
113
+ }
114
+ const result = await node.api.configBlocklet({
115
+ input: {
116
+ did: dids,
117
+ configs: [{
118
+ key: data.key
119
+ }]
120
+ }
121
+ });
122
+ if (result.code === 'ok') {
123
+ onConfigChanged(result.blocklet);
124
+ }
125
+ };
126
+
127
+ // configs
128
+ const componentConfigs = (blocklet.configs || []).filter(x => !_constant.BLOCKLET_CONFIGURABLE_KEY[x.key]);
129
+ const sharedConfigObj = (0, _util.getSharedConfigObj)(blocklet, ancestors);
130
+ const missingRequiredConfigs = (0, _util.getComponentMissingConfigs)(blocklet, ancestors);
131
+ const configs = componentConfigs.map(x => _objectSpread(_objectSpread({}, x), {}, {
132
+ value: sharedConfigObj[x.key] || x.value
133
+ }));
134
+ const hasBWAConfig = configs.some(x => x.key && x.key.startsWith('BWA_'));
135
+ const action = {
136
+ onRowAdd: onAddConfig,
137
+ onRowUpdate: onEditConfig,
138
+ onRowDelete: onDeleteConfig,
139
+ // environment declare in blocklet.yml can't be deleted, only custom env can be deleted
140
+ isDeletable: isConfigEditable
141
+ };
142
+ const onColumns = () => [{
143
+ title: t('common.key'),
144
+ field: 'key',
145
+ initialEditValue: 'Key',
146
+ width: '30%',
147
+ render: d => /*#__PURE__*/(0, _jsxRuntime.jsx)(_clickToCopy.default, {
148
+ value: d.value,
149
+ style: {
150
+ color: d.required && !d.value ? '#ff4436' : '#222222',
151
+ fontWeight: d.required ? 'bold' : 'normal'
152
+ },
153
+ children: d.key
154
+ }),
155
+ editComponent: props => {
156
+ const {
157
+ value,
158
+ rowData,
159
+ onChange: _onChange
160
+ } = props;
161
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(EditDiv, {
162
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_TextField.default, {
163
+ fullWidth: true,
164
+ size: "small",
165
+ disabled: isConfigEditable(rowData) === false,
166
+ value: value,
167
+ onChange: e => _onChange(e.target.value),
168
+ variant: "outlined",
169
+ label: "Key",
170
+ placeholder: t('blocklet.config.environment.key'),
171
+ margin: "dense",
172
+ autoFocus: true
173
+ })
174
+ });
175
+ }
176
+ }, {
177
+ title: t('common.value'),
178
+ field: 'value',
179
+ initialEditValue: 'Value',
180
+ width: 'calc((100% - (96px + 30%)) / 1)',
181
+ render: d => {
182
+ if (d.secure) {
183
+ return '******';
184
+ }
185
+ if (!d.value) {
186
+ return null;
187
+ }
188
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_clickToCopy.default, {
189
+ unstyled: true,
190
+ value: d.value,
191
+ style: {
192
+ wordBreak: 'break-all'
193
+ },
194
+ children: d.value
195
+ });
196
+ },
197
+ // eslint-disable-next-line no-shadow
198
+ editComponent: props => {
199
+ const {
200
+ value,
201
+ rowData,
202
+ onChange: _onChange2
203
+ } = props;
204
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(EditDiv, {
205
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_TextField.default, {
206
+ fullWidth: true,
207
+ size: "small",
208
+ value: value === '__encrypted__' ? '' : value,
209
+ onChange: e => _onChange2(e.target.value),
210
+ variant: "outlined",
211
+ label: t('common.value'),
212
+ placeholder: t('blocklet.config.environment.value'),
213
+ margin: "dense",
214
+ autoFocus: true
215
+ }), rowData.description && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
216
+ style: {
217
+ marginLeft: 12
218
+ },
219
+ children: rowData.description
220
+ })]
221
+ });
222
+ }
223
+ }];
224
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Div, {
225
+ children: [!!missingRequiredConfigs.length && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Alert.default, {
226
+ severity: "error",
227
+ style: {
228
+ marginTop: 24
229
+ },
230
+ children: t('blocklet.config.missingRequired')
231
+ }), hasBWAConfig && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Alert.default, {
232
+ severity: "info",
233
+ children: t('blocklet.config.environment.tip')
234
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_permission.default, {
235
+ permission: inService ? '' : 'mutate_blocklet',
236
+ role: inService ? _util2.BlockletAdminRoles : [],
237
+ children: hasPermission => /*#__PURE__*/(0, _jsxRuntime.jsx)(_table.default, {
238
+ className: (0, _util2.isBlockletDev)(blocklet) ? 'readonly-block config-table' : 'config-table',
239
+ "data-disabled-text": t('blocklet.config.disabledText'),
240
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_core.default, {
241
+ title: /*#__PURE__*/(0, _jsxRuntime.jsx)("h4", {
242
+ children: t('common.environment')
243
+ }),
244
+ columns: onColumns(),
245
+ icons: _objectSpread(_objectSpread({}, _icons.default), _tableIcons.default),
246
+ options: {
247
+ emptyRowsWhenPaging: false,
248
+ actionsColumnIndex: -1,
249
+ tableLayout: 'auto',
250
+ maxBodyHeight: '100%',
251
+ paging: false,
252
+ search: false
253
+ },
254
+ localization: {
255
+ header: {
256
+ actions: t('common.actions')
257
+ },
258
+ body: {
259
+ emptyDataSourceMessage: t('common.noData')
260
+ }
261
+ },
262
+ data: configs,
263
+ editable: hasPermission ? action : {}
264
+ })
265
+ })
266
+ })]
267
+ });
268
+ }
269
+ ComponentEnvironment.propTypes = {
270
+ blocklet: _propTypes.default.object.isRequired,
271
+ ancestors: _propTypes.default.array
272
+ };
273
+ ComponentEnvironment.defaultProps = {
274
+ ancestors: []
275
+ };
276
+ const Div = _styled.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .readonly-block {\n position: relative;\n &::after {\n content: attr(data-disabled-text);\n position: absolute;\n display: flex;\n align-items: center;\n justify-content: center;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n background-color: rgba(230, 230, 230, 0.7);\n font-size: 24px;\n letter-spacing: 2px;\n color: #e33371;\n padding: 20px;\n word-break: break-all;\n word-wrap: break-word;\n z-index: 10;\n }\n }\n .config-table {\n margin-bottom: 24px;\n position: relative;\n .hide-control {\n position: absolute;\n top: 10px;\n left: 200px;\n @media (max-width: ", "px) {\n left: 160px;\n }\n }\n\n .MuiToolbar-root {\n display: flex;\n }\n\n .MuiTableRow-head {\n display: none;\n }\n\n &.hide-header {\n .MuiToolbar-root {\n display: none;\n }\n }\n }\n\n .accordion {\n margin-bottom: 16px;\n &:last-of-type {\n margin-bottom: 0;\n }\n padding: 8px 0 8px 0px;\n &.MuiAccordion-root {\n background: transparent;\n box-shadow: none;\n border: 1px solid #ddd;\n border-radius: 4px;\n &::before,\n &::after {\n height: 0;\n }\n .MuiAccordionSummary-root {\n padding-left: 0;\n }\n .accordion-title {\n font-weight: bold;\n padding-left: 16px;\n }\n }\n }\n"])), props => props.theme.breakpoints.values.sm);
277
+ const EditDiv = _styled.default.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n height: 60px;\n"])));