@abtnode/ux 1.16.11-next-a232f5fb → 1.16.11-next-3d2b39f7

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.
package/lib/actions.js CHANGED
@@ -56,7 +56,7 @@ function Actions(_ref) {
56
56
  "aria-haspopup": "true",
57
57
  "data-cy": "actions-menu-icon",
58
58
  onClick: onOpen,
59
- size: "large",
59
+ size: "small",
60
60
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_MoreHoriz.default, {})
61
61
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Menu.default, {
62
62
  id: "actions-menu",
@@ -82,13 +82,14 @@ function Actions(_ref) {
82
82
  return /*#__PURE__*/(0, _react.createElement)(_MenuItem.default, _objectSpread(_objectSpread({}, opts), {}, {
83
83
  disabled: disabled,
84
84
  dense: true,
85
- onClick: e => {
85
+ onClick: async e => {
86
+ await _onClick(e);
86
87
  onClose();
87
- _onClick(e);
88
88
  }
89
89
  // eslint-disable-next-line react/no-array-index-key
90
90
  ,
91
- key: index
91
+ key: index,
92
+ "data-cy": "actions-menu-".concat(index)
92
93
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ListItemIcon.default, {
93
94
  style: {
94
95
  minWidth: 24,
@@ -93,6 +93,10 @@ function BlockletActions(_ref) {
93
93
  await fn(params);
94
94
  } else if (action === 'start') {
95
95
  var _blocklet$settings;
96
+ if (!(0, _util.hasRunnableComponent)(blocklet)) {
97
+ _Toast.default.error(t('blocklet.noComponent'));
98
+ return;
99
+ }
96
100
  if (!inService && !skipSetup && !((_blocklet$settings = blocklet.settings) !== null && _blocklet$settings !== void 0 && _blocklet$settings.initialized)) {
97
101
  // 跳转到 setup 流程界面时携带 serverUrl 查询参数
98
102
  const serverUrl = (0, _util3.getServerUrl)(node.info);
@@ -105,10 +109,6 @@ function BlockletActions(_ref) {
105
109
  });
106
110
  return;
107
111
  }
108
- if (!(0, _util.hasRunnableComponent)(blocklet)) {
109
- _Toast.default.error(t('blocklet.noComponent'));
110
- return;
111
- }
112
112
  const input = {
113
113
  did: blocklet.meta.did
114
114
  };
@@ -30,7 +30,10 @@ function DeleteComponent(_ref) {
30
30
  component,
31
31
  remove,
32
32
  disabled,
33
- tip
33
+ tip,
34
+ showConfirm,
35
+ hideBtn,
36
+ onCancel: _onCancel
34
37
  } = _ref;
35
38
  const {
36
39
  t
@@ -44,9 +47,8 @@ function DeleteComponent(_ref) {
44
47
  setDeleteSetting(null);
45
48
  };
46
49
  const componentDisabled = disabled || loading;
47
- const btn = /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledButton, {
48
- disabled: componentDisabled,
49
- onClick: () => setDeleteSetting({
50
+ const doShowConfirm = () => {
51
+ setDeleteSetting({
50
52
  title: "".concat(t('common.delete'), " ").concat(component.meta.title || component.meta.name),
51
53
  // eslint-disable-next-line react/no-unstable-nested-components
52
54
  description: (params, setParams) => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Typography.default, {
@@ -78,8 +80,25 @@ function DeleteComponent(_ref) {
78
80
  removeType: 'keepData'
79
81
  },
80
82
  onConfirm: deleteComponent,
81
- onCancel: () => setDeleteSetting(null)
82
- }),
83
+ onCancel: () => {
84
+ setDeleteSetting(null);
85
+ _onCancel();
86
+ }
87
+ });
88
+ };
89
+ (0, _react.useEffect)(() => {
90
+ if (showConfirm) {
91
+ doShowConfirm();
92
+ } else {
93
+ setLoading(false);
94
+ setDeleteSetting(null);
95
+ }
96
+ // eslint-disable-next-line react-hooks/exhaustive-deps
97
+ }, [showConfirm]);
98
+ const btn = /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledButton, {
99
+ size: "small",
100
+ disabled: componentDisabled,
101
+ onClick: () => doShowConfirm,
83
102
  "data-cy": "delete-component-btn",
84
103
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Delete.default, {
85
104
  disabled: componentDisabled
@@ -92,7 +111,7 @@ function DeleteComponent(_ref) {
92
111
  })
93
112
  });
94
113
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
95
- children: [btnWithToolTip, deleteSetting && /*#__PURE__*/(0, _jsxRuntime.jsx)(_confirm.default, {
114
+ children: [!hideBtn && btnWithToolTip, deleteSetting && /*#__PURE__*/(0, _jsxRuntime.jsx)(_confirm.default, {
96
115
  title: deleteSetting.title,
97
116
  description: deleteSetting.description,
98
117
  confirm: deleteSetting.confirm,
@@ -106,12 +125,18 @@ function DeleteComponent(_ref) {
106
125
  DeleteComponent.propTypes = {
107
126
  component: _propTypes.default.object.isRequired,
108
127
  remove: _propTypes.default.func,
128
+ onCancel: _propTypes.default.func,
109
129
  disabled: _propTypes.default.bool,
130
+ showConfirm: _propTypes.default.bool,
131
+ hideBtn: _propTypes.default.bool,
110
132
  tip: _propTypes.default.string
111
133
  };
112
134
  DeleteComponent.defaultProps = {
113
135
  remove: async () => {},
114
136
  disabled: false,
137
+ showConfirm: false,
138
+ hideBtn: false,
139
+ onCancel: () => {},
115
140
  tip: ''
116
141
  };
117
142
  const StyledButton = (0, _styled.default)(_IconButton.default)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n &.Mui-disabled {\n opacity: 0.5;\n }\n"])));
@@ -26,6 +26,9 @@ var _ArrowForward = _interopRequireDefault(require("@mui/icons-material/ArrowFor
26
26
  var _ExpandMore = _interopRequireDefault(require("@mui/icons-material/ExpandMore"));
27
27
  var _ChevronRight = _interopRequireDefault(require("@mui/icons-material/ChevronRight"));
28
28
  var _Checkbox = _interopRequireDefault(require("@mui/material/Checkbox"));
29
+ var _Replay = _interopRequireDefault(require("@mui/icons-material/Replay"));
30
+ var _Autorenew = _interopRequireDefault(require("@mui/icons-material/Autorenew"));
31
+ var _Delete = _interopRequireDefault(require("@mui/icons-material/Delete"));
29
32
  var _react2 = require("@iconify/react");
30
33
  var _constant = require("@abtnode/constant");
31
34
  var _CircularProgress = _interopRequireDefault(require("@mui/material/CircularProgress"));
@@ -49,13 +52,15 @@ var _bundleAvatar = _interopRequireDefault(require("../bundle-avatar"));
49
52
  var _mode = _interopRequireDefault(require("../mode"));
50
53
  var _configuration = _interopRequireDefault(require("./configuration"));
51
54
  var _delete = _interopRequireDefault(require("./delete"));
55
+ var _start = _interopRequireDefault(require("./start"));
52
56
  var _line = _interopRequireDefault(require("./line"));
53
57
  var _add = _interopRequireDefault(require("./add"));
54
58
  var _addRule = _interopRequireDefault(require("../router/action/add-rule"));
55
59
  var _ruleList = _interopRequireDefault(require("../router/rule-list"));
60
+ var _actions = _interopRequireDefault(require("../../actions"));
56
61
  var _jsxRuntime = require("react/jsx-runtime");
57
62
  const _excluded = ["blocklet", "onUpdate", "getComponentUrl"];
58
- var _templateObject, _templateObject2;
63
+ var _templateObject, _templateObject2, _templateObject3;
59
64
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
60
65
  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; }
61
66
  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; }
@@ -137,6 +142,10 @@ function ComponentItem(_ref) {
137
142
  ancestors,
138
143
  depth,
139
144
  onRemove,
145
+ onStart,
146
+ onStop,
147
+ onRestart,
148
+ onReload,
140
149
  getComponentUrl,
141
150
  app
142
151
  } = _ref;
@@ -145,6 +154,8 @@ function ComponentItem(_ref) {
145
154
  } = (0, _react.useContext)(_context.LocaleContext);
146
155
  const [expand, setExpand] = (0, _react.useState)(true);
147
156
  const [componentInfo, setComponentInfo] = (0, _react.useState)();
157
+ const [showDeleteConfirm, setShowDeleteConfirm] = (0, _react.useState)(false);
158
+ const [loading, setLoading] = (0, _react.useState)(false);
148
159
  const {
149
160
  deletingBlocklets: deletingComponents
150
161
  } = (0, _deletingBlocklets.useDeletingBlockletContext)();
@@ -156,9 +167,6 @@ function ComponentItem(_ref) {
156
167
  }
157
168
  const mountPoint = "/".concat(ancestors.slice(1) // ignore mountPoint of root component
158
169
  .map(x => x.mountPoint || '/').join('/'), "/").concat(blocklet.mountPoint || '/').replace(/\/+/g, '/');
159
-
160
- // hide root's status and only display specific status
161
- const showStatus = !!ancestors.length && ['downloading', 'deleting', 'starting'].includes(status);
162
170
  const canExpand = depth > 0 && blocklet.children.length > 0;
163
171
  const expandIcon = /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
164
172
  size: "small",
@@ -203,7 +211,13 @@ function ComponentItem(_ref) {
203
211
  status: status,
204
212
  source: componentInfo.source
205
213
  })
206
- }, {
214
+ }, blocklet.status === 'running' ? {
215
+ name: t('blocklet.startedAt'),
216
+ value: (0, _util2.formatToDatetime)(blocklet.startedAt)
217
+ } : null, blocklet.status !== 'running' ? {
218
+ name: t('blocklet.stoppedAt'),
219
+ value: (0, _util2.formatToDatetime)(blocklet.stoppedAt)
220
+ } : null, {
207
221
  name: t('common.mountPoint'),
208
222
  value: mountPoint
209
223
  }, {
@@ -267,7 +281,9 @@ function ComponentItem(_ref) {
267
281
  });
268
282
  }
269
283
  }
270
- return [(depth > 0 || blocklet.meta.group !== 'gateway') && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
284
+ const appInProgress = (0, _util.isInProgress)(root.status);
285
+ const componentInProgress = (0, _util.isInProgress)(blocklet.status);
286
+ return [(depth > 0 || blocklet.meta.group !== 'gateway') && /*#__PURE__*/(0, _jsxRuntime.jsxs)(StyledComponentRow, {
271
287
  display: "flex",
272
288
  py: 2,
273
289
  className: "component-item",
@@ -293,10 +309,8 @@ function ComponentItem(_ref) {
293
309
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
294
310
  ml: "16px",
295
311
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
296
- style: {
297
- color: '#222',
298
- fontSize: 18
299
- },
312
+ className: "component-name",
313
+ onClick: () => setComponentInfo(blocklet),
300
314
  children: (0, _util.getDisplayName)(blocklet, true)
301
315
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
302
316
  display: "flex",
@@ -309,7 +323,7 @@ function ComponentItem(_ref) {
309
323
  marginLeft: 4
310
324
  },
311
325
  mode: blocklet.mode || ''
312
- }), showStatus && /*#__PURE__*/(0, _jsxRuntime.jsx)(_status.default, {
326
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_status.default, {
313
327
  style: {
314
328
  marginLeft: 4
315
329
  },
@@ -359,6 +373,8 @@ function ComponentItem(_ref) {
359
373
  })
360
374
  })
361
375
  }, mountPoint), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
376
+ display: "flex",
377
+ alignItems: "center",
362
378
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Tooltip.default, {
363
379
  title: t('common.visit'),
364
380
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)("a", {
@@ -366,15 +382,10 @@ function ComponentItem(_ref) {
366
382
  href: href,
367
383
  rel: "noopener noreferrer",
368
384
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
385
+ size: "small",
369
386
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Launch.default, {})
370
387
  })
371
388
  })
372
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tooltip.default, {
373
- title: t('common.overview'),
374
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
375
- onClick: () => setComponentInfo(blocklet),
376
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_InfoOutlined.default, {})
377
- })
378
389
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_configuration.default, {
379
390
  blocklet: blocklet,
380
391
  ancestors: ancestors,
@@ -391,17 +402,53 @@ function ComponentItem(_ref) {
391
402
  invisible: !(0, _util.getComponentMissingConfigs)(blocklet, ancestors).length,
392
403
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
393
404
  onClick: open,
405
+ size: "small",
394
406
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_SettingsOutlined.default, {})
395
407
  })
396
408
  })
397
409
  }, "config");
398
410
  }
399
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_delete.default, {
411
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_start.default, {
400
412
  blocklet: root,
401
413
  component: blocklet,
402
- remove: onRemove,
414
+ onStart: onStart,
415
+ onStop: onStop,
403
416
  disabled: !!deleteDisabledTip,
404
417
  tip: deleteDisabledTip
418
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_actions.default, {
419
+ "data-cy": "component-actions",
420
+ actions: [{
421
+ icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_InfoOutlined.default, {}),
422
+ text: t('common.detail'),
423
+ onClick: () => {
424
+ setComponentInfo(blocklet);
425
+ }
426
+ }, {
427
+ icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Replay.default, {}),
428
+ text: t('common.restart'),
429
+ onClick: async () => {
430
+ setLoading(true);
431
+ await onRestart(blocklet);
432
+ setLoading(false);
433
+ },
434
+ disabled: appInProgress || componentInProgress || blocklet.status !== 'running'
435
+ }, {
436
+ icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Autorenew.default, {}),
437
+ text: t('common.reload'),
438
+ onClick: async () => {
439
+ setLoading(true);
440
+ await onReload(blocklet);
441
+ setLoading(false);
442
+ },
443
+ disabled: loading || appInProgress || componentInProgress || blocklet.status !== 'running'
444
+ }, {
445
+ icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Delete.default, {}),
446
+ text: t('common.delete'),
447
+ onClick: () => {
448
+ setShowDeleteConfirm(true);
449
+ },
450
+ disabled: appInProgress || componentInProgress
451
+ }]
405
452
  })]
