@abtnode/ux 1.16.14-beta-963cb583 → 1.16.14-beta-a2de000a

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.
@@ -1115,6 +1115,7 @@ const DialogWrapper = styled(Dialog)`
1115
1115
  padding-right: 0;
1116
1116
  padding-bottom: 0;
1117
1117
  }
1118
+
1118
1119
  .MuiDialogActions-root {
1119
1120
  padding: 16px 24px;
1120
1121
  }
@@ -1127,8 +1128,8 @@ const TypographyWrapper = styled(Typography)`
1127
1128
  height: 100%;
1128
1129
  `;
1129
1130
  const RightContent = styled.div`
1130
- padding: 34px 24px 24px;
1131
1131
  width: 100%;
1132
+ height: 100%;
1132
1133
  display: flex;
1133
1134
  flex-direction: column;
1134
1135
  justify-content: flex-start;
@@ -1158,6 +1159,8 @@ const DialogContentWrapper = styled(DialogContentText)`
1158
1159
  // mobile extra style
1159
1160
  if (className === 'mobileStyle') {
1160
1161
  return `
1162
+ height: 100%;
1163
+
1161
1164
  & > div{
1162
1165
  height: 100%;
1163
1166
  }
@@ -1167,6 +1170,8 @@ const DialogContentWrapper = styled(DialogContentText)`
1167
1170
  }
1168
1171
  }
1169
1172
 
1173
+
1174
+
1170
1175
  // content-panel
1171
1176
  .root-header + div{
1172
1177
  padding-top: 0;
@@ -1176,6 +1181,19 @@ const DialogContentWrapper = styled(DialogContentText)`
1176
1181
  }
1177
1182
  }
1178
1183
 
1184
+ header + div {
1185
+ padding-top: 0;
1186
+ }
1187
+
1188
+ header {
1189
+ .header-title {
1190
+ margin-left: 0;
1191
+ }
1192
+
1193
+ .header-title-name {
1194
+ max-width: 100% !important;
1195
+ }
1196
+ }
1179
1197
  `;
1180
1198
  }
1181
1199
  return `
@@ -2,52 +2,12 @@ import Tag from '@arcblock/ux/lib/Tag';
2
2
  import Datatable from '@arcblock/ux/lib/Datatable';
3
3
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
4
4
  import { Box, CircularProgress, Icon, Link, Tooltip, Typography } from '@mui/material';
5
- import React, { useCallback, useState } from 'react';
6
- import { isEmpty, isNull, throttle } from 'lodash';
7
- import { useAsyncEffect } from 'ahooks';
5
+ import React from 'react';
6
+ import { isEmpty, isNull } from 'lodash';
8
7
  import dayjs from '@abtnode/util/lib/dayjs';
9
8
  import HelpOutlineIcon from '@mui/icons-material/HelpOutline';
10
9
  import { array, object } from 'prop-types';
11
- import { useNodeContext } from '../../contexts/node';
12
- import { useBlockletContext } from '../../contexts/blocklet';
13
-
14
- /**
15
- * @description
16
- * @param {{ blocklet: import('@abtnode/client').BlockletState }} { blocklet }
17
- * @return {{backups: import('@abtnode/client').Backup[]}}
18
- */
19
- import { jsx as _jsx } from "react/jsx-runtime";
20
- import { jsxs as _jsxs } from "react/jsx-runtime";
21
- import { Fragment as _Fragment } from "react/jsx-runtime";
22
- function useBackups({
23
- blocklet,
24
- loading,
25
- progress
26
- }) {
27
- const [backups, setBackups] = useState([]);
28
- const {
29
- api
30
- } = useNodeContext();
31
- // eslint-disable-next-line react-hooks/exhaustive-deps
32
- const fetchBackups = useCallback(throttle(async () => {
33
- const {
34
- backups: data
35
- } = await api.getBlockletBackups({
36
- input: {
37
- did: blocklet?.meta?.did
38
- }
39
- });
40
- setBackups(data ?? []);
41
- }, 2000), []);
42
-
43
- // eslint-disable-next-line require-await
44
- useAsyncEffect(async () => {
45
- fetchBackups();
46
- }, [blocklet?.meta?.did, progress, loading]);
47
- return {
48
- backups
49
- };
50
- }
10
+ import useBackups from '../../hooks/use-backups';
51
11
 
