@abtnode/ux 1.16.19-beta-710018ca → 1.16.19-beta-ba354e01
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/component/add-component-core.js +49 -36
- package/es/blocklet/component/button.js +12 -0
- package/es/blocklet/component/did-space/connect-to.js +355 -0
- package/es/blocklet/component/did-space/connected.js +42 -0
- package/es/blocklet/component/did-space/delete.js +104 -0
- package/es/blocklet/component/did-space/disconnect.js +230 -0
- package/es/blocklet/component/did-space/index.js +73 -0
- package/es/blocklet/component/did-space/item.js +233 -0
- package/es/blocklet/component/index.js +3 -3
- package/es/blocklet/component/step-actions.js +99 -0
- package/es/blocklet/publish/create-project.js +1 -1
- package/es/blocklet/publish/create-release.js +39 -20
- package/es/blocklet/publish/index.js +15 -2
- package/es/blocklet/publish/project-list.js +32 -1
- package/es/blocklet/publish/release-list.js +1 -0
- package/es/blocklet/publish/resource.js +2 -13
- package/es/blocklet/publish/tree.js +4 -0
- package/es/blocklet/resource-type.js +34 -0
- package/es/blocklet/storage/connect-to.js +11 -15
- package/es/contexts/config-space.js +160 -0
- package/es/hooks/use-mobile.js +17 -0
- package/es/hooks/use-storage-endpoint.js +23 -0
- package/es/images.js +48 -0
- package/es/locales/en.js +5 -0
- package/es/locales/zh.js +5 -0
- package/es/util/constants.js +2 -1
- package/es/util/index.js +5 -1
- package/es/util/spaces.js +66 -5
- package/lib/blocklet/component/add-component-core.js +59 -45
- package/lib/blocklet/component/button.js +23 -0
- package/lib/blocklet/component/did-space/connect-to.js +362 -0
- package/lib/blocklet/component/did-space/connected.js +49 -0
- package/lib/blocklet/component/did-space/delete.js +111 -0
- package/lib/blocklet/component/did-space/disconnect.js +241 -0
- package/lib/blocklet/component/did-space/index.js +82 -0
- package/lib/blocklet/component/did-space/item.js +197 -0
- package/lib/blocklet/component/index.js +3 -3
- package/lib/blocklet/component/step-actions.js +63 -0
- package/lib/blocklet/publish/create-project.js +1 -1
- package/lib/blocklet/publish/create-release.js +39 -19
- package/lib/blocklet/publish/index.js +18 -4
- package/lib/blocklet/publish/project-list.js +32 -1
- package/lib/blocklet/publish/release-list.js +1 -0
- package/lib/blocklet/publish/resource.js +1 -12
- package/lib/blocklet/publish/tree.js +45 -38
- package/lib/blocklet/resource-type.js +51 -0
- package/lib/blocklet/storage/connect-to.js +11 -15
- package/lib/contexts/config-space.js +169 -0
- package/lib/hooks/use-mobile.js +24 -0
- package/lib/hooks/use-storage-endpoint.js +28 -0
- package/lib/images.js +51 -0
- package/lib/locales/en.js +5 -0
- package/lib/locales/zh.js +5 -0
- package/lib/util/constants.js +4 -2
- package/lib/util/index.js +8 -2
- package/lib/util/spaces.js +69 -3
- package/package.json +11 -7
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _material = require("@mui/material");
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
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 _urlJoin = _interopRequireDefault(require("url-join"));
|
|
13
|
+
var _Toast = _interopRequireDefault(require("@arcblock/ux/lib/Toast"));
|
|
14
|
+
var _SplitButton = _interopRequireDefault(require("@arcblock/ux/lib/SplitButton"));
|
|
15
|
+
var _Dialog = _interopRequireDefault(require("@arcblock/ux/lib/Dialog"));
|
|
16
|
+
var _Alert = _interopRequireDefault(require("@arcblock/ux/lib/Alert"));
|
|
17
|
+
var _propTypes = require("prop-types");
|
|
18
|
+
var _constant = require("@abtnode/constant");
|
|
19
|
+
var _useBlockletInfoForConnectDidSpaces = _interopRequireDefault(require("../../../hooks/use-blocklet-info-for-connect-did-spaces"));
|
|
20
|
+
var _spaces = require("../../../util/spaces");
|
|
21
|
+
var _util = require("../../../../lib/util");
|
|
22
|
+
var _blocklet = require("../../../contexts/blocklet");
|
|
23
|
+
var _configSpace = require("../../../contexts/config-space");
|
|
24
|
+
var _node = require("../../../contexts/node");
|
|
25
|
+
var _api = require("../../../util/api");
|
|
26
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
27
|
+
const _excluded = ["onConnect"];
|
|
28
|
+
/**
|
|
29
|
+
* @typedef {import('../../../contexts/config-space').SpaceGateway} SpaceGateway
|
|
30
|
+
*/
|
|
31
|
+
/**
|
|
32
|
+
* @FIXME: 后续可以思考一下,refactor 一下
|
|
33
|
+
* @description
|
|
34
|
+
* @param {{
|
|
35
|
+
* onConnect(spaceGateway: SpaceGateway): void | Promise<void>,
|
|
36
|
+
* }} { onConnect, ...rest }
|
|
37
|
+
* @return {React.Component}
|
|
38
|
+
*/
|
|
39
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
40
|
+
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); }
|
|
41
|
+
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; }
|
|
42
|
+
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; }
|
|
43
|
+
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; }
|
|
44
|
+
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; }
|
|
45
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
46
|
+
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); }
|
|
47
|
+
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; }
|
|
48
|
+
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; }
|
|
49
|
+
function ConnectTo(_ref) {
|
|
50
|
+
let {
|
|
51
|
+
onConnect
|
|
52
|
+
} = _ref,
|
|
53
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
54
|
+
const {
|
|
55
|
+
blocklet
|
|
56
|
+
} = (0, _blocklet.useBlockletContext)();
|
|
57
|
+
const {
|
|
58
|
+
info
|
|
59
|
+
} = (0, _node.useNodeContext)();
|
|
60
|
+
const {
|
|
61
|
+
t,
|
|
62
|
+
locale
|
|
63
|
+
} = (0, _context.useLocaleContext)();
|
|
64
|
+
const [url, setUrl] = (0, _react.useState)('');
|
|
65
|
+
const [loading, setLoading] = (0, _react.useState)(false);
|
|
66
|
+
const [open, setOpen] = (0, _react.useState)(false);
|
|
67
|
+
const [errorMessage, setErrorMessage] = (0, _react.useState)('');
|
|
68
|
+
const blockletInfo = (0, _useBlockletInfoForConnectDidSpaces.default)({
|
|
69
|
+
blocklet
|
|
70
|
+
});
|
|
71
|
+
const webWalletUrl = (0, _util.getWebWalletUrl)(info);
|
|
72
|
+
const {
|
|
73
|
+
storageEndpoint
|
|
74
|
+
} = (0, _configSpace.useConfigSpaceContext)();
|
|
75
|
+
const [authorizeFromNftConnect, setAuthorizeFromNftConnect] = (0, _react.useState)({
|
|
76
|
+
open: false,
|
|
77
|
+
action: 'one-click-authorization',
|
|
78
|
+
checkTimeout: 1000 * 300,
|
|
79
|
+
prefix: (0, _urlJoin.default)(_constant.PROD_DID_SPACES.CORE_URL, 'space/api/did'),
|
|
80
|
+
baseUrl: new URL(_constant.PROD_DID_SPACES.CORE_URL).origin,
|
|
81
|
+
checkFn: _api.axios.create({
|
|
82
|
+
baseURL: (0, _urlJoin.default)(_constant.PROD_DID_SPACES.CORE_URL, 'space')
|
|
83
|
+
}).get,
|
|
84
|
+
messages: {
|
|
85
|
+
title: t('storage.spaces.provideNFT.title', {
|
|
86
|
+
appName: blockletInfo.appName
|
|
87
|
+
}, locale),
|
|
88
|
+
scan: t('storage.spaces.provideNFT.scan', {
|
|
89
|
+
appName: blockletInfo.appName
|
|
90
|
+
}, locale),
|
|
91
|
+
confirm: '',
|
|
92
|
+
success: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
93
|
+
gutterBottom: true,
|
|
94
|
+
children: t('storage.spaces.provideNFT.success')
|
|
95
|
+
})
|
|
96
|
+
},
|
|
97
|
+
onClose: () => {
|
|
98
|
+
// eslint-disable-next-line no-shadow
|
|
99
|
+
setAuthorizeFromNftConnect(preValue => _objectSpread(_objectSpread({}, preValue), {}, {
|
|
100
|
+
open: false
|
|
101
|
+
}));
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
const [authorizeConnect, setAuthorizeConnect] = (0, _react.useState)({
|
|
105
|
+
open: false,
|
|
106
|
+
action: 'one-click-authorization',
|
|
107
|
+
checkTimeout: 1000 * 300,
|
|
108
|
+
messages: {
|
|
109
|
+
title: t('storage.spaces.authorize.title', {
|
|
110
|
+
appName: blockletInfo.appName
|
|
111
|
+
}, locale),
|
|
112
|
+
scan: t('storage.spaces.authorize.scan', {
|
|
113
|
+
appName: blockletInfo.appName
|
|
114
|
+
}, locale),
|
|
115
|
+
confirm: '',
|
|
116
|
+
success: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
117
|
+
gutterBottom: true,
|
|
118
|
+
children: t('storage.spaces.authorize.success')
|
|
119
|
+
})
|
|
120
|
+
},
|
|
121
|
+
onClose: () => {
|
|
122
|
+
// eslint-disable-next-line no-shadow
|
|
123
|
+
setAuthorizeConnect(preValue => _objectSpread(_objectSpread({}, preValue), {}, {
|
|
124
|
+
open: false
|
|
125
|
+
}));
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
const onAuthorizeConnectSuccess = (response, decrypt) => {
|
|
129
|
+
setTimeout(async () => {
|
|
130
|
+
setAuthorizeConnect(preValue => _objectSpread(_objectSpread({}, preValue), {}, {
|
|
131
|
+
open: false
|
|
132
|
+
}));
|
|
133
|
+
setUrl(null);
|
|
134
|
+
setAuthorizeFromNftConnect(preValue => _objectSpread(_objectSpread({}, preValue), {}, {
|
|
135
|
+
open: false
|
|
136
|
+
}));
|
|
137
|
+
const endpoint = decrypt(response.endpoint);
|
|
138
|
+
const space = response.space ? decrypt(response.space) : {};
|
|
139
|
+
|
|
140
|
+
// eslint-disable-next-line no-use-before-define
|
|
141
|
+
await updateSpaceGateway(_objectSpread(_objectSpread({
|
|
142
|
+
endpoint
|
|
143
|
+
}, {
|
|
144
|
+
did: (0, _spaces.getDIDSpaceDidFromEndpoint)(endpoint),
|
|
145
|
+
name: 'DID Space'
|
|
146
|
+
}), space));
|
|
147
|
+
}, 0);
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
*
|
|
152
|
+
* @param {} {endpoint, name, did}
|
|
153
|
+
* @returns {Promise<void>}
|
|
154
|
+
*/
|
|
155
|
+
const updateSpaceGateway = async _ref2 => {
|
|
156
|
+
let {
|
|
157
|
+
did,
|
|
158
|
+
name,
|
|
159
|
+
endpoint
|
|
160
|
+
} = _ref2;
|
|
161
|
+
const spaceGatewayUrl = await (0, _spaces.getSpaceGatewayUrl)(endpoint);
|
|
162
|
+
if (!(await (0, _spaces.isValidSpaceGatewayUrl)(spaceGatewayUrl))) {
|
|
163
|
+
_Toast.default.error(t('storage.spaces.gateway.add.invalidUrl'));
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** @type {SpaceGateway} */
|
|
168
|
+
const spaceGateway = {
|
|
169
|
+
name,
|
|
170
|
+
did,
|
|
171
|
+
url: spaceGatewayUrl,
|
|
172
|
+
endpoint
|
|
173
|
+
};
|
|
174
|
+
await onConnect(spaceGateway);
|
|
175
|
+
_Toast.default.success(t('storage.spaces.connectedWithName', {
|
|
176
|
+
name: spaceGateway.name
|
|
177
|
+
}));
|
|
178
|
+
};
|
|
179
|
+
const handleUseWalletConnect = () => {
|
|
180
|
+
setAuthorizeFromNftConnect(preValue => _objectSpread(_objectSpread({}, preValue), {}, {
|
|
181
|
+
open: true,
|
|
182
|
+
extraParams: {
|
|
183
|
+
appDid: blockletInfo.appDid,
|
|
184
|
+
appName: blockletInfo.appName,
|
|
185
|
+
appDescription: blockletInfo.appDescription,
|
|
186
|
+
scopes: blockletInfo.scopes,
|
|
187
|
+
appUrl: blockletInfo.appUrl,
|
|
188
|
+
referrer: blockletInfo.referrer,
|
|
189
|
+
nodeDid: info.did
|
|
190
|
+
}
|
|
191
|
+
}));
|
|
192
|
+
};
|
|
193
|
+
const handleUseSpaceGatewayConnect = async () => {
|
|
194
|
+
try {
|
|
195
|
+
setLoading(true);
|
|
196
|
+
const spaceGatewayUrl = await (0, _spaces.getSpaceGatewayUrl)(url);
|
|
197
|
+
const didSpacesCoreUrl = (0, _spaces.extraDIDSpacesCoreUrl)(spaceGatewayUrl);
|
|
198
|
+
const spaceDid = new URL(spaceGatewayUrl).searchParams.get('spaceDid');
|
|
199
|
+
if (!(await (0, _spaces.isValidSpaceGatewayUrl)(didSpacesCoreUrl))) {
|
|
200
|
+
throw new Error(t('storage.spaces.gateway.add.invalidUrl'));
|
|
201
|
+
}
|
|
202
|
+
setAuthorizeConnect(preValue => _objectSpread(_objectSpread({}, preValue), {}, {
|
|
203
|
+
open: true,
|
|
204
|
+
prefix: (0, _urlJoin.default)(didSpacesCoreUrl, 'space/api/did'),
|
|
205
|
+
baseUrl: new URL(didSpacesCoreUrl).origin,
|
|
206
|
+
checkFn: _api.axios.create({
|
|
207
|
+
baseURL: (0, _urlJoin.default)(didSpacesCoreUrl, 'space')
|
|
208
|
+
}).get,
|
|
209
|
+
extraParams: {
|
|
210
|
+
appDid: blockletInfo.appDid,
|
|
211
|
+
appName: blockletInfo.appName,
|
|
212
|
+
appDescription: blockletInfo.appDescription,
|
|
213
|
+
scopes: blockletInfo.scopes,
|
|
214
|
+
appUrl: blockletInfo.appUrl,
|
|
215
|
+
referrer: blockletInfo.referrer,
|
|
216
|
+
nodeDid: info.did,
|
|
217
|
+
spaceDid
|
|
218
|
+
}
|
|
219
|
+
}));
|
|
220
|
+
setOpen(false);
|
|
221
|
+
} catch (err) {
|
|
222
|
+
const _errorMessage = "".concat(t('storage.spaces.gateway.add.failed', locale), ": ").concat((0, _util.formatError)(err));
|
|
223
|
+
setErrorMessage(_errorMessage);
|
|
224
|
+
} finally {
|
|
225
|
+
setLoading(false);
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
229
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_SplitButton.default, {
|
|
230
|
+
color: "primary",
|
|
231
|
+
style: {
|
|
232
|
+
textTransform: 'none !important',
|
|
233
|
+
fontSize: '1rem'
|
|
234
|
+
},
|
|
235
|
+
size: "small",
|
|
236
|
+
onClick: handleUseWalletConnect,
|
|
237
|
+
variant: "outlined",
|
|
238
|
+
menu: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_SplitButton.default.Item, _objectSpread(_objectSpread({
|
|
239
|
+
sx: {
|
|
240
|
+
textTransform: 'none'
|
|
241
|
+
},
|
|
242
|
+
onClick: () => setOpen(true),
|
|
243
|
+
size: "small"
|
|
244
|
+
}, rest), {}, {
|
|
245
|
+
children: storageEndpoint ? t('storage.spaces.connect.useSpaceGatewayReconnect') : t('storage.spaces.connect.useSpaceGateway')
|
|
246
|
+
}), "1")],
|
|
247
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
248
|
+
sx: {
|
|
249
|
+
fontWeight: 'bold',
|
|
250
|
+
textTransform: 'none'
|
|
251
|
+
},
|
|
252
|
+
children: storageEndpoint ? t('storage.spaces.connect.useWalletReconnect') : t('storage.spaces.connect.useWallet')
|
|
253
|
+
})
|
|
254
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Connect.default, {
|
|
255
|
+
forceConnected: false,
|
|
256
|
+
saveConnect: false,
|
|
257
|
+
prefix: authorizeFromNftConnect.prefix,
|
|
258
|
+
open: authorizeFromNftConnect.open,
|
|
259
|
+
popup: true,
|
|
260
|
+
action: authorizeFromNftConnect.action,
|
|
261
|
+
webWalletUrl: webWalletUrl,
|
|
262
|
+
baseUrl: authorizeFromNftConnect.baseUrl,
|
|
263
|
+
checkFn: authorizeFromNftConnect.checkFn,
|
|
264
|
+
onSuccess: onAuthorizeConnectSuccess,
|
|
265
|
+
onClose: authorizeFromNftConnect.onClose,
|
|
266
|
+
checkTimeout: authorizeFromNftConnect.checkTimeout,
|
|
267
|
+
extraParams: authorizeFromNftConnect.extraParams,
|
|
268
|
+
messages: authorizeFromNftConnect.messages,
|
|
269
|
+
locale: locale
|
|
270
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Connect.default, {
|
|
271
|
+
forceConnected: false,
|
|
272
|
+
saveConnect: false,
|
|
273
|
+
prefix: authorizeConnect.prefix,
|
|
274
|
+
open: authorizeConnect.open,
|
|
275
|
+
popup: true,
|
|
276
|
+
action: authorizeConnect.action,
|
|
277
|
+
baseUrl: authorizeConnect.baseUrl,
|
|
278
|
+
checkFn: authorizeConnect.checkFn,
|
|
279
|
+
onSuccess: onAuthorizeConnectSuccess,
|
|
280
|
+
onClose: authorizeConnect.onClose,
|
|
281
|
+
checkTimeout: authorizeConnect.checkTimeout,
|
|
282
|
+
extraParams: authorizeConnect.extraParams,
|
|
283
|
+
messages: authorizeConnect.messages,
|
|
284
|
+
locale: locale
|
|
285
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Dialog.default, {
|
|
286
|
+
title: t('storage.spaces.gateway.add.title'),
|
|
287
|
+
fullWidth: true,
|
|
288
|
+
maxWidth: "md",
|
|
289
|
+
open: open,
|
|
290
|
+
onClose: () => setOpen(false),
|
|
291
|
+
PaperProps: {
|
|
292
|
+
style: {
|
|
293
|
+
minHeight: 'auto'
|
|
294
|
+
}
|
|
295
|
+
},
|
|
296
|
+
actions: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
297
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
|
|
298
|
+
onClick: e => {
|
|
299
|
+
e.stopPropagation();
|
|
300
|
+
setOpen(false);
|
|
301
|
+
},
|
|
302
|
+
color: "inherit",
|
|
303
|
+
children: t('common.cancel')
|
|
304
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Button.default, {
|
|
305
|
+
onClick: handleUseSpaceGatewayConnect,
|
|
306
|
+
color: "primary",
|
|
307
|
+
disabled: loading || !url,
|
|
308
|
+
variant: "contained",
|
|
309
|
+
autoFocus: true,
|
|
310
|
+
children: [loading && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.CircularProgress, {
|
|
311
|
+
size: 16
|
|
312
|
+
}), t('common.confirm')]
|
|
313
|
+
})]
|
|
314
|
+
}),
|
|
315
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
316
|
+
style: {
|
|
317
|
+
paddingTop: 12,
|
|
318
|
+
overflowY: 'hidden'
|
|
319
|
+
},
|
|
320
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.DialogContentText, {
|
|
321
|
+
component: "div",
|
|
322
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
323
|
+
component: "div",
|
|
324
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TextField, {
|
|
325
|
+
label: t('storage.spaces.gateway.add.label'),
|
|
326
|
+
autoComplete: "off",
|
|
327
|
+
variant: "outlined",
|
|
328
|
+
name: "url",
|
|
329
|
+
fullWidth: true,
|
|
330
|
+
value: url,
|
|
331
|
+
onChange: e => {
|
|
332
|
+
setErrorMessage(null);
|
|
333
|
+
setUrl(e.target.value);
|
|
334
|
+
},
|
|
335
|
+
disabled: loading,
|
|
336
|
+
onKeyPress: async e => {
|
|
337
|
+
if (e.key === 'Enter') {
|
|
338
|
+
await handleUseSpaceGatewayConnect();
|
|
339
|
+
}
|
|
340
|
+
},
|
|
341
|
+
autoFocus: true
|
|
342
|
+
})
|
|
343
|
+
})
|
|
344
|
+
})
|
|
345
|
+
}), Boolean(errorMessage) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Alert.default, {
|
|
346
|
+
type: "error",
|
|
347
|
+
style: {
|
|
348
|
+
width: '100%'
|
|
349
|
+
},
|
|
350
|
+
children: errorMessage
|
|
351
|
+
})]
|
|
352
|
+
})]
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
ConnectTo.propTypes = {
|
|
356
|
+
onConnect: _propTypes.func
|
|
357
|
+
};
|
|
358
|
+
ConnectTo.defaultProps = {
|
|
359
|
+
onConnect: () => undefined
|
|
360
|
+
};
|
|
361
|
+
var _default = ConnectTo;
|
|
362
|
+
exports.default = _default;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _material = require("@mui/material");
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
10
|
+
var _item = _interopRequireDefault(require("./item"));
|
|
11
|
+
var _configSpace = require("../../../contexts/config-space");
|
|
12
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
+
function Connected() {
|
|
15
|
+
const {
|
|
16
|
+
t
|
|
17
|
+
} = (0, _context.useLocaleContext)();
|
|
18
|
+
const {
|
|
19
|
+
spaceGateway,
|
|
20
|
+
settingStorageEndpoint
|
|
21
|
+
} = (0, _configSpace.useConfigSpaceContext)();
|
|
22
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
23
|
+
display: "flex",
|
|
24
|
+
flexDirection: "column",
|
|
25
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
|
|
26
|
+
display: "flex",
|
|
27
|
+
flexDirection: "row",
|
|
28
|
+
alignItems: "center",
|
|
29
|
+
justifyContent: "space-between",
|
|
30
|
+
marginBottom: "12px",
|
|
31
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
32
|
+
fontSize: "1.2rem",
|
|
33
|
+
fontWeight: "bold",
|
|
34
|
+
children: t('storage.spaces.connected.title')
|
|
35
|
+
})
|
|
36
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
|
|
37
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_item.default, {
|
|
38
|
+
style: {
|
|
39
|
+
marginTop: '12px'
|
|
40
|
+
},
|
|
41
|
+
spaceGateway: spaceGateway,
|
|
42
|
+
connected: true,
|
|
43
|
+
onDisconnect: () => settingStorageEndpoint(null)
|
|
44
|
+
}, spaceGateway.endpoint)
|
|
45
|
+
})]
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
var _default = Connected;
|
|
49
|
+
exports.default = _default;
|
|
@@ -0,0 +1,111 @@
|
|
|
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 _material = require("@mui/material");
|
|
10
|
+
var _DeleteOutline = _interopRequireDefault(require("@mui/icons-material/DeleteOutline"));
|
|
11
|
+
var _confirm = _interopRequireDefault(require("@arcblock/ux/lib/Dialog/confirm"));
|
|
12
|
+
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
13
|
+
var _Toast = _interopRequireDefault(require("@arcblock/ux/lib/Toast"));
|
|
14
|
+
var _formatError = _interopRequireDefault(require("@abtnode/util/lib/format-error"));
|
|
15
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
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); }
|
|
18
|
+
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; }
|
|
19
|
+
/**
|
|
20
|
+
* @typedef {import('../../../contexts/config-space').SpaceGateway} SpaceGateway
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
*
|
|
25
|
+
*
|
|
26
|
+
* @export
|
|
27
|
+
* @param {{
|
|
28
|
+
* spaceGateway: SpaceGateway,
|
|
29
|
+
* onDeleteSpace: (spaceGateway: SpaceGateway) => Promise<void> | void
|
|
30
|
+
* }} { spaceGateway, onDelete }
|
|
31
|
+
* @return {React.Component}
|
|
32
|
+
*/function SpaceDelete(_ref) {
|
|
33
|
+
let {
|
|
34
|
+
spaceGateway,
|
|
35
|
+
onDeleteSpace
|
|
36
|
+
} = _ref;
|
|
37
|
+
const {
|
|
38
|
+
t
|
|
39
|
+
} = (0, _context.useLocaleContext)();
|
|
40
|
+
const [open, setOpen] = (0, _react.useState)(false);
|
|
41
|
+
const [loading, setLoading] = (0, _react.useState)(false);
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @description
|
|
45
|
+
* @param {React.MouseEvent} e
|
|
46
|
+
*/
|
|
47
|
+
const handleOpen = (e, bool) => {
|
|
48
|
+
e === null || e === void 0 ? void 0 : e.stopPropagation();
|
|
49
|
+
setOpen(bool);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @description
|
|
54
|
+
* @param {React.MouseEvent} e
|
|
55
|
+
*/
|
|
56
|
+
const handleOnDelete = async e => {
|
|
57
|
+
try {
|
|
58
|
+
e === null || e === void 0 ? void 0 : e.stopPropagation();
|
|
59
|
+
setLoading(true);
|
|
60
|
+
await onDeleteSpace(spaceGateway);
|
|
61
|
+
setOpen(false);
|
|
62
|
+
} catch (error) {
|
|
63
|
+
console.error(error);
|
|
64
|
+
_Toast.default.error("".concat(t('storage.spaces.gateway.delete.failed'), ": ").concat((0, _formatError.default)(error)));
|
|
65
|
+
} finally {
|
|
66
|
+
setLoading(false);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
70
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.IconButton, {
|
|
71
|
+
size: "small",
|
|
72
|
+
onClick: e => handleOpen(e, true),
|
|
73
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_DeleteOutline.default, {})
|
|
74
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_confirm.default, {
|
|
75
|
+
title: t('common.delConfirmDescription', {
|
|
76
|
+
data: "".concat(spaceGateway === null || spaceGateway === void 0 ? void 0 : spaceGateway.name)
|
|
77
|
+
}),
|
|
78
|
+
open: open,
|
|
79
|
+
confirmButton: {
|
|
80
|
+
text: t('common.confirm'),
|
|
81
|
+
props: {
|
|
82
|
+
variant: 'contained',
|
|
83
|
+
color: 'error',
|
|
84
|
+
loading
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
cancelButton: {
|
|
88
|
+
text: t('common.cancel'),
|
|
89
|
+
props: {
|
|
90
|
+
variant: 'contained',
|
|
91
|
+
color: 'primary'
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
onConfirm: handleOnDelete,
|
|
95
|
+
onCancel: e => handleOpen(e, false)
|
|
96
|
+
})]
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
SpaceDelete.propTypes = {
|
|
100
|
+
onDeleteSpace: _propTypes.default.func,
|
|
101
|
+
spaceGateway: _propTypes.default.shape({
|
|
102
|
+
name: _propTypes.default.string.isRequired,
|
|
103
|
+
url: _propTypes.default.string.isRequired,
|
|
104
|
+
protected: _propTypes.default.bool
|
|
105
|
+
}).isRequired
|
|
106
|
+
};
|
|
107
|
+
SpaceDelete.defaultProps = {
|
|
108
|
+
onDeleteSpace: () => undefined
|
|
109
|
+
};
|
|
110
|
+
var _default = SpaceDelete;
|
|
111
|
+
exports.default = _default;
|