406
453
  }, "actions")]
407
454
  }, "group-not-gateway-box"), /*#__PURE__*/(0, _jsxRuntime.jsx)(_line.default, {
@@ -413,6 +460,10 @@ function ComponentItem(_ref) {
413
460
  ancestors: [...ancestors, blocklet],
414
461
  depth: depth + 1,
415
462
  onRemove: onRemove,
463
+ onStart: onStart,
464
+ onStop: onStop,
465
+ onRestart: onRestart,
466
+ onReload: onReload,
416
467
  getComponentUrl: getComponentUrl,
417
468
  app: app
418
469
  }, "".concat(depth + 1, "-").concat(x.meta.did)))
@@ -431,13 +482,35 @@ function ComponentItem(_ref) {
431
482
  children: renderRows(componentRows)
432
483
  })]
433
484
  }, "dialog-wrapper")
434
- }, "base-info-dialog")];
485
+ }, "base-info-dialog"), /*#__PURE__*/(0, _jsxRuntime.jsx)(_delete.default, {
486
+ blocklet: root,
487
+ component: blocklet,
488
+ remove: async function remove() {
489
+ setLoading(true);
490
+ try {
491
+ await onRemove(...arguments);
492
+ } catch (_unused) {
493
+ // ignore
494
+ }
495
+ setLoading(false);
496
+ setShowDeleteConfirm(false);
497
+ },
498
+ onCancel: () => setShowDeleteConfirm(false),
499
+ disabled: !!deleteDisabledTip,
500
+ tip: deleteDisabledTip,
501
+ hideBtn: true,
502
+ showConfirm: showDeleteConfirm
503
+ })];
435
504
  }