52
12
  /**
53
13
  * @description
@@ -57,6 +17,9 @@ function useBackups({
57
17
  * }} { progress, spaceGateways, ...rest }
58
18
  * @return {*}
59
19
  */
20
+ import { jsx as _jsx } from "react/jsx-runtime";
21
+ import { jsxs as _jsxs } from "react/jsx-runtime";
22
+ import { Fragment as _Fragment } from "react/jsx-runtime";
60
23
  function SpacesBackupRecords({
61
24
  progress,
62
25
  spaceGateways,
@@ -66,13 +29,9 @@ function SpacesBackupRecords({
66
29
  t,
67
30
  locale
68
31
  } = useLocaleContext();
69
- const {
70
- blocklet
71
- } = useBlockletContext();
72
32
  const {
73
33
  backups
74
34
  } = useBackups({
75
- blocklet,
76
35
  progress
77
36
  });
78
37
  const columns = [{
@@ -152,9 +111,14 @@ function SpacesBackupRecords({
152
111
  customBodyRenderLite: index => {
153
112
  const {
154
113
  status,
155
- message
114
+ message,
115
+ createdAt
156
116
  } = backups?.[index] ?? {};
157
- if (isNull(status)) {
117
+ const timeoutError = isNull(status) && dayjs().diff(createdAt, 'hours') > 6;
118
+ const timeoutErrorMessage = timeoutError && t('common.timeoutError');
119
+ const pending = isNull(status) && !timeoutError;
120
+ const success = status === 0 && !timeoutError;
121
+ if (pending) {
158
122
  return /*#__PURE__*/_jsxs(Typography, {
159
123
  display: "inline-flex",
160
124
  alignItems: "center",
@@ -167,10 +131,13 @@ function SpacesBackupRecords({
167
131
  }), t('common.progress')]
168
132
  });
169
133
  }
170
- const node = !status ? /*#__PURE__*/_jsx(Tag, {
171
- type: "success",
172
- children: t('common.succeeded')
173
- }) : /*#__PURE__*/_jsxs(Box, {
134
+ if (success) {
135
+ return /*#__PURE__*/_jsx(Tag, {
136
+ type: "success",
137
+ children: t('common.succeeded')
138
+ });
139
+ }
140
+ return /*#__PURE__*/_jsxs(Box, {
174
141
  display: "inline-flex",
175
142
  alignItems: "center",
176
143
  children: [/*#__PURE__*/_jsx(Tag, {
@@ -182,7 +149,7 @@ function SpacesBackupRecords({
182
149
  alignItems: 'center',
183
150
  flexShrink: 0
184
151
  },
185
- title: message,
152
+ title: message || timeoutErrorMessage,
186
153
  children: /*#__PURE__*/_jsx(Icon, {
187
154
  children: /*#__PURE__*/_jsx(HelpOutlineIcon, {
188
155
  style: {
@@ -194,7 +161,6 @@ function SpacesBackupRecords({
194
161
  })
195
162
  })]
196
163
  });
197
- return node;
198
164
  }
199
165
  }
200
166
  }];
@@ -1,6 +1,8 @@
1
- import { useState } from 'react';
1
+ import { useEffect, useState } from 'react';
2
2
  import { BlockletEvents } from '@blocklet/constant';
3
+ import { isNull } from 'lodash';
3
4
  import { useNodeContext } from '../contexts/node';
5
+ import useBackups from './use-backups';
4
6
 
5
7
  /**
6
8
  * @description 实时显示备份的进度
@@ -10,6 +12,9 @@ import { useNodeContext } from '../contexts/node';
10
12
  function useBackupProgress({
11
13
  appDid
12
14
  }) {
15
+ const {
16
+ backups
17
+ } = useBackups();
13
18
  const [progress, setProgress] = useState({
14
19
  message: '',
15
20
  progress: 0,
@@ -26,6 +31,18 @@ function useBackupProgress({
26
31
  ...data
27
32
  }));
28
33
  }, [appDid]);
34
+ useEffect(() => {
35
+ // @note: isNull(backups[0]?.status) 表示正在备份中...
36
+ if (backups?.length && isNull(backups[0]?.status)) {
37
+ const [backup] = backups;
38
+ setProgress(() => ({
39
+ message: backup.message,
40
+ progress: backup.progress,
41
+ // @note: backup.progress 可能是一个浮点型
42
+ completed: Boolean(backup.progress >= 100)
43
+ }));
44
+ }
45
+ }, [backups]);
29
46
  return progress;
30
47
  }
31
48
  export default useBackupProgress;
@@ -0,0 +1,42 @@
1
+ import { useCallback, useState } from 'react';
2
+ import { throttle } from 'lodash';
3
+ import { useAsyncEffect } from 'ahooks';
4
+ import { useNodeContext } from '../contexts/node';
5
+ import { useBlockletContext } from '../contexts/blocklet';
6
+
7
+ /**
8
+ * @description
9
+ * @param {{ blocklet: import('@abtnode/client').BlockletState, progress: Object, loading: boolean, }} { blocklet, progress, loading }
10
+ * @return {{backups: import('@abtnode/client').Backup[]}}
11
+ */
12
+ export default function useBackups({
13
+ loading,
14
+ progress
15
+ } = {}) {
16
+ const {
17
+ blocklet
18
+ } = useBlockletContext();
19
+ const [backups, setBackups] = useState([]);
20
+ const {
21
+ api
22
+ } = useNodeContext();
23
+ // eslint-disable-next-line react-hooks/exhaustive-deps
24
+ const fetchBackups = useCallback(throttle(async () => {
25
+ const {
26
+ backups: data
27
+ } = await api.getBlockletBackups({
28
+ input: {
29
+ did: blocklet?.meta?.did
30
+ }
31
+ });
32
+ setBackups(data ?? []);
33
+ }, 2000), []);
34
+
35
+ // eslint-disable-next-line require-await
36
+ useAsyncEffect(async () => {
37
+ fetchBackups();
38
+ }, [blocklet?.meta?.did, progress, loading]);
39
+ return {
40
+ backups
41
+ };
42
+ }
package/es/locales/en.js CHANGED
@@ -160,7 +160,7 @@ module.exports = {
160
160
  expires: 'Expires',
161
161
  export: 'Export',
162
162
  externalIp: 'External IP',
163
- failed: 'failed',
163
+ failed: 'Failed',
164
164
  filter: 'Log Filter',
165
165
  fingerprint: 'Fingerprint',
166
166
  finish: 'Finish',
@@ -311,7 +311,8 @@ module.exports = {
311
311
  progress: 'In progress',
312
312
  startTime: 'Start time',
313
313
  endTime: 'End time',
314
- selected: 'Selected'
314
+ selected: 'Selected',
315
+ timeoutError: 'Timeout error'
315
316
  },
316
317
  blocklet: {
317
318
  external: 'External',
package/es/locales/zh.js CHANGED
@@ -316,7 +316,8 @@ module.exports = {
316
316
  progress: '进行中',
317
317
  startTime: '开始时间',
318
318
  endTime: '结束时间',
319
- selected: '已选中'
319
+ selected: '已选中',
320
+ timeoutError: '超时错误'
320
321
  },
321
322
  blocklet: {
322
323
  external: '外部',
@@ -1117,9 +1117,9 @@ AddComponent.defaultProps = {
1117
1117
  };
1118
1118
 
1119
1119
  // FIXME: @zhanghan 下面代码中的 header:empty 用于修复 e2e-test 中的问题 core/webapp/cypress/e2e/3-blocklet-lifecycle.cy.js L70
1120
- const DialogWrapper = (0, _styled.default)(_Dialog.default)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .MuiDialogContent-root {\n padding-left: 0;\n padding-right: 0;\n padding-bottom: 0;\n }\n .MuiDialogActions-root {\n padding: 16px 24px;\n }\n header:empty {\n display: none;\n }\n"])));
1120
+ const DialogWrapper = (0, _styled.default)(_Dialog.default)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .MuiDialogContent-root {\n padding-left: 0;\n padding-right: 0;\n padding-bottom: 0;\n }\n\n .MuiDialogActions-root {\n padding: 16px 24px;\n }\n header:empty {\n display: none;\n }\n"])));
1121
1121
  const TypographyWrapper = (0, _styled.default)(_Typography.default)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n width: 100%;\n height: 100%;\n"])));
1122
- const RightContent = _styled.default.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n padding: 34px 24px 24px;\n width: 100%;\n display: flex;\n flex-direction: column;\n justify-content: flex-start;\n align-items: flex-start;\n\n .bottom-button {\n min-width: 200px;\n }\n\n // blocklet-select-side\n aside {\n width: 140px;\n }\n"])));
1122
+ const RightContent = _styled.default.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n width: 100%;\n height: 100%;\n display: flex;\n flex-direction: column;\n justify-content: flex-start;\n align-items: flex-start;\n\n .bottom-button {\n min-width: 200px;\n }\n\n // blocklet-select-side\n aside {\n width: 140px;\n }\n"])));
1123
1123
  const isMobileDialogContent = props => {
1124
1124
  if (props.isMobile) {
1125
1125
  return "\n height: calc(100vh - 56px - 64px - 48px);\n ";
@@ -1132,7 +1132,7 @@ const DialogContentWrapper = (0, _styled.default)(_DialogContentText.default)(_t
1132
1132
  } = _ref9;
1133
1133
  // mobile extra style
1134
1134
  if (className === 'mobileStyle') {
1135
- return "\n & > div{\n height: 100%;\n }\n .root-header {\n .app-name-content {\n display: none;\n }\n }\n\n // content-panel\n .root-header + div{\n padding-top: 0;\n position: relative;\n & > div {\n padding-top: 0;\n }\n }\n\n ";
1135
+ return "\n height: 100%;\n\n & > div{\n height: 100%;\n }\n .root-header {\n .app-name-content {\n display: none;\n }\n }\n\n\n\n // content-panel\n .root-header + div{\n padding-top: 0;\n position: relative;\n & > div {\n padding-top: 0;\n }\n }\n\n header + div {\n padding-top: 0;\n }\n\n header {\n .header-title {\n margin-left: 0;\n }\n\n .header-title-name {\n max-width: 100% !important;\n }\n }\n ";
1136
1136
  }
1137
1137
  return "\n height: 72vh;\n position: relative;\n .root-header {\n z-index: auto !important;\n position: fixed !important;\n }\n & > div {\n height: 100%;\n width: 100%;\n max-width: 100%;\n & > div {\n max-height: unset !important;\n max-width: 100%;\n & > div {\n // left-panel\n &:first-child {\n padding-top: 0;\n // padding-left: 0;\n width: 25%;\n min-width: 240px;\n & > div:first-child {\n display: none;\n }\n // step\n & > div:last-child {\n // margin-top: 32px;\n margin-top: 0;\n }\n }\n // right-panel\n &:last-child {\n padding-top: 0;\n padding-right: 24px;\n overflow-y: auto;\n .app-content {\n padding: 0 0 24px 0;\n }\n .button-container {\n padding-right: 0;\n }\n }\n }\n }\n }\n\n ";
1138
1138
  }, props => isMobileDialogContent(props), props => isMobileDialogContent(props));
@@ -8,23 +8,22 @@ var _Tag = _interopRequireDefault(require("@arcblock/ux/lib/Tag"));
8
8
  var _Datatable = _interopRequireDefault(require("@arcblock/ux/lib/Datatable"));
9
9
  var _context = require("@arcblock/ux/lib/Locale/context");
10
10
  var _material = require("@mui/material");
11
- var _react = _interopRequireWildcard(require("react"));
11
+ var _react = _interopRequireDefault(require("react"));
12
12
  var _lodash = require("lodash");
13
- var _ahooks = require("ahooks");
14
13
  var _dayjs = _interopRequireDefault(require("@abtnode/util/lib/dayjs"));
15
14
  var _HelpOutline = _interopRequireDefault(require("@mui/icons-material/HelpOutline"));
16
15
  var _propTypes = require("prop-types");
17
- var _node = require("../../contexts/node");
18
- var _blocklet = require("../../contexts/blocklet");
16
+ var _useBackups = _interopRequireDefault(require("../../hooks/use-backups"));
19
17
  var _jsxRuntime = require("react/jsx-runtime");
20
18
  const _excluded = ["progress", "spaceGateways"];
21
19
  /**
22
20
  * @description
23
- * @param {{ blocklet: import('@abtnode/client').BlockletState }} { blocklet }
24
- * @return {{backups: import('@abtnode/client').Backup[]}}
21
+ * @param {{
22
+ * progress: any,
23
+ * spaceGateways: Array<import('./connected').SpaceGateway>
24
+ * }} { progress, spaceGateways, ...rest }
25
+ * @return {*}
25
26
  */
26
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
27
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
28
27
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
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; }
30
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; }
@@ -33,64 +32,19 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typ
33
32
  function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
34
33
  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; }
35
34
  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; }
36
- function useBackups(_ref) {
37
- var _blocklet$meta2;
38
- let {
39
- blocklet,
40
- loading,
41
- progress
42
- } = _ref;
43
- const [backups, setBackups] = (0, _react.useState)([]);
44
- const {
45
- api
46
- } = (0, _node.useNodeContext)();
47
- // eslint-disable-next-line react-hooks/exhaustive-deps
48
- const fetchBackups = (0, _react.useCallback)((0, _lodash.throttle)(async () => {
49
- var _blocklet$meta;
50
- const {
51
- backups: data
52
- } = await api.getBlockletBackups({
53
- input: {
54
- did: blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta = blocklet.meta) === null || _blocklet$meta === void 0 ? void 0 : _blocklet$meta.did
55
- }
56
- });
57
- setBackups(data !== null && data !== void 0 ? data : []);
58
- }, 2000), []);
59
-
60
- // eslint-disable-next-line require-await
61
- (0, _ahooks.useAsyncEffect)(async () => {
62
- fetchBackups();
63
- }, [blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta2 = blocklet.meta) === null || _blocklet$meta2 === void 0 ? void 0 : _blocklet$meta2.did, progress, loading]);
64
- return {
65
- backups
66
- };
67
- }
68
-
69
- /**
70
- * @description
71
- * @param {{
72
- * progress: any,
73
- * spaceGateways: Array<import('./connected').SpaceGateway>
74
- * }} { progress, spaceGateways, ...rest }
75
- * @return {*}
76
- */
77
- function SpacesBackupRecords(_ref2) {
35
+ function SpacesBackupRecords(_ref) {
78
36
  let {
79
37
  progress,
80
38
  spaceGateways
81
- } = _ref2,
82
- rest = _objectWithoutProperties(_ref2, _excluded);
39
+ } = _ref,
40
+ rest = _objectWithoutProperties(_ref, _excluded);
83
41
  const {
84
42
  t,
85
43
  locale
86
44
  } = (0, _context.useLocaleContext)();
87
- const {
88
- blocklet
89
- } = (0, _blocklet.useBlockletContext)();
90
45
  const {
91
46
  backups
92
- } = useBackups({
93
- blocklet,
47
+ } = (0, _useBackups.default)({
94
48
  progress
95
49
  });
96
50
  const columns = [{
@@ -172,9 +126,14 @@ function SpacesBackupRecords(_ref2) {
172
126
  var _backups$index;
173
127
  const {
174
128
  status,
175
- message
129
+ message,
130
+ createdAt
176
131
  } = (_backups$index = backups === null || backups === void 0 ? void 0 : backups[index]) !== null && _backups$index !== void 0 ? _backups$index : {};
177
- if ((0, _lodash.isNull)(status)) {
132
+ const timeoutError = (0, _lodash.isNull)(status) && (0, _dayjs.default)().diff(createdAt, 'hours') > 6;
133
+ const timeoutErrorMessage = timeoutError && t('common.timeoutError');
134
+ const pending = (0, _lodash.isNull)(status) && !timeoutError;
135
+ const success = status === 0 && !timeoutError;
136
+ if (pending) {
178
137
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Typography, {
179
138
  display: "inline-flex",
180
139
  alignItems: "center",
@@ -187,10 +146,13 @@ function SpacesBackupRecords(_ref2) {
187
146
  }), t('common.progress')]
188
147
  });
189
148
  }
190
- const node = !status ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tag.default, {
191
- type: "success",
192
- children: t('common.succeeded')
193
- }) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
149
+ if (success) {
150
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tag.default, {
151
+ type: "success",
152
+ children: t('common.succeeded')
153
+ });
154
+ }
155
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
194
156
  display: "inline-flex",
195
157
  alignItems: "center",
196
158
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Tag.default, {
@@ -202,7 +164,7 @@ function SpacesBackupRecords(_ref2) {
202
164
  alignItems: 'center',
203
165
  flexShrink: 0
204
166
  },
205
- title: message,
167
+ title: message || timeoutErrorMessage,
206
168
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Icon, {
207
169
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_HelpOutline.default, {
208
170
  style: {
@@ -214,7 +176,6 @@ function SpacesBackupRecords(_ref2) {
214
176
  })
215
177
  })]
216
178
  });
217
- return node;
218
179
  }
219
180
  }
220
181
  }];
@@ -6,7 +6,10 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _react = require("react");
8
8
  var _constant = require("@blocklet/constant");
9
+ var _lodash = require("lodash");
9
10
  var _node = require("../contexts/node");
11
+ var _useBackups = _interopRequireDefault(require("./use-backups"));
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
13
  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; }
11
14
  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; }
12
15
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
@@ -21,6 +24,9 @@ function useBackupProgress(_ref) {
21
24
  let {
22
25
  appDid
23
26
  } = _ref;
27
+ const {
28
+ backups
29
+ } = (0, _useBackups.default)();
24
30
  const [progress, setProgress] = (0, _react.useState)({
25
31
  message: '',
26
32
  progress: 0,
@@ -35,6 +41,19 @@ function useBackupProgress(_ref) {
35
41
  useSubscription(_constant.BlockletEvents.backupProgress, data => {
36
42
  setProgress(() => _objectSpread({}, data));
37
43
  }, [appDid]);
44
+ (0, _react.useEffect)(() => {
45
+ var _backups$;
46
+ // @note: isNull(backups[0]?.status) 表示正在备份中...
47
+ if (backups !== null && backups !== void 0 && backups.length && (0, _lodash.isNull)((_backups$ = backups[0]) === null || _backups$ === void 0 ? void 0 : _backups$.status)) {
48
+ const [backup] = backups;
49
+ setProgress(() => ({
50
+ message: backup.message,
51
+ progress: backup.progress,
52
+ // @note: backup.progress 可能是一个浮点型
53
+ completed: Boolean(backup.progress >= 100)
54
+ }));
55
+ }
56
+ }, [backups]);
38
57
  return progress;
39
58
  }
40
59
  var _default = useBackupProgress;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = useBackups;
7
+ var _react = require("react");
8
+ var _lodash = require("lodash");
9
+ var _ahooks = require("ahooks");
10
+ var _node = require("../contexts/node");
11
+ var _blocklet = require("../contexts/blocklet");
12
+ /**
13
+ * @description
14
+ * @param {{ blocklet: import('@abtnode/client').BlockletState, progress: Object, loading: boolean, }} { blocklet, progress, loading }
15
+ * @return {{backups: import('@abtnode/client').Backup[]}}
16
+ */
17
+ function useBackups() {
18
+ var _blocklet$meta2;
19
+ let {
20
+ loading,
21
+ progress
22
+ } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
23
+ const {
24
+ blocklet
25
+ } = (0, _blocklet.useBlockletContext)();
26
+ const [backups, setBackups] = (0, _react.useState)([]);
27
+ const {
28
+ api
29
+ } = (0, _node.useNodeContext)();
30
+ // eslint-disable-next-line react-hooks/exhaustive-deps
31
+ const fetchBackups = (0, _react.useCallback)((0, _lodash.throttle)(async () => {
32
+ var _blocklet$meta;
33
+ const {
34
+ backups: data
35
+ } = await api.getBlockletBackups({
36
+ input: {
37
+ did: blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta = blocklet.meta) === null || _blocklet$meta === void 0 ? void 0 : _blocklet$meta.did
38
+ }
39
+ });
40
+ setBackups(data !== null && data !== void 0 ? data : []);
41
+ }, 2000), []);
42
+
43
+ // eslint-disable-next-line require-await
44
+ (0, _ahooks.useAsyncEffect)(async () => {
45
+ fetchBackups();
46
+ }, [blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta2 = blocklet.meta) === null || _blocklet$meta2 === void 0 ? void 0 : _blocklet$meta2.did, progress, loading]);
47
+ return {
48
+ backups
49
+ };
50
+ }
package/lib/locales/en.js CHANGED
@@ -162,7 +162,7 @@ module.exports = {
162
162
  expires: 'Expires',
163
163
  export: 'Export',
164
164
  externalIp: 'External IP',
165
- failed: 'failed',
165
+ failed: 'Failed',
166
166
  filter: 'Log Filter',
167
167
  fingerprint: 'Fingerprint',
168
168
  finish: 'Finish',
@@ -313,7 +313,8 @@ module.exports = {
313
313
  progress: 'In progress',
314
314
  startTime: 'Start time',
315
315
  endTime: 'End time',
316
- selected: 'Selected'
316
+ selected: 'Selected',
317
+ timeoutError: 'Timeout error'
317
318
  },
318
319
  blocklet: {
319
320
  external: 'External',
package/lib/locales/zh.js CHANGED
@@ -318,7 +318,8 @@ module.exports = {
318
318
  progress: '进行中',
319
319
  startTime: '开始时间',
320
320
  endTime: '结束时间',
321
- selected: '已选中'
321
+ selected: '已选中',
322
+ timeoutError: '超时错误'
322
323
  },
323
324
  blocklet: {
324
325
  external: '外部',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abtnode/ux",
3
- "version": "1.16.14-beta-963cb583",
3
+ "version": "1.16.14-beta-a2de000a",
4
4
  "description": "UX components shared across abtnode packages",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -27,23 +27,23 @@
27
27
  "author": "linchen <linchen1987@foxmail.com> (http://github.com/linchen1987)",
28
28
  "license": "Apache-2.0",
29
29
  "dependencies": {
30
- "@abtnode/auth": "1.16.14-beta-963cb583",
31
- "@abtnode/constant": "1.16.14-beta-963cb583",
32
- "@abtnode/util": "1.16.14-beta-963cb583",
30
+ "@abtnode/auth": "1.16.14-beta-a2de000a",
31
+ "@abtnode/constant": "1.16.14-beta-a2de000a",
32
+ "@abtnode/util": "1.16.14-beta-a2de000a",
33
33
  "@ahooksjs/use-url-state": "^3.5.1",
34
34
  "@arcblock/did": "^1.18.89",
35
- "@arcblock/did-connect": "^2.7.5",
35
+ "@arcblock/did-connect": "^2.7.6",
36
36
  "@arcblock/did-motif": "^1.1.13",
37
- "@arcblock/icons": "^2.7.5",
38
- "@arcblock/nft-display": "2.7.5",
39
- "@arcblock/react-hooks": "^2.7.5",
40
- "@arcblock/terminal": "^2.7.5",
41
- "@arcblock/ux": "^2.7.5",
42
- "@blocklet/constant": "1.16.14-beta-963cb583",
43
- "@blocklet/launcher-layout": "2.1.90",
37
+ "@arcblock/icons": "^2.7.6",
38
+ "@arcblock/nft-display": "2.7.6",
39
+ "@arcblock/react-hooks": "^2.7.6",
40
+ "@arcblock/terminal": "^2.7.6",
41
+ "@arcblock/ux": "^2.7.6",
42
+ "@blocklet/constant": "1.16.14-beta-a2de000a",
43
+ "@blocklet/launcher-layout": "2.1.93",
44
44
  "@blocklet/list": "^0.12.25",
45
- "@blocklet/meta": "1.16.14-beta-963cb583",
46
- "@blocklet/ui-react": "^2.7.5",
45
+ "@blocklet/meta": "1.16.14-beta-a2de000a",
46
+ "@blocklet/ui-react": "^2.7.6",
47
47
  "@emotion/react": "^11.10.4",
48
48
  "@emotion/styled": "^11.10.4",
49
49
  "@iconify/react": "^4.0.0",
@@ -98,7 +98,7 @@
98
98
  "babel-plugin-inline-react-svg": "^1.1.2",
99
99
  "glob": "^10.3.3"
100
100
  },
101
- "gitHead": "82bae80cd584a096719d6985740e13f15b4f46bf",
101
+ "gitHead": "ed1336f2b7d3e6a4d5eeafd3816e6573c53ad543",
102
102
  "exports": {
103
103
  ".": {
104
104
  "import": "./es/index.js",