@abtnode/ux 1.16.11-next-8a4df821 → 1.16.11-next-ca5f18b5
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/blocklet/storage/action.js +146 -0
- package/lib/blocklet/storage/backups.js +254 -0
- package/lib/blocklet/storage/connect-to.js +368 -0
- package/lib/blocklet/storage/connected.js +134 -0
- package/lib/blocklet/storage/delete.js +35 -21
- package/lib/blocklet/storage/disconnect.js +78 -0
- package/lib/blocklet/storage/index.js +12 -421
- package/lib/blocklet/storage/item.js +509 -84
- package/lib/hooks/use-backup-progress.js +41 -0
- package/lib/hooks/use-blocklet-info-for-connect-did-spaces.js +59 -0
- package/lib/icons/empty-spaces-nft.svg +9 -0
- package/lib/icons/space-connected.svg +3 -0
- package/lib/icons/space-disconnect.svg +3 -0
- package/lib/locales/en.js +27 -6
- package/lib/locales/zh.js +32 -6
- package/lib/util/mode.js +3 -3
- package/lib/util/spaces.js +27 -0
- package/package.json +8 -8
- package/lib/blocklet/storage/add.js +0 -157
- package/lib/blocklet/storage/connect.js +0 -226
- package/lib/blocklet/storage/switch-did-spaces.js +0 -315
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _Button = _interopRequireDefault(require("@arcblock/ux/lib/Button"));
|
|
8
|
-
var _Dialog = _interopRequireDefault(require("@arcblock/ux/lib/Dialog"));
|
|
9
|
-
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
10
|
-
var _material = require("@mui/material");
|
|
11
|
-
var _react = require("react");
|
|
12
|
-
var _DialogContentText = _interopRequireDefault(require("@mui/material/DialogContentText"));
|
|
13
|
-
var _Alert = _interopRequireDefault(require("@arcblock/ux/lib/Alert"));
|
|
14
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
|
-
var _util = require("../../util");
|
|
16
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
|
-
const _excluded = ["onAdd"];
|
|
18
|
-
/**
|
|
19
|
-
* @typedef {{
|
|
20
|
-
* name: string,
|
|
21
|
-
* url: string,
|
|
22
|
-
* protected?: boolean,
|
|
23
|
-
* }} SpaceGateway
|
|
24
|
-
*/
|
|
25
|
-
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* @export
|
|
29
|
-
* @param {{
|
|
30
|
-
* onAdd: (url: string) => Promise<void> | void,
|
|
31
|
-
* }} { onAdd, spaceGateways, ...rest }
|
|
32
|
-
* @return {*}
|
|
33
|
-
*/
|
|
34
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
35
|
-
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; }
|
|
36
|
-
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; }
|
|
37
|
-
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; }
|
|
38
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
39
|
-
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); }
|
|
40
|
-
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; }
|
|
41
|
-
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; }
|
|
42
|
-
function AddDIDSpacesGateWay(_ref) {
|
|
43
|
-
let {
|
|
44
|
-
onAdd
|
|
45
|
-
} = _ref,
|
|
46
|
-
rest = _objectWithoutProperties(_ref, _excluded);
|
|
47
|
-
const {
|
|
48
|
-
t,
|
|
49
|
-
locale
|
|
50
|
-
} = (0, _context.useLocaleContext)();
|
|
51
|
-
const [url, setUrl] = (0, _react.useState)('');
|
|
52
|
-
const [loading, setLoading] = (0, _react.useState)(false);
|
|
53
|
-
const [open, setOpen] = (0, _react.useState)(false);
|
|
54
|
-
const [errorMessage, setErrorMessage] = (0, _react.useState)('');
|
|
55
|
-
const onConfirm = async () => {
|
|
56
|
-
try {
|
|
57
|
-
setLoading(true);
|
|
58
|
-
await onAdd(url);
|
|
59
|
-
setOpen(false);
|
|
60
|
-
} catch (err) {
|
|
61
|
-
const _errorMessage = "".concat(t('storage.spaces.gateway.add.failed', locale), ": ").concat((0, _util.formatError)(err));
|
|
62
|
-
setErrorMessage(_errorMessage);
|
|
63
|
-
} finally {
|
|
64
|
-
setLoading(false);
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
68
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, _objectSpread(_objectSpread({
|
|
69
|
-
size: "small",
|
|
70
|
-
color: "primary",
|
|
71
|
-
variant: "outlined",
|
|
72
|
-
onClick: () => setOpen(true)
|
|
73
|
-
}, rest), {}, {
|
|
74
|
-
children: t('storage.spaces.gateway.add.title')
|
|
75
|
-
})), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Dialog.default, {
|
|
76
|
-
title: t('storage.spaces.gateway.add.title'),
|
|
77
|
-
fullWidth: true,
|
|
78
|
-
maxWidth: "md",
|
|
79
|
-
open: open,
|
|
80
|
-
onClose: () => setOpen(false),
|
|
81
|
-
PaperProps: {
|
|
82
|
-
style: {
|
|
83
|
-
minHeight: 'auto'
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
actions: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
87
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
|
|
88
|
-
onClick: e => {
|
|
89
|
-
e.stopPropagation();
|
|
90
|
-
setOpen(false);
|
|
91
|
-
},
|
|
92
|
-
color: "inherit",
|
|
93
|
-
children: t('common.cancel')
|
|
94
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Button.default, {
|
|
95
|
-
onClick: e => {
|
|
96
|
-
e.stopPropagation();
|
|
97
|
-
onConfirm();
|
|
98
|
-
},
|
|
99
|
-
color: "primary",
|
|
100
|
-
"data-cy": "install-blocklet-next-step",
|
|
101
|
-
disabled: loading || !url,
|
|
102
|
-
variant: "contained",
|
|
103
|
-
autoFocus: true,
|
|
104
|
-
children: [loading && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.CircularProgress, {
|
|
105
|
-
size: 16
|
|
106
|
-
}), t('common.confirm')]
|
|
107
|
-
})]
|
|
108
|
-
}),
|
|
109
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
110
|
-
style: {
|
|
111
|
-
paddingTop: 12,
|
|
112
|
-
overflowY: 'hidden'
|
|
113
|
-
},
|
|
114
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_DialogContentText.default, {
|
|
115
|
-
component: "div",
|
|
116
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
117
|
-
component: "div",
|
|
118
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TextField, {
|
|
119
|
-
label: t('storage.spaces.gateway.add.label'),
|
|
120
|
-
autoComplete: "off",
|
|
121
|
-
variant: "outlined",
|
|
122
|
-
name: "url",
|
|
123
|
-
fullWidth: true,
|
|
124
|
-
value: url,
|
|
125
|
-
onChange: e => {
|
|
126
|
-
setErrorMessage(null);
|
|
127
|
-
setUrl(e.target.value);
|
|
128
|
-
},
|
|
129
|
-
disabled: loading,
|
|
130
|
-
onKeyPress: async e => {
|
|
131
|
-
if (e.key === 'Enter') {
|
|
132
|
-
e.preventDefault();
|
|
133
|
-
await onConfirm();
|
|
134
|
-
}
|
|
135
|
-
},
|
|
136
|
-
autoFocus: true
|
|
137
|
-
})
|
|
138
|
-
})
|
|
139
|
-
})
|
|
140
|
-
}), !!errorMessage && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Alert.default, {
|
|
141
|
-
type: "error",
|
|
142
|
-
style: {
|
|
143
|
-
width: '100%'
|
|
144
|
-
},
|
|
145
|
-
children: errorMessage
|
|
146
|
-
})]
|
|
147
|
-
})]
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
AddDIDSpacesGateWay.propTypes = {
|
|
151
|
-
onAdd: _propTypes.default.func
|
|
152
|
-
};
|
|
153
|
-
AddDIDSpacesGateWay.defaultProps = {
|
|
154
|
-
onAdd: async () => undefined
|
|
155
|
-
};
|
|
156
|
-
var _default = AddDIDSpacesGateWay;
|
|
157
|
-
exports.default = _default;
|
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
-
var _Button = _interopRequireDefault(require("@arcblock/ux/lib/Button"));
|
|
10
|
-
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
11
|
-
var _Connect = _interopRequireDefault(require("@arcblock/did-connect/lib/Connect"));
|
|
12
|
-
var _material = require("@mui/material");
|
|
13
|
-
var _lodash = require("lodash");
|
|
14
|
-
var _urlJoin = _interopRequireDefault(require("url-join"));
|
|
15
|
-
var _axios = _interopRequireDefault(require("axios"));
|
|
16
|
-
var _util = require("@blocklet/meta/lib/util");
|
|
17
|
-
var _Toast = _interopRequireDefault(require("@arcblock/ux/lib/Toast"));
|
|
18
|
-
var _node = require("../../contexts/node");
|
|
19
|
-
var _blocklet = require("../../../lib/contexts/blocklet");
|
|
20
|
-
var _spaces = require("../../util/spaces");
|
|
21
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
-
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); }
|
|
24
|
-
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; }
|
|
25
|
-
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
|
-
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; }
|
|
27
|
-
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; }
|
|
28
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
29
|
-
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); } /**
|
|
30
|
-
* @typedef {{
|
|
31
|
-
* name: string,
|
|
32
|
-
* url: string,
|
|
33
|
-
* protected?: boolean,
|
|
34
|
-
* endpoint?: string,
|
|
35
|
-
* }} SpaceGateway
|
|
36
|
-
*/ /**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* @param {import('@abtnode/client').BlockletState} blocklet
|
|
40
|
-
* @return {*}
|
|
41
|
-
*/
|
|
42
|
-
function useBlockletInfo(blocklet) {
|
|
43
|
-
var _blocklet$site, _blocklet$site$domain, _blocklet$site$domain2;
|
|
44
|
-
const {
|
|
45
|
-
appDid
|
|
46
|
-
} = blocklet;
|
|
47
|
-
const appName = (0, _util.getAppName)(blocklet);
|
|
48
|
-
const appDescription = (0, _util.getAppDescription)(blocklet);
|
|
49
|
-
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) => {
|
|
50
|
-
if (a.accessibility.accessible && b.accessibility.accessible) {
|
|
51
|
-
return +a.isProtected - +b.isProtected;
|
|
52
|
-
}
|
|
53
|
-
return +b.accessibility.accessible - +a.accessibility.accessible;
|
|
54
|
-
})) === null || _blocklet$site$domain2 === void 0 ? void 0 : _blocklet$site$domain2.map(domainAlias => {
|
|
55
|
-
var _domainAlias$domainSt;
|
|
56
|
-
const protocol = domainAlias !== null && domainAlias !== void 0 && (_domainAlias$domainSt = domainAlias.domainStatus) !== null && _domainAlias$domainSt !== void 0 && _domainAlias$domainSt.isHttps ? 'https://' : 'http://';
|
|
57
|
-
const value = domainAlias === null || domainAlias === void 0 ? void 0 : domainAlias.value;
|
|
58
|
-
return "".concat(protocol).concat(value);
|
|
59
|
-
}).filter(Boolean);
|
|
60
|
-
const appUrl = appUrls === null || appUrls === void 0 ? void 0 : appUrls[0];
|
|
61
|
-
const scopes = 'list:object read:object write:object';
|
|
62
|
-
const referrer = window.location.href;
|
|
63
|
-
|
|
64
|
-
// 授权的时候提供 appUrl, 因为 appUrl 可能很久都拿不到值,所以加一个 isReady 来表示就绪状态
|
|
65
|
-
return {
|
|
66
|
-
appDid,
|
|
67
|
-
appName,
|
|
68
|
-
appDescription,
|
|
69
|
-
appUrl,
|
|
70
|
-
scopes,
|
|
71
|
-
referrer,
|
|
72
|
-
isReady: Boolean(appUrl)
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
* @export
|
|
80
|
-
* @param {{
|
|
81
|
-
* spaceGateway: SpaceGateway,
|
|
82
|
-
* onConnect: (spaceGateway: SpaceGateway, endpoint: string) => void | Promise<void>
|
|
83
|
-
* }} { spaceGateway, onConnect }
|
|
84
|
-
* @return {React.Component}
|
|
85
|
-
*/
|
|
86
|
-
function ConnectDIDSpaces(_ref) {
|
|
87
|
-
let {
|
|
88
|
-
spaceGateway,
|
|
89
|
-
onConnect
|
|
90
|
-
} = _ref;
|
|
91
|
-
const {
|
|
92
|
-
t,
|
|
93
|
-
locale
|
|
94
|
-
} = (0, _context.useLocaleContext)();
|
|
95
|
-
const {
|
|
96
|
-
info
|
|
97
|
-
} = (0, _node.useNodeContext)();
|
|
98
|
-
const nodeDid = info.did;
|
|
99
|
-
const {
|
|
100
|
-
url
|
|
101
|
-
} = spaceGateway;
|
|
102
|
-
const [loading, setLoading] = (0, _react.useState)(false);
|
|
103
|
-
/** @type {{ blocklet: import('@abtnode/client').BlockletState }} */
|
|
104
|
-
const {
|
|
105
|
-
blocklet,
|
|
106
|
-
actions: {
|
|
107
|
-
refreshBlocklet
|
|
108
|
-
}
|
|
109
|
-
} = (0, _blocklet.useBlockletContext)();
|
|
110
|
-
const {
|
|
111
|
-
appDid,
|
|
112
|
-
appName,
|
|
113
|
-
appDescription,
|
|
114
|
-
appUrl,
|
|
115
|
-
scopes,
|
|
116
|
-
referrer,
|
|
117
|
-
isReady
|
|
118
|
-
} = useBlockletInfo(blocklet);
|
|
119
|
-
const [authorizeConnect, setAuthorizeConnect] = (0, _react.useState)({
|
|
120
|
-
open: false,
|
|
121
|
-
action: 'one-click-authorization',
|
|
122
|
-
checkTimeout: 1000 * 300,
|
|
123
|
-
messages: {
|
|
124
|
-
title: t('storage.spaces.authorize.title', {
|
|
125
|
-
appName
|
|
126
|
-
}, locale),
|
|
127
|
-
scan: t('storage.spaces.authorize.scan', {
|
|
128
|
-
appName
|
|
129
|
-
}, locale),
|
|
130
|
-
confirm: '',
|
|
131
|
-
success: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
132
|
-
gutterBottom: true,
|
|
133
|
-
children: t('storage.spaces.authorize.success')
|
|
134
|
-
})
|
|
135
|
-
},
|
|
136
|
-
extraParams: {
|
|
137
|
-
appDid,
|
|
138
|
-
appName,
|
|
139
|
-
appDescription,
|
|
140
|
-
scopes,
|
|
141
|
-
appUrl,
|
|
142
|
-
referrer,
|
|
143
|
-
nodeDid
|
|
144
|
-
},
|
|
145
|
-
onClose: () => {
|
|
146
|
-
// eslint-disable-next-line no-shadow
|
|
147
|
-
setAuthorizeConnect(preValue => _objectSpread(_objectSpread({}, preValue), {}, {
|
|
148
|
-
open: false
|
|
149
|
-
}));
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
const onConnectSuccess = async (response, decrypt) => {
|
|
153
|
-
setTimeout(async () => {
|
|
154
|
-
setAuthorizeConnect(preValue => _objectSpread(_objectSpread({}, preValue), {}, {
|
|
155
|
-
open: false
|
|
156
|
-
}));
|
|
157
|
-
const endpoint = decrypt(response.endpoint);
|
|
158
|
-
await onConnect(spaceGateway, endpoint);
|
|
159
|
-
refreshBlocklet();
|
|
160
|
-
}, 3000);
|
|
161
|
-
};
|
|
162
|
-
const handleOnClick = async () => {
|
|
163
|
-
try {
|
|
164
|
-
setLoading(true);
|
|
165
|
-
if ((0, _lodash.isEmpty)(url)) {
|
|
166
|
-
_Toast.default.error(t('storage.spaces.addressCannotEmpty', locale));
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// 我们已经有 endpoint && 权限还在 的话,就无需 connect 了
|
|
171
|
-
if (await (0, _spaces.hasPermissionByEndpoint)(spaceGateway === null || spaceGateway === void 0 ? void 0 : spaceGateway.endpoint)) {
|
|
172
|
-
await onConnect(spaceGateway, spaceGateway.endpoint);
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
setAuthorizeConnect(preValue => _objectSpread(_objectSpread({}, preValue), {}, {
|
|
176
|
-
open: true,
|
|
177
|
-
prefix: (0, _urlJoin.default)(url, 'space/api/did'),
|
|
178
|
-
baseUrl: new URL(url).origin,
|
|
179
|
-
checkFn: _axios.default.create({
|
|
180
|
-
baseURL: (0, _urlJoin.default)(url, 'space')
|
|
181
|
-
}).get
|
|
182
|
-
}));
|
|
183
|
-
} finally {
|
|
184
|
-
setLoading(false);
|
|
185
|
-
}
|
|
186
|
-
};
|
|
187
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
188
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
|
|
189
|
-
size: "small",
|
|
190
|
-
loading: !isReady || loading,
|
|
191
|
-
color: "secondary",
|
|
192
|
-
variant: "contained",
|
|
193
|
-
onClick: handleOnClick,
|
|
194
|
-
children: t('storage.spaces.gateway.connectTo')
|
|
195
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Connect.default, {
|
|
196
|
-
forceConnected: false,
|
|
197
|
-
saveConnect: false,
|
|
198
|
-
prefix: authorizeConnect.prefix,
|
|
199
|
-
open: authorizeConnect.open,
|
|
200
|
-
popup: true,
|
|
201
|
-
action: authorizeConnect.action,
|
|
202
|
-
baseUrl: authorizeConnect.baseUrl,
|
|
203
|
-
checkFn: authorizeConnect.checkFn,
|
|
204
|
-
onSuccess: onConnectSuccess,
|
|
205
|
-
onClose: authorizeConnect.onClose,
|
|
206
|
-
checkTimeout: authorizeConnect.checkTimeout,
|
|
207
|
-
extraParams: authorizeConnect.extraParams,
|
|
208
|
-
messages: authorizeConnect.messages,
|
|
209
|
-
locale: locale
|
|
210
|
-
})]
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
ConnectDIDSpaces.propTypes = {
|
|
214
|
-
spaceGateway: _propTypes.default.shape({
|
|
215
|
-
name: _propTypes.default.string.isRequired,
|
|
216
|
-
url: _propTypes.default.string.isRequired,
|
|
217
|
-
protected: _propTypes.default.bool,
|
|
218
|
-
endpoint: _propTypes.default.string
|
|
219
|
-
}).isRequired,
|
|
220
|
-
onConnect: _propTypes.default.func
|
|
221
|
-
};
|
|
222
|
-
ConnectDIDSpaces.defaultProps = {
|
|
223
|
-
onConnect: async () => undefined
|
|
224
|
-
};
|
|
225
|
-
var _default = ConnectDIDSpaces;
|
|
226
|
-
exports.default = _default;
|