436
505
  ComponentItem.propTypes = {
437
506
  blocklet: _propTypes.default.object.isRequired,
438
507
  ancestors: _propTypes.default.array,
439
508
  depth: _propTypes.default.number,
440
509
  onRemove: _propTypes.default.func,
510
+ onStart: _propTypes.default.func,
511
+ onStop: _propTypes.default.func,
512
+ onRestart: _propTypes.default.func,
513
+ onReload: _propTypes.default.func,
441
514
  getComponentUrl: _propTypes.default.func,
442
515
  app: _propTypes.default.object
443
516
  };
@@ -445,10 +518,15 @@ ComponentItem.defaultProps = {
445
518
  ancestors: [],
446
519
  depth: 0,
447
520
  onRemove: () => {},
521
+ onStart: () => {},
522
+ onStop: () => {},
523
+ onRestart: () => {},
524
+ onReload: () => {},
448
525
  getComponentUrl: () => window.location.origin,
449
526
  app: null
450
527
  };
451
528
  const StyledBadge = (0, _styled.default)(_Badge.default)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .BaseBadge-badge {\n top: ", "px;\n right: ", "px;\n }\n"])), props => props.top * 8 || 6, props => props.right * 8 || 6);
529
+ const StyledComponentRow = (0, _styled.default)(_Box.default)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n .component-name {\n color: #222;\n font-size: 16px;\n cursor: pointer;\n }\n"])));
452
530
  function BlockletComponent(_ref4) {
453
531
  let {
454
532
  blocklet,
@@ -581,6 +659,59 @@ function BlockletComponent(_ref4) {
581
659
  removeDeletingDid(d.meta.did);
582
660
  }
583
661
  };
662
+ const startComponent = async d => {
663
+ try {
664
+ await api.startBlocklet({
665
+ input: {
666
+ did: blocklet.meta.did,
667
+ componentDids: [d.meta.did]
668
+ }
669
+ });
670
+ await (0, _util2.sleep)(800);
671
+ } catch (err) {
672
+ _Toast.default.error((0, _util2.formatError)(err));
673
+ }
674
+ };
675
+ const stopComponent = async d => {
676
+ try {
677
+ await api.stopBlocklet({
678
+ input: {
679
+ did: blocklet.meta.did,
680
+ componentDids: [d.meta.did]
681
+ }
682
+ });
683
+ await (0, _util2.sleep)(800);
684
+ } catch (err) {
685
+ _Toast.default.error((0, _util2.formatError)(err));
686
+ }
687
+ };
688
+ const restartComponent = async d => {
689
+ try {
690
+ await api.restartBlocklet({
691
+ input: {
692
+ did: blocklet.meta.did,
693
+ componentDids: [d.meta.did]
694
+ }
695
+ });
696
+ await (0, _util2.sleep)(800);
697
+ } catch (err) {
698
+ _Toast.default.error((0, _util2.formatError)(err));
699
+ }
700
+ };
701
+ const reloadComponent = async d => {
702
+ try {
703
+ await api.reloadBlocklet({
704
+ input: {
705
+ did: blocklet.meta.did,
706
+ componentDids: [d.meta.did]
707
+ }
708
+ });
709
+ await (0, _util2.sleep)(800);
710
+ _Toast.default.success(t('blocklet.reloadSuccess'));
711
+ } catch (err) {
712
+ _Toast.default.error((0, _util2.formatError)(err));
713
+ }
714
+ };
584
715
  const onUpdateChecksChange = (e, groupId) => {
585
716
  const {
586
717
  checked: newValue
@@ -697,6 +828,10 @@ function BlockletComponent(_ref4) {
697
828
  blocklet: blocklet,
698
829
  app: blocklet,
699
830
  onRemove: removeComponent,
831
+ onStart: startComponent,
832
+ onStop: stopComponent,
833
+ onReload: reloadComponent,
834
+ onRestart: restartComponent,
700
835
  getComponentUrl: getComponentUrl
701
836
  }, "0-".concat(blocklet.meta.did))
702
837
  }, "top-blocklet-".concat(blocklet.meta.did))] : /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
