@abtnode/ux 1.16.17-beta-5d4664f8 → 1.16.17-beta-ce49fe0e
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/auto-backup.js +55 -0
- package/es/blocklet/storage/connected.js +6 -0
- package/es/contexts/blocklet-storage.js +28 -1
- package/es/hooks/use-auto-backup.js +33 -0
- package/es/locales/en.js +5 -0
- package/es/locales/zh.js +5 -0
- package/lib/blocklet/storage/auto-backup.js +64 -0
- package/lib/blocklet/storage/connected.js +6 -0
- package/lib/contexts/blocklet-storage.js +28 -1
- package/lib/hooks/use-auto-backup.js +43 -0
- package/lib/locales/en.js +5 -0
- package/lib/locales/zh.js +5 -0
- package/package.json +7 -7
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Typography } from '@mui/material';
|
|
3
|
+
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
4
|
+
import Toast from '@arcblock/ux/lib/Toast';
|
|
5
|
+
import SwitchControl from '../component/switch-control';
|
|
6
|
+
import { useBlockletStorageContext } from '../../contexts/blocklet-storage';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @description
|
|
10
|
+
* @param {{
|
|
11
|
+
* style: import('react').CSSProperties
|
|
12
|
+
* }} {...rest}
|
|
13
|
+
* @return {*}
|
|
14
|
+
*/
|
|
15
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
|
+
function AutoBackup({
|
|
17
|
+
...rest
|
|
18
|
+
}) {
|
|
19
|
+
const {
|
|
20
|
+
t
|
|
21
|
+
} = useLocaleContext();
|
|
22
|
+
const {
|
|
23
|
+
autoBackup,
|
|
24
|
+
updateAutoBackup
|
|
25
|
+
} = useBlockletStorageContext();
|
|
26
|
+
const configAutoBackup = async () => {
|
|
27
|
+
try {
|
|
28
|
+
const enabled = !autoBackup.enabled;
|
|
29
|
+
await updateAutoBackup({
|
|
30
|
+
enabled
|
|
31
|
+
});
|
|
32
|
+
Toast.success(enabled ? t('storage.spaces.autoBackup.enabled') : t('storage.spaces.autoBackup.disabled'));
|
|
33
|
+
} catch (error) {
|
|
34
|
+
Toast.error(error.message);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
return /*#__PURE__*/_jsx(SwitchControl, {
|
|
38
|
+
checked: Boolean(autoBackup?.enabled),
|
|
39
|
+
onChange: configAutoBackup,
|
|
40
|
+
name: "enableWelcomePage",
|
|
41
|
+
labelProps: {
|
|
42
|
+
label: /*#__PURE__*/_jsx(Typography, {
|
|
43
|
+
marginRight: "8px",
|
|
44
|
+
children: /*#__PURE__*/_jsx("span", {
|
|
45
|
+
children: t('storage.spaces.autoBackup.title')
|
|
46
|
+
})
|
|
47
|
+
})
|
|
48
|
+
},
|
|
49
|
+
style: {
|
|
50
|
+
...rest.style
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
AutoBackup.propTypes = {};
|
|
55
|
+
export default AutoBackup;
|
|
@@ -9,6 +9,7 @@ import { useBlockletContext } from '../../contexts/blocklet';
|
|
|
9
9
|
import { useNodeContext } from '../../contexts/node';
|
|
10
10
|
import DiskInfo from '../disk-info';
|
|
11
11
|
import { useBlockletStorageContext } from '../../contexts/blocklet-storage';
|
|
12
|
+
import AutoBackup from './auto-backup';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* @typedef {{
|
|
@@ -72,7 +73,12 @@ function Connected() {
|
|
|
72
73
|
children: [/*#__PURE__*/_jsx(Typography, {
|
|
73
74
|
fontSize: "1.2rem",
|
|
74
75
|
fontWeight: "bold",
|
|
76
|
+
flexGrow: 1,
|
|
75
77
|
children: t('storage.spaces.connected.title')
|
|
78
|
+
}), /*#__PURE__*/_jsx(AutoBackup, {
|
|
79
|
+
style: {
|
|
80
|
+
marginRight: '32px'
|
|
81
|
+
}
|
|
76
82
|
}), /*#__PURE__*/_jsx(ConnectTo, {})]
|
|
77
83
|
}), /*#__PURE__*/_jsx(Box, {
|
|
78
84
|
children: shouldShowLoading ? /*#__PURE__*/_jsx(Box, {
|
|
@@ -9,10 +9,12 @@ import useSpaceGateways from '../hooks/use-space-gateways';
|
|
|
9
9
|
import { useNodeContext } from './node';
|
|
10
10
|
import useBackupProgress from '../hooks/use-backup-progress';
|
|
11
11
|
import useBackups from '../hooks/use-backups';
|
|
12
|
+
import { useAutoBackup } from '../hooks/use-auto-backup';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* @typedef {import('../blocklet/storage/connected').SpaceGateway} SpaceGateway
|
|
15
16
|
* @typedef {import('@abtnode/client').Backup} Backup
|
|
17
|
+
* @typedef {import('@abtnode/client').AutoBackup} AutoBackup
|
|
16
18
|
*/
|
|
17
19
|
|
|
18
20
|
/**
|
|
@@ -25,12 +27,14 @@ import useBackups from '../hooks/use-backups';
|
|
|
25
27
|
* refreshSpaceGateways: () => void,
|
|
26
28
|
* spaceGatewaysLoading: boolean,
|
|
27
29
|
* spaceGatewayIsSelected: (spaceGateway: SpaceGateway) => boolean,
|
|
30
|
+
* updateAutoBackup: (autoBackup: { enabled: boolean }) => Promise<void>,
|
|
28
31
|
*
|
|
29
32
|
* backupEndpoint: string,
|
|
30
33
|
* backupProgress: any,
|
|
31
34
|
* backups: Backup[],
|
|
32
35
|
* backupsLoading: boolean,
|
|
33
36
|
* refreshBackupEndpoint: () => void,
|
|
37
|
+
* autoBackup: AutoBackup,
|
|
34
38
|
* }} BlockletStorageContextType
|
|
35
39
|
*/
|
|
36
40
|
|
|
@@ -78,6 +82,10 @@ function BlockletStorageProvider({
|
|
|
78
82
|
setLoading: setBackupsLoading
|
|
79
83
|
});
|
|
80
84
|
const [selectedSpaceGateway, setSelectedSpaceGateway] = useState(spaceGateways?.find(x => x.endpoint === backupEndpoint));
|
|
85
|
+
const [autoBackupRefresh, setAutoBackupRefresh] = useState(false);
|
|
86
|
+
const autoBackup = useAutoBackup({
|
|
87
|
+
deps: [autoBackupRefresh]
|
|
88
|
+
});
|
|
81
89
|
|
|
82
90
|
/**
|
|
83
91
|
* @description
|
|
@@ -172,9 +180,26 @@ function BlockletStorageProvider({
|
|
|
172
180
|
* @param {SpaceGateway} spaceGateway
|
|
173
181
|
*/
|
|
174
182
|
const spaceGatewayIsSelected = spaceGateway => spaceGateway?.endpoint === backupEndpoint;
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* @description
|
|
186
|
+
* @param {AutoBackup} value
|
|
187
|
+
*/
|
|
188
|
+
const updateAutoBackup = async value => {
|
|
189
|
+
await api.updateAutoBackup({
|
|
190
|
+
input: {
|
|
191
|
+
did: blocklet.meta.did,
|
|
192
|
+
autoBackup: value
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
refreshAutoBackup();
|
|
196
|
+
};
|
|
175
197
|
const refreshBackupEndpoint = () => {
|
|
176
198
|
setBackupEndpointRefresh(p => !p);
|
|
177
199
|
};
|
|
200
|
+
const refreshAutoBackup = () => {
|
|
201
|
+
setAutoBackupRefresh(x => !x);
|
|
202
|
+
};
|
|
178
203
|
return /*#__PURE__*/_jsx(Provider, {
|
|
179
204
|
value: {
|
|
180
205
|
spaceGateways,
|
|
@@ -185,11 +210,13 @@ function BlockletStorageProvider({
|
|
|
185
210
|
refreshSpaceGateways,
|
|
186
211
|
spaceGatewaysLoading,
|
|
187
212
|
spaceGatewayIsSelected,
|
|
213
|
+
updateAutoBackup,
|
|
188
214
|
backupEndpoint,
|
|
189
215
|
backupProgress,
|
|
190
216
|
backups,
|
|
191
217
|
backupsLoading,
|
|
192
|
-
refreshBackupEndpoint
|
|
218
|
+
refreshBackupEndpoint,
|
|
219
|
+
autoBackup
|
|
193
220
|
},
|
|
194
221
|
children: children
|
|
195
222
|
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/* eslint-disable import/prefer-default-export */
|
|
2
|
+
import { useAsyncEffect } from 'ahooks';
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import { useBlockletContext } from '../contexts/blocklet';
|
|
5
|
+
import { useNodeContext } from '../contexts/node';
|
|
6
|
+
export function useAutoBackup({
|
|
7
|
+
deps
|
|
8
|
+
} = {
|
|
9
|
+
deps: []
|
|
10
|
+
}) {
|
|
11
|
+
/** @type {{ blocklet: import('@abtnode/client').BlockletState }} */
|
|
12
|
+
const {
|
|
13
|
+
blocklet
|
|
14
|
+
} = useBlockletContext();
|
|
15
|
+
/** @type {{api: import('@abtnode/client')}} */
|
|
16
|
+
const {
|
|
17
|
+
api
|
|
18
|
+
} = useNodeContext();
|
|
19
|
+
const [autoBackup, setAutoBackup] = useState(null);
|
|
20
|
+
useAsyncEffect(async () => {
|
|
21
|
+
if (blocklet?.meta?.did) {
|
|
22
|
+
const {
|
|
23
|
+
autoBackup: data
|
|
24
|
+
} = await api.getAutoBackup({
|
|
25
|
+
input: {
|
|
26
|
+
did: blocklet.meta.did
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
setAutoBackup(data);
|
|
30
|
+
}
|
|
31
|
+
}, [blocklet?.meta?.did].concat(deps));
|
|
32
|
+
return autoBackup;
|
|
33
|
+
}
|
package/es/locales/en.js
CHANGED
|
@@ -1437,6 +1437,11 @@ module.exports = {
|
|
|
1437
1437
|
title: 'Backup',
|
|
1438
1438
|
records: 'Backup Records'
|
|
1439
1439
|
},
|
|
1440
|
+
autoBackup: {
|
|
1441
|
+
title: 'Auto backup',
|
|
1442
|
+
enabled: 'Automatic backup is on',
|
|
1443
|
+
disabled: 'Automatic backup is off'
|
|
1444
|
+
},
|
|
1440
1445
|
backupSuccessfully: 'Backup successfully',
|
|
1441
1446
|
restore: 'Restore',
|
|
1442
1447
|
restoreSuccessfully: 'Restore successfully',
|
package/es/locales/zh.js
CHANGED
|
@@ -1441,6 +1441,11 @@ module.exports = {
|
|
|
1441
1441
|
title: '备份',
|
|
1442
1442
|
records: '备份记录'
|
|
1443
1443
|
},
|
|
1444
|
+
autoBackup: {
|
|
1445
|
+
title: '自动备份',
|
|
1446
|
+
enabled: '自动备份已开启',
|
|
1447
|
+
disabled: '自动备份已关闭'
|
|
1448
|
+
},
|
|
1444
1449
|
backupSuccessfully: '备份成功',
|
|
1445
1450
|
restore: '还原',
|
|
1446
1451
|
restoreSuccessfully: '还原成功',
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _material = require("@mui/material");
|
|
9
|
+
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
10
|
+
var _Toast = _interopRequireDefault(require("@arcblock/ux/lib/Toast"));
|
|
11
|
+
var _switchControl = _interopRequireDefault(require("../component/switch-control"));
|
|
12
|
+
var _blockletStorage = require("../../contexts/blocklet-storage");
|
|
13
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
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; }
|
|
16
|
+
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; }
|
|
17
|
+
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; }
|
|
18
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
19
|
+
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); }
|
|
20
|
+
function _objectDestructuringEmpty(obj) { if (obj == null) throw new TypeError("Cannot destructure " + obj); } /**
|
|
21
|
+
* @description
|
|
22
|
+
* @param {{
|
|
23
|
+
* style: import('react').CSSProperties
|
|
24
|
+
* }} {...rest}
|
|
25
|
+
* @return {*}
|
|
26
|
+
*/
|
|
27
|
+
function AutoBackup(_ref) {
|
|
28
|
+
let rest = Object.assign({}, (_objectDestructuringEmpty(_ref), _ref));
|
|
29
|
+
const {
|
|
30
|
+
t
|
|
31
|
+
} = (0, _context.useLocaleContext)();
|
|
32
|
+
const {
|
|
33
|
+
autoBackup,
|
|
34
|
+
updateAutoBackup
|
|
35
|
+
} = (0, _blockletStorage.useBlockletStorageContext)();
|
|
36
|
+
const configAutoBackup = async () => {
|
|
37
|
+
try {
|
|
38
|
+
const enabled = !autoBackup.enabled;
|
|
39
|
+
await updateAutoBackup({
|
|
40
|
+
enabled
|
|
41
|
+
});
|
|
42
|
+
_Toast.default.success(enabled ? t('storage.spaces.autoBackup.enabled') : t('storage.spaces.autoBackup.disabled'));
|
|
43
|
+
} catch (error) {
|
|
44
|
+
_Toast.default.error(error.message);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_switchControl.default, {
|
|
48
|
+
checked: Boolean(autoBackup === null || autoBackup === void 0 ? void 0 : autoBackup.enabled),
|
|
49
|
+
onChange: configAutoBackup,
|
|
50
|
+
name: "enableWelcomePage",
|
|
51
|
+
labelProps: {
|
|
52
|
+
label: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
53
|
+
marginRight: "8px",
|
|
54
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
55
|
+
children: t('storage.spaces.autoBackup.title')
|
|
56
|
+
})
|
|
57
|
+
})
|
|
58
|
+
},
|
|
59
|
+
style: _objectSpread({}, rest.style)
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
AutoBackup.propTypes = {};
|
|
63
|
+
var _default = AutoBackup;
|
|
64
|
+
exports.default = _default;
|
|
@@ -15,6 +15,7 @@ var _blocklet = require("../../contexts/blocklet");
|
|
|
15
15
|
var _node = require("../../contexts/node");
|
|
16
16
|
var _diskInfo = _interopRequireDefault(require("../disk-info"));
|
|
17
17
|
var _blockletStorage = require("../../contexts/blocklet-storage");
|
|
18
|
+
var _autoBackup = _interopRequireDefault(require("./auto-backup"));
|
|
18
19
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
21
|
/**
|
|
@@ -76,7 +77,12 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
76
77
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
77
78
|
fontSize: "1.2rem",
|
|
78
79
|
fontWeight: "bold",
|
|
80
|
+
flexGrow: 1,
|
|
79
81
|
children: t('storage.spaces.connected.title')
|
|
82
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_autoBackup.default, {
|
|
83
|
+
style: {
|
|
84
|
+
marginRight: '32px'
|
|
85
|
+
}
|
|
80
86
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_connectTo.default, {})]
|
|
81
87
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
|
|
82
88
|
children: shouldShowLoading ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
|
|
@@ -17,6 +17,7 @@ var _useSpaceGateways = _interopRequireDefault(require("../hooks/use-space-gatew
|
|
|
17
17
|
var _node = require("./node");
|
|
18
18
|
var _useBackupProgress = _interopRequireDefault(require("../hooks/use-backup-progress"));
|
|
19
19
|
var _useBackups = _interopRequireDefault(require("../hooks/use-backups"));
|
|
20
|
+
var _useAutoBackup = require("../hooks/use-auto-backup");
|
|
20
21
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
21
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
23
|
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; }
|
|
@@ -26,6 +27,7 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typ
|
|
|
26
27
|
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); } /**
|
|
27
28
|
* @typedef {import('../blocklet/storage/connected').SpaceGateway} SpaceGateway
|
|
28
29
|
* @typedef {import('@abtnode/client').Backup} Backup
|
|
30
|
+
* @typedef {import('@abtnode/client').AutoBackup} AutoBackup
|
|
29
31
|
*/ /**
|
|
30
32
|
* @typedef {{
|
|
31
33
|
* spaceGateways: SpaceGateway[],
|
|
@@ -36,12 +38,14 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
|
|
|
36
38
|
* refreshSpaceGateways: () => void,
|
|
37
39
|
* spaceGatewaysLoading: boolean,
|
|
38
40
|
* spaceGatewayIsSelected: (spaceGateway: SpaceGateway) => boolean,
|
|
41
|
+
* updateAutoBackup: (autoBackup: { enabled: boolean }) => Promise<void>,
|
|
39
42
|
*
|
|
40
43
|
* backupEndpoint: string,
|
|
41
44
|
* backupProgress: any,
|
|
42
45
|
* backups: Backup[],
|
|
43
46
|
* backupsLoading: boolean,
|
|
44
47
|
* refreshBackupEndpoint: () => void,
|
|
48
|
+
* autoBackup: AutoBackup,
|
|
45
49
|
* }} BlockletStorageContextType
|
|
46
50
|
*/ /** @type {import('react').Context<BlockletStorageContextType>} */
|
|
47
51
|
const BlockletStorageContext = /*#__PURE__*/(0, _react.createContext)({});
|
|
@@ -89,6 +93,10 @@ function BlockletStorageProvider(_ref) {
|
|
|
89
93
|
setLoading: setBackupsLoading
|
|
90
94
|
});
|
|
91
95
|
const [selectedSpaceGateway, setSelectedSpaceGateway] = (0, _react.useState)(spaceGateways === null || spaceGateways === void 0 ? void 0 : spaceGateways.find(x => x.endpoint === backupEndpoint));
|
|
96
|
+
const [autoBackupRefresh, setAutoBackupRefresh] = (0, _react.useState)(false);
|
|
97
|
+
const autoBackup = (0, _useAutoBackup.useAutoBackup)({
|
|
98
|
+
deps: [autoBackupRefresh]
|
|
99
|
+
});
|
|
92
100
|
|
|
93
101
|
/**
|
|
94
102
|
* @description
|
|
@@ -183,9 +191,26 @@ function BlockletStorageProvider(_ref) {
|
|
|
183
191
|
* @param {SpaceGateway} spaceGateway
|
|
184
192
|
*/
|
|
185
193
|
const spaceGatewayIsSelected = spaceGateway => (spaceGateway === null || spaceGateway === void 0 ? void 0 : spaceGateway.endpoint) === backupEndpoint;
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* @description
|
|
197
|
+
* @param {AutoBackup} value
|
|
198
|
+
*/
|
|
199
|
+
const updateAutoBackup = async value => {
|
|
200
|
+
await api.updateAutoBackup({
|
|
201
|
+
input: {
|
|
202
|
+
did: blocklet.meta.did,
|
|
203
|
+
autoBackup: value
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
refreshAutoBackup();
|
|
207
|
+
};
|
|
186
208
|
const refreshBackupEndpoint = () => {
|
|
187
209
|
setBackupEndpointRefresh(p => !p);
|
|
188
210
|
};
|
|
211
|
+
const refreshAutoBackup = () => {
|
|
212
|
+
setAutoBackupRefresh(x => !x);
|
|
213
|
+
};
|
|
189
214
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Provider, {
|
|
190
215
|
value: {
|
|
191
216
|
spaceGateways,
|
|
@@ -196,11 +221,13 @@ function BlockletStorageProvider(_ref) {
|
|
|
196
221
|
refreshSpaceGateways,
|
|
197
222
|
spaceGatewaysLoading,
|
|
198
223
|
spaceGatewayIsSelected,
|
|
224
|
+
updateAutoBackup,
|
|
199
225
|
backupEndpoint,
|
|
200
226
|
backupProgress,
|
|
201
227
|
backups,
|
|
202
228
|
backupsLoading,
|
|
203
|
-
refreshBackupEndpoint
|
|
229
|
+
refreshBackupEndpoint,
|
|
230
|
+
autoBackup
|
|
204
231
|
},
|
|
205
232
|
children: children
|
|
206
233
|
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useAutoBackup = useAutoBackup;
|
|
7
|
+
var _ahooks = require("ahooks");
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _blocklet = require("../contexts/blocklet");
|
|
10
|
+
var _node = require("../contexts/node");
|
|
11
|
+
/* eslint-disable import/prefer-default-export */
|
|
12
|
+
|
|
13
|
+
function useAutoBackup() {
|
|
14
|
+
var _blocklet$meta2;
|
|
15
|
+
let {
|
|
16
|
+
deps
|
|
17
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
18
|
+
deps: []
|
|
19
|
+
};
|
|
20
|
+
/** @type {{ blocklet: import('@abtnode/client').BlockletState }} */
|
|
21
|
+
const {
|
|
22
|
+
blocklet
|
|
23
|
+
} = (0, _blocklet.useBlockletContext)();
|
|
24
|
+
/** @type {{api: import('@abtnode/client')}} */
|
|
25
|
+
const {
|
|
26
|
+
api
|
|
27
|
+
} = (0, _node.useNodeContext)();
|
|
28
|
+
const [autoBackup, setAutoBackup] = (0, _react.useState)(null);
|
|
29
|
+
(0, _ahooks.useAsyncEffect)(async () => {
|
|
30
|
+
var _blocklet$meta;
|
|
31
|
+
if (blocklet !== null && blocklet !== void 0 && (_blocklet$meta = blocklet.meta) !== null && _blocklet$meta !== void 0 && _blocklet$meta.did) {
|
|
32
|
+
const {
|
|
33
|
+
autoBackup: data
|
|
34
|
+
} = await api.getAutoBackup({
|
|
35
|
+
input: {
|
|
36
|
+
did: blocklet.meta.did
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
setAutoBackup(data);
|
|
40
|
+
}
|
|
41
|
+
}, [blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta2 = blocklet.meta) === null || _blocklet$meta2 === void 0 ? void 0 : _blocklet$meta2.did].concat(deps));
|
|
42
|
+
return autoBackup;
|
|
43
|
+
}
|
package/lib/locales/en.js
CHANGED
|
@@ -1439,6 +1439,11 @@ module.exports = {
|
|
|
1439
1439
|
title: 'Backup',
|
|
1440
1440
|
records: 'Backup Records'
|
|
1441
1441
|
},
|
|
1442
|
+
autoBackup: {
|
|
1443
|
+
title: 'Auto backup',
|
|
1444
|
+
enabled: 'Automatic backup is on',
|
|
1445
|
+
disabled: 'Automatic backup is off'
|
|
1446
|
+
},
|
|
1442
1447
|
backupSuccessfully: 'Backup successfully',
|
|
1443
1448
|
restore: 'Restore',
|
|
1444
1449
|
restoreSuccessfully: 'Restore successfully',
|
package/lib/locales/zh.js
CHANGED
|
@@ -1443,6 +1443,11 @@ module.exports = {
|
|
|
1443
1443
|
title: '备份',
|
|
1444
1444
|
records: '备份记录'
|
|
1445
1445
|
},
|
|
1446
|
+
autoBackup: {
|
|
1447
|
+
title: '自动备份',
|
|
1448
|
+
enabled: '自动备份已开启',
|
|
1449
|
+
disabled: '自动备份已关闭'
|
|
1450
|
+
},
|
|
1446
1451
|
backupSuccessfully: '备份成功',
|
|
1447
1452
|
restore: '还原',
|
|
1448
1453
|
restoreSuccessfully: '还原成功',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abtnode/ux",
|
|
3
|
-
"version": "1.16.17-beta-
|
|
3
|
+
"version": "1.16.17-beta-ce49fe0e",
|
|
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.17-beta-
|
|
31
|
-
"@abtnode/constant": "1.16.17-beta-
|
|
32
|
-
"@abtnode/util": "1.16.17-beta-
|
|
30
|
+
"@abtnode/auth": "1.16.17-beta-ce49fe0e",
|
|
31
|
+
"@abtnode/constant": "1.16.17-beta-ce49fe0e",
|
|
32
|
+
"@abtnode/util": "1.16.17-beta-ce49fe0e",
|
|
33
33
|
"@ahooksjs/use-url-state": "^3.5.1",
|
|
34
34
|
"@arcblock/did": "^1.18.92",
|
|
35
35
|
"@arcblock/did-connect": "^2.7.29",
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
"@arcblock/react-hooks": "^2.7.29",
|
|
40
40
|
"@arcblock/terminal": "^2.7.29",
|
|
41
41
|
"@arcblock/ux": "^2.7.29",
|
|
42
|
-
"@blocklet/constant": "1.16.17-beta-
|
|
42
|
+
"@blocklet/constant": "1.16.17-beta-ce49fe0e",
|
|
43
43
|
"@blocklet/launcher-layout": "2.2.21",
|
|
44
44
|
"@blocklet/list": "^0.12.45",
|
|
45
|
-
"@blocklet/meta": "1.16.17-beta-
|
|
45
|
+
"@blocklet/meta": "1.16.17-beta-ce49fe0e",
|
|
46
46
|
"@blocklet/ui-react": "^2.7.29",
|
|
47
47
|
"@blocklet/uploader": "^0.0.29",
|
|
48
48
|
"@emotion/react": "^11.10.4",
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
"babel-plugin-inline-react-svg": "^1.1.2",
|
|
101
101
|
"glob": "^10.3.3"
|
|
102
102
|
},
|
|
103
|
-
"gitHead": "
|
|
103
|
+
"gitHead": "d8a04ff2ef9cd52a02d019bc2c9a743785e869c3",
|
|
104
104
|
"exports": {
|
|
105
105
|
".": {
|
|
106
106
|
"import": "./es/index.js",
|