@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
|
@@ -38,7 +38,8 @@ import Agreement from '../agreement';
|
|
|
38
38
|
import InstallFromUrl from '../install-from-url';
|
|
39
39
|
import SelectStore from './select-store';
|
|
40
40
|
import BlockletList from './store-blocklet-list';
|
|
41
|
-
import
|
|
41
|
+
import DidSpace from './did-space';
|
|
42
|
+
import { ConfigSpaceProvider } from '../../contexts/config-space';
|
|
42
43
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
43
44
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
44
45
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
@@ -108,7 +109,7 @@ const StepContent = /*#__PURE__*/forwardRef(({
|
|
|
108
109
|
component: "div",
|
|
109
110
|
className: isMobile ? 'mobileStyle' : '',
|
|
110
111
|
sx: {
|
|
111
|
-
height: '100%'
|
|
112
|
+
height: 'calc(100% - 56px)'
|
|
112
113
|
},
|
|
113
114
|
children: /*#__PURE__*/_jsx(Layout, {
|
|
114
115
|
locale: locale,
|
|
@@ -138,19 +139,22 @@ StepContent.propTypes = {
|
|
|
138
139
|
StepContent.defaultProps = {
|
|
139
140
|
meta: null
|
|
140
141
|
};
|
|
141
|
-
const postInstalledMessage = componentDid => {
|
|
142
|
+
const postInstalledMessage = (componentDid, timeout = 1000) => {
|
|
142
143
|
// send event to parent window
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
144
|
+
setTimeout(() => {
|
|
145
|
+
window.parent.postMessage({
|
|
146
|
+
event: 'component.installed',
|
|
147
|
+
componentDid
|
|
148
|
+
}, '*');
|
|
149
|
+
}, timeout);
|
|
147
150
|
};
|
|
148
151
|
export default function AddComponentCore({
|
|
149
152
|
onClose,
|
|
150
153
|
mode,
|
|
151
154
|
stores,
|
|
152
155
|
resourceType,
|
|
153
|
-
storageKey
|
|
156
|
+
storageKey,
|
|
157
|
+
inDialog
|
|
154
158
|
}) {
|
|
155
159
|
const {
|
|
156
160
|
t,
|
|
@@ -234,6 +238,12 @@ export default function AddComponentCore({
|
|
|
234
238
|
}
|
|
235
239
|
}, [activeStep]); // eslint-disable-line
|
|
236
240
|
|
|
241
|
+
const refreshDidSpaceEndpoint = () => {
|
|
242
|
+
const didSpaceEndpoint = getDIDSpaceEndpoint(blocklet) ?? '';
|
|
243
|
+
updateParams({
|
|
244
|
+
didSpaceEndpoint
|
|
245
|
+
});
|
|
246
|
+
};
|
|
237
247
|
const getComponentName = () => {
|
|
238
248
|
if (component?.current?.meta) {
|
|
239
249
|
return getDisplayName(component.current);
|
|
@@ -294,6 +304,11 @@ export default function AddComponentCore({
|
|
|
294
304
|
break;
|
|
295
305
|
default:
|
|
296
306
|
}
|
|
307
|
+
const didSpaceEndpoint = getDIDSpaceEndpoint(blocklet);
|
|
308
|
+
updateParams(p => ({
|
|
309
|
+
...p,
|
|
310
|
+
didSpaceEndpoint
|
|
311
|
+
}));
|
|
297
312
|
}), [blocklet?.meta?.did]);
|
|
298
313
|
useSubscription(BlockletEvents.downloadFailed, createBlockletEventHandler(() => {
|
|
299
314
|
setInstallErrorResult(t('blocklet.component.installComponentError'));
|
|
@@ -937,35 +952,31 @@ export default function AddComponentCore({
|
|
|
937
952
|
}),
|
|
938
953
|
disabled: params.didSpaceCapability === 'required' && !params.didSpaceEndpoint,
|
|
939
954
|
body: () => {
|
|
940
|
-
return /*#__PURE__*/
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
mt: '36px',
|
|
948
|
-
'& > div': {
|
|
949
|
-
maxWidth: 'unset !important',
|
|
950
|
-
'& .MuiAutocomplete-root': {
|
|
951
|
-
maxWidth: 'unset !important'
|
|
952
|
-
}
|
|
953
|
-
}
|
|
954
|
-
},
|
|
955
|
-
children: /*#__PURE__*/_jsx(SpaceConnector, {
|
|
955
|
+
return /*#__PURE__*/_jsx(ConfigSpaceProvider, {
|
|
956
|
+
children: /*#__PURE__*/_jsxs(TypographyWrapper, {
|
|
957
|
+
component: "div",
|
|
958
|
+
children: [/*#__PURE__*/_jsx(PageHeaderWrapper, {
|
|
959
|
+
title: t('blocklet.component.didSpaceConfig'),
|
|
960
|
+
subTitle: t('blocklet.component.didSpaceConfigTip')
|
|
961
|
+
}), /*#__PURE__*/_jsx(Box, {
|
|
956
962
|
sx: {
|
|
957
|
-
|
|
958
|
-
|
|
963
|
+
mt: '36px',
|
|
964
|
+
'& > div': {
|
|
965
|
+
maxWidth: 'unset !important',
|
|
966
|
+
'& .MuiAutocomplete-root': {
|
|
967
|
+
maxWidth: 'unset !important'
|
|
968
|
+
}
|
|
959
969
|
}
|
|
960
970
|
},
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
971
|
+
children: /*#__PURE__*/_jsx(DidSpace, {
|
|
972
|
+
blockletMeta: component.current.meta,
|
|
973
|
+
onNext: () => {
|
|
974
|
+
onNext();
|
|
975
|
+
},
|
|
976
|
+
onEndpointUpdate: refreshDidSpaceEndpoint
|
|
977
|
+
})
|
|
978
|
+
})]
|
|
979
|
+
})
|
|
969
980
|
});
|
|
970
981
|
},
|
|
971
982
|
cancel: t('common.pre'),
|
|
@@ -1032,7 +1043,7 @@ export default function AddComponentCore({
|
|
|
1032
1043
|
height: window.innerHeight
|
|
1033
1044
|
} : {
|
|
1034
1045
|
width: '100%',
|
|
1035
|
-
height:
|
|
1046
|
+
height: inDialog ? '72vh' : '100vh'
|
|
1036
1047
|
},
|
|
1037
1048
|
children: [/*#__PURE__*/_jsx(StepProvider, {
|
|
1038
1049
|
steps: steps,
|
|
@@ -1092,6 +1103,7 @@ export default function AddComponentCore({
|
|
|
1092
1103
|
AddComponentCore.propTypes = {
|
|
1093
1104
|
onClose: PropTypes.func,
|
|
1094
1105
|
mode: PropTypes.oneOf(['normal', 'embed']),
|
|
1106
|
+
inDialog: PropTypes.bool,
|
|
1095
1107
|
stores: PropTypes.arrayOf(PropTypes.string),
|
|
1096
1108
|
resourceType: PropTypes.string,
|
|
1097
1109
|
storageKey: PropTypes.string
|
|
@@ -1101,7 +1113,8 @@ AddComponentCore.defaultProps = {
|
|
|
1101
1113
|
mode: 'normal',
|
|
1102
1114
|
stores: [],
|
|
1103
1115
|
resourceType: '',
|
|
1104
|
-
storageKey: ''
|
|
1116
|
+
storageKey: '',
|
|
1117
|
+
inDialog: true
|
|
1105
1118
|
};
|
|
1106
1119
|
const Wrapper = styled(Box)`
|
|
1107
1120
|
.action-bar {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import Button from '@arcblock/ux/lib/Button';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
export default function StyledButton({
|
|
4
|
+
...props
|
|
5
|
+
}) {
|
|
6
|
+
return /*#__PURE__*/_jsx(Button, {
|
|
7
|
+
className: "bottom-button",
|
|
8
|
+
variant: "contained",
|
|
9
|
+
color: "primary",
|
|
10
|
+
...props
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
import { Box, CircularProgress, DialogContentText, TextField, Typography } from '@mui/material';
|
|
2
|
+
import React, { useState } from 'react';
|
|
3
|
+
import Button from '@arcblock/ux/lib/Button';
|
|
4
|
+
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
5
|
+
import DidConnect from '@arcblock/did-connect/lib/Connect';
|
|
6
|
+
import joinUrl from 'url-join';
|
|
7
|
+
import toast from '@arcblock/ux/lib/Toast';
|
|
8
|
+
import SplitButton from '@arcblock/ux/lib/SplitButton';
|
|
9
|
+
import Dialog from '@arcblock/ux/lib/Dialog';
|
|
10
|
+
import Alert from '@arcblock/ux/lib/Alert';
|
|
11
|
+
import { func } from 'prop-types';
|
|
12
|
+
import { PROD_DID_SPACES } from '@abtnode/constant';
|
|
13
|
+
import useBlockletInfoForConnectDIDSpaces from '../../../hooks/use-blocklet-info-for-connect-did-spaces';
|
|
14
|
+
import { extraDIDSpacesCoreUrl, getDIDSpaceDidFromEndpoint, getSpaceGatewayUrl, isValidSpaceGatewayUrl } from '../../../util/spaces';
|
|
15
|
+
import { formatError, getWebWalletUrl } from '../../../../lib/util';
|
|
16
|
+
import { useBlockletContext } from '../../../contexts/blocklet';
|
|
17
|
+
import { useConfigSpaceContext } from '../../../contexts/config-space';
|
|
18
|
+
import { useNodeContext } from '../../../contexts/node';
|
|
19
|
+
import { axios } from '../../../util/api';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @typedef {import('../../../contexts/config-space').SpaceGateway} SpaceGateway
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @FIXME: 后续可以思考一下,refactor 一下
|
|
27
|
+
* @description
|
|
28
|
+
* @param {{
|
|
29
|
+
* onConnect(spaceGateway: SpaceGateway): void | Promise<void>,
|
|
30
|
+
* }} { onConnect, ...rest }
|
|
31
|
+
* @return {React.Component}
|
|
32
|
+
*/
|
|
33
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
34
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
35
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
36
|
+
function ConnectTo({
|
|
37
|
+
onConnect,
|
|
38
|
+
...rest
|
|
39
|
+
}) {
|
|
40
|
+
const {
|
|
41
|
+
blocklet
|
|
42
|
+
} = useBlockletContext();
|
|
43
|
+
const {
|
|
44
|
+
info
|
|
45
|
+
} = useNodeContext();
|
|
46
|
+
const {
|
|
47
|
+
t,
|
|
48
|
+
locale
|
|
49
|
+
} = useLocaleContext();
|
|
50
|
+
const [url, setUrl] = useState('');
|
|
51
|
+
const [loading, setLoading] = useState(false);
|
|
52
|
+
const [open, setOpen] = useState(false);
|
|
53
|
+
const [errorMessage, setErrorMessage] = useState('');
|
|
54
|
+
const blockletInfo = useBlockletInfoForConnectDIDSpaces({
|
|
55
|
+
blocklet
|
|
56
|
+
});
|
|
57
|
+
const webWalletUrl = getWebWalletUrl(info);
|
|
58
|
+
const {
|
|
59
|
+
storageEndpoint
|
|
60
|
+
} = useConfigSpaceContext();
|
|
61
|
+
const [authorizeFromNftConnect, setAuthorizeFromNftConnect] = useState({
|
|
62
|
+
open: false,
|
|
63
|
+
action: 'one-click-authorization',
|
|
64
|
+
checkTimeout: 1000 * 300,
|
|
65
|
+
prefix: joinUrl(PROD_DID_SPACES.CORE_URL, 'space/api/did'),
|
|
66
|
+
baseUrl: new URL(PROD_DID_SPACES.CORE_URL).origin,
|
|
67
|
+
checkFn: axios.create({
|
|
68
|
+
baseURL: joinUrl(PROD_DID_SPACES.CORE_URL, 'space')
|
|
69
|
+
}).get,
|
|
70
|
+
messages: {
|
|
71
|
+
title: t('storage.spaces.provideNFT.title', {
|
|
72
|
+
appName: blockletInfo.appName
|
|
73
|
+
}, locale),
|
|
74
|
+
scan: t('storage.spaces.provideNFT.scan', {
|
|
75
|
+
appName: blockletInfo.appName
|
|
76
|
+
}, locale),
|
|
77
|
+
confirm: '',
|
|
78
|
+
success: /*#__PURE__*/_jsx(Typography, {
|
|
79
|
+
gutterBottom: true,
|
|
80
|
+
children: t('storage.spaces.provideNFT.success')
|
|
81
|
+
})
|
|
82
|
+
},
|
|
83
|
+
onClose: () => {
|
|
84
|
+
// eslint-disable-next-line no-shadow
|
|
85
|
+
setAuthorizeFromNftConnect(preValue => ({
|
|
86
|
+
...preValue,
|
|
87
|
+
open: false
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
const [authorizeConnect, setAuthorizeConnect] = useState({
|
|
92
|
+
open: false,
|
|
93
|
+
action: 'one-click-authorization',
|
|
94
|
+
checkTimeout: 1000 * 300,
|
|
95
|
+
messages: {
|
|
96
|
+
title: t('storage.spaces.authorize.title', {
|
|
97
|
+
appName: blockletInfo.appName
|
|
98
|
+
}, locale),
|
|
99
|
+
scan: t('storage.spaces.authorize.scan', {
|
|
100
|
+
appName: blockletInfo.appName
|
|
101
|
+
}, locale),
|
|
102
|
+
confirm: '',
|
|
103
|
+
success: /*#__PURE__*/_jsx(Typography, {
|
|
104
|
+
gutterBottom: true,
|
|
105
|
+
children: t('storage.spaces.authorize.success')
|
|
106
|
+
})
|
|
107
|
+
},
|
|
108
|
+
onClose: () => {
|
|
109
|
+
// eslint-disable-next-line no-shadow
|
|
110
|
+
setAuthorizeConnect(preValue => ({
|
|
111
|
+
...preValue,
|
|
112
|
+
open: false
|
|
113
|
+
}));
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
const onAuthorizeConnectSuccess = (response, decrypt) => {
|
|
117
|
+
setTimeout(async () => {
|
|
118
|
+
setAuthorizeConnect(preValue => ({
|
|
119
|
+
...preValue,
|
|
120
|
+
open: false
|
|
121
|
+
}));
|
|
122
|
+
setUrl(null);
|
|
123
|
+
setAuthorizeFromNftConnect(preValue => ({
|
|
124
|
+
...preValue,
|
|
125
|
+
open: false
|
|
126
|
+
}));
|
|
127
|
+
const endpoint = decrypt(response.endpoint);
|
|
128
|
+
const space = response.space ? decrypt(response.space) : {};
|
|
129
|
+
|
|
130
|
+
// eslint-disable-next-line no-use-before-define
|
|
131
|
+
await updateSpaceGateway({
|
|
132
|
+
endpoint,
|
|
133
|
+
// name 默认为 DID Space,兼容旧版本的 DID Spaces
|
|
134
|
+
...{
|
|
135
|
+
did: getDIDSpaceDidFromEndpoint(endpoint),
|
|
136
|
+
name: 'DID Space'
|
|
137
|
+
},
|
|
138
|
+
...space
|
|
139
|
+
});
|
|
140
|
+
}, 0);
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
*
|
|
145
|
+
* @param {} {endpoint, name, did}
|
|
146
|
+
* @returns {Promise<void>}
|
|
147
|
+
*/
|
|
148
|
+
const updateSpaceGateway = async ({
|
|
149
|
+
did,
|
|
150
|
+
name,
|
|
151
|
+
endpoint
|
|
152
|
+
}) => {
|
|
153
|
+
const spaceGatewayUrl = await getSpaceGatewayUrl(endpoint);
|
|
154
|
+
if (!(await isValidSpaceGatewayUrl(spaceGatewayUrl))) {
|
|
155
|
+
toast.error(t('storage.spaces.gateway.add.invalidUrl'));
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** @type {SpaceGateway} */
|
|
160
|
+
const spaceGateway = {
|
|
161
|
+
name,
|
|
162
|
+
did,
|
|
163
|
+
url: spaceGatewayUrl,
|
|
164
|
+
endpoint
|
|
165
|
+
};
|
|
166
|
+
await onConnect(spaceGateway);
|
|
167
|
+
toast.success(t('storage.spaces.connectedWithName', {
|
|
168
|
+
name: spaceGateway.name
|
|
169
|
+
}));
|
|
170
|
+
};
|
|
171
|
+
const handleUseWalletConnect = () => {
|
|
172
|
+
setAuthorizeFromNftConnect(preValue => ({
|
|
173
|
+
...preValue,
|
|
174
|
+
open: true,
|
|
175
|
+
extraParams: {
|
|
176
|
+
appDid: blockletInfo.appDid,
|
|
177
|
+
appName: blockletInfo.appName,
|
|
178
|
+
appDescription: blockletInfo.appDescription,
|
|
179
|
+
scopes: blockletInfo.scopes,
|
|
180
|
+
appUrl: blockletInfo.appUrl,
|
|
181
|
+
referrer: blockletInfo.referrer,
|
|
182
|
+
nodeDid: info.did
|
|
183
|
+
}
|
|
184
|
+
}));
|
|
185
|
+
};
|
|
186
|
+
const handleUseSpaceGatewayConnect = async () => {
|
|
187
|
+
try {
|
|
188
|
+
setLoading(true);
|
|
189
|
+
const spaceGatewayUrl = await getSpaceGatewayUrl(url);
|
|
190
|
+
const didSpacesCoreUrl = extraDIDSpacesCoreUrl(spaceGatewayUrl);
|
|
191
|
+
const spaceDid = new URL(spaceGatewayUrl).searchParams.get('spaceDid');
|
|
192
|
+
if (!(await isValidSpaceGatewayUrl(didSpacesCoreUrl))) {
|
|
193
|
+
throw new Error(t('storage.spaces.gateway.add.invalidUrl'));
|
|
194
|
+
}
|
|
195
|
+
setAuthorizeConnect(preValue => ({
|
|
196
|
+
...preValue,
|
|
197
|
+
open: true,
|
|
198
|
+
prefix: joinUrl(didSpacesCoreUrl, 'space/api/did'),
|
|
199
|
+
baseUrl: new URL(didSpacesCoreUrl).origin,
|
|
200
|
+
checkFn: axios.create({
|
|
201
|
+
baseURL: joinUrl(didSpacesCoreUrl, 'space')
|
|
202
|
+
}).get,
|
|
203
|
+
extraParams: {
|
|
204
|
+
appDid: blockletInfo.appDid,
|
|
205
|
+
appName: blockletInfo.appName,
|
|
206
|
+
appDescription: blockletInfo.appDescription,
|
|
207
|
+
scopes: blockletInfo.scopes,
|
|
208
|
+
appUrl: blockletInfo.appUrl,
|
|
209
|
+
referrer: blockletInfo.referrer,
|
|
210
|
+
nodeDid: info.did,
|
|
211
|
+
spaceDid
|
|
212
|
+
}
|
|
213
|
+
}));
|
|
214
|
+
setOpen(false);
|
|
215
|
+
} catch (err) {
|
|
216
|
+
const _errorMessage = `${t('storage.spaces.gateway.add.failed', locale)}: ${formatError(err)}`;
|
|
217
|
+
setErrorMessage(_errorMessage);
|
|
218
|
+
} finally {
|
|
219
|
+
setLoading(false);
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
return /*#__PURE__*/_jsxs(Box, {
|
|
223
|
+
children: [/*#__PURE__*/_jsx(SplitButton, {
|
|
224
|
+
color: "primary",
|
|
225
|
+
style: {
|
|
226
|
+
textTransform: 'none !important',
|
|
227
|
+
fontSize: '1rem'
|
|
228
|
+
},
|
|
229
|
+
size: "small",
|
|
230
|
+
onClick: handleUseWalletConnect,
|
|
231
|
+
variant: "outlined",
|
|
232
|
+
menu: [/*#__PURE__*/_jsx(SplitButton.Item, {
|
|
233
|
+
sx: {
|
|
234
|
+
textTransform: 'none'
|
|
235
|
+
},
|
|
236
|
+
onClick: () => setOpen(true),
|
|
237
|
+
size: "small",
|
|
238
|
+
...rest,
|
|
239
|
+
children: storageEndpoint ? t('storage.spaces.connect.useSpaceGatewayReconnect') : t('storage.spaces.connect.useSpaceGateway')
|
|
240
|
+
}, "1")],
|
|
241
|
+
children: /*#__PURE__*/_jsx(Typography, {
|
|
242
|
+
sx: {
|
|
243
|
+
fontWeight: 'bold',
|
|
244
|
+
textTransform: 'none'
|
|
245
|
+
},
|
|
246
|
+
children: storageEndpoint ? t('storage.spaces.connect.useWalletReconnect') : t('storage.spaces.connect.useWallet')
|
|
247
|
+
})
|
|
248
|
+
}), /*#__PURE__*/_jsx(DidConnect, {
|
|
249
|
+
forceConnected: false,
|
|
250
|
+
saveConnect: false,
|
|
251
|
+
prefix: authorizeFromNftConnect.prefix,
|
|
252
|
+
open: authorizeFromNftConnect.open,
|
|
253
|
+
popup: true,
|
|
254
|
+
action: authorizeFromNftConnect.action,
|
|
255
|
+
webWalletUrl: webWalletUrl,
|
|
256
|
+
baseUrl: authorizeFromNftConnect.baseUrl,
|
|
257
|
+
checkFn: authorizeFromNftConnect.checkFn,
|
|
258
|
+
onSuccess: onAuthorizeConnectSuccess,
|
|
259
|
+
onClose: authorizeFromNftConnect.onClose,
|
|
260
|
+
checkTimeout: authorizeFromNftConnect.checkTimeout,
|
|
261
|
+
extraParams: authorizeFromNftConnect.extraParams,
|
|
262
|
+
messages: authorizeFromNftConnect.messages,
|
|
263
|
+
locale: locale
|
|
264
|
+
}), /*#__PURE__*/_jsx(DidConnect, {
|
|
265
|
+
forceConnected: false,
|
|
266
|
+
saveConnect: false,
|
|
267
|
+
prefix: authorizeConnect.prefix,
|
|
268
|
+
open: authorizeConnect.open,
|
|
269
|
+
popup: true,
|
|
270
|
+
action: authorizeConnect.action,
|
|
271
|
+
baseUrl: authorizeConnect.baseUrl,
|
|
272
|
+
checkFn: authorizeConnect.checkFn,
|
|
273
|
+
onSuccess: onAuthorizeConnectSuccess,
|
|
274
|
+
onClose: authorizeConnect.onClose,
|
|
275
|
+
checkTimeout: authorizeConnect.checkTimeout,
|
|
276
|
+
extraParams: authorizeConnect.extraParams,
|
|
277
|
+
messages: authorizeConnect.messages,
|
|
278
|
+
locale: locale
|
|
279
|
+
}), /*#__PURE__*/_jsxs(Dialog, {
|
|
280
|
+
title: t('storage.spaces.gateway.add.title'),
|
|
281
|
+
fullWidth: true,
|
|
282
|
+
maxWidth: "md",
|
|
283
|
+
open: open,
|
|
284
|
+
onClose: () => setOpen(false),
|
|
285
|
+
PaperProps: {
|
|
286
|
+
style: {
|
|
287
|
+
minHeight: 'auto'
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
actions: /*#__PURE__*/_jsxs(_Fragment, {
|
|
291
|
+
children: [/*#__PURE__*/_jsx(Button, {
|
|
292
|
+
onClick: e => {
|
|
293
|
+
e.stopPropagation();
|
|
294
|
+
setOpen(false);
|
|
295
|
+
},
|
|
296
|
+
color: "inherit",
|
|
297
|
+
children: t('common.cancel')
|
|
298
|
+
}), /*#__PURE__*/_jsxs(Button, {
|
|
299
|
+
onClick: handleUseSpaceGatewayConnect,
|
|
300
|
+
color: "primary",
|
|
301
|
+
disabled: loading || !url,
|
|
302
|
+
variant: "contained",
|
|
303
|
+
autoFocus: true,
|
|
304
|
+
children: [loading && /*#__PURE__*/_jsx(CircularProgress, {
|
|
305
|
+
size: 16
|
|
306
|
+
}), t('common.confirm')]
|
|
307
|
+
})]
|
|
308
|
+
}),
|
|
309
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
310
|
+
style: {
|
|
311
|
+
paddingTop: 12,
|
|
312
|
+
overflowY: 'hidden'
|
|
313
|
+
},
|
|
314
|
+
children: /*#__PURE__*/_jsx(DialogContentText, {
|
|
315
|
+
component: "div",
|
|
316
|
+
children: /*#__PURE__*/_jsx(Typography, {
|
|
317
|
+
component: "div",
|
|
318
|
+
children: /*#__PURE__*/_jsx(TextField, {
|
|
319
|
+
label: t('storage.spaces.gateway.add.label'),
|
|
320
|
+
autoComplete: "off",
|
|
321
|
+
variant: "outlined",
|
|
322
|
+
name: "url",
|
|
323
|
+
fullWidth: true,
|
|
324
|
+
value: url,
|
|
325
|
+
onChange: e => {
|
|
326
|
+
setErrorMessage(null);
|
|
327
|
+
setUrl(e.target.value);
|
|
328
|
+
},
|
|
329
|
+
disabled: loading,
|
|
330
|
+
onKeyPress: async e => {
|
|
331
|
+
if (e.key === 'Enter') {
|
|
332
|
+
await handleUseSpaceGatewayConnect();
|
|
333
|
+
}
|
|
334
|
+
},
|
|
335
|
+
autoFocus: true
|
|
336
|
+
})
|
|
337
|
+
})
|
|
338
|
+
})
|
|
339
|
+
}), Boolean(errorMessage) && /*#__PURE__*/_jsx(Alert, {
|
|
340
|
+
type: "error",
|
|
341
|
+
style: {
|
|
342
|
+
width: '100%'
|
|
343
|
+
},
|
|
344
|
+
children: errorMessage
|
|
345
|
+
})]
|
|
346
|
+
})]
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
ConnectTo.propTypes = {
|
|
350
|
+
onConnect: func
|
|
351
|
+
};
|
|
352
|
+
ConnectTo.defaultProps = {
|
|
353
|
+
onConnect: () => undefined
|
|
354
|
+
};
|
|
355
|
+
export default ConnectTo;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Box, Typography } from '@mui/material';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
4
|
+
import SpaceItem from './item';
|
|
5
|
+
import { useConfigSpaceContext } from '../../../contexts/config-space';
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
+
function Connected() {
|
|
9
|
+
const {
|
|
10
|
+
t
|
|
11
|
+
} = useLocaleContext();
|
|
12
|
+
const {
|
|
13
|
+
spaceGateway,
|
|
14
|
+
settingStorageEndpoint
|
|
15
|
+
} = useConfigSpaceContext();
|
|
16
|
+
return /*#__PURE__*/_jsxs(Box, {
|
|
17
|
+
display: "flex",
|
|
18
|
+
flexDirection: "column",
|
|
19
|
+
children: [/*#__PURE__*/_jsx(Box, {
|
|
20
|
+
display: "flex",
|
|
21
|
+
flexDirection: "row",
|
|
22
|
+
alignItems: "center",
|
|
23
|
+
justifyContent: "space-between",
|
|
24
|
+
marginBottom: "12px",
|
|
25
|
+
children: /*#__PURE__*/_jsx(Typography, {
|
|
26
|
+
fontSize: "1.2rem",
|
|
27
|
+
fontWeight: "bold",
|
|
28
|
+
children: t('storage.spaces.connected.title')
|
|
29
|
+
})
|
|
30
|
+
}), /*#__PURE__*/_jsx(Box, {
|
|
31
|
+
children: /*#__PURE__*/_jsx(SpaceItem, {
|
|
32
|
+
style: {
|
|
33
|
+
marginTop: '12px'
|
|
34
|
+
},
|
|
35
|
+
spaceGateway: spaceGateway,
|
|
36
|
+
connected: true,
|
|
37
|
+
onDisconnect: () => settingStorageEndpoint(null)
|
|
38
|
+
}, spaceGateway.endpoint)
|
|
39
|
+
})]
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
export default Connected;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { IconButton } from '@mui/material';
|
|
4
|
+
import DeleteOutlineIcon from '@mui/icons-material/DeleteOutline';
|
|
5
|
+
import Confirm from '@arcblock/ux/lib/Dialog/confirm';
|
|
6
|
+
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
7
|
+
import toast from '@arcblock/ux/lib/Toast';
|
|
8
|
+
import formatError from '@abtnode/util/lib/format-error';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {import('../../../contexts/config-space').SpaceGateway} SpaceGateway
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
*
|
|
17
|
+
* @export
|
|
18
|
+
* @param {{
|
|
19
|
+
* spaceGateway: SpaceGateway,
|
|
20
|
+
* onDeleteSpace: (spaceGateway: SpaceGateway) => Promise<void> | void
|
|
21
|
+
* }} { spaceGateway, onDelete }
|
|
22
|
+
* @return {React.Component}
|
|
23
|
+
*/
|
|
24
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
25
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
26
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
27
|
+
function SpaceDelete({
|
|
28
|
+
spaceGateway,
|
|
29
|
+
onDeleteSpace
|
|
30
|
+
}) {
|
|
31
|
+
const {
|
|
32
|
+
t
|
|
33
|
+
} = useLocaleContext();
|
|
34
|
+
const [open, setOpen] = useState(false);
|
|
35
|
+
const [loading, setLoading] = useState(false);
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @description
|
|
39
|
+
* @param {React.MouseEvent} e
|
|
40
|
+
*/
|
|
41
|
+
const handleOpen = (e, bool) => {
|
|
42
|
+
e?.stopPropagation();
|
|
43
|
+
setOpen(bool);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @description
|
|
48
|
+
* @param {React.MouseEvent} e
|
|
49
|
+
*/
|
|
50
|
+
const handleOnDelete = async e => {
|
|
51
|
+
try {
|
|
52
|
+
e?.stopPropagation();
|
|
53
|
+
setLoading(true);
|
|
54
|
+
await onDeleteSpace(spaceGateway);
|
|
55
|
+
setOpen(false);
|
|
56
|
+
} catch (error) {
|
|
57
|
+
console.error(error);
|
|
58
|
+
toast.error(`${t('storage.spaces.gateway.delete.failed')}: ${formatError(error)}`);
|
|
59
|
+
} finally {
|
|
60
|
+
setLoading(false);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
64
|
+
children: [/*#__PURE__*/_jsx(IconButton, {
|
|
65
|
+
size: "small",
|
|
66
|
+
onClick: e => handleOpen(e, true),
|
|
67
|
+
children: /*#__PURE__*/_jsx(DeleteOutlineIcon, {})
|
|
68
|
+
}), /*#__PURE__*/_jsx(Confirm, {
|
|
69
|
+
title: t('common.delConfirmDescription', {
|
|
70
|
+
data: `${spaceGateway?.name}`
|
|
71
|
+
}),
|
|
72
|
+
open: open,
|
|
73
|
+
confirmButton: {
|
|
74
|
+
text: t('common.confirm'),
|
|
75
|
+
props: {
|
|
76
|
+
variant: 'contained',
|
|
77
|
+
color: 'error',
|
|
78
|
+
loading
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
cancelButton: {
|
|
82
|
+
text: t('common.cancel'),
|
|
83
|
+
props: {
|
|
84
|
+
variant: 'contained',
|
|
85
|
+
color: 'primary'
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
onConfirm: handleOnDelete,
|
|
89
|
+
onCancel: e => handleOpen(e, false)
|
|
90
|
+
})]
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
SpaceDelete.propTypes = {
|
|
94
|
+
onDeleteSpace: PropTypes.func,
|
|
95
|
+
spaceGateway: PropTypes.shape({
|
|
96
|
+
name: PropTypes.string.isRequired,
|
|
97
|
+
url: PropTypes.string.isRequired,
|
|
98
|
+
protected: PropTypes.bool
|
|
99
|
+
}).isRequired
|
|
100
|
+
};
|
|
101
|
+
SpaceDelete.defaultProps = {
|
|
102
|
+
onDeleteSpace: () => undefined
|
|
103
|
+
};
|
|
104
|
+
export default SpaceDelete;
|