@@ -803,4 +938,4 @@ BlockletComponent.defaultProps = {
803
938
  onUpdate: () => {},
804
939
  getComponentUrl: () => window.location.origin
805
940
  };
806
- const Div = _styled.default.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n .title {\n font-size: 1.2rem;\n font-weight: bold;\n margin-bottom: ", ";\n }\n\n @keyframes showDelay {\n 0% {\n opacity: 0;\n }\n\n 100% {\n opacity: 1;\n }\n }\n\n .component-item {\n animation: showDelay 0.75s ease 1;\n }\n"])), props => props.theme.spacing(1));
941
+ const Div = _styled.default.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n .title {\n font-size: 1.2rem;\n font-weight: bold;\n margin-bottom: ", ";\n }\n\n @keyframes showDelay {\n 0% {\n opacity: 0;\n }\n\n 100% {\n opacity: 1;\n }\n }\n\n .component-item {\n animation: showDelay 0.75s ease 1;\n }\n"])), props => props.theme.spacing(1));
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = StartComponent;
7
+ var _react = require("react");
8
+ var _styled = _interopRequireDefault(require("@emotion/styled"));
9
+ var _propTypes = _interopRequireDefault(require("prop-types"));
10
+ var _Toast = _interopRequireDefault(require("@arcblock/ux/lib/Toast"));
11
+ var _PlayArrow = _interopRequireDefault(require("@mui/icons-material/PlayArrow"));
12
+ var _Stop = _interopRequireDefault(require("@mui/icons-material/Stop"));
13
+ var _context = require("@arcblock/ux/lib/Locale/context");
14
+ var _IconButton = _interopRequireDefault(require("@mui/material/IconButton"));
15
+ var _Tooltip = _interopRequireDefault(require("@mui/material/Tooltip"));
16
+ var _confirm = _interopRequireDefault(require("../../confirm"));
17
+ var _jsxRuntime = require("react/jsx-runtime");
18
+ var _templateObject;
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 StartComponent(_ref) {
22
+ let {
23
+ component,
24
+ onStart,
25
+ onStop,
26
+ disabled,
27
+ tip
28
+ } = _ref;
29
+ const {
30
+ t
31
+ } = (0, _react.useContext)(_context.LocaleContext);
32
+ const [loading, setLoading] = (0, _react.useState)(false);
33
+ const [confirmSetting, setConfirmSetting] = (0, _react.useState)();
34
+ const startComponent = async () => {
35
+ setLoading(true);
36
+ try {
37
+ await onStart(component);
38
+ } catch (error) {
39
+ _Toast.default.error(error.message);
40
+ }
41
+ setLoading(false);
42
+ };
43
+ const stopComponent = async () => {
44
+ setLoading(true);
45
+ try {
46
+ await onStop(component);
47
+ } catch (error) {
48
+ _Toast.default.error(error.message);
49
+ }
50
+ setLoading(false);
51
+ };
52
+ const componentDisabled = disabled || loading;
53
+ const isStop = component.status === 'running';
54
+ const Icon = isStop ? _Stop.default : _PlayArrow.default;
55
+ const btn = /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledButton, {
56
+ disabled: componentDisabled,
57
+ onClick: () => {
58
+ if (isStop) {
59
+ var _component$meta;
60
+ setConfirmSetting({
61
+ title: "".concat(t('common.stop'), " ").concat(component === null || component === void 0 ? void 0 : (_component$meta = component.meta) === null || _component$meta === void 0 ? void 0 : _component$meta.title),
62
+ description: t('blocklet.action.stopComponentDescription'),
63
+ confirm: t('blocklet.action.confirmStop'),
64
+ cancel: t('common.cancel'),
65
+ onConfirm: () => {
66
+ setConfirmSetting(null);
67
+ return stopComponent();
68
+ },
69
+ onCancel: () => setConfirmSetting(null)
70
+ });
71
+ } else {
72
+ startComponent();
73
+ }
74
+ },
75
+ "data-cy": "".concat(isStop ? 'stop' : 'start', "-component-btn"),
76
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Icon, {
77
+ disabled: componentDisabled
78
+ })
79
+ });
80
+ return [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Tooltip.default, {
81
+ title: tip || t("common.".concat(isStop ? 'stop' : 'start')),
82
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
83
+ children: btn
84
+ })
85
+ }), confirmSetting && /*#__PURE__*/(0, _jsxRuntime.jsx)(_confirm.default, {
86
+ title: confirmSetting.title,
87
+ description: confirmSetting.description,
88
+ confirm: confirmSetting.confirm,
89
+ cancel: confirmSetting.cancel,
90
+ params: confirmSetting.params,
91
+ onConfirm: confirmSetting.onConfirm,
92
+ onCancel: confirmSetting.onCancel
93
+ })];
94
+ }
95
+ StartComponent.propTypes = {
96
+ component: _propTypes.default.object.isRequired,
97
+ onStart: _propTypes.default.func,
98
+ onStop: _propTypes.default.func,
99
+ disabled: _propTypes.default.bool,
100
+ tip: _propTypes.default.string
101
+ };
102
+ StartComponent.defaultProps = {
103
+ onStart: async () => {},
104
+ onStop: async () => {},
105
+ disabled: false,
106
+ tip: ''
107
+ };
108
+ const StyledButton = (0, _styled.default)(_IconButton.default)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n &.Mui-disabled {\n opacity: 0.5;\n }\n"])));
@@ -155,13 +155,7 @@ function BlockletOverview() {
155
155
  } : null, {
156
156
  name: t('blocklet.installedAt'),
157
157
  value: (0, _util2.formatToDatetime)(blocklet.installedAt)
158
- }, blocklet.status === 'running' ? {
159
- name: t('blocklet.startedAt'),
160
- value: (0, _util2.formatToDatetime)(blocklet.startedAt)
161
- } : null, blocklet.status !== 'running' ? {
162
- name: t('blocklet.stoppedAt'),
163
- value: (0, _util2.formatToDatetime)(blocklet.stoppedAt)
164
- } : null, {
158
+ }, {
165
159
  name: t('blocklet.overview.accessControl'),
166
160
  value: t("team.whoCanAccess.".concat((0, _util.getWhoCanAccess)(blocklet), ".title"))
167
161
  }, {
@@ -40,6 +40,7 @@ function RuleActions(rule) {
40
40
  rel: "noopener noreferrer",
41
41
  title: href,
42
42
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
43
+ size: "small",
43
44
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Launch.default, {})
44
45
  })
