@abtnode/ux 1.15.17 → 1.16.0-beta-8ee536d7
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 +111 -0
- package/lib/blocklet/access/config-access.js +303 -0
- package/lib/blocklet/access/index.js +221 -0
- package/lib/blocklet/actions.js +438 -0
- package/lib/blocklet/add-cert.js +191 -0
- package/lib/blocklet/agreement-app.js +30 -0
- package/lib/blocklet/agreement.js +72 -0
- package/lib/blocklet/app-avatar.js +74 -0
- package/lib/blocklet/audit-logs.js +197 -0
- package/lib/blocklet/blocklet-source.js +56 -0
- package/lib/blocklet/bundle-avatar.js +80 -0
- package/lib/blocklet/component/add.js +1063 -0
- package/lib/blocklet/component/configuration.js +124 -0
- package/lib/blocklet/component/delete.js +117 -0
- package/lib/blocklet/component/environment.js +289 -0
- package/lib/blocklet/component/expiration.js +53 -0
- package/lib/blocklet/component/index.js +804 -0
- package/lib/blocklet/component/line.js +28 -0
- package/lib/blocklet/component/navigation/locale-tabs.js +218 -0
- package/lib/blocklet/component/navigation/navigation-actions.js +120 -0
- package/lib/blocklet/component/navigation/navigation-dialog.js +620 -0
- package/lib/blocklet/component/navigation/navigation-preview.js +102 -0
- package/lib/blocklet/component/navigation/simple-select.js +131 -0
- package/lib/blocklet/component/select-store.js +153 -0
- package/lib/blocklet/component/setting.js +151 -0
- package/lib/blocklet/component/sortable-tree.js +138 -0
- package/lib/blocklet/component/space-gateway-selector.js +174 -0
- package/lib/blocklet/component/store-blocklet-list.js +205 -0
- package/lib/blocklet/config-navigation.js +344 -0
- package/lib/blocklet/configuration.js +574 -0
- package/lib/blocklet/disk-info.js +91 -0
- package/lib/blocklet/icons.js +26 -0
- package/lib/blocklet/install-from-url.js +347 -0
- package/lib/blocklet/log.js +62 -0
- package/lib/blocklet/migration.js +153 -0
- package/lib/blocklet/mode.js +35 -0
- package/lib/blocklet/monitor.js +186 -0
- package/lib/blocklet/overview.js +236 -0
- package/lib/blocklet/preferences/app-sk.js +131 -0
- package/lib/blocklet/preferences/index.js +238 -0
- package/lib/blocklet/preferences/wallet-type.js +107 -0
- package/lib/blocklet/purchase/common.js +103 -0
- package/lib/blocklet/purchase/component-purchase.js +253 -0
- package/lib/blocklet/purchase/index.js +13 -0
- package/lib/blocklet/router/action/add-domain-alias.js +173 -0
- package/lib/blocklet/router/action/add-rule.js +204 -0
- package/lib/blocklet/router/action/config-routing-rule.js +129 -0
- package/lib/blocklet/router/action/delete-domain-alias.js +107 -0
- package/lib/blocklet/router/action/delete-rule.js +114 -0
- package/lib/blocklet/router/action/update-rule.js +203 -0
- package/lib/blocklet/router/domain-actions.js +71 -0
- package/lib/blocklet/router/domain-status.js +96 -0
- package/lib/blocklet/router/rule-actions.js +77 -0
- package/lib/blocklet/router/rule-list.js +181 -0
- package/lib/blocklet/router/util.js +146 -0
- package/lib/blocklet/runtime-info.js +87 -0
- package/lib/blocklet/status.js +105 -0
- package/lib/blocklet/storage.js +322 -0
- package/lib/blocklet/types.js +25 -0
- package/lib/blocklet/util.js +233 -0
- package/lib/blocklet/version.js +156 -0
- package/lib/card-selector.js +109 -0
- package/lib/certificate.js +110 -0
- package/lib/click-to-copy.js +38 -0
- package/lib/confirm.js +149 -0
- package/lib/contexts/audit-log.js +141 -0
- package/lib/contexts/blocklet.js +19 -0
- package/lib/contexts/deleting-blocklets.js +78 -0
- package/lib/contexts/node.js +30 -0
- package/lib/contexts/session.js +20 -0
- package/lib/contexts/team.js +19 -0
- package/lib/delete-confirm.js +127 -0
- package/lib/did-address.js +77 -0
- package/lib/dot.js +18 -0
- package/lib/form/form-text-input.js +266 -0
- package/lib/form/form-wrapper.js +13 -0
- package/lib/form/required.js +13 -0
- package/lib/hooks/blocklet.js +231 -0
- package/lib/hooks/mobile-width.js +19 -0
- package/lib/hooks/url-evaluation.js +168 -0
- package/lib/hooks/use-app-logo.js +25 -0
- package/lib/hooks/use-bundle-logo.js +36 -0
- package/lib/hooks/use-navigation.js +355 -0
- package/lib/hooks/use-passport-id.js +21 -0
- package/lib/hooks/use-subscription.js +28 -0
- package/lib/icons/long-arrow.svg +5 -0
- package/lib/index.js +0 -3
- package/lib/invitation/invitation-app.js +51 -0
- package/lib/invitation/invitation-login.js +47 -0
- package/lib/invitation/invitation-passport.js +130 -0
- package/lib/invitation/invitation-receive.js +108 -0
- package/lib/invitation/invitation-success.js +82 -0
- package/lib/invitation/invitation-user.js +79 -0
- package/lib/invitation/invitation.js +80 -0
- package/lib/issue-passport.js +84 -84
- package/lib/launch-blocklet/content-layout.js +33 -0
- package/lib/launch-blocklet/page-header.js +38 -0
- package/lib/layout/addon.js +100 -0
- package/lib/layout/feedback.js +55 -0
- package/lib/locales/en.js +1221 -10
- package/lib/locales/index.js +3 -4
- package/lib/locales/zh.js +1232 -15
- package/lib/logs/clock.js +19 -0
- package/lib/logs/download.js +139 -0
- package/lib/logs/log-terminal.js +183 -0
- package/lib/lost-passport.js +207 -192
- package/lib/monitor/card.js +73 -0
- package/lib/monitor/cpu.js +109 -0
- package/lib/monitor/disk.js +122 -0
- package/lib/monitor/memory.js +144 -0
- package/lib/nav-logo.js +120 -0
- package/lib/passport-tag.js +43 -0
- package/lib/permission.js +70 -0
- package/lib/relative-time.js +61 -0
- package/lib/schema-form/color-input.js +105 -0
- package/lib/schema-form/common-prop-types.js +21 -0
- package/lib/schema-form/index.js +229 -0
- package/lib/schema-form/passport-input.js +66 -0
- package/lib/schema-form/text-input.js +72 -0
- package/lib/store/add.js +185 -0
- package/lib/store/delete.js +102 -0
- package/lib/store/item.js +84 -0
- package/lib/table-icons.js +42 -0
- package/lib/table.js +13 -0
- package/lib/tag.js +37 -0
- package/lib/team/members/actions.js +99 -0
- package/lib/team/members/index.js +503 -0
- package/lib/team/members/invitations.js +196 -0
- package/lib/team/members/invite-member.js +212 -0
- package/lib/team/members/issue-passport.js +155 -0
- package/lib/team/members/member.js +300 -0
- package/lib/team/members/passport-issuances.js +154 -0
- package/lib/team/members/passports.js +336 -0
- package/lib/team/members/toggle-user-approval.js +128 -0
- package/lib/team/members/transfer-node.js +262 -0
- package/lib/team/members/util.js +20 -0
- package/lib/team/passports/color.js +132 -0
- package/lib/team/passports/detail.js +271 -0
- package/lib/team/passports/index.js +233 -0
- package/lib/team/passports/mutate-role.js +204 -0
- package/lib/team/passports/trusted-issuer.js +297 -0
- package/lib/team/passports/trusted-issuers.js +240 -0
- package/lib/team/search-input.js +38 -0
- package/lib/team/styles/dialog.js +13 -0
- package/lib/team/styles/list-header.js +13 -0
- package/lib/toast.js +86 -0
- package/lib/util/api.js +21 -0
- package/lib/util/constants.js +10 -0
- package/lib/util/index.js +703 -0
- package/lib/util/locales.js +28 -0
- package/lib/util/mode.js +11 -0
- package/lib/who-can-access/config.js +46 -0
- package/lib/wrap-locale.js +12 -13
- package/package.json +71 -17
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = BlockletStatus;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _CircularProgress = _interopRequireDefault(require("@mui/material/CircularProgress"));
|
|
10
|
+
var _Tooltip = _interopRequireDefault(require("@mui/material/Tooltip"));
|
|
11
|
+
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
12
|
+
var _dot = _interopRequireDefault(require("../dot"));
|
|
13
|
+
var _tag = _interopRequireDefault(require("../tag"));
|
|
14
|
+
var _util = require("../util");
|
|
15
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
|
+
const _excluded = ["status", "variant", "source"];
|
|
17
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
|
+
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; }
|
|
19
|
+
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; }
|
|
20
|
+
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
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
22
|
+
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 _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; }
|
|
24
|
+
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; }
|
|
25
|
+
const colors = {
|
|
26
|
+
yellow: '#FFCF71',
|
|
27
|
+
grey: '#888888'
|
|
28
|
+
};
|
|
29
|
+
function BlockletStatus(_ref) {
|
|
30
|
+
let {
|
|
31
|
+
status,
|
|
32
|
+
variant,
|
|
33
|
+
source
|
|
34
|
+
} = _ref,
|
|
35
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
36
|
+
const {
|
|
37
|
+
t
|
|
38
|
+
} = (0, _react.useContext)(_context.LocaleContext);
|
|
39
|
+
const map = {
|
|
40
|
+
added: 'primary',
|
|
41
|
+
waiting: 'warning',
|
|
42
|
+
downloading: 'warning',
|
|
43
|
+
downloaded: 'primary',
|
|
44
|
+
installing: 'warning',
|
|
45
|
+
installed: 'primary',
|
|
46
|
+
starting: 'warning',
|
|
47
|
+
running: 'success',
|
|
48
|
+
stopping: 'warning',
|
|
49
|
+
stopped: 'reverse',
|
|
50
|
+
error: 'error',
|
|
51
|
+
upgrading: 'warning',
|
|
52
|
+
restarting: 'warning',
|
|
53
|
+
corrupted: 'error',
|
|
54
|
+
deleting: 'warning'
|
|
55
|
+
};
|
|
56
|
+
const colorMap = {
|
|
57
|
+
added: colors.grey,
|
|
58
|
+
waiting: colors.yellow,
|
|
59
|
+
downloading: colors.yellow,
|
|
60
|
+
downloaded: colors.grey,
|
|
61
|
+
installing: colors.yellow,
|
|
62
|
+
installed: colors.grey,
|
|
63
|
+
starting: colors.yellow,
|
|
64
|
+
running: 'success',
|
|
65
|
+
stopping: colors.yellow,
|
|
66
|
+
stopped: colors.grey,
|
|
67
|
+
error: 'error',
|
|
68
|
+
upgrading: colors.yellow,
|
|
69
|
+
restarting: colors.yellow,
|
|
70
|
+
corrupted: 'error',
|
|
71
|
+
deleting: colors.yellow
|
|
72
|
+
};
|
|
73
|
+
const inProgress = (0, _util.isInProgress)(status);
|
|
74
|
+
const statusTxt = t("blocklet.status.".concat(status));
|
|
75
|
+
if (variant === 'dot') {
|
|
76
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tooltip.default, {
|
|
77
|
+
title: t('blocklet.statusTip', {
|
|
78
|
+
status: statusTxt
|
|
79
|
+
}),
|
|
80
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_dot.default, _objectSpread({
|
|
81
|
+
color: colorMap[status]
|
|
82
|
+
}, rest))
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_tag.default, _objectSpread(_objectSpread({
|
|
86
|
+
type: map[status]
|
|
87
|
+
}, rest), {}, {
|
|
88
|
+
children: [inProgress && /*#__PURE__*/(0, _jsxRuntime.jsx)(_CircularProgress.default, {
|
|
89
|
+
size: 12,
|
|
90
|
+
color: "inherit",
|
|
91
|
+
style: {
|
|
92
|
+
marginRight: 5
|
|
93
|
+
}
|
|
94
|
+
}), statusTxt]
|
|
95
|
+
}));
|
|
96
|
+
}
|
|
97
|
+
BlockletStatus.propTypes = {
|
|
98
|
+
status: _propTypes.default.string.isRequired,
|
|
99
|
+
variant: _propTypes.default.oneOf(['dot', 'tag']),
|
|
100
|
+
source: _propTypes.default.string
|
|
101
|
+
};
|
|
102
|
+
BlockletStatus.defaultProps = {
|
|
103
|
+
variant: 'tag',
|
|
104
|
+
source: ''
|
|
105
|
+
};
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = Storage;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _Box = _interopRequireDefault(require("@mui/material/Box"));
|
|
9
|
+
var _Connect = _interopRequireDefault(require("@arcblock/did-connect/lib/Connect"));
|
|
10
|
+
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
11
|
+
var _constant = require("@blocklet/constant");
|
|
12
|
+
var _axios = _interopRequireDefault(require("axios"));
|
|
13
|
+
var _urlJoin = _interopRequireDefault(require("url-join"));
|
|
14
|
+
var _styled = _interopRequireDefault(require("@emotion/styled"));
|
|
15
|
+
var _lodash = require("lodash");
|
|
16
|
+
var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
|
|
17
|
+
var _material = require("@mui/material");
|
|
18
|
+
var _Button = _interopRequireDefault(require("@arcblock/ux/lib/Button"));
|
|
19
|
+
var _util = require("@blocklet/meta/lib/util");
|
|
20
|
+
var _blocklet = require("../../lib/contexts/blocklet");
|
|
21
|
+
var _node = require("../contexts/node");
|
|
22
|
+
var _toast = _interopRequireDefault(require("../../lib/toast"));
|
|
23
|
+
var _spaceGatewaySelector = _interopRequireDefault(require("./component/space-gateway-selector"));
|
|
24
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
25
|
+
var _templateObject;
|
|
26
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
|
+
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); }
|
|
28
|
+
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; }
|
|
29
|
+
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
|
+
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; }
|
|
31
|
+
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; }
|
|
32
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
33
|
+
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
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
35
|
+
const Container = (0, _styled.default)('div')(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n height: 100%;\n overflow-y: auto;\n"])));
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @description 实时显示备份的进度
|
|
39
|
+
* @param {{appDid: string}} {appDid}
|
|
40
|
+
* @return {{message: string, progress: number, completed: boolean}}
|
|
41
|
+
*/
|
|
42
|
+
function useBackupProgress(_ref) {
|
|
43
|
+
let {
|
|
44
|
+
appDid
|
|
45
|
+
} = _ref;
|
|
46
|
+
const [progress, setProgress] = (0, _react.useState)({
|
|
47
|
+
message: '',
|
|
48
|
+
progress: 0,
|
|
49
|
+
completed: false
|
|
50
|
+
});
|
|
51
|
+
const node = (0, _node.useNodeContext)();
|
|
52
|
+
const webSocketClient = node.ws.getWsClient();
|
|
53
|
+
(0, _react.useEffect)(() => {
|
|
54
|
+
webSocketClient.on(_constant.BlockletEvents.backupProgress, data => {
|
|
55
|
+
if (appDid === (data === null || data === void 0 ? void 0 : data.appDid)) {
|
|
56
|
+
setProgress(preValue => _objectSpread(_objectSpread({}, preValue), data));
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
return () => {
|
|
60
|
+
webSocketClient.off(_constant.BlockletEvents.backupProgress);
|
|
61
|
+
};
|
|
62
|
+
}, [appDid, webSocketClient]);
|
|
63
|
+
return progress;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
*
|
|
68
|
+
*
|
|
69
|
+
* @param {import('@abtnode/client').BlockletState} blocklet
|
|
70
|
+
* @return {*}
|
|
71
|
+
*/
|
|
72
|
+
function useAppUrl(blocklet) {
|
|
73
|
+
var _blocklet$site, _blocklet$site$domain, _blocklet$site$domain2;
|
|
74
|
+
const appUrls = blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$site = blocklet.site) === null || _blocklet$site === void 0 ? void 0 : (_blocklet$site$domain = _blocklet$site.domainAliases) === null || _blocklet$site$domain === void 0 ? void 0 : (_blocklet$site$domain2 = _blocklet$site$domain.sort((a, b) => {
|
|
75
|
+
if (a.accessibility.accessible && b.accessibility.accessible) {
|
|
76
|
+
return +a.isProtected - +b.isProtected;
|
|
77
|
+
}
|
|
78
|
+
return +b.accessibility.accessible - +a.accessibility.accessible;
|
|
79
|
+
})) === null || _blocklet$site$domain2 === void 0 ? void 0 : _blocklet$site$domain2.map(domainAlias => {
|
|
80
|
+
var _domainAlias$domainSt;
|
|
81
|
+
const protocol = domainAlias !== null && domainAlias !== void 0 && (_domainAlias$domainSt = domainAlias.domainStatus) !== null && _domainAlias$domainSt !== void 0 && _domainAlias$domainSt.isHttps ? 'https://' : 'http://';
|
|
82
|
+
const value = domainAlias === null || domainAlias === void 0 ? void 0 : domainAlias.value;
|
|
83
|
+
return "".concat(protocol).concat(value);
|
|
84
|
+
}).filter(Boolean);
|
|
85
|
+
const appUrl = appUrls === null || appUrls === void 0 ? void 0 : appUrls[0];
|
|
86
|
+
|
|
87
|
+
// 授权的时候提供 appUrl, 因为 appUrl 可能很久都拿不到值,所以加一个 loading 效果过渡一下
|
|
88
|
+
return {
|
|
89
|
+
appUrl,
|
|
90
|
+
isReady: Boolean(appUrl)
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
function Storage() {
|
|
94
|
+
var _blocklet$environment;
|
|
95
|
+
/** @type {{ api: import('@abtnode/client').ABTNodeClient, info: import('@abtnode/client').NodeState }} */
|
|
96
|
+
const {
|
|
97
|
+
api,
|
|
98
|
+
info
|
|
99
|
+
} = (0, _node.useNodeContext)();
|
|
100
|
+
const nodeDid = info.did;
|
|
101
|
+
const {
|
|
102
|
+
t,
|
|
103
|
+
locale
|
|
104
|
+
} = (0, _react.useContext)(_context.LocaleContext);
|
|
105
|
+
/** @type {{ blocklet: import('@abtnode/client').BlockletState }} */
|
|
106
|
+
const {
|
|
107
|
+
blocklet
|
|
108
|
+
} = (0, _blocklet.useBlockletContext)();
|
|
109
|
+
const [gatewayUrl, setGatewayUrl] = (0, _react.useState)('');
|
|
110
|
+
const [endpoint, setEndpoint] = (0, _react.useState)(((_blocklet$environment = blocklet.environments.find(e => e.key === _constant.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_SPACE_ENDPOINT)) === null || _blocklet$environment === void 0 ? void 0 : _blocklet$environment.value) || '');
|
|
111
|
+
const progress = useBackupProgress({
|
|
112
|
+
appDid: blocklet === null || blocklet === void 0 ? void 0 : blocklet.appDid
|
|
113
|
+
});
|
|
114
|
+
const [isLoading, setIsLoading] = (0, _react.useState)(false);
|
|
115
|
+
const appName = (0, _util.getAppName)(blocklet);
|
|
116
|
+
const appDescription = (0, _util.getAppDescription)(blocklet);
|
|
117
|
+
const {
|
|
118
|
+
appUrl,
|
|
119
|
+
isReady
|
|
120
|
+
} = useAppUrl(blocklet);
|
|
121
|
+
async function saveStorageEndpoint(did, storageEndpoint) {
|
|
122
|
+
await api.configBlocklet({
|
|
123
|
+
input: {
|
|
124
|
+
did: [did],
|
|
125
|
+
configs: [{
|
|
126
|
+
key: _constant.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_SPACES_URL,
|
|
127
|
+
value: gatewayUrl
|
|
128
|
+
}, {
|
|
129
|
+
key: _constant.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_SPACE_ENDPOINT,
|
|
130
|
+
value: storageEndpoint
|
|
131
|
+
}]
|
|
132
|
+
}
|
|
133
|
+
}).then(() => {
|
|
134
|
+
_toast.default.success(t('storage.spaces.connected', locale));
|
|
135
|
+
}).catch(error => {
|
|
136
|
+
console.error(error);
|
|
137
|
+
_toast.default.error(error.message);
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
const onAuthorizeConnectSuccess = async (response, decrypt) => {
|
|
141
|
+
setEndpoint(decrypt(response.endpoint));
|
|
142
|
+
await saveStorageEndpoint(blocklet.meta.did, decrypt(response.endpoint));
|
|
143
|
+
setTimeout(() => {
|
|
144
|
+
setAuthorizeConnect(preValue => _objectSpread(_objectSpread({}, preValue), {}, {
|
|
145
|
+
open: false
|
|
146
|
+
}));
|
|
147
|
+
}, 3000);
|
|
148
|
+
};
|
|
149
|
+
const [authorizeConnect, setAuthorizeConnect] = (0, _react.useState)({
|
|
150
|
+
open: false
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
// eslint-disable-next-line no-shadow
|
|
154
|
+
const handleOnClickAuthorize = async gatewayUrl => {
|
|
155
|
+
if ((0, _lodash.isEmpty)(gatewayUrl)) {
|
|
156
|
+
_toast.default.error(t('storage.spaces.addressCannotEmpty', locale));
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
setGatewayUrl(gatewayUrl);
|
|
160
|
+
setAuthorizeConnect(preValue => _objectSpread(_objectSpread({}, preValue), {}, {
|
|
161
|
+
action: 'one-click-authorization',
|
|
162
|
+
checkTimeout: 1000 * 300,
|
|
163
|
+
prefix: (0, _urlJoin.default)(gatewayUrl, 'space/api/did'),
|
|
164
|
+
baseUrl: new URL(gatewayUrl).origin,
|
|
165
|
+
checkFn: _axios.default.create({
|
|
166
|
+
baseURL: (0, _urlJoin.default)(gatewayUrl, 'space')
|
|
167
|
+
}).get,
|
|
168
|
+
extraParams: {
|
|
169
|
+
appDid: blocklet.appDid,
|
|
170
|
+
appName,
|
|
171
|
+
appDescription,
|
|
172
|
+
scopes: 'list:object read:object write:object',
|
|
173
|
+
appUrl,
|
|
174
|
+
referrer: window.location.href,
|
|
175
|
+
nodeDid
|
|
176
|
+
},
|
|
177
|
+
onClose: () => {
|
|
178
|
+
// eslint-disable-next-line no-shadow
|
|
179
|
+
setAuthorizeConnect(preValue => _objectSpread(_objectSpread({}, preValue), {}, {
|
|
180
|
+
open: false
|
|
181
|
+
}));
|
|
182
|
+
},
|
|
183
|
+
open: true
|
|
184
|
+
}));
|
|
185
|
+
};
|
|
186
|
+
const onBackup = async () => {
|
|
187
|
+
try {
|
|
188
|
+
if (isLoading) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
setIsLoading(true);
|
|
192
|
+
await api.backupToSpaces({
|
|
193
|
+
input: {
|
|
194
|
+
appDid: blocklet.appDid
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
_toast.default.success(t('storage.spaces.backupSuccessfully'));
|
|
198
|
+
} catch (error) {
|
|
199
|
+
_toast.default.error(error.message);
|
|
200
|
+
console.error(error);
|
|
201
|
+
} finally {
|
|
202
|
+
setIsLoading(false);
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
(0, _react.useEffect)(() => {
|
|
206
|
+
setAuthorizeConnect(preValue => _objectSpread(_objectSpread({}, preValue), {}, {
|
|
207
|
+
messages: {
|
|
208
|
+
title: t('storage.spaces.authorize.title', {
|
|
209
|
+
appName
|
|
210
|
+
}),
|
|
211
|
+
scan: t('storage.spaces.authorize.scan', {
|
|
212
|
+
appName
|
|
213
|
+
}),
|
|
214
|
+
confirm: '',
|
|
215
|
+
success: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
|
216
|
+
gutterBottom: true,
|
|
217
|
+
children: t('storage.spaces.authorize.success')
|
|
218
|
+
})
|
|
219
|
+
}
|
|
220
|
+
}));
|
|
221
|
+
}, [appName, locale, t]);
|
|
222
|
+
(0, _react.useEffect)(() => {
|
|
223
|
+
if (progress !== null && progress !== void 0 && progress.completed) {
|
|
224
|
+
setIsLoading(false);
|
|
225
|
+
if (progress !== null && progress !== void 0 && progress.progress) {
|
|
226
|
+
progress.progress = 0;
|
|
227
|
+
}
|
|
228
|
+
} else if (progress !== null && progress !== void 0 && progress.message) {
|
|
229
|
+
setIsLoading(true);
|
|
230
|
+
}
|
|
231
|
+
}, [progress]);
|
|
232
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Container, {
|
|
233
|
+
style: {
|
|
234
|
+
maxWidth: '720px'
|
|
235
|
+
},
|
|
236
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_spaceGatewaySelector.default, {
|
|
237
|
+
sx: {
|
|
238
|
+
marginTop: '24px',
|
|
239
|
+
marginBottom: '40px'
|
|
240
|
+
},
|
|
241
|
+
onSelect: handleOnClickAuthorize,
|
|
242
|
+
endpoint: endpoint,
|
|
243
|
+
loading: !isReady
|
|
244
|
+
}), endpoint && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
|
|
245
|
+
mt: 3,
|
|
246
|
+
display: "flex",
|
|
247
|
+
alignItems: "center",
|
|
248
|
+
justifyContent: "space-between",
|
|
249
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
|
|
250
|
+
display: "inline",
|
|
251
|
+
children: [t('storage.spaces.tips'), ": \xA0", ' ', /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
|
|
252
|
+
display: "inline",
|
|
253
|
+
color: "primary.main",
|
|
254
|
+
fontWeight: "fontWeightBold",
|
|
255
|
+
children: t('storage.spaces.connected')
|
|
256
|
+
})]
|
|
257
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
|
|
258
|
+
onClick: onBackup,
|
|
259
|
+
loading: isLoading,
|
|
260
|
+
variant: "contained",
|
|
261
|
+
color: "primary",
|
|
262
|
+
"data-cy": "add-domain-alias",
|
|
263
|
+
disabled: !endpoint || isLoading,
|
|
264
|
+
children: t('storage.spaces.backup')
|
|
265
|
+
})]
|
|
266
|
+
}), isLoading && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
|
|
267
|
+
sx: {
|
|
268
|
+
overflow: 'hidden'
|
|
269
|
+
},
|
|
270
|
+
display: "flex",
|
|
271
|
+
flexDirection: "column",
|
|
272
|
+
justifyContent: "center",
|
|
273
|
+
textAlign: "center",
|
|
274
|
+
marginTop: "16px",
|
|
275
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
|
276
|
+
color: "primary",
|
|
277
|
+
children: progress === null || progress === void 0 ? void 0 : progress.message
|
|
278
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
|
|
279
|
+
sx: {
|
|
280
|
+
display: 'flex',
|
|
281
|
+
alignItems: 'center'
|
|
282
|
+
},
|
|
283
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
|
|
284
|
+
sx: {
|
|
285
|
+
width: '100%',
|
|
286
|
+
mr: 1
|
|
287
|
+
},
|
|
288
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.LinearProgress, {
|
|
289
|
+
color: "primary",
|
|
290
|
+
variant: "indeterminate",
|
|
291
|
+
value: progress === null || progress === void 0 ? void 0 : progress.progress
|
|
292
|
+
})
|
|
293
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
|
|
294
|
+
sx: {
|
|
295
|
+
minWidth: 35
|
|
296
|
+
},
|
|
297
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Typography.default, {
|
|
298
|
+
variant: "body2",
|
|
299
|
+
color: "text.secondary",
|
|
300
|
+
children: [progress === null || progress === void 0 ? void 0 : progress.progress, "%"]
|
|
301
|
+
})
|
|
302
|
+
})]
|
|
303
|
+
})]
|
|
304
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Connect.default, {
|
|
305
|
+
forceConnected: false,
|
|
306
|
+
saveConnect: false,
|
|
307
|
+
prefix: authorizeConnect.prefix,
|
|
308
|
+
open: authorizeConnect.open,
|
|
309
|
+
popup: true,
|
|
310
|
+
action: authorizeConnect.action,
|
|
311
|
+
baseUrl: authorizeConnect.baseUrl,
|
|
312
|
+
checkFn: authorizeConnect.checkFn,
|
|
313
|
+
onSuccess: onAuthorizeConnectSuccess,
|
|
314
|
+
onClose: authorizeConnect.onClose,
|
|
315
|
+
checkTimeout: authorizeConnect.checkTimeout,
|
|
316
|
+
extraParams: authorizeConnect.extraParams,
|
|
317
|
+
messages: authorizeConnect.messages,
|
|
318
|
+
locale: locale
|
|
319
|
+
})]
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
Storage.propTypes = {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.DomainType = void 0;
|
|
7
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
+
// eslint-disable-next-line import/prefer-default-export
|
|
10
|
+
const DomainType = _propTypes.default.shape({
|
|
11
|
+
href: _propTypes.default.string,
|
|
12
|
+
accessibility: _propTypes.default.shape({
|
|
13
|
+
loading: _propTypes.default.bool,
|
|
14
|
+
accessible: _propTypes.default.bool
|
|
15
|
+
}),
|
|
16
|
+
domainStatus: _propTypes.default.shape({
|
|
17
|
+
isHttps: _propTypes.default.bool,
|
|
18
|
+
matchedCert: _propTypes.default.object
|
|
19
|
+
}),
|
|
20
|
+
dns: _propTypes.default.shape({
|
|
21
|
+
resolved: _propTypes.default.bool,
|
|
22
|
+
ip: _propTypes.default.string
|
|
23
|
+
})
|
|
24
|
+
});
|
|
25
|
+
exports.DomainType = DomainType;
|