@abtnode/ux 1.8.34 → 1.8.35

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.
@@ -232,7 +232,7 @@ function ComponentEnvironment(_ref) {
232
232
  severity: "info",
233
233
  children: t('blocklet.config.environment.tip')
234
234
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_permission.default, {
235
- permission: inService ? '' : 'mutate_blocklet',
235
+ permission: inService ? '' : 'mutate_blockets',
236
236
  role: inService ? _util2.BlockletAdminRoles : [],
237
237
  children: hasPermission => /*#__PURE__*/(0, _jsxRuntime.jsx)(_table.default, {
238
238
  className: (0, _util2.isBlockletDev)(blocklet) ? 'readonly-block config-table' : 'config-table',
@@ -586,7 +586,7 @@ function BlockletComponent(_ref4) {
586
586
  children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
587
587
  className: "title",
588
588
  children: [t('common.components'), /*#__PURE__*/(0, _jsxRuntime.jsx)(_permission.default, {
589
- permission: inService ? '' : 'mutate_blocklet',
589
+ permission: inService ? '' : 'mutate_blockets',
590
590
  role: inService ? _util2.BlockletAdminRoles : [],
591
591
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledBadge, {
592
592
  top: 1.2,
@@ -617,7 +617,7 @@ function BlockletComponent(_ref4) {
617
617
  })
618
618
  })]
619
619
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_permission.default, {
620
- permission: inService ? '' : 'mutate_blocklet',
620
+ permission: inService ? '' : 'mutate_blockets',
621
621
  role: inService ? _util2.BlockletAdminRoles : [],
622
622
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
623
623
  display: "flex",
@@ -112,7 +112,7 @@ function ComponentSetting(_ref) {
112
112
  })
113
113
  }));
114
114
  }
115
- const ComponentSettingInDaemon = (0, _permission.withPermission)(ComponentSetting, 'mutate_blocklet');
115
+ const ComponentSettingInDaemon = (0, _permission.withPermission)(ComponentSetting, 'mutate_blockets');
116
116
  const ComponentSettingInService = (0, _permission.withPermission)(ComponentSetting, '', _util.BlockletAdminRoles);
117
117
  function ComponentSettingWithPermission(props) {
118
118
  const {
@@ -102,7 +102,6 @@ function BlockletEnvironment(_ref) {
102
102
  const customType = blocklet.environments.find(x => x.key === 'BLOCKLET_WALLET_TYPE');
103
103
  const customDelete = blocklet.environments.find(x => x.key === 'BLOCKLET_DELETABLE');
104
104
  const deletable = !customDelete || customDelete.value === 'yes';
105
- const customColor = blocklet.environments.find(x => x.key === 'BLOCKLET_PASSPORT_COLOR');
106
105
  const customUrl = blocklet.environments.find(x => x.key === 'BLOCKLET_APP_URL');
107
106
  const customLogo = blocklet.environments.find(x => x.key === 'BLOCKLET_APP_LOGO');
108
107
  const customLogoSquare = blocklet.environments.find(x => x.key === 'BLOCKLET_APP_LOGO_SQUARE');
@@ -114,14 +113,6 @@ function BlockletEnvironment(_ref) {
114
113
  key: _constant.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_DESCRIPTION,
115
114
  description: t('blocklet.config.description'),
116
115
  value: blocklet.environments.find(x => x.key === 'BLOCKLET_APP_DESCRIPTION').value
117
- }, {
118
- key: _constant.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_PASSPORT_COLOR,
119
- description: t('blocklet.config.passportColor'),
120
- value: customColor ? customColor.value : 'auto',
121
- componentType: 'passport',
122
- componentProps: {
123
- blocklet
124
- }
125
116
  }, {
126
117
  key: _constant.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_URL,
127
118
  description: t('blocklet.config.appUrl'),
@@ -301,10 +292,11 @@ function BlockletEnvironment(_ref) {
301
292
  }
302
293
  try {
303
294
  setLoading(true);
295
+ const corsAllowedOrigins = newValue.length ? newValue : ['__none__'];
304
296
  await node.api.updateRoutingSite({
305
297
  input: {
306
298
  id: site.id,
307
- corsAllowedOrigins: value.split(',').map(x => x.trim()),
299
+ corsAllowedOrigins,
308
300
  teamDid: blocklet.meta.did
309
301
  }
310
302
  });
@@ -619,7 +611,7 @@ function BlockletEnvironment(_ref) {
619
611
  })]
620
612
  }));
621
613
  }
