@abtnode/ux 1.16.15-beta-a635f48d → 1.16.15-beta-58d50c9a
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.
|
@@ -1,12 +1,15 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
1
2
|
import Tag from '@arcblock/ux/lib/Tag';
|
|
2
3
|
import Datatable from '@arcblock/ux/lib/Datatable';
|
|
3
4
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
4
5
|
import { Box, CircularProgress, Icon, Link, Tooltip, Typography } from '@mui/material';
|
|
5
6
|
import React from 'react';
|
|
6
|
-
import { isEmpty
|
|
7
|
+
import { isEmpty } from 'lodash';
|
|
7
8
|
import dayjs from '@abtnode/util/lib/dayjs';
|
|
8
9
|
import HelpOutlineIcon from '@mui/icons-material/HelpOutline';
|
|
10
|
+
import { BACKUPS } from '@abtnode/constant';
|
|
9
11
|
import { useBlockletStorageContext } from '../../contexts/blocklet-storage';
|
|
12
|
+
import { getDIDSpaceDidFromEndpoint } from '../../util/spaces';
|
|
10
13
|
|
|
11
14
|
/**
|
|
12
15
|
*
|
|
@@ -39,9 +42,20 @@ function SpacesBackupRecords({
|
|
|
39
42
|
// eslint-disable-next-line no-unused-vars
|
|
40
43
|
const {
|
|
41
44
|
targetUrl,
|
|
42
|
-
targetName
|
|
45
|
+
targetName,
|
|
46
|
+
status,
|
|
47
|
+
createdAt
|
|
43
48
|
} = backups[index];
|
|
44
|
-
const
|
|
49
|
+
const timeoutError = status === BACKUPS.STATUS.PROGRESS && dayjs().diff(createdAt, 'hours') >= BACKUPS.TIMEOUT_HOURS;
|
|
50
|
+
const success = status === BACKUPS.STATUS.SUCCEEDED && !timeoutError;
|
|
51
|
+
const spaceName = targetName || spaceGateways.find(spaceGateway => targetUrl?.includes(getDIDSpaceDidFromEndpoint(spaceGateway?.endpoint)))?.name || 'Unknown DID Space';
|
|
52
|
+
if (!success) {
|
|
53
|
+
return /*#__PURE__*/_jsx(Typography, {
|
|
54
|
+
variant: "body1",
|
|
55
|
+
fontSize: "16px",
|
|
56
|
+
children: spaceName
|
|
57
|
+
});
|
|
58
|
+
}
|
|
45
59
|
return /*#__PURE__*/_jsx(Link, {
|
|
46
60
|
fontSize: "16px",
|
|
47
61
|
href: targetUrl,
|
|
@@ -110,10 +124,10 @@ function SpacesBackupRecords({
|
|
|
110
124
|
message,
|
|
111
125
|
createdAt
|
|
112
126
|
} = backups?.[index] ?? {};
|
|
113
|
-
const timeoutError =
|
|
127
|
+
const timeoutError = status === BACKUPS.STATUS.PROGRESS && dayjs().diff(createdAt, 'hours') >= BACKUPS.TIMEOUT_HOURS;
|
|
114
128
|
const timeoutErrorMessage = timeoutError && t('common.timeoutError');
|
|
115
|
-
const pending =
|
|
116
|
-
const success = status ===
|
|
129
|
+
const pending = status === BACKUPS.STATUS.PROGRESS && !timeoutError;
|
|
130
|
+
const success = status === BACKUPS.STATUS.SUCCEEDED && !timeoutError;
|
|
117
131
|
if (pending) {
|
|
118
132
|
return /*#__PURE__*/_jsxs(Typography, {
|
|
119
133
|
display: "inline-flex",
|
|
@@ -64,10 +64,9 @@ import { useBlockletStorageContext } from '../../contexts/blocklet-storage';
|
|
|
64
64
|
* @param {{
|
|
65
65
|
* spaceGateway: import('./connected').SpaceGateway
|
|
66
66
|
* connected: boolean,
|
|
67
|
-
* progress: any,
|
|
68
67
|
* onDelete: (spaceGateway: import('./connected').SpaceGateway) => Promise<void>,
|
|
69
68
|
* onBackupNow: () => Promise<void>,
|
|
70
|
-
* }} { spaceGateway }
|
|
69
|
+
* }} { spaceGateway, connected,, onDelete, onBackupNow }
|
|
71
70
|
*/
|
|
72
71
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
73
72
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
@@ -107,14 +106,10 @@ function SpaceItem({
|
|
|
107
106
|
const {
|
|
108
107
|
updateSpaceGateway,
|
|
109
108
|
backupEndpoint,
|
|
110
|
-
backupProgress
|
|
109
|
+
backupProgress,
|
|
110
|
+
refreshBackupEndpoint
|
|
111
111
|
} = useBlockletStorageContext();
|
|
112
|
-
|
|
113
|
-
// TEST:
|
|
114
112
|
const [loading, setLoading] = useState(false);
|
|
115
|
-
// backupProgress.message = '(12/99)备份到备份到备份到备份到备';
|
|
116
|
-
// backupProgress.progress = 99;
|
|
117
|
-
|
|
118
113
|
const [authorizeConnect, setAuthorizeConnect] = useState({
|
|
119
114
|
open: false,
|
|
120
115
|
action: 'one-click-authorization',
|
|
@@ -176,6 +171,7 @@ function SpaceItem({
|
|
|
176
171
|
}]
|
|
177
172
|
}
|
|
178
173
|
});
|
|
174
|
+
refreshBackupEndpoint();
|
|
179
175
|
Toast.success(t('storage.spaces.connect.switchToSpaceSucceeded', {
|
|
180
176
|
name: spaceGateway.name ? `(${spaceGateway.name})` : ''
|
|
181
177
|
}));
|
|
@@ -30,6 +30,7 @@ import useBackups from '../hooks/use-backups';
|
|
|
30
30
|
* backupProgress: any,
|
|
31
31
|
* backups: Backup[],
|
|
32
32
|
* backupsLoading: boolean,
|
|
33
|
+
* refreshBackupEndpoint: () => void,
|
|
33
34
|
* }} BlockletStorageContextType
|
|
34
35
|
*/
|
|
35
36
|
|
|
@@ -65,9 +66,10 @@ function BlockletStorageProvider({
|
|
|
65
66
|
const backupProgress = useBackupProgress({
|
|
66
67
|
appDid: blocklet?.appDid
|
|
67
68
|
});
|
|
69
|
+
const [backupEndpointRefresh, setBackupEndpointRefresh] = useState(false);
|
|
68
70
|
const backupEndpoint = useMemo(() => getSpaceBackupEndpoint(blocklet?.environments),
|
|
69
71
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
70
|
-
[blocklet, spaceGatewaysRefresh]);
|
|
72
|
+
[blocklet, spaceGatewaysRefresh, backupEndpointRefresh]);
|
|
71
73
|
const [backupsLoading, setBackupsLoading] = useState(false);
|
|
72
74
|
const {
|
|
73
75
|
backups
|
|
@@ -140,7 +142,7 @@ function BlockletStorageProvider({
|
|
|
140
142
|
input: {
|
|
141
143
|
did: blocklet.meta.did,
|
|
142
144
|
where: {
|
|
143
|
-
|
|
145
|
+
did: spaceGateway.did
|
|
144
146
|
},
|
|
145
147
|
spaceGateway
|
|
146
148
|
}
|
|
@@ -170,6 +172,9 @@ function BlockletStorageProvider({
|
|
|
170
172
|
* @param {SpaceGateway} spaceGateway
|
|
171
173
|
*/
|
|
172
174
|
const spaceGatewayIsSelected = spaceGateway => spaceGateway?.endpoint === backupEndpoint;
|
|
175
|
+
const refreshBackupEndpoint = () => {
|
|
176
|
+
setBackupEndpointRefresh(p => !p);
|
|
177
|
+
};
|
|
173
178
|
return /*#__PURE__*/_jsx(Provider, {
|
|
174
179
|
value: {
|
|
175
180
|
spaceGateways,
|
|
@@ -183,7 +188,8 @@ function BlockletStorageProvider({
|
|
|
183
188
|
backupEndpoint,
|
|
184
189
|
backupProgress,
|
|
185
190
|
backups,
|
|
186
|
-
backupsLoading
|
|
191
|
+
backupsLoading,
|
|
192
|
+
refreshBackupEndpoint
|
|
187
193
|
},
|
|
188
194
|
children: children
|
|
189
195
|
});
|
|
@@ -12,7 +12,9 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
12
12
|
var _lodash = require("lodash");
|
|
13
13
|
var _dayjs = _interopRequireDefault(require("@abtnode/util/lib/dayjs"));
|
|
14
14
|
var _HelpOutline = _interopRequireDefault(require("@mui/icons-material/HelpOutline"));
|
|
15
|
+
var _constant = require("@abtnode/constant");
|
|
15
16
|
var _blockletStorage = require("../../contexts/blocklet-storage");
|
|
17
|
+
var _spaces = require("../../util/spaces");
|
|
16
18
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
19
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
20
|
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; }
|
|
@@ -20,14 +22,14 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
20
22
|
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
23
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
22
24
|
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); }
|
|
23
|
-
function _objectDestructuringEmpty(obj) { if (obj == null) throw new TypeError("Cannot destructure " + obj); } /**
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
function _objectDestructuringEmpty(obj) { if (obj == null) throw new TypeError("Cannot destructure " + obj); } /* eslint-disable no-console */ /**
|
|
26
|
+
*
|
|
27
|
+
* @description
|
|
28
|
+
* @param {{
|
|
29
|
+
* progress: any,
|
|
30
|
+
* } & import('@mui/material').BoxProps} { progress, ...rest }
|
|
31
|
+
* @return {React.Component}
|
|
32
|
+
*/
|
|
31
33
|
function SpacesBackupRecords(_ref) {
|
|
32
34
|
let rest = Object.assign({}, (_objectDestructuringEmpty(_ref), _ref));
|
|
33
35
|
const {
|
|
@@ -48,9 +50,20 @@ function SpacesBackupRecords(_ref) {
|
|
|
48
50
|
// eslint-disable-next-line no-unused-vars
|
|
49
51
|
const {
|
|
50
52
|
targetUrl,
|
|
51
|
-
targetName
|
|
53
|
+
targetName,
|
|
54
|
+
status,
|
|
55
|
+
createdAt
|
|
52
56
|
} = backups[index];
|
|
53
|
-
const
|
|
57
|
+
const timeoutError = status === _constant.BACKUPS.STATUS.PROGRESS && (0, _dayjs.default)().diff(createdAt, 'hours') >= _constant.BACKUPS.TIMEOUT_HOURS;
|
|
58
|
+
const success = status === _constant.BACKUPS.STATUS.SUCCEEDED && !timeoutError;
|
|
59
|
+
const spaceName = targetName || ((_spaceGateways$find = spaceGateways.find(spaceGateway => targetUrl === null || targetUrl === void 0 ? void 0 : targetUrl.includes((0, _spaces.getDIDSpaceDidFromEndpoint)(spaceGateway === null || spaceGateway === void 0 ? void 0 : spaceGateway.endpoint)))) === null || _spaceGateways$find === void 0 ? void 0 : _spaceGateways$find.name) || 'Unknown DID Space';
|
|
60
|
+
if (!success) {
|
|
61
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
62
|
+
variant: "body1",
|
|
63
|
+
fontSize: "16px",
|
|
64
|
+
children: spaceName
|
|
65
|
+
});
|
|
66
|
+
}
|
|
54
67
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Link, {
|
|
55
68
|
fontSize: "16px",
|
|
56
69
|
href: targetUrl,
|
|
@@ -120,10 +133,10 @@ function SpacesBackupRecords(_ref) {
|
|
|
120
133
|
message,
|
|
121
134
|
createdAt
|
|
122
135
|
} = (_backups$index = backups === null || backups === void 0 ? void 0 : backups[index]) !== null && _backups$index !== void 0 ? _backups$index : {};
|
|
123
|
-
const timeoutError =
|
|
136
|
+
const timeoutError = status === _constant.BACKUPS.STATUS.PROGRESS && (0, _dayjs.default)().diff(createdAt, 'hours') >= _constant.BACKUPS.TIMEOUT_HOURS;
|
|
124
137
|
const timeoutErrorMessage = timeoutError && t('common.timeoutError');
|
|
125
|
-
const pending =
|
|
126
|
-
const success = status ===
|
|
138
|
+
const pending = status === _constant.BACKUPS.STATUS.PROGRESS && !timeoutError;
|
|
139
|
+
const success = status === _constant.BACKUPS.STATUS.SUCCEEDED && !timeoutError;
|
|
127
140
|
if (pending) {
|
|
128
141
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
129
142
|
display: "inline-flex",
|
|
@@ -81,10 +81,9 @@ SpaceDisconnected.defaultProps = {
|
|
|
81
81
|
* @param {{
|
|
82
82
|
* spaceGateway: import('./connected').SpaceGateway
|
|
83
83
|
* connected: boolean,
|
|
84
|
-
* progress: any,
|
|
85
84
|
* onDelete: (spaceGateway: import('./connected').SpaceGateway) => Promise<void>,
|
|
86
85
|
* onBackupNow: () => Promise<void>,
|
|
87
|
-
* }} { spaceGateway }
|
|
86
|
+
* }} { spaceGateway, connected,, onDelete, onBackupNow }
|
|
88
87
|
*/
|
|
89
88
|
function SpaceItem(_ref) {
|
|
90
89
|
let {
|
|
@@ -122,14 +121,10 @@ function SpaceItem(_ref) {
|
|
|
122
121
|
const {
|
|
123
122
|
updateSpaceGateway,
|
|
124
123
|
backupEndpoint,
|
|
125
|
-
backupProgress
|
|
124
|
+
backupProgress,
|
|
125
|
+
refreshBackupEndpoint
|
|
126
126
|
} = (0, _blockletStorage.useBlockletStorageContext)();
|
|
127
|
-
|
|
128
|
-
// TEST:
|
|
129
127
|
const [loading, setLoading] = (0, _react.useState)(false);
|
|
130
|
-
// backupProgress.message = '(12/99)备份到备份到备份到备份到备';
|
|
131
|
-
// backupProgress.progress = 99;
|
|
132
|
-
|
|
133
128
|
const [authorizeConnect, setAuthorizeConnect] = (0, _react.useState)({
|
|
134
129
|
open: false,
|
|
135
130
|
action: 'one-click-authorization',
|
|
@@ -190,6 +185,7 @@ function SpaceItem(_ref) {
|
|
|
190
185
|
}]
|
|
191
186
|
}
|
|
192
187
|
});
|
|
188
|
+
refreshBackupEndpoint();
|
|
193
189
|
_Toast.default.success(t('storage.spaces.connect.switchToSpaceSucceeded', {
|
|
194
190
|
name: spaceGateway.name ? "(".concat(spaceGateway.name, ")") : ''
|
|
195
191
|
}));
|
|
@@ -41,6 +41,7 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
|
|
|
41
41
|
* backupProgress: any,
|
|
42
42
|
* backups: Backup[],
|
|
43
43
|
* backupsLoading: boolean,
|
|
44
|
+
* refreshBackupEndpoint: () => void,
|
|
44
45
|
* }} BlockletStorageContextType
|
|
45
46
|
*/ /** @type {import('react').Context<BlockletStorageContextType>} */
|
|
46
47
|
const BlockletStorageContext = /*#__PURE__*/(0, _react.createContext)({});
|
|
@@ -76,9 +77,10 @@ function BlockletStorageProvider(_ref) {
|
|
|
76
77
|
const backupProgress = (0, _useBackupProgress.default)({
|
|
77
78
|
appDid: blocklet === null || blocklet === void 0 ? void 0 : blocklet.appDid
|
|
78
79
|
});
|
|
80
|
+
const [backupEndpointRefresh, setBackupEndpointRefresh] = (0, _react.useState)(false);
|
|
79
81
|
const backupEndpoint = (0, _react.useMemo)(() => (0, _spaces.getSpaceBackupEndpoint)(blocklet === null || blocklet === void 0 ? void 0 : blocklet.environments),
|
|
80
82
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
81
|
-
[blocklet, spaceGatewaysRefresh]);
|
|
83
|
+
[blocklet, spaceGatewaysRefresh, backupEndpointRefresh]);
|
|
82
84
|
const [backupsLoading, setBackupsLoading] = (0, _react.useState)(false);
|
|
83
85
|
const {
|
|
84
86
|
backups
|
|
@@ -151,7 +153,7 @@ function BlockletStorageProvider(_ref) {
|
|
|
151
153
|
input: {
|
|
152
154
|
did: blocklet.meta.did,
|
|
153
155
|
where: {
|
|
154
|
-
|
|
156
|
+
did: spaceGateway.did
|
|
155
157
|
},
|
|
156
158
|
spaceGateway
|
|
157
159
|
}
|
|
@@ -181,6 +183,9 @@ function BlockletStorageProvider(_ref) {
|
|
|
181
183
|
* @param {SpaceGateway} spaceGateway
|
|
182
184
|
*/
|
|
183
185
|
const spaceGatewayIsSelected = spaceGateway => (spaceGateway === null || spaceGateway === void 0 ? void 0 : spaceGateway.endpoint) === backupEndpoint;
|
|
186
|
+
const refreshBackupEndpoint = () => {
|
|
187
|
+
setBackupEndpointRefresh(p => !p);
|
|
188
|
+
};
|
|
184
189
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Provider, {
|
|
185
190
|
value: {
|
|
186
191
|
spaceGateways,
|
|
@@ -194,7 +199,8 @@ function BlockletStorageProvider(_ref) {
|
|
|
194
199
|
backupEndpoint,
|
|
195
200
|
backupProgress,
|
|
196
201
|
backups,
|
|
197
|
-
backupsLoading
|
|
202
|
+
backupsLoading,
|
|
203
|
+
refreshBackupEndpoint
|
|
198
204
|
},
|
|
199
205
|
children: children
|
|
200
206
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abtnode/ux",
|
|
3
|
-
"version": "1.16.15-beta-
|
|
3
|
+
"version": "1.16.15-beta-58d50c9a",
|
|
4
4
|
"description": "UX components shared across abtnode packages",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -27,9 +27,9 @@
|
|
|
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.15-beta-
|
|
31
|
-
"@abtnode/constant": "1.16.15-beta-
|
|
32
|
-
"@abtnode/util": "1.16.15-beta-
|
|
30
|
+
"@abtnode/auth": "1.16.15-beta-58d50c9a",
|
|
31
|
+
"@abtnode/constant": "1.16.15-beta-58d50c9a",
|
|
32
|
+
"@abtnode/util": "1.16.15-beta-58d50c9a",
|
|
33
33
|
"@ahooksjs/use-url-state": "^3.5.1",
|
|
34
34
|
"@arcblock/did": "^1.18.89",
|
|
35
35
|
"@arcblock/did-connect": "^2.7.9",
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
"@arcblock/react-hooks": "^2.7.9",
|
|
40
40
|
"@arcblock/terminal": "^2.7.9",
|
|
41
41
|
"@arcblock/ux": "^2.7.9",
|
|
42
|
-
"@blocklet/constant": "1.16.15-beta-
|
|
42
|
+
"@blocklet/constant": "1.16.15-beta-58d50c9a",
|
|
43
43
|
"@blocklet/launcher-layout": "2.1.101",
|
|
44
44
|
"@blocklet/list": "^0.12.31",
|
|
45
|
-
"@blocklet/meta": "1.16.15-beta-
|
|
45
|
+
"@blocklet/meta": "1.16.15-beta-58d50c9a",
|
|
46
46
|
"@blocklet/ui-react": "^2.7.9",
|
|
47
47
|
"@emotion/react": "^11.10.4",
|
|
48
48
|
"@emotion/styled": "^11.10.4",
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
"babel-plugin-inline-react-svg": "^1.1.2",
|
|
99
99
|
"glob": "^10.3.3"
|
|
100
100
|
},
|
|
101
|
-
"gitHead": "
|
|
101
|
+
"gitHead": "c54236c1daace6451db561fa6b3eea21ba07bb4d",
|
|
102
102
|
"exports": {
|
|
103
103
|
".": {
|
|
104
104
|
"import": "./es/index.js",
|