45
46
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_updateRule.default, _objectSpread(_objectSpread({}, rule), {}, {
@@ -48,6 +49,7 @@ function RuleActions(rule) {
48
49
  open: o
49
50
  } = _ref;
50
51
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
52
+ size: "small",
51
53
  onClick: o,
52
54
  disabled: rule.isProtected,
53
55
  "data-cy": "action-update-rule",
@@ -60,6 +62,7 @@ function RuleActions(rule) {
60
62
  open
61
63
  } = _ref2;
62
64
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
65
+ size: "small",
63
66
  onClick: open,
64
67
  disabled: rule.isProtected,
65
68
  "data-cy": "action-delete-rule",
@@ -83,7 +83,7 @@ function RuleList(_ref2) {
83
83
  placement: "top",
84
84
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
85
85
  disabled: true,
86
- size: "large",
86
+ size: "small",
87
87
  style: {
88
88
  pointerEvents: 'auto',
89
89
  // padding replace to margin, fix the tooltip position
package/lib/locales/en.js CHANGED
@@ -343,6 +343,7 @@ module.exports = {
343
343
  },
344
344
  action: {
345
345
  stopDescription: 'Stopping the blocklet will make its public interfaces unaccessible, which may cause end user failures',
346
+ stopComponentDescription: 'Stopping the component will make its public interfaces unaccessible, which may cause end user failures',
346
347
  confirmStop: 'Yes, Stop It',
347
348
  cancelDownloadDescription: 'Cancel download {name} ?',
348
349
  removeApplicationDescription: 'Removing the application will erase code and data generated by this application, which is not recoverable if you do not have any backups',
package/lib/locales/zh.js CHANGED
@@ -338,6 +338,7 @@ module.exports = {
338
338
  noComponent: '应用没有组件,无法启动',
339
339
  action: {
340
340
  stopDescription: '停止该基石程序将会使页面不可以访问,可能会导致使用它的用户出现错误',
341
+ stopComponentDescription: '停止该组件将会使页面不可以访问,可能会导致使用它的用户出现错误',
341
342
  confirmStop: '是的,停止',
342
343
  cancelDownloadDescription: '取消下载 {name} ?',
343
344
  removeApplicationDescription: '如果没有备份数据,删除应用将会删除所有数据,包括应用运行时产生的所有数据',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abtnode/ux",
3
- "version": "1.16.11-next-a232f5fb",
3
+ "version": "1.16.11-next-3d2b39f7",
4
4
  "description": "UX components shared across abtnode packages",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -23,9 +23,9 @@
23
23
  "author": "linchen <linchen1987@foxmail.com> (http://github.com/linchen1987)",
24
24
  "license": "Apache-2.0",
25
25
  "dependencies": {
26
- "@abtnode/auth": "1.16.11-next-a232f5fb",
27
- "@abtnode/constant": "1.16.11-next-a232f5fb",
28
- "@abtnode/util": "1.16.11-next-a232f5fb",
26
+ "@abtnode/auth": "1.16.11-next-3d2b39f7",
27
+ "@abtnode/constant": "1.16.11-next-3d2b39f7",
28
+ "@abtnode/util": "1.16.11-next-3d2b39f7",
29
29
  "@ahooksjs/use-url-state": "^3.5.1",
30
30
  "@arcblock/did": "^1.18.80",
31
31
  "@arcblock/did-connect": "^2.5.47",
@@ -34,10 +34,10 @@
34
34
  "@arcblock/react-hooks": "^2.5.47",
35
35
  "@arcblock/terminal": "^2.5.47",
36
36
  "@arcblock/ux": "^2.5.47",
37
- "@blocklet/constant": "1.16.11-next-a232f5fb",
37
+ "@blocklet/constant": "1.16.11-next-3d2b39f7",
38
38
  "@blocklet/launcher-layout": "2.1.0",
39
39
  "@blocklet/list": "^0.11.28",
40
- "@blocklet/meta": "1.16.11-next-a232f5fb",
40
+ "@blocklet/meta": "1.16.11-next-3d2b39f7",
41
41
  "@blocklet/ui-react": "^2.5.47",
42
42
  "@emotion/react": "^11.10.4",
43
43
  "@emotion/styled": "^11.10.4",
@@ -93,5 +93,5 @@
93
93
  "@babel/preset-react": "^7.18.6",
94
94
  "babel-plugin-inline-react-svg": "^1.1.2"
95
95
  },
96
- "gitHead": "1af264e9b6648aa191fbf23c67717262ac717697"
96
+ "gitHead": "d0142bd2d1e49b94dcb5542d78e294a7b2258faa"
97
97
  }