622
- const BlockletEnvironmentInDaemon = (0, _permission.withPermission)(BlockletEnvironment, 'mutate_blocklet');
614
+ const BlockletEnvironmentInDaemon = (0, _permission.withPermission)(BlockletEnvironment, 'mutate_blockets');
623
615
  const BlockletEnvironmentInService = (0, _permission.withPermission)(BlockletEnvironment, '', _util2.BlockletAdminRoles);
624
616
  function BlockletEnvironmentWithPermission(props) {
625
617
  const {
@@ -51,6 +51,7 @@ function AddDomainAlias(_ref) {
51
51
  teamDid
52
52
  }
53
53
  });
54
+ await (0, _util.sleep)(2000);
54
55
  } catch (err) {
55
56
  _toast.default.error(err.message);
56
57
  } finally {
@@ -13,6 +13,7 @@ var _context = require("@arcblock/ux/lib/Locale/context");
13
13
  var _confirm = _interopRequireDefault(require("../../../confirm"));
14
14
  var _toast = _interopRequireDefault(require("../../../toast"));
15
15
  var _node = require("../../../contexts/node");
16
+ var _util = require("../../../util");
16
17
  var _jsxRuntime = require("react/jsx-runtime");
17
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
19
  function DeleteDomainAlias(props) {
@@ -47,10 +48,11 @@ function DeleteDomainAlias(props) {
47
48
  teamDid
48
49
  }
49
50
  });
50
- setConfirmSetting(null);
51
+ await (0, _util.sleep)(2000);
51
52
  } catch (err) {
52
53
  _toast.default.error(err.message);
53
54
  } finally {
55
+ setConfirmSetting(null);
54
56
  setLoading(false);
55
57
  }
56
58
  };
