@abtnode/ux 1.16.15-beta-ed0db59e → 1.16.15-beta-d464647a
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/es/blocklet/storage/action.js +26 -13
- package/es/blocklet/storage/backups.js +7 -14
- package/es/blocklet/storage/connect-to.js +28 -52
- package/es/blocklet/storage/connected.js +19 -110
- package/es/blocklet/storage/delete.js +2 -1
- package/es/blocklet/storage/index.js +5 -8
- package/es/blocklet/storage/item.js +52 -60
- package/es/contexts/blocklet-storage.js +199 -0
- package/es/hooks/use-backups.js +36 -17
- package/es/hooks/use-space-gateways.js +66 -0
- package/es/locales/en.js +1 -1
- package/es/locales/zh.js +1 -1
- package/lib/blocklet/storage/action.js +25 -12
- package/lib/blocklet/storage/backups.js +13 -25
- package/lib/blocklet/storage/connect-to.js +33 -62
- package/lib/blocklet/storage/connected.js +18 -113
- package/lib/blocklet/storage/delete.js +2 -1
- package/lib/blocklet/storage/index.js +5 -10
- package/lib/blocklet/storage/item.js +50 -58
- package/lib/contexts/blocklet-storage.js +209 -0
- package/lib/hooks/use-backups.js +36 -17
- package/lib/hooks/use-space-gateways.js +74 -0
- package/lib/locales/en.js +1 -1
- package/lib/locales/zh.js +1 -1
- package/package.json +16 -16
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
|
-
import { IconButton, ListItemIcon, ListItemText, Menu, MenuItem } from '@mui/material';
|
|
2
|
+
import { CircularProgress, IconButton, ListItemIcon, ListItemText, Menu, MenuItem } from '@mui/material';
|
|
3
3
|
import MoreVertIcon from '@mui/icons-material/MoreVert';
|
|
4
4
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
5
5
|
import ArrowOutwardIcon from '@mui/icons-material/ArrowOutward';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import ElectricBoltOutlinedIcon from '@mui/icons-material/ElectricBoltOutlined';
|
|
8
8
|
import FolderOutlinedIcon from '@mui/icons-material/FolderOutlined';
|
|
9
|
+
import Toast from '@arcblock/ux/lib/Toast';
|
|
9
10
|
import { getBackupFilesUrlFromEndpoint, getDIDSpaceUrlFromEndpoint } from '../../util/spaces';
|
|
10
11
|
import DeleteDIDSpacesGateWay from './delete';
|
|
11
12
|
|
|
@@ -13,12 +14,12 @@ import DeleteDIDSpacesGateWay from './delete';
|
|
|
13
14
|
* @description
|
|
14
15
|
* @param {{
|
|
15
16
|
* spaceGateway: import('./connected').SpaceGateway,
|
|
16
|
-
* onDelete: (import('./connected').SpaceGateway) => Promise<void>,
|
|
17
|
-
*
|
|
18
|
-
* enableSwitchToSpace:
|
|
19
|
-
* connected:
|
|
20
|
-
* }} { spaceGateway, onDelete, ...rest }
|
|
21
|
-
* @return {
|
|
17
|
+
* onDelete: (spaceGateway: import('./connected').SpaceGateway) => Promise<void>,
|
|
18
|
+
* onConnect: (spaceGateway: import('./connected').SpaceGateway) => Promise<void>,
|
|
19
|
+
* enableSwitchToSpace: true | false,
|
|
20
|
+
* connected: false | true
|
|
21
|
+
* } & import('@mui/material').IconButtonProps} { spaceGateway, onDelete, onConnect, enableSwitchToSpace, connected, ...rest }
|
|
22
|
+
* @return {React.Component}
|
|
22
23
|
*/
|
|
23
24
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
25
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -35,6 +36,7 @@ function SpaceItemAction({
|
|
|
35
36
|
const {
|
|
36
37
|
t
|
|
37
38
|
} = useLocaleContext();
|
|
39
|
+
const [loading, setLoading] = useState(false);
|
|
38
40
|
|
|
39
41
|
/**
|
|
40
42
|
* @description
|
|
@@ -45,9 +47,17 @@ function SpaceItemAction({
|
|
|
45
47
|
event.preventDefault();
|
|
46
48
|
setAnchorEl(open && event.currentTarget);
|
|
47
49
|
};
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
const handleOnSwitchSpace = async e => {
|
|
51
|
+
try {
|
|
52
|
+
setLoading(true);
|
|
53
|
+
handleOpen(e, false);
|
|
54
|
+
await onConnect(spaceGateway);
|
|
55
|
+
} catch (error) {
|
|
56
|
+
console.error(error);
|
|
57
|
+
Toast.error(error.message);
|
|
58
|
+
} finally {
|
|
59
|
+
setLoading(false);
|
|
60
|
+
}
|
|
51
61
|
};
|
|
52
62
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
53
63
|
children: [/*#__PURE__*/_jsx(IconButton, {
|
|
@@ -58,7 +68,9 @@ function SpaceItemAction({
|
|
|
58
68
|
onClick: e => handleOpen(e, true),
|
|
59
69
|
size: "small",
|
|
60
70
|
...rest,
|
|
61
|
-
children: /*#__PURE__*/_jsx(
|
|
71
|
+
children: loading || spaceGateway?.loading ? /*#__PURE__*/_jsx(CircularProgress, {
|
|
72
|
+
size: "24px"
|
|
73
|
+
}) : /*#__PURE__*/_jsx(MoreVertIcon, {})
|
|
62
74
|
}), /*#__PURE__*/_jsxs(Menu, {
|
|
63
75
|
id: "simple-menu",
|
|
64
76
|
anchorEl: anchorEl,
|
|
@@ -96,7 +108,7 @@ function SpaceItemAction({
|
|
|
96
108
|
children: t('storage.spaces.strategy.viewBackupFiles')
|
|
97
109
|
})]
|
|
98
110
|
}), !connected && enableSwitchToSpace && /*#__PURE__*/_jsxs(MenuItem, {
|
|
99
|
-
onClick:
|
|
111
|
+
onClick: handleOnSwitchSpace,
|
|
100
112
|
children: [/*#__PURE__*/_jsx(ListItemIcon, {
|
|
101
113
|
style: {
|
|
102
114
|
minWidth: 24
|
|
@@ -119,7 +131,8 @@ SpaceItemAction.propTypes = {
|
|
|
119
131
|
name: PropTypes.string.isRequired,
|
|
120
132
|
url: PropTypes.string.isRequired,
|
|
121
133
|
protected: PropTypes.bool,
|
|
122
|
-
endpoint: PropTypes.string.isRequired
|
|
134
|
+
endpoint: PropTypes.string.isRequired,
|
|
135
|
+
loading: PropTypes.bool
|
|
123
136
|
}).isRequired,
|
|
124
137
|
connected: PropTypes.bool.isRequired,
|
|
125
138
|
enableSwitchToSpace: PropTypes.bool,
|
|
@@ -6,23 +6,20 @@ import React from 'react';
|
|
|
6
6
|
import { isEmpty, isNull } from 'lodash';
|
|
7
7
|
import dayjs from '@abtnode/util/lib/dayjs';
|
|
8
8
|
import HelpOutlineIcon from '@mui/icons-material/HelpOutline';
|
|
9
|
-
import {
|
|
10
|
-
import useBackups from '../../hooks/use-backups';
|
|
9
|
+
import { useBlockletStorageContext } from '../../contexts/blocklet-storage';
|
|
11
10
|
|
|
12
11
|
/**
|
|
12
|
+
*
|
|
13
13
|
* @description
|
|
14
14
|
* @param {{
|
|
15
15
|
* progress: any,
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* @return {*}
|
|
16
|
+
* } & import('@mui/material').BoxProps} { progress, ...rest }
|
|
17
|
+
* @return {React.Component}
|
|
19
18
|
*/
|
|
20
19
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
21
20
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
22
21
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
23
22
|
function SpacesBackupRecords({
|
|
24
|
-
progress,
|
|
25
|
-
spaceGateways,
|
|
26
23
|
...rest
|
|
27
24
|
}) {
|
|
28
25
|
const {
|
|
@@ -30,10 +27,9 @@ function SpacesBackupRecords({
|
|
|
30
27
|
locale
|
|
31
28
|
} = useLocaleContext();
|
|
32
29
|
const {
|
|
30
|
+
spaceGateways,
|
|
33
31
|
backups
|
|
34
|
-
} =
|
|
35
|
-
progress
|
|
36
|
-
});
|
|
32
|
+
} = useBlockletStorageContext();
|
|
37
33
|
const columns = [{
|
|
38
34
|
label: 'DID Spaces',
|
|
39
35
|
name: 'target',
|
|
@@ -200,8 +196,5 @@ function SpacesBackupRecords({
|
|
|
200
196
|
})
|
|
201
197
|
});
|
|
202
198
|
}
|
|
203
|
-
SpacesBackupRecords.propTypes = {
|
|
204
|
-
progress: object.isRequired,
|
|
205
|
-
spaceGateways: array.isRequired
|
|
206
|
-
};
|
|
199
|
+
SpacesBackupRecords.propTypes = {};
|
|
207
200
|
export default SpacesBackupRecords;
|
|
@@ -1,50 +1,42 @@
|
|
|
1
1
|
import { Box, CircularProgress, DialogContentText, TextField, Typography } from '@mui/material';
|
|
2
|
-
import React, {
|
|
2
|
+
import React, { useState } from 'react';
|
|
3
3
|
import Button from '@arcblock/ux/lib/Button';
|
|
4
4
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
5
5
|
import DidConnect from '@arcblock/did-connect/lib/Connect';
|
|
6
6
|
import joinUrl from 'url-join';
|
|
7
7
|
import toast from '@arcblock/ux/lib/Toast';
|
|
8
|
-
import { BLOCKLET_CONFIGURABLE_KEY } from '@blocklet/constant';
|
|
9
8
|
import SplitButton from '@arcblock/ux/lib/SplitButton';
|
|
10
9
|
import Dialog from '@arcblock/ux/lib/Dialog';
|
|
11
10
|
import Alert from '@arcblock/ux/lib/Alert';
|
|
12
|
-
import { array, func } from 'prop-types';
|
|
13
11
|
import { PROD_DID_SPACES } from '@abtnode/constant';
|
|
14
12
|
import { useBlockletContext } from '../../contexts/blocklet';
|
|
15
13
|
import { axios } from '../../util/api';
|
|
16
14
|
import { formatError, getWebWalletUrl } from '../../util';
|
|
17
15
|
import { useNodeContext } from '../../contexts/node';
|
|
18
16
|
import useBlockletInfoForConnectDIDSpaces from '../../hooks/use-blocklet-info-for-connect-did-spaces';
|
|
19
|
-
import { getDIDSpaceDidFromEndpoint,
|
|
17
|
+
import { getDIDSpaceDidFromEndpoint, isValidSpaceGatewayUrl } from '../../util/spaces';
|
|
18
|
+
import { useBlockletStorageContext } from '../../contexts/blocklet-storage';
|
|
20
19
|
/**
|
|
21
20
|
* @description
|
|
22
|
-
* @param {{
|
|
23
|
-
* spaceGateways?: Array<import('./connected').SpaceGateway>,
|
|
24
|
-
* refreshSpaceGateways: () => void,
|
|
25
|
-
* }} { spaceGateways, refreshSpaceGateways, ...rest }
|
|
21
|
+
* @param {{}} { ...rest }
|
|
26
22
|
* @return {React.Component}
|
|
27
23
|
*/
|
|
28
24
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
29
25
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
30
26
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
31
27
|
function ConnectTo({
|
|
32
|
-
spaceGateways,
|
|
33
|
-
refreshSpaceGateways,
|
|
34
28
|
...rest
|
|
35
29
|
}) {
|
|
36
30
|
const {
|
|
37
31
|
blocklet
|
|
38
32
|
} = useBlockletContext();
|
|
39
33
|
const {
|
|
40
|
-
info
|
|
41
|
-
api: nodeApi
|
|
34
|
+
info
|
|
42
35
|
} = useNodeContext();
|
|
43
36
|
const {
|
|
44
37
|
t,
|
|
45
38
|
locale
|
|
46
39
|
} = useLocaleContext();
|
|
47
|
-
const spaceBackupEndpoint = useMemo(() => getSpaceBackupEndpoint(blocklet?.environments), [blocklet]);
|
|
48
40
|
const [url, setUrl] = useState('');
|
|
49
41
|
const [loading, setLoading] = useState(false);
|
|
50
42
|
const [open, setOpen] = useState(false);
|
|
@@ -53,6 +45,10 @@ function ConnectTo({
|
|
|
53
45
|
blocklet
|
|
54
46
|
});
|
|
55
47
|
const webWalletUrl = getWebWalletUrl(info);
|
|
48
|
+
const {
|
|
49
|
+
spaceGateways,
|
|
50
|
+
addSpaceGateway
|
|
51
|
+
} = useBlockletStorageContext();
|
|
56
52
|
const [authorizeFromNftConnect, setAuthorizeFromNftConnect] = useState({
|
|
57
53
|
open: false,
|
|
58
54
|
action: 'one-click-authorization',
|
|
@@ -108,19 +104,11 @@ function ConnectTo({
|
|
|
108
104
|
}));
|
|
109
105
|
}
|
|
110
106
|
});
|
|
111
|
-
const onAuthorizeConnectSuccess = (response, decrypt) => {
|
|
112
|
-
|
|
113
|
-
setAuthorizeConnect(preValue => ({
|
|
114
|
-
...preValue,
|
|
115
|
-
open: false
|
|
116
|
-
}));
|
|
117
|
-
setAuthorizeFromNftConnect(preValue => ({
|
|
118
|
-
...preValue,
|
|
119
|
-
open: false
|
|
120
|
-
}));
|
|
107
|
+
const onAuthorizeConnectSuccess = async (response, decrypt) => {
|
|
108
|
+
try {
|
|
121
109
|
const endpoint = decrypt(response.endpoint);
|
|
122
110
|
const space = response.space ? decrypt(response.space) : {};
|
|
123
|
-
await
|
|
111
|
+
await addSpaceGatewayNow({
|
|
124
112
|
endpoint,
|
|
125
113
|
// name 默认为 DID Space,兼容旧版本的 DID Spaces
|
|
126
114
|
...{
|
|
@@ -129,7 +117,18 @@ function ConnectTo({
|
|
|
129
117
|
},
|
|
130
118
|
...space
|
|
131
119
|
});
|
|
132
|
-
|
|
120
|
+
setAuthorizeConnect(preValue => ({
|
|
121
|
+
...preValue,
|
|
122
|
+
open: false
|
|
123
|
+
}));
|
|
124
|
+
setAuthorizeFromNftConnect(preValue => ({
|
|
125
|
+
...preValue,
|
|
126
|
+
open: false
|
|
127
|
+
}));
|
|
128
|
+
} catch (error) {
|
|
129
|
+
console.error(error);
|
|
130
|
+
toast.error(formatError(error));
|
|
131
|
+
}
|
|
133
132
|
};
|
|
134
133
|
|
|
135
134
|
/**
|
|
@@ -141,7 +140,7 @@ function ConnectTo({
|
|
|
141
140
|
* }} {endpoint, name, did}
|
|
142
141
|
* @returns {Promise<void>}
|
|
143
142
|
*/
|
|
144
|
-
const
|
|
143
|
+
const addSpaceGatewayNow = async ({
|
|
145
144
|
endpoint,
|
|
146
145
|
name,
|
|
147
146
|
did
|
|
@@ -168,27 +167,10 @@ function ConnectTo({
|
|
|
168
167
|
url: normalizeUrl,
|
|
169
168
|
endpoint
|
|
170
169
|
};
|
|
171
|
-
await
|
|
172
|
-
input: {
|
|
173
|
-
did: blocklet.meta.did,
|
|
174
|
-
spaceGateway
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
if (spaceBackupEndpoint !== endpoint) {
|
|
178
|
-
await nodeApi.configBlocklet({
|
|
179
|
-
input: {
|
|
180
|
-
did: [blocklet.meta.did],
|
|
181
|
-
configs: [{
|
|
182
|
-
key: BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,
|
|
183
|
-
value: endpoint
|
|
184
|
-
}]
|
|
185
|
-
}
|
|
186
|
-
});
|
|
187
|
-
}
|
|
170
|
+
await addSpaceGateway(spaceGateway, endpoint);
|
|
188
171
|
toast.success(t('storage.spaces.connectedWithName', {
|
|
189
172
|
name: spaceGateway?.name ?? 'DID Spaces'
|
|
190
173
|
}));
|
|
191
|
-
refreshSpaceGateways();
|
|
192
174
|
};
|
|
193
175
|
const handleUseWalletConnect = () => {
|
|
194
176
|
setAuthorizeFromNftConnect(preValue => ({
|
|
@@ -364,12 +346,6 @@ function ConnectTo({
|
|
|
364
346
|
})]
|
|
365
347
|
});
|
|
366
348
|
}
|
|
367
|
-
ConnectTo.propTypes = {
|
|
368
|
-
|
|
369
|
-
refreshSpaceGateways: func
|
|
370
|
-
};
|
|
371
|
-
ConnectTo.defaultProps = {
|
|
372
|
-
spaceGateways: [],
|
|
373
|
-
refreshSpaceGateways: () => undefined
|
|
374
|
-
};
|
|
349
|
+
ConnectTo.propTypes = {};
|
|
350
|
+
ConnectTo.defaultProps = {};
|
|
375
351
|
export default ConnectTo;
|
|
@@ -1,77 +1,14 @@
|
|
|
1
1
|
import { Box, CircularProgress, Typography } from '@mui/material';
|
|
2
|
-
import React
|
|
2
|
+
import React from 'react';
|
|
3
3
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
4
|
-
import { useAsyncEffect } from 'ahooks';
|
|
5
4
|
import toast from '@arcblock/ux/lib/Toast';
|
|
6
5
|
import ConnectTo from './connect-to';
|
|
7
6
|
import SpaceItem from './item';
|
|
8
7
|
import SpacesBackupRecords from './backups';
|
|
9
8
|
import { useBlockletContext } from '../../contexts/blocklet';
|
|
10
9
|
import { useNodeContext } from '../../contexts/node';
|
|
11
|
-
import { getSpaceBackupEndpoint } from '../../util/spaces';
|
|
12
|
-
import useBackupProgress from '../../hooks/use-backup-progress';
|
|
13
|
-
import { updateSpaceGatewaysFromDIDSpaces } from '../../util/space-gateway';
|
|
14
10
|
import DiskInfo from '../disk-info';
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @description
|
|
19
|
-
* @param {{
|
|
20
|
-
* blockletDid: string,
|
|
21
|
-
* setLoading: (bool: boolean) => void,
|
|
22
|
-
* refreshBlocklet: Function
|
|
23
|
-
* }} { blockletDid, setLoading = () => undefined, refreshBlocklet }
|
|
24
|
-
* @return {{
|
|
25
|
-
* spaceGateways: Array<SpaceGateway>
|
|
26
|
-
* refreshSpaceGateways: Function
|
|
27
|
-
* }} {spaceGateways}
|
|
28
|
-
*/
|
|
29
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
30
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
31
|
-
function useSpaceGateways({
|
|
32
|
-
blockletDid,
|
|
33
|
-
setLoading = () => undefined
|
|
34
|
-
}) {
|
|
35
|
-
const [refresh, setRefresh] = useState(false);
|
|
36
|
-
const [spaceGateways, setSpaceGateways] = useState([]);
|
|
37
|
-
const {
|
|
38
|
-
api: nodeApi
|
|
39
|
-
} = useNodeContext();
|
|
40
|
-
const refreshSpaceGateways = () => {
|
|
41
|
-
setRefresh(x => !x);
|
|
42
|
-
};
|
|
43
|
-
useAsyncEffect(async () => {
|
|
44
|
-
try {
|
|
45
|
-
if (!blockletDid) {
|
|
46
|
-
setSpaceGateways([]);
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
setLoading(true);
|
|
50
|
-
const {
|
|
51
|
-
spaceGateways: _spaceGateways
|
|
52
|
-
} = await nodeApi.getBlockletSpaceGateways({
|
|
53
|
-
input: {
|
|
54
|
-
did: blockletDid
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
const latestSpaceGateways = await updateSpaceGatewaysFromDIDSpaces({
|
|
58
|
-
blockletDid,
|
|
59
|
-
nodeApi,
|
|
60
|
-
spaceGateways: _spaceGateways
|
|
61
|
-
});
|
|
62
|
-
setSpaceGateways(latestSpaceGateways ?? []);
|
|
63
|
-
} catch (error) {
|
|
64
|
-
console.error(error);
|
|
65
|
-
toast.error(formatError(error));
|
|
66
|
-
} finally {
|
|
67
|
-
setLoading(false);
|
|
68
|
-
}
|
|
69
|
-
}, [blockletDid, refresh]);
|
|
70
|
-
return {
|
|
71
|
-
refreshSpaceGateways,
|
|
72
|
-
spaceGateways
|
|
73
|
-
};
|
|
74
|
-
}
|
|
11
|
+
import { useBlockletStorageContext } from '../../contexts/blocklet-storage';
|
|
75
12
|
|
|
76
13
|
/**
|
|
77
14
|
* @typedef {{
|
|
@@ -80,37 +17,29 @@ function useSpaceGateways({
|
|
|
80
17
|
* url: string,
|
|
81
18
|
* endpoint: string
|
|
82
19
|
* protected?: boolean,
|
|
20
|
+
* loading?: boolean,
|
|
83
21
|
* }} SpaceGateway
|
|
84
22
|
*/
|
|
85
|
-
|
|
23
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
86
25
|
function Connected() {
|
|
87
26
|
const {
|
|
88
27
|
t
|
|
89
28
|
} = useLocaleContext();
|
|
90
29
|
/** @type {{ blocklet: import('@abtnode/client').BlockletState }} */
|
|
91
30
|
const {
|
|
92
|
-
blocklet
|
|
93
|
-
actions: {
|
|
94
|
-
refreshBlocklet
|
|
95
|
-
}
|
|
31
|
+
blocklet
|
|
96
32
|
} = useBlockletContext();
|
|
97
33
|
const {
|
|
98
34
|
api: nodeApi
|
|
99
35
|
} = useNodeContext();
|
|
100
|
-
const backupEndpoint = useMemo(() => getSpaceBackupEndpoint(blocklet?.environments), [blocklet]);
|
|
101
|
-
const progress = useBackupProgress({
|
|
102
|
-
appDid: blocklet?.appDid
|
|
103
|
-
});
|
|
104
|
-
const [loading, setLoading] = useState(false);
|
|
105
36
|
const {
|
|
106
37
|
spaceGateways,
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
});
|
|
113
|
-
const shouldShowLoading = loading && !spaceGateways?.length;
|
|
38
|
+
spaceGatewaysLoading,
|
|
39
|
+
deleteSpaceGateway,
|
|
40
|
+
spaceGatewayIsSelected
|
|
41
|
+
} = useBlockletStorageContext();
|
|
42
|
+
const shouldShowLoading = spaceGatewaysLoading && !spaceGateways?.length;
|
|
114
43
|
|
|
115
44
|
/**
|
|
116
45
|
*
|
|
@@ -118,23 +47,10 @@ function Connected() {
|
|
|
118
47
|
* @param {SpaceGateway} spaceGateway
|
|
119
48
|
*/
|
|
120
49
|
const onDeleteGateway = async spaceGateway => {
|
|
121
|
-
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
if (spaceGateway.endpoint === backupEndpoint) {
|
|
125
|
-
toast.warning(t('storage.spaces.gateway.delete.failedForConnected'));
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
await nodeApi.deleteBlockletSpaceGateway({
|
|
129
|
-
input: {
|
|
130
|
-
did: blocklet.meta.did,
|
|
131
|
-
spaceGatewayDid: spaceGateway?.did
|
|
132
|
-
}
|
|
133
|
-
});
|
|
50
|
+
await deleteSpaceGateway(spaceGateway);
|
|
134
51
|
toast.success(t('storage.spaces.gateway.delete.succeeded', {
|
|
135
52
|
name: `(${spaceGateway.name})`
|
|
136
53
|
}));
|
|
137
|
-
refreshSpaceGateways();
|
|
138
54
|
};
|
|
139
55
|
const onBackupNow = async () => {
|
|
140
56
|
await nodeApi.backupBlocklet({
|
|
@@ -157,34 +73,27 @@ function Connected() {
|
|
|
157
73
|
fontSize: "1.2rem",
|
|
158
74
|
fontWeight: "bold",
|
|
159
75
|
children: t('storage.spaces.connected.title')
|
|
160
|
-
}), /*#__PURE__*/_jsx(ConnectTo, {
|
|
161
|
-
spaceGateways: spaceGateways,
|
|
162
|
-
refreshSpaceGateways: refreshSpaceGateways
|
|
163
|
-
})]
|
|
76
|
+
}), /*#__PURE__*/_jsx(ConnectTo, {})]
|
|
164
77
|
}), /*#__PURE__*/_jsx(Box, {
|
|
165
78
|
children: shouldShowLoading ? /*#__PURE__*/_jsx(Box, {
|
|
166
79
|
display: "flex",
|
|
167
80
|
justifyContent: "center",
|
|
168
81
|
children: /*#__PURE__*/_jsx(CircularProgress, {})
|
|
169
|
-
}) : spaceGateways.map(
|
|
82
|
+
}) : spaceGateways.map(x => {
|
|
170
83
|
return /*#__PURE__*/_jsx(SpaceItem, {
|
|
171
84
|
style: {
|
|
172
85
|
marginTop: '12px'
|
|
173
86
|
},
|
|
174
|
-
spaceGateway:
|
|
175
|
-
connected:
|
|
87
|
+
spaceGateway: x,
|
|
88
|
+
connected: spaceGatewayIsSelected(x),
|
|
176
89
|
onDelete: onDeleteGateway,
|
|
177
|
-
onBackupNow: onBackupNow
|
|
178
|
-
|
|
179
|
-
refreshSpaceGateways: refreshSpaceGateways
|
|
180
|
-
}, spaceGateway.endpoint);
|
|
90
|
+
onBackupNow: onBackupNow
|
|
91
|
+
}, x.endpoint);
|
|
181
92
|
})
|
|
182
93
|
}), /*#__PURE__*/_jsx(SpacesBackupRecords, {
|
|
183
94
|
sx: {
|
|
184
95
|
marginTop: '24px'
|
|
185
|
-
}
|
|
186
|
-
spaceGateways: spaceGateways,
|
|
187
|
-
progress: progress
|
|
96
|
+
}
|
|
188
97
|
}), /*#__PURE__*/_jsx(Typography, {
|
|
189
98
|
fontSize: "1.2rem",
|
|
190
99
|
fontWeight: "bold",
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import { useBlockletContext } from '../../contexts/blocklet';
|
|
3
|
-
import { getSpaceBackupEndpoint } from '../../util/spaces';
|
|
1
|
+
import React from 'react';
|
|
4
2
|
import Disconnect from './disconnect';
|
|
5
3
|
import Connected from './connected';
|
|
4
|
+
import { useBlockletStorageContext } from '../../contexts/blocklet-storage';
|
|
6
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
6
|
function NewStorage() {
|
|
8
|
-
/** @type {{ blocklet: import('@abtnode/client').BlockletState }} */
|
|
9
7
|
const {
|
|
10
|
-
|
|
11
|
-
} =
|
|
12
|
-
|
|
13
|
-
if (endpoint) {
|
|
8
|
+
backupEndpoint
|
|
9
|
+
} = useBlockletStorageContext();
|
|
10
|
+
if (backupEndpoint) {
|
|
14
11
|
return /*#__PURE__*/_jsx(Connected, {});
|
|
15
12
|
}
|
|
16
13
|
return /*#__PURE__*/_jsx(Disconnect, {});
|