@abtnode/ux 1.16.14-beta-ab7f615e → 1.16.14-beta-cb53c14b
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/actions.js +97 -0
- package/es/analytics/card.js +92 -0
- package/es/analytics/chart.js +96 -0
- package/es/analytics/cpu.js +36 -0
- package/es/analytics/disk.js +111 -0
- package/es/analytics/memory.js +72 -0
- package/es/analytics/runtime.js +173 -0
- package/es/analytics/traffic.js +259 -0
- package/es/blocklet/access/config-access.js +307 -0
- package/es/blocklet/access/index.js +216 -0
- package/es/blocklet/actions.js +474 -0
- package/es/blocklet/add-cert.js +177 -0
- package/es/blocklet/agreement-app.js +21 -0
- package/es/blocklet/agreement.js +127 -0
- package/es/blocklet/app-avatar.js +57 -0
- package/es/blocklet/audit-logs.js +259 -0
- package/es/blocklet/blocklet-source.js +48 -0
- package/es/blocklet/bundle-avatar.js +64 -0
- package/es/blocklet/component/add.js +1308 -0
- package/es/blocklet/component/configuration.js +122 -0
- package/es/blocklet/component/delete.js +134 -0
- package/es/blocklet/component/environment.js +370 -0
- package/es/blocklet/component/index.js +975 -0
- package/es/blocklet/component/line.js +20 -0
- package/es/blocklet/component/navigation/locale-tabs.js +225 -0
- package/es/blocklet/component/navigation/navigation-actions.js +112 -0
- package/es/blocklet/component/navigation/navigation-dialog.js +607 -0
- package/es/blocklet/component/navigation/navigation-preview.js +101 -0
- package/es/blocklet/component/navigation/simple-select.js +124 -0
- package/es/blocklet/component/select-store.js +155 -0
- package/es/blocklet/component/setting.js +109 -0
- package/es/blocklet/component/sortable-tree.js +126 -0
- package/es/blocklet/component/space-connector.js +199 -0
- package/es/blocklet/component/space-selector.js +178 -0
- package/es/blocklet/component/start.js +101 -0
- package/es/blocklet/component/store-blocklet-list.js +200 -0
- package/es/blocklet/component/switch-control.js +57 -0
- package/es/blocklet/config-navigation.js +331 -0
- package/es/blocklet/configuration.js +603 -0
- package/es/blocklet/disk-info.js +75 -0
- package/es/blocklet/icons.js +18 -0
- package/es/blocklet/install-from-url.js +337 -0
- package/es/blocklet/log.js +90 -0
- package/es/blocklet/migration.js +149 -0
- package/es/blocklet/mode.js +19 -0
- package/es/blocklet/notification/email.js +257 -0
- package/es/blocklet/notification/index.js +49 -0
- package/es/blocklet/oauth/auth0.js +145 -0
- package/es/blocklet/oauth/common-settings.js +133 -0
- package/es/blocklet/oauth/federated-detail-dialog.js +175 -0
- package/es/blocklet/oauth/federated-invite-dialog.js +83 -0
- package/es/blocklet/oauth/federated-join-dialog.js +111 -0
- package/es/blocklet/oauth/federated-site-list.js +338 -0
- package/es/blocklet/oauth/federated.js +81 -0
- package/es/blocklet/oauth/index.js +69 -0
- package/es/blocklet/overview.js +293 -0
- package/es/blocklet/page-group.js +19 -0
- package/es/blocklet/preferences/app-sk.js +142 -0
- package/es/blocklet/preferences/index.js +305 -0
- package/es/blocklet/purchase/common.js +95 -0
- package/es/blocklet/purchase/component-purchase.js +237 -0
- package/es/blocklet/purchase/index.js +4 -0
- package/es/blocklet/router/action/add-domain-alias.js +167 -0
- package/es/blocklet/router/action/add-rule.js +211 -0
- package/es/blocklet/router/action/config-routing-rule.js +232 -0
- package/es/blocklet/router/action/delete-domain-alias.js +99 -0
- package/es/blocklet/router/action/delete-rule.js +108 -0
- package/es/blocklet/router/action/update-rule.js +209 -0
- package/es/blocklet/router/domain-actions.js +64 -0
- package/es/blocklet/router/domain-status.js +88 -0
- package/es/blocklet/router/rule-actions.js +66 -0
- package/es/blocklet/router/rule-list.js +190 -0
- package/es/blocklet/router/util.js +131 -0
- package/es/blocklet/runtime-info.js +68 -0
- package/es/blocklet/status.js +91 -0
- package/es/blocklet/storage/action.js +134 -0
- package/es/blocklet/storage/backups.js +241 -0
- package/es/blocklet/storage/connect-to.js +373 -0
- package/es/blocklet/storage/connected.js +198 -0
- package/es/blocklet/storage/delete.js +113 -0
- package/es/blocklet/storage/disconnect.js +243 -0
- package/es/blocklet/storage/index.js +19 -0
- package/es/blocklet/storage/item.js +558 -0
- package/es/blocklet/storage/preview-nft.js +286 -0
- package/es/blocklet/transfer-owner.js +198 -0
- package/es/blocklet/types.js +18 -0
- package/es/blocklet/util.js +145 -0
- package/es/blocklet/version.js +141 -0
- package/es/card-selector.js +134 -0
- package/es/certificate.js +105 -0
- package/es/chain.js +13 -0
- package/es/click-to-copy.js +22 -0
- package/es/confirm.js +149 -0
- package/es/contexts/audit-log.js +152 -0
- package/es/contexts/blocklet.js +10 -0
- package/es/contexts/deleting-blocklets.js +70 -0
- package/es/contexts/node.js +17 -0
- package/es/contexts/session.js +8 -0
- package/es/contexts/team.js +10 -0
- package/es/delete-confirm.js +121 -0
- package/es/did-address.js +46 -0
- package/es/dot.js +14 -0
- package/es/exchange-passport.js +102 -0
- package/es/form/form-select-input.js +184 -0
- package/es/form/form-text-input.js +178 -0
- package/es/form/form-wrapper.js +88 -0
- package/es/form/input-triggers.js +98 -0
- package/es/form/required.js +8 -0
- package/es/hooks/blocklet.js +229 -0
- package/es/hooks/confirm.js +90 -0
- package/es/hooks/mobile-width.js +11 -0
- package/es/hooks/url-evaluation.js +155 -0
- package/es/hooks/use-app-logo.js +16 -0
- package/es/hooks/use-backup-progress.js +31 -0
- package/es/hooks/use-blocklet-info-for-connect-did-spaces.js +50 -0
- package/es/hooks/use-bundle-logo.js +27 -0
- package/es/hooks/use-navigation.js +347 -0
- package/es/hooks/use-passport-id.js +14 -0
- package/es/hooks/use-subscription.js +22 -0
- package/es/icons/empty-space-nft.svg +59 -0
- package/es/icons/empty-spaces-nft.svg +58 -0
- package/es/icons/long-arrow.svg +5 -0
- package/es/icons/space-connected.svg +3 -0
- package/es/icons/space-disconnect.svg +3 -0
- package/es/index.js +3 -0
- package/es/invitation/invitation-app.js +58 -0
- package/es/invitation/invitation-login.js +68 -0
- package/es/invitation/invitation-passport.js +144 -0
- package/es/invitation/invitation-receive.js +138 -0
- package/es/invitation/invitation-success.js +93 -0
- package/es/invitation/invitation-user.js +90 -0
- package/es/invitation/invitation.js +90 -0
- package/es/issue-passport.js +142 -0
- package/es/launch-blocklet/content-layout.js +58 -0
- package/es/launch-blocklet/page-header.js +43 -0
- package/es/layout/addon.js +114 -0
- package/es/layout/feedback.js +55 -0
- package/es/locales/en.js +1534 -0
- package/es/locales/index.js +9 -0
- package/es/locales/zh.js +1537 -0
- package/es/logs/clock.js +11 -0
- package/es/logs/download.js +132 -0
- package/es/logs/log-terminal.js +253 -0
- package/es/lost-passport.js +452 -0
- package/es/nav-logo.js +219 -0
- package/es/passport-tag.js +43 -0
- package/es/permission.js +57 -0
- package/es/relative-time.js +53 -0
- package/es/result-message.js +11 -0
- package/es/schema-form/color-input.js +98 -0
- package/es/schema-form/common-prop-types.js +13 -0
- package/es/schema-form/index.js +215 -0
- package/es/schema-form/passport-input.js +54 -0
- package/es/schema-form/text-input.js +57 -0
- package/es/store/add.js +179 -0
- package/es/store/delete.js +96 -0
- package/es/store/item.js +76 -0
- package/es/subscription.js +144 -0
- package/es/table-icons.js +34 -0
- package/es/table.js +52 -0
- package/es/tag.js +21 -0
- package/es/team/members/actions.js +89 -0
- package/es/team/members/index.js +636 -0
- package/es/team/members/invitations.js +188 -0
- package/es/team/members/invite-member.js +208 -0
- package/es/team/members/issue-passport.js +152 -0
- package/es/team/members/member.js +408 -0
- package/es/team/members/passport-issuances.js +155 -0
- package/es/team/members/passports.js +364 -0
- package/es/team/members/toggle-user-approval.js +122 -0
- package/es/team/members/transfer-node.js +256 -0
- package/es/team/members/util.js +14 -0
- package/es/team/passports/color.js +126 -0
- package/es/team/passports/detail.js +312 -0
- package/es/team/passports/index.js +282 -0
- package/es/team/passports/mutate-role.js +198 -0
- package/es/team/passports/trusted-factories.js +221 -0
- package/es/team/passports/trusted-factory.js +343 -0
- package/es/team/passports/trusted-issuer.js +296 -0
- package/es/team/passports/trusted-issuers.js +226 -0
- package/es/team/search-input.js +46 -0
- package/es/team/styles/dialog.js +72 -0
- package/es/team/styles/list-header.js +31 -0
- package/es/util/api.js +6 -0
- package/es/util/constants.js +2 -0
- package/es/util/index.js +598 -0
- package/es/util/mode.js +4 -0
- package/es/util/space-gateway.js +51 -0
- package/es/util/spaces.js +151 -0
- package/es/who-can-access/config.js +38 -0
- package/es/wrap-locale.js +15 -0
- package/lib/blocklet/component/space-connector.js +1 -1
- package/lib/blocklet/component/space-selector.js +1 -1
- package/lib/blocklet/storage/backups.js +1 -1
- package/lib/blocklet/storage/connect-to.js +1 -1
- package/lib/blocklet/storage/connected.js +1 -1
- package/lib/blocklet/storage/disconnect.js +1 -1
- package/lib/blocklet/storage/index.js +1 -1
- package/lib/blocklet/storage/item.js +1 -1
- package/lib/invitation/invitation-receive.js +1 -1
- package/lib/team/passports/trusted-factory.js +1 -1
- package/package.json +81 -18
|
@@ -0,0 +1,558 @@
|
|
|
1
|
+
import { Box, Chip, LinearProgress, Typography } from '@mui/material';
|
|
2
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
3
|
+
import Button from '@arcblock/ux/lib/Button';
|
|
4
|
+
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import Toast from '@arcblock/ux/lib/Toast';
|
|
7
|
+
import joinUrl from 'url-join';
|
|
8
|
+
import { BLOCKLET_CONFIGURABLE_KEY } from '@blocklet/constant';
|
|
9
|
+
import DidConnect from '@arcblock/did-connect/lib/Connect';
|
|
10
|
+
import { useRequest } from 'ahooks';
|
|
11
|
+
import { isEmpty } from 'lodash';
|
|
12
|
+
import CheckIcon from '@mui/icons-material/Check';
|
|
13
|
+
import styled from '@emotion/styled';
|
|
14
|
+
var SpacesConnected = function SpacesConnected(props) {
|
|
15
|
+
return /*#__PURE__*/_jsx("svg", {
|
|
16
|
+
...props,
|
|
17
|
+
children: /*#__PURE__*/_jsx("circle", {
|
|
18
|
+
cx: "4",
|
|
19
|
+
cy: "4",
|
|
20
|
+
r: "4",
|
|
21
|
+
fill: "#25C99B"
|
|
22
|
+
})
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
SpacesConnected.defaultProps = {
|
|
26
|
+
width: "8",
|
|
27
|
+
height: "8",
|
|
28
|
+
viewBox: "0 0 8 8",
|
|
29
|
+
fill: "none",
|
|
30
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
31
|
+
};
|
|
32
|
+
var SpaceDisconnected = function SpaceDisconnected(props) {
|
|
33
|
+
return /*#__PURE__*/_jsx("svg", {
|
|
34
|
+
...props,
|
|
35
|
+
children: /*#__PURE__*/_jsx("circle", {
|
|
36
|
+
cx: "4",
|
|
37
|
+
cy: "4",
|
|
38
|
+
r: "4",
|
|
39
|
+
fill: "#F16E6E"
|
|
40
|
+
})
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
SpaceDisconnected.defaultProps = {
|
|
44
|
+
width: "8",
|
|
45
|
+
height: "8",
|
|
46
|
+
viewBox: "0 0 8 8",
|
|
47
|
+
fill: "none",
|
|
48
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
49
|
+
};
|
|
50
|
+
import DidAddress from '../../did-address';
|
|
51
|
+
import SwitchControl from '../component/switch-control';
|
|
52
|
+
import SpaceItemAction from './action';
|
|
53
|
+
import { enableDebug } from '../../util/mode';
|
|
54
|
+
import { axios } from '../../util/api';
|
|
55
|
+
import { useNodeContext } from '../../contexts/node';
|
|
56
|
+
import { useBlockletContext } from '../../contexts/blocklet';
|
|
57
|
+
import useBlockletInfoForConnectDIDSpaces from '../../hooks/use-blocklet-info-for-connect-did-spaces';
|
|
58
|
+
import { getDIDSpaceDidFromEndpoint, getSpaceBackupEndpoint, getSpaceNftDisplayUrlFromEndpoint, hasPermissionByEndpoint } from '../../util/spaces';
|
|
59
|
+
import PreviewSpaceNft from './preview-nft';
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @description
|
|
63
|
+
* @param {{
|
|
64
|
+
* spaceGateway: import('./connected').SpaceGateway
|
|
65
|
+
* connected: boolean,
|
|
66
|
+
* progress: any,
|
|
67
|
+
* onDelete: (spaceGateway: import('./connected').SpaceGateway) => Promise<void>,
|
|
68
|
+
* onBackupNow: () => Promise<void>,
|
|
69
|
+
* refreshSpaceGateways: () => void
|
|
70
|
+
* }} { spaceGateway }
|
|
71
|
+
*/
|
|
72
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
73
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
74
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
75
|
+
function SpaceItem({
|
|
76
|
+
spaceGateway,
|
|
77
|
+
connected,
|
|
78
|
+
progress,
|
|
79
|
+
onDelete,
|
|
80
|
+
onBackupNow,
|
|
81
|
+
refreshSpaceGateways,
|
|
82
|
+
...rest
|
|
83
|
+
}) {
|
|
84
|
+
const {
|
|
85
|
+
t,
|
|
86
|
+
locale
|
|
87
|
+
} = useLocaleContext();
|
|
88
|
+
const [loading, setLoading] = useState(false);
|
|
89
|
+
/** @type {{ blocklet: import('@abtnode/client').BlockletState }} */
|
|
90
|
+
const {
|
|
91
|
+
blocklet
|
|
92
|
+
} = useBlockletContext();
|
|
93
|
+
const {
|
|
94
|
+
api: nodeApi,
|
|
95
|
+
info: {
|
|
96
|
+
did: nodeDid
|
|
97
|
+
}
|
|
98
|
+
} = useNodeContext();
|
|
99
|
+
const {
|
|
100
|
+
appDid,
|
|
101
|
+
appName,
|
|
102
|
+
appDescription,
|
|
103
|
+
scopes,
|
|
104
|
+
appUrl,
|
|
105
|
+
referrer
|
|
106
|
+
} = useBlockletInfoForConnectDIDSpaces({
|
|
107
|
+
blocklet
|
|
108
|
+
});
|
|
109
|
+
const spaceBackupEndpoint = useMemo(() => getSpaceBackupEndpoint(blocklet?.environments), [blocklet]);
|
|
110
|
+
const [authorizeConnect, setAuthorizeConnect] = useState({
|
|
111
|
+
open: false,
|
|
112
|
+
action: 'one-click-authorization',
|
|
113
|
+
checkTimeout: 1000 * 300,
|
|
114
|
+
messages: {
|
|
115
|
+
title: t('storage.spaces.authorize.title', {
|
|
116
|
+
appName
|
|
117
|
+
}, locale),
|
|
118
|
+
scan: t('storage.spaces.authorize.scan', {
|
|
119
|
+
appName
|
|
120
|
+
}, locale),
|
|
121
|
+
confirm: '',
|
|
122
|
+
success: /*#__PURE__*/_jsx(Typography, {
|
|
123
|
+
gutterBottom: true,
|
|
124
|
+
children: t('storage.spaces.authorize.success')
|
|
125
|
+
})
|
|
126
|
+
},
|
|
127
|
+
onClose: () => {
|
|
128
|
+
// eslint-disable-next-line no-shadow
|
|
129
|
+
setAuthorizeConnect(preValue => ({
|
|
130
|
+
...preValue,
|
|
131
|
+
open: false
|
|
132
|
+
}));
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
const {
|
|
136
|
+
data: hasPermission,
|
|
137
|
+
loading: hasPermissionLoading
|
|
138
|
+
} = useRequest(
|
|
139
|
+
// eslint-disable-next-line require-await
|
|
140
|
+
async () => {
|
|
141
|
+
if (!connected) {
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
return hasPermissionByEndpoint(spaceBackupEndpoint);
|
|
145
|
+
}, {
|
|
146
|
+
refreshDeps: [connected, spaceBackupEndpoint, authorizeConnect?.open, loading]
|
|
147
|
+
});
|
|
148
|
+
const shouldDisplayConnected = connected && hasPermission;
|
|
149
|
+
const shouldDisplayBackupStrategy = connected && !loading && hasPermission;
|
|
150
|
+
const shouldDisplayBackupProgress = connected && loading && hasPermission;
|
|
151
|
+
const shouldDisplayReconnectNow = connected && !hasPermission && !hasPermissionLoading && !loading;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
*
|
|
155
|
+
* @param {import('./connected').SpaceGateway} _spaceGateway
|
|
156
|
+
* @param {string} endpoint
|
|
157
|
+
* @return {Promise<void>}
|
|
158
|
+
*/
|
|
159
|
+
const onConnect = async () => {
|
|
160
|
+
const alreadyAuthorize = await hasPermissionByEndpoint(spaceGateway?.endpoint);
|
|
161
|
+
if (alreadyAuthorize) {
|
|
162
|
+
await nodeApi.configBlocklet({
|
|
163
|
+
input: {
|
|
164
|
+
did: [blocklet.meta.did],
|
|
165
|
+
configs: [{
|
|
166
|
+
key: BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,
|
|
167
|
+
value: spaceGateway.endpoint
|
|
168
|
+
}]
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
Toast.success(t('storage.spaces.connect.switchToSpaceSucceeded', {
|
|
172
|
+
name: spaceGateway.name ? `(${spaceGateway.name})` : ''
|
|
173
|
+
}));
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
setAuthorizeConnect(preValue => ({
|
|
177
|
+
...preValue,
|
|
178
|
+
open: true,
|
|
179
|
+
prefix: joinUrl(spaceGateway.url, 'space/api/did'),
|
|
180
|
+
baseUrl: new URL(spaceGateway.url).origin,
|
|
181
|
+
checkFn: axios.create({
|
|
182
|
+
baseURL: joinUrl(spaceGateway.url, 'space')
|
|
183
|
+
}).get,
|
|
184
|
+
extraParams: {
|
|
185
|
+
appDid,
|
|
186
|
+
appName,
|
|
187
|
+
appDescription,
|
|
188
|
+
scopes,
|
|
189
|
+
appUrl,
|
|
190
|
+
referrer,
|
|
191
|
+
nodeDid
|
|
192
|
+
}
|
|
193
|
+
}));
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* @description
|
|
198
|
+
* @param {Record<string, any>} response
|
|
199
|
+
* @param {Function} decrypt
|
|
200
|
+
*/
|
|
201
|
+
const onAuthorizeConnectSuccess = async (response, decrypt) => {
|
|
202
|
+
const endpoint = decrypt(response.endpoint);
|
|
203
|
+
const spaceDid = getDIDSpaceDidFromEndpoint(endpoint);
|
|
204
|
+
const space = response.space ? decrypt(response.space) : {};
|
|
205
|
+
if (spaceGateway.did && spaceDid !== spaceGateway.did) {
|
|
206
|
+
setAuthorizeConnect(preValue => ({
|
|
207
|
+
...preValue,
|
|
208
|
+
open: false
|
|
209
|
+
}));
|
|
210
|
+
Toast.error(t('storage.spaces.gateway.switch.failedForMismatchSpace', {
|
|
211
|
+
name: space?.name ? space.name : ''
|
|
212
|
+
}));
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
await nodeApi.updateBlockletSpaceGateway({
|
|
216
|
+
input: {
|
|
217
|
+
did: blocklet.meta.did,
|
|
218
|
+
where: {
|
|
219
|
+
url: spaceGateway?.url
|
|
220
|
+
},
|
|
221
|
+
spaceGateway: {
|
|
222
|
+
...spaceGateway,
|
|
223
|
+
name: space.name ?? 'DID Space',
|
|
224
|
+
did: space.did ?? getDIDSpaceDidFromEndpoint(endpoint),
|
|
225
|
+
endpoint
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
if (spaceBackupEndpoint !== endpoint) {
|
|
230
|
+
await nodeApi.configBlocklet({
|
|
231
|
+
input: {
|
|
232
|
+
did: [blocklet.meta.did],
|
|
233
|
+
configs: [{
|
|
234
|
+
key: BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,
|
|
235
|
+
value: endpoint
|
|
236
|
+
}]
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
Toast.success(t('storage.spaces.connectedWithName', {
|
|
241
|
+
name: spaceGateway?.name ?? 'DID Spaces'
|
|
242
|
+
}));
|
|
243
|
+
setAuthorizeConnect(preValue => ({
|
|
244
|
+
...preValue,
|
|
245
|
+
open: false
|
|
246
|
+
}));
|
|
247
|
+
refreshSpaceGateways();
|
|
248
|
+
};
|
|
249
|
+
const _onBackupNow = async () => {
|
|
250
|
+
try {
|
|
251
|
+
if (loading) {
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
setLoading(true);
|
|
255
|
+
await onBackupNow();
|
|
256
|
+
} catch (error) {
|
|
257
|
+
console.error(error);
|
|
258
|
+
Toast.error(error.message);
|
|
259
|
+
} finally {
|
|
260
|
+
setLoading(true);
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
useEffect(() => {
|
|
264
|
+
if (progress?.completed) {
|
|
265
|
+
if (progress?.progress === 100) {
|
|
266
|
+
Toast.success(t('storage.spaces.backupSuccessfully'));
|
|
267
|
+
} else if (progress?.progress === -1) {
|
|
268
|
+
Toast.error(progress?.message);
|
|
269
|
+
}
|
|
270
|
+
setLoading(false);
|
|
271
|
+
progress.progress = 0;
|
|
272
|
+
progress.message = '';
|
|
273
|
+
} else if (progress.progress) {
|
|
274
|
+
setLoading(true);
|
|
275
|
+
}
|
|
276
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
277
|
+
}, [progress]);
|
|
278
|
+
return /*#__PURE__*/_jsxs(BoxContainer, {
|
|
279
|
+
style: {
|
|
280
|
+
position: 'relative'
|
|
281
|
+
},
|
|
282
|
+
children: [/*#__PURE__*/_jsxs(Box, {
|
|
283
|
+
sx: {
|
|
284
|
+
backgroundColor: connected ? '#F0FDFF' : 'inherit',
|
|
285
|
+
'&:hover': {
|
|
286
|
+
backgroundColor: connected ? '#F0FDFF' : '#FBFBFB'
|
|
287
|
+
},
|
|
288
|
+
borderRadius: '8px'
|
|
289
|
+
},
|
|
290
|
+
display: "flex",
|
|
291
|
+
padding: "12px 20px",
|
|
292
|
+
...rest,
|
|
293
|
+
children: [/*#__PURE__*/_jsx(Box, {
|
|
294
|
+
display: "flex",
|
|
295
|
+
children: /*#__PURE__*/_jsx(PreviewSpaceNft, {
|
|
296
|
+
alt: spaceGateway.did,
|
|
297
|
+
src: getSpaceNftDisplayUrlFromEndpoint(spaceGateway.endpoint)
|
|
298
|
+
})
|
|
299
|
+
}), /*#__PURE__*/_jsxs(Box, {
|
|
300
|
+
className: "spaces-info",
|
|
301
|
+
display: "flex",
|
|
302
|
+
flexGrow: 1,
|
|
303
|
+
flexDirection: shouldDisplayBackupProgress ? 'row' : 'column',
|
|
304
|
+
sx: {
|
|
305
|
+
marginLeft: '20px',
|
|
306
|
+
padding: '0px 0px'
|
|
307
|
+
},
|
|
308
|
+
children: [/*#__PURE__*/_jsxs(Box, {
|
|
309
|
+
className: "spaces-info",
|
|
310
|
+
display: "flex",
|
|
311
|
+
maxWidth: "360px",
|
|
312
|
+
alignItems: "center",
|
|
313
|
+
children: [/*#__PURE__*/_jsx(Typography, {
|
|
314
|
+
color: connected ? 'primary' : 'inherit',
|
|
315
|
+
fontSize: "1rem",
|
|
316
|
+
fontWeight: "bold",
|
|
317
|
+
children: spaceGateway.name
|
|
318
|
+
}), shouldDisplayConnected && /*#__PURE__*/_jsx(Chip, {
|
|
319
|
+
label: /*#__PURE__*/_jsxs(_Fragment, {
|
|
320
|
+
children: [/*#__PURE__*/_jsx(SpacesConnected, {
|
|
321
|
+
style: {
|
|
322
|
+
marginRight: '4px'
|
|
323
|
+
}
|
|
324
|
+
}), t('storage.spaces.connected.tag')]
|
|
325
|
+
}),
|
|
326
|
+
variant: "outlined",
|
|
327
|
+
size: "small",
|
|
328
|
+
style: {
|
|
329
|
+
marginLeft: '20px',
|
|
330
|
+
fontWeight: 'bold'
|
|
331
|
+
}
|
|
332
|
+
}), shouldDisplayReconnectNow && /*#__PURE__*/_jsx(Chip, {
|
|
333
|
+
label: /*#__PURE__*/_jsxs(_Fragment, {
|
|
334
|
+
children: [/*#__PURE__*/_jsx(SpaceDisconnected, {
|
|
335
|
+
style: {
|
|
336
|
+
marginRight: '4px'
|
|
337
|
+
}
|
|
338
|
+
}), t('storage.spaces.disconnected.tag')]
|
|
339
|
+
}),
|
|
340
|
+
variant: "outlined",
|
|
341
|
+
size: "small",
|
|
342
|
+
style: {
|
|
343
|
+
marginLeft: '20px',
|
|
344
|
+
fontWeight: 'bold'
|
|
345
|
+
}
|
|
346
|
+
})]
|
|
347
|
+
}), /*#__PURE__*/_jsx(Box, {
|
|
348
|
+
className: "spaces-address",
|
|
349
|
+
display: shouldDisplayBackupProgress ? 'none' : 'flex',
|
|
350
|
+
color: "#9397A1",
|
|
351
|
+
marginTop: "8px",
|
|
352
|
+
children: /*#__PURE__*/_jsx(Typography, {
|
|
353
|
+
sx: {
|
|
354
|
+
display: 'inline-flex',
|
|
355
|
+
alignItems: 'center',
|
|
356
|
+
fontSize: '14px'
|
|
357
|
+
},
|
|
358
|
+
color: "#9397A1",
|
|
359
|
+
children: spaceGateway.did && /*#__PURE__*/_jsx(DidAddress, {
|
|
360
|
+
copyable: false,
|
|
361
|
+
size: 14,
|
|
362
|
+
compact: true,
|
|
363
|
+
responsive: false,
|
|
364
|
+
did: spaceGateway.did
|
|
365
|
+
})
|
|
366
|
+
})
|
|
367
|
+
})]
|
|
368
|
+
}), /*#__PURE__*/_jsxs(Box, {
|
|
369
|
+
className: "spaces-backup",
|
|
370
|
+
display: "flex",
|
|
371
|
+
alignItems: "center",
|
|
372
|
+
children: [shouldDisplayBackupStrategy && /*#__PURE__*/_jsxs(Box, {
|
|
373
|
+
className: "backup-strategy",
|
|
374
|
+
display: "flex",
|
|
375
|
+
alignItems: "center",
|
|
376
|
+
width: "100%",
|
|
377
|
+
children: [/*#__PURE__*/_jsx(Button, {
|
|
378
|
+
variant: "contained",
|
|
379
|
+
size: "small",
|
|
380
|
+
onClick: _onBackupNow,
|
|
381
|
+
children: t('storage.spaces.strategy.backupNow')
|
|
382
|
+
}), enableDebug && /*#__PURE__*/_jsx(SwitchControl, {
|
|
383
|
+
name: "enable-auto-backup",
|
|
384
|
+
title: "coming soon",
|
|
385
|
+
disabled: true,
|
|
386
|
+
labelProps: {
|
|
387
|
+
label: /*#__PURE__*/_jsx(Typography, {
|
|
388
|
+
sx: {
|
|
389
|
+
marginRight: '8px',
|
|
390
|
+
fontSize: '16px'
|
|
391
|
+
},
|
|
392
|
+
children: /*#__PURE__*/_jsx("span", {
|
|
393
|
+
children: t('storage.spaces.strategy.autoBackup')
|
|
394
|
+
})
|
|
395
|
+
})
|
|
396
|
+
},
|
|
397
|
+
style: {
|
|
398
|
+
marginLeft: '64px'
|
|
399
|
+
}
|
|
400
|
+
})]
|
|
401
|
+
}), shouldDisplayBackupProgress && /*#__PURE__*/_jsxs(Box, {
|
|
402
|
+
className: "backup-progress",
|
|
403
|
+
display: "flex",
|
|
404
|
+
flexDirection: "column",
|
|
405
|
+
alignItems: "center",
|
|
406
|
+
minWidth: "640px",
|
|
407
|
+
marginRight: "auto",
|
|
408
|
+
alignSelf: "end",
|
|
409
|
+
children: [/*#__PURE__*/_jsx(Typography, {
|
|
410
|
+
color: "primary",
|
|
411
|
+
children: progress?.message
|
|
412
|
+
}), /*#__PURE__*/_jsxs(Box, {
|
|
413
|
+
sx: {
|
|
414
|
+
display: 'flex',
|
|
415
|
+
alignItems: 'center'
|
|
416
|
+
},
|
|
417
|
+
width: "100%",
|
|
418
|
+
children: [/*#__PURE__*/_jsx(Box, {
|
|
419
|
+
sx: {
|
|
420
|
+
width: '100%',
|
|
421
|
+
mr: 1
|
|
422
|
+
},
|
|
423
|
+
children: /*#__PURE__*/_jsx(LinearProgress, {
|
|
424
|
+
color: "primary",
|
|
425
|
+
variant: "determinate",
|
|
426
|
+
value: progress?.progress
|
|
427
|
+
})
|
|
428
|
+
}), /*#__PURE__*/_jsx(Box, {
|
|
429
|
+
sx: {
|
|
430
|
+
minWidth: 35
|
|
431
|
+
},
|
|
432
|
+
children: /*#__PURE__*/_jsxs(Typography, {
|
|
433
|
+
variant: "body2",
|
|
434
|
+
color: "text.secondary",
|
|
435
|
+
children: [progress?.progress, "%"]
|
|
436
|
+
})
|
|
437
|
+
})]
|
|
438
|
+
})]
|
|
439
|
+
}), shouldDisplayReconnectNow && /*#__PURE__*/_jsx(Box, {
|
|
440
|
+
className: "backup-strategy",
|
|
441
|
+
display: "flex",
|
|
442
|
+
alignItems: "center",
|
|
443
|
+
width: "100%",
|
|
444
|
+
children: /*#__PURE__*/_jsx(Button, {
|
|
445
|
+
color: "error",
|
|
446
|
+
variant: "contained",
|
|
447
|
+
size: "small",
|
|
448
|
+
onClick: onConnect,
|
|
449
|
+
children: t('storage.spaces.disconnected.reconnectNow')
|
|
450
|
+
})
|
|
451
|
+
}), /*#__PURE__*/_jsx(SpaceItemAction, {
|
|
452
|
+
sx: {
|
|
453
|
+
marginLeft: '16px',
|
|
454
|
+
marginRight: '16px'
|
|
455
|
+
},
|
|
456
|
+
spaceGateway: spaceGateway,
|
|
457
|
+
connected: connected,
|
|
458
|
+
onDelete: onDelete,
|
|
459
|
+
onConnect: onConnect,
|
|
460
|
+
enableSwitchToSpace: progress?.completed || isEmpty(progress?.message)
|
|
461
|
+
})]
|
|
462
|
+
})]
|
|
463
|
+
}), /*#__PURE__*/_jsx(DidConnect, {
|
|
464
|
+
forceConnected: false,
|
|
465
|
+
saveConnect: false,
|
|
466
|
+
prefix: authorizeConnect.prefix,
|
|
467
|
+
open: authorizeConnect.open,
|
|
468
|
+
popup: true,
|
|
469
|
+
action: authorizeConnect.action,
|
|
470
|
+
baseUrl: authorizeConnect.baseUrl,
|
|
471
|
+
checkFn: authorizeConnect.checkFn,
|
|
472
|
+
onSuccess: onAuthorizeConnectSuccess,
|
|
473
|
+
onClose: authorizeConnect.onClose,
|
|
474
|
+
checkTimeout: authorizeConnect.checkTimeout,
|
|
475
|
+
extraParams: authorizeConnect.extraParams,
|
|
476
|
+
messages: authorizeConnect.messages,
|
|
477
|
+
locale: locale
|
|
478
|
+
}, "get-endpoint"), /*#__PURE__*/_jsx(Box, {
|
|
479
|
+
className: `selected-container ${connected ? 'selected' : ''}`,
|
|
480
|
+
children: /*#__PURE__*/_jsx(CheckIcon, {
|
|
481
|
+
className: "selected-icon"
|
|
482
|
+
})
|
|
483
|
+
})]
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
SpaceItem.propTypes = {
|
|
487
|
+
spaceGateway: PropTypes.shape({
|
|
488
|
+
did: PropTypes.string.isRequired,
|
|
489
|
+
name: PropTypes.string.isRequired,
|
|
490
|
+
url: PropTypes.string.isRequired,
|
|
491
|
+
endpoint: PropTypes.string.isRequired,
|
|
492
|
+
protected: PropTypes.bool
|
|
493
|
+
}).isRequired,
|
|
494
|
+
connected: PropTypes.bool.isRequired,
|
|
495
|
+
progress: PropTypes.any.isRequired,
|
|
496
|
+
refreshSpaceGateways: PropTypes.func.isRequired,
|
|
497
|
+
onDelete: PropTypes.func,
|
|
498
|
+
onBackupNow: PropTypes.func
|
|
499
|
+
};
|
|
500
|
+
SpaceItem.defaultProps = {
|
|
501
|
+
onDelete: () => undefined,
|
|
502
|
+
onBackupNow: () => undefined
|
|
503
|
+
};
|
|
504
|
+
const BoxContainer = styled(Box)`
|
|
505
|
+
.selected-container {
|
|
506
|
+
position: absolute;
|
|
507
|
+
right: 0px;
|
|
508
|
+
bottom: 0px;
|
|
509
|
+
display: flex;
|
|
510
|
+
-webkit-box-pack: end;
|
|
511
|
+
justify-content: flex-end;
|
|
512
|
+
align-items: flex-end;
|
|
513
|
+
width: 32px;
|
|
514
|
+
height: 32px;
|
|
515
|
+
border-radius: 0px 0px 8px;
|
|
516
|
+
color: rgb(255, 255, 255);
|
|
517
|
+
overflow: hidden;
|
|
518
|
+
transition: all 0.4s ease 0s;
|
|
519
|
+
|
|
520
|
+
&::after {
|
|
521
|
+
position: absolute;
|
|
522
|
+
z-index: 0;
|
|
523
|
+
left: 60px;
|
|
524
|
+
top: 60px;
|
|
525
|
+
display: block;
|
|
526
|
+
width: 0px;
|
|
527
|
+
height: 0px;
|
|
528
|
+
border-width: 16px;
|
|
529
|
+
border-style: solid;
|
|
530
|
+
border-color: transparent #1dc1c7 #1dc1c7 transparent;
|
|
531
|
+
transition: all 0.1s ease 0s;
|
|
532
|
+
content: '';
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
.selected-icon {
|
|
536
|
+
visibility: hidden;
|
|
537
|
+
width: 60%;
|
|
538
|
+
height: 60%;
|
|
539
|
+
position: relative;
|
|
540
|
+
z-index: 2;
|
|
541
|
+
margin: 0px 1px 1px 0px;
|
|
542
|
+
font-size: 16px;
|
|
543
|
+
transition: all 0.2s ease 0s;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
.selected-container.selected {
|
|
548
|
+
&::after {
|
|
549
|
+
left: 0px;
|
|
550
|
+
top: 0px;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
.selected-icon {
|
|
554
|
+
visibility: visible;
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
`;
|
|
558
|
+
export default SpaceItem;
|