@@ -166,7 +166,7 @@ RuleList.propTypes = {
166
166
  RuleList.defaultProps = {
167
167
  hasPermission: false
168
168
  };
169
- const RuleListInDaemon = (0, _permission.withPermission)(RuleList, 'mutate_blocklet');
169
+ const RuleListInDaemon = (0, _permission.withPermission)(RuleList, 'mutate_blockets');
170
170
  const RuleListInService = (0, _permission.withPermission)(RuleList, '', _util.BlockletAdminRoles);
171
171
  function RuleListWithPermission(props) {
172
172
  const {
@@ -10,6 +10,7 @@ exports.getLaunchURL = exports.getLaunchAgreementUrl = void 0;
10
10
  exports.getNameByTitle = getNameByTitle;
11
11
  exports.getServerUrl = void 0;
12
12
  var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
13
+ var _pick = _interopRequireDefault(require("lodash/pick"));
13
14
  var _pickBy = _interopRequireDefault(require("lodash/pickBy"));
14
15
  var _sortBy = _interopRequireDefault(require("lodash/sortBy"));
15
16
  var _jszip = _interopRequireDefault(require("jszip"));
@@ -32,7 +33,7 @@ const base64ToArrayBuffer = base64 => {
32
33
  };
33
34
  const getLogo = did => {
34
35
  const url = (0, _didMotif.toDataURL)(did, {
35
- size: 200
36
+ size: 256
36
37
  });
37
38
  const base64 = url.replace(/^[^,]*,/, '');
38
39
  return base64ToArrayBuffer(base64);
@@ -41,19 +42,23 @@ function getNameByTitle(title) {
41
42
  return title.replace(/[\s/@_]/g, '-').replace(/[^a-zA-Z0-9_-]/g, '').replace(/(^[-\s]+)|([-\s]+$)/g, '').toLowerCase();
42
43
  }
43
44
  function genExportedMeta(name, blocklet) {
44
- const meta = (0, _pickBy.default)((0, _cloneDeep.default)(blocklet.meta), x => x !== null);
45
- meta.name = name;
46
- meta.did = (0, _did.default)(name);
47
- meta.logo = 'logo.png';
45
+ let meta = (0, _pick.default)((0, _cloneDeep.default)(blocklet.meta), ['title', 'description', 'group', 'version', 'capabilities', 'interfaces', 'requirements']);
46
+
47
+ // filter null or undefined
48
+ meta = (0, _pickBy.default)(meta, x => x !== null);
49
+ meta.requirements = (0, _pickBy.default)(meta.requirements, x => !!x);
48
50
  meta.interfaces.forEach(x => {
49
- // filter null or undefined
50
51
  if (!x.services) {
51
52
  delete x.services;
52
53
  }
53
54
  });
55
+ meta.name = name;
56
+ meta.did = (0, _did.default)(name);
57
+ meta.logo = 'logo.png';
58
+ meta.components = [];
54
59
  blocklet.children.forEach(child => {
55
60
  if (child.dynamic && child.bundleSource) {
56
- meta.children.push({
61
+ meta.components.push({
57
62
  name: child.meta.name,
58
63
  source: child.bundleSource,
59
64
  title: child.meta.title,
@@ -170,6 +175,12 @@ const fixBlocklet = async function fixBlocklet(blocklet) {
170
175
  oldBlocklet,
171
176
  getIP
172
177
  } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
178
+ if (!blocklet.site) {
179
+ blocklet.site = {
180
+ domainAliases: [],
181
+ rules: []
182
+ };
183
+ }
173
184
  blocklet.site.rules.forEach(rule => {
174
185
  rule.from.pathPrefix = (0, _normalizePathPrefix.default)(rule.from.pathPrefix || '/');
175
186
  });
@@ -165,7 +165,7 @@ Version.defaultProps = {
165
165
  checkUpgrade: true,
166
166
  hasPermission: false
167
167
  };
168
- const BlockletVersionInDaemon = (0, _permission.withPermission)(Version, 'mutate_blocklet');
168
+ const BlockletVersionInDaemon = (0, _permission.withPermission)(Version, 'mutate_blockets');
169
169
  const BlockletVersionInService = (0, _permission.withPermission)(Version, '', _util2.BlockletAdminRoles);
170
170
  function BlockletVersion(props) {
171
171
  const {
@@ -72,6 +72,9 @@ function useBlocklet(_ref) {
72
72
  showError = true,
73
73
  attachRuntimeInfo = true
74
74
  } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
75
+ if (loading) {
76
+ return;
77
+ }
75
78
  try {
76
79
  setLoading(true);
77
80
  setError(null);
@@ -37,27 +37,27 @@ function HeaderAddon(_ref) {
37
37
  locale
38
38
  } = (0, _react.useContext)(_context.LocaleContext);
39
39
  const location = (0, _reactRouterDom.useLocation)();
40
- const docPaths = {
41
- '/dashboard': '/introduction/abtnode-overview',
42
- '/store': '/marketplace',
43
- '/blocklets': '/blocklet',
44
- '/router/rules': '/router',
45
- '/router/engine': '/router',
46
- '/settings/basic': '/misc',
47
- '/settings/team': '/misc/member-management',
48
- '/console': '/misc/graphql-console'
40
+ const defaultEndpoint = 'https://developer.blocklet.io/docs';
41
+ const docMap = {
42
+ '/store': {
43
+ endpoint: 'https://store.blocklet.io'
44
+ },
45
+ '/dashboard': {
46
+ path: '/conceptual/overview'
47
+ },
48
+ '/settings/router': {
49
+ path: '/conceptual/server-architecture'
50
+ }
49
51
  };
50
52
  const onHelpClick = () => {
51
53
  const pathName = location.pathname;
52
- let path = '';
53
- if (pathName.indexOf('/blocklets') > -1) {
54
- path = docPaths['/blocklets'];
55
- } else if (pathName.indexOf('/store') > -1) {
56
- path = docPaths['/store'];
57
- } else if (docPaths[pathName]) {
58
- path = docPaths[pathName];
54
+ let doc = {};
55
+ if (pathName.indexOf('/store') > -1) {
56
+ doc = docMap['/store'];
57
+ } else if (docMap[pathName]) {
58
+ doc = docMap[pathName];
59
59
  }
60
- window.open("https://docs.arcblock.io/abtnode/".concat(locale).concat(path), '_blank');
60
+ window.open("".concat(doc.endpoint || defaultEndpoint, "/").concat(locale).concat(doc.path || ''), '_blank');
61
61
  };
62
62
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Div, {
63
63
  children: [extraItems.map((x, index) => /*#__PURE__*/(0, _react.cloneElement)(x, {
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = Feedback;
7
+ var _propTypes = _interopRequireDefault(require("prop-types"));
8
+ var _material = require("@mui/material");
9
+ var _Link = _interopRequireDefault(require("@mui/material/Link"));
10
+ var _context = require("@arcblock/ux/lib/Locale/context");
11
+ var _jsxRuntime = require("@emotion/react/jsx-runtime");
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+ /** @jsxImportSource @emotion/react */
14
+
15
+ function Feedback(_ref) {
16
+ let {
17
+ id,
18
+ version,
19
+ bundleName
20
+ } = _ref;
21
+ const {
22
+ t
23
+ } = (0, _context.useLocaleContext)();
24
+ const feedbackUrl = new URL('https://github.com/blocklet/blocklet-site/issues/new');
25
+ feedbackUrl.searchParams.set('title', '[Feedback]');
26
+ feedbackUrl.searchParams.set('body', "\n\n[Enter feedback here]\n\n\n---\n#### Document Details\n* App Id: ".concat(id, "\n* App Version: ").concat(version, "\n* App Bundle Name: ").concat(bundleName, "\n* Page: ").concat(window.location.href, "\n"));
27
+ return (0, _jsxRuntime.jsx)(_material.Box, {
28
+ sx: {
29
+ mx: {
30
+ xs: 0,
31
+ md: 2
32
+ }
33
+ },
34
+ children: (0, _jsxRuntime.jsx)(_Link.default, {
35
+ sx: {
36
+ color: 'text.primary'
37
+ },
38
+ target: "_blank",
39
+ href: feedbackUrl.href,
40
+ rel: "noreferrer",
41
+ style: {
42
+ textDecoration: 'underline'
43
+ },
44
+ children: t('common.reportIssue')
45
+ })
46
+ });
47
+ }
48
+ Feedback.propTypes = {
49
+ id: _propTypes.default.string,
50
+ version: _propTypes.default.string,
51
+ bundleName: _propTypes.default.string
52
+ };
53
+ Feedback.defaultProps = {
54
+ id: '',
55
+ version: '',
56
+ bundleName: ''
57
+ };
package/lib/locales/en.js CHANGED
@@ -210,6 +210,7 @@ module.exports = {
210
210
  reload: 'Reload',
211
211
  remark: 'Remark',
212
212
  remove: 'Remove',
213
+ reportIssue: 'Report an issue',
213
214
  requiredErrorText: '{name} is required',
214
215
  resource: 'Resource',
215
216
  restart: 'Restart',
@@ -956,7 +957,9 @@ module.exports = {
956
957
  defaultRule: 'Default rule',
957
958
  search: 'Search Passport',
958
959
  searchIssuerDid: 'Search Issuer DID',
959
- issueBy: 'Issue by {name}'
960
+ issueBy: 'Issue by {name}',
961
+ configColor: 'Config Passport Color',
962
+ color: 'Passport Color'
960
963
  },
961
964
  inviting: {
962
965
  link: 'Invite Link',
package/lib/locales/zh.js CHANGED
@@ -216,6 +216,7 @@ module.exports = {
216
216
  reload: '优雅重启',
217
217
  remark: '备注',
218
218
  remove: '删除',
219
+ reportIssue: '问题反馈',
219
220
  requiredErrorText: '{name}是必填的',
220
221
  resource: '资源',
221
222
  restart: '重启',
@@ -962,7 +963,9 @@ module.exports = {
962
963
  defaultRule: '默认规则',
963
964
  search: '搜索通行证',
964
965
  searchIssuerDid: '搜索颁发者 DID',
965
- issueBy: '由 {name} 颁发'
966
+ issueBy: '由 {name} 颁发',
967
+ configColor: '设置通行证颜色',
968
+ color: '通行证颜色'
966
969
  },
967
970
  inviting: {
968
971
  link: '邀请链接',
@@ -91,6 +91,11 @@ function SchemaForm(_ref2) {
91
91
  [key]: '__encrypted__'
92
92
  }));
93
93
  }
94
+ if (['confirm', 'cancel'].includes(action)) {
95
+ onItemEditingStatusChange(null);
96
+ } else {
97
+ onItemEditingStatusChange(item);
98
+ }
94
99
  }
95
100
  function onItemEditingStatusChange(item) {
96
101
  if (item) {
@@ -147,7 +152,10 @@ function SchemaForm(_ref2) {
147
152
  description,
148
153
  editing,
149
154
  value: currentValue,
150
- onChange: changeValue => onFormItemChange(x, changeValue, 'change'),
155
+ onChange: function onChange(changeValue) {
156
+ let action = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'change';
157
+ return onFormItemChange(x, changeValue, action);
158
+ },
151
159
  componentProps
152
160
  };
153
161
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
@@ -170,7 +178,6 @@ function SchemaForm(_ref2) {
170
178
  "data-cy": "schema-form-item-confirm",
171
179
  onClick: () => {
172
180
  onFormItemChange(x, currentValue, 'confirm');
173
- onItemEditingStatusChange(null);
174
181
  },
175
182
  disabled: disabled || loading,
176
183
  size: "large",
@@ -181,7 +188,6 @@ function SchemaForm(_ref2) {
181
188
  "data-cy": "schema-form-item-cancel",
182
189
  onClick: () => {
183
190
  onFormItemChange(x, editingItemInitialValue.current, 'cancel');
184
- onItemEditingStatusChange(null);
185
191
  },
186
192
  disabled: disabled || loading,
187
193
  size: "large",
@@ -191,7 +197,6 @@ function SchemaForm(_ref2) {
191
197
  "data-cy": "schema-form-item-edit",
192
198
  onClick: () => {
193
199
  onFormItemChange(x, formValues[key], 'edit');
194
- onItemEditingStatusChange(x);
195
200
  },
196
201
  disabled: disabled || editingItem,
197
202
  size: "large",
@@ -33,7 +33,7 @@ function TextInput(_ref) {
33
33
  // enter keydown
34
34
  const handleKeydown = e => {
35
35
  if (e.key === 'Enter') {
36
- onChange(inputValue.current);
36
+ onChange(inputValue.current, 'confirm');
37
37
  }
38
38
  };
39
39
  const onInputChange = changeValue => {
@@ -195,24 +195,30 @@ function MemberList(_ref2) {
195
195
  _toast.default.error(err.message);
196
196
  });
197
197
  };
198
- (0, _react.useEffect)(() => {
199
- getUsers();
200
- }, ["".concat(search.hideBlocked, "-").concat(search.role, "-").concat(search.page, "-").concat(search.pageSize, "-").concat(search.searchText)]); //eslint-disable-line
201
-
202
- // user counts
203
- (0, _react.useEffect)(() => {
198
+ const getUserCounts = () => {
204
199
  api.getUsersCountPerRole().then(res => {
205
200
  setUserCounts(res.counts || []);
206
201
  }).catch(err => {
207
202
  _toast.default.error(err.message);
208
203
  });
209
- }, []); //eslint-disable-line
210
-
211
- useSubscription(_constant.EVENTS.USER_UPDATED, data => {
204
+ };
205
+ const handleUserChange = data => {
212
206
  if (data.teamDid === teamDid) {
213
207
  getUsers();
208
+ getUserCounts();
214
209
  }
215
- }, [search]);
210
+ };
211
+ (0, _react.useEffect)(() => {
212
+ getUsers();
213
+ }, ["".concat(search.hideBlocked, "-").concat(search.role, "-").concat(search.page, "-").concat(search.pageSize, "-").concat(search.searchText)]); //eslint-disable-line
214
+
215
+ // user counts
216
+ (0, _react.useEffect)(() => {
217
+ getUserCounts();
218
+ }, []); //eslint-disable-line
219
+
220
+ useSubscription(_constant.EVENTS.USER_UPDATED, handleUserChange, [search]);
221
+ useSubscription(_constant.EVENTS.USER_ADDED, handleUserChange, [search]);
216
222
  const isInvitationEnabled = enablePassportIssuance;
217
223
  const columns = [{
218
224
  label: t('common.name'),
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = PassportColorWithPermission;
7
+ var _react = require("react");
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+ var _Box = _interopRequireDefault(require("@mui/material/Box"));
10
+ var _Dialog = _interopRequireDefault(require("@arcblock/ux/lib/Dialog"));
11
+ var _Spinner = _interopRequireDefault(require("@arcblock/ux/lib/Spinner"));
12
+ var _reactColor = require("react-color");
13
+ var _context = require("@arcblock/ux/lib/Locale/context");
14
+ var _Button = _interopRequireDefault(require("@arcblock/ux/lib/Button"));
15
+ var _createPassportSvg = _interopRequireDefault(require("@abtnode/auth/lib/util/create-passport-svg"));
16
+ var _util = require("@blocklet/meta/lib/util");
17
+ var _passportColor = require("@abtnode/auth/lib/util/passport-color");
18
+ var _constant = require("@blocklet/constant");
19
+ var _toast = _interopRequireDefault(require("../../toast"));
20
+ var _node = require("../../contexts/node");
21
+ var _blocklet = require("../../contexts/blocklet");
22
+ var _util2 = require("../../util");
23
+ var _permission = require("../../permission");
24
+ var _jsxRuntime = require("react/jsx-runtime");
25
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
26
+ 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; }
27
+ 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; }
28
+ 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; }
29
+ function PassportColor(_ref) {
30
+ let {
31
+ onCancel,
32
+ onSuccess
33
+ } = _ref;
34
+ const {
35
+ api
36
+ } = (0, _node.useNodeContext)();
37
+ const {
38
+ blocklet
39
+ } = (0, _blocklet.useBlockletContext)();
40
+ const {
41
+ t
42
+ } = (0, _context.useLocaleContext)();
43
+ const [loading, setLoading] = (0, _react.useState)(false);
44
+ const curColor = (blocklet.environments.find(x => x.key === 'BLOCKLET_PASSPORT_COLOR') || {}).value || 'auto';
45
+ const defaultColor = curColor === 'auto' ? (0, _passportColor.getPassportColorFromDid)(blocklet.appDid) : curColor;
46
+ const [color, setColor] = (0, _react.useState)(defaultColor);
47
+ const onSubmit = async () => {
48
+ const params = [{
49
+ key: _constant.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_PASSPORT_COLOR,
50
+ value: color,
51
+ custom: true
52
+ }];
53
+ try {
54
+ setLoading(true);
55
+ await api.configBlocklet({
56
+ input: {
57
+ did: blocklet.meta.did,
58
+ configs: params
59
+ }
60
+ });
61
+ onSuccess();
62
+ } catch (err) {
63
+ _toast.default.error(err.message);
64
+ } finally {
65
+ setLoading(false);
66
+ }
67
+ };
68
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Dialog.default, {
69
+ title: t('team.passport.color'),
70
+ onClose: onCancel,
71
+ open: true,
72
+ fullWidth: true,
73
+ actions: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
74
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
75
+ onClick: onCancel,
76
+ color: "inherit",
77
+ children: t('common.cancel')
78
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Button.default, {
79
+ onClick: onSubmit,
80
+ color: "primary",
81
+ disabled: loading,
82
+ variant: "contained",
83
+ autoFocus: true,
84
+ "data-cy": "bind-permission-btn-confirm",
85
+ children: [loading && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Spinner.default, {
86
+ size: [16, 10]
87
+ }), t('common.save')]
88
+ })]
89
+ }),
90
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
91
+ display: "flex",
92
+ justifyContent: "center",
93
+ alignItems: "center",
94
+ className: "dialog-content",
95
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactColor.ChromePicker, {
96
+ color: color,
97
+ onChange: c => setColor(c.hex)
98
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
99
+ style: {
100
+ width: 96,
101
+ marginLeft: 48
102
+ },
103
+ alt: "",
104
+ src: (0, _createPassportSvg.default)({
105
+ title: 'Owner',
106
+ issuer: (0, _util.getDisplayName)(blocklet),
107
+ issuerDid: blocklet.appDid,
108
+ ownerName: 'Your Name',
109
+ isDataUrl: true,
110
+ preferredColor: color
111
+ })
112
+ })]
113
+ })
114
+ });
115
+ }
116
+ const PassportColorInDaemon = (0, _permission.withPermission)(PassportColor, 'mutate_team');
117
+ const PassportColorInService = (0, _permission.withPermission)(PassportColor, '', _util2.BlockletAdminRoles);
118
+ function PassportColorWithPermission(props) {
119
+ const {
120
+ inService
121
+ } = (0, _node.useNodeContext)();
122
+ if (inService) {
123
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(PassportColorInService, _objectSpread({}, props));
124
+ }
125
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(PassportColorInDaemon, _objectSpread({}, props));
126
+ }
127
+ PassportColor.propTypes = {
128
+ onCancel: _propTypes.default.func.isRequired,
129
+ onSuccess: _propTypes.default.func.isRequired
130
+ };
131
+ PassportColor.defaultProps = {};
@@ -24,6 +24,7 @@ var _permission = _interopRequireDefault(require("../../permission"));
24
24
  var _searchInput = _interopRequireDefault(require("../search-input"));
25
25
  var _listHeader = _interopRequireDefault(require("../styles/list-header"));
26
26
  var _detail = _interopRequireDefault(require("./detail"));
27
+ var _color = _interopRequireDefault(require("./color"));
27
28
  var _mutateRole = _interopRequireDefault(require("./mutate-role"));
28
29
  var _trustedIssuers = _interopRequireDefault(require("./trusted-issuers"));
29
30
  var _jsxRuntime = require("react/jsx-runtime");
@@ -50,6 +51,7 @@ function PassportList() {
50
51
  } = (0, _team.useTeamContext)();
51
52
  const [showCreate, setShowCreate] = (0, _react.useState)(false);
52
53
  const [updateForm, setUpdateForm] = (0, _react.useState)(false);
54
+ const [showColor, setShowColor] = (0, _react.useState)(false);
53
55
  const [showTrustedIssuers, setShowTrustedIssuers] = (0, _react.useState)(null);
54
56
  const [search, setSearch] = (0, _react.useState)('');
55
57
  const [loading, setLoading] = (0, _react.useState)(false);
@@ -94,27 +96,34 @@ function PassportList() {
94
96
  menuButtonProps: {
95
97
  'data-cy': 'trusted-issuers-more'
96
98
  },
97
- menu: /*#__PURE__*/(0, _jsxRuntime.jsx)(_SplitButton.default.Item, {
98
- "data-cy": "config-show-issue-passport",
99
- onClick: () => {
100
- toggleShowIssue();
101
- },
102
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
103
- display: "flex",
104
- alignItems: "center",
105
- children: [loading && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Spinner.default, {
106
- size: [16, 10],
107
- style: {
108
- marginRight: 8
109
- }
110
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
111
- children: [enablePassportIssuance ? t('team.passport.disableIssuance') : t('team.passport.enableIssuance'), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
112
- fontSize: 12,
113
- color: "#888",
114
- children: enablePassportIssuance ? t('team.passport.disableIssuanceTip') : t('team.passport.enableIssuanceTip')
99
+ menu: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
100
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_SplitButton.default.Item, {
101
+ "data-cy": "config-show-issue-passport",
102
+ onClick: () => {
103
+ toggleShowIssue();
104
+ },
105
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
106
+ display: "flex",
107
+ alignItems: "center",
108
+ children: [loading && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Spinner.default, {
109
+ size: [16, 10],
110
+ style: {
111
+ marginRight: 8
112
+ }
113
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
114
+ children: [enablePassportIssuance ? t('team.passport.disableIssuance') : t('team.passport.enableIssuance'), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
115
+ fontSize: 12,
116
+ color: "#888",
117
+ children: enablePassportIssuance ? t('team.passport.disableIssuanceTip') : t('team.passport.enableIssuanceTip')
118
+ })]
115
119
  })]
116
- })]
117
- })
120
+ })
121
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_SplitButton.default.Item, {
122
+ onClick: () => setShowColor(true),
123
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
124
+ children: t('team.passport.configColor')
125
+ })
126
+ })]
118
127
  }),
119
128
  children: () => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Button.default, {
120
129
  variant: "outlined",
@@ -212,6 +221,9 @@ function PassportList() {
212
221
  item: updateForm
213
222
  }), showTrustedIssuers && /*#__PURE__*/(0, _jsxRuntime.jsx)(_trustedIssuers.default, {
214
223
  onCancel: () => setShowTrustedIssuers(false)
224
+ }), showColor && /*#__PURE__*/(0, _jsxRuntime.jsx)(_color.default, {
225
+ onCancel: () => setShowColor(null),
226
+ onSuccess: () => setShowColor(null)
215
227
  })]
216
228
  });
217
229
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.8.34",
6
+ "version": "1.8.35",
7
7
  "description": "UX components shared across abtnode packages",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -21,17 +21,17 @@
21
21
  "author": "linchen <linchen1987@foxmail.com> (http://github.com/linchen1987)",
22
22
  "license": "MIT",
23
23
  "dependencies": {
24
- "@abtnode/auth": "1.8.34",
25
- "@abtnode/constant": "1.8.34",
26
- "@abtnode/util": "1.8.34",
27
- "@arcblock/did-connect": "^2.4.49",
24
+ "@abtnode/auth": "1.8.35",
25
+ "@abtnode/constant": "1.8.35",
26
+ "@abtnode/util": "1.8.35",
27
+ "@arcblock/did-connect": "^2.4.52",
28
28
  "@arcblock/did-motif": "^1.1.10",
29
- "@arcblock/icons": "^2.4.49",
30
- "@arcblock/terminal": "^2.4.49",
31
- "@arcblock/ux": "^2.4.49",
32
- "@blocklet/constant": "1.8.34",
33
- "@blocklet/launcher-layout": "^1.9.9",
34
- "@blocklet/meta": "1.8.34",
29
+ "@arcblock/icons": "^2.4.52",
30
+ "@arcblock/terminal": "^2.4.52",
31
+ "@arcblock/ux": "^2.4.52",
32
+ "@blocklet/constant": "1.8.35",
33
+ "@blocklet/launcher-layout": "^1.9.10",
34
+ "@blocklet/meta": "1.8.35",
35
35
  "@emotion/react": "^11.10.4",
36
36
  "@emotion/styled": "^11.10.4",
37
37
  "@material-table/core": "^0.2.48",
@@ -73,5 +73,5 @@
73
73
  "@babel/preset-react": "^7.18.6",
74
74
  "babel-plugin-inline-react-svg": "^1.1.2"
75
75
  },
76
- "gitHead": "c5fbb8e57493db62f212217cfde1980c82f00297"
76
+ "gitHead": "dd89e7a61dc8cff64302608ad5ab6545dd903daa"
77
77
  }