@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,337 @@
|
|
|
1
|
+
import { useState, useEffect } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import Dialog from '@arcblock/ux/lib/Dialog';
|
|
4
|
+
import Spinner from '@mui/material/CircularProgress';
|
|
5
|
+
import DialogContentText from '@mui/material/DialogContentText';
|
|
6
|
+
import Typography from '@mui/material/Typography';
|
|
7
|
+
import TextField from '@mui/material/TextField';
|
|
8
|
+
import Stepper from '@mui/material/Stepper';
|
|
9
|
+
import Step from '@mui/material/Step';
|
|
10
|
+
import StepLabel from '@mui/material/StepLabel';
|
|
11
|
+
import InfoRow from '@arcblock/ux/lib/InfoRow';
|
|
12
|
+
import DidConnect from '@arcblock/did-connect/lib/Connect';
|
|
13
|
+
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
14
|
+
import Button from '@arcblock/ux/lib/Button';
|
|
15
|
+
import Alert from '@arcblock/ux/lib/Alert';
|
|
16
|
+
import { getDisplayName } from '@blocklet/meta/lib/util';
|
|
17
|
+
import { useNodeContext } from '../contexts/node';
|
|
18
|
+
import { useSessionContext } from '../contexts/session';
|
|
19
|
+
import { formatError, formatPerson } from '../util';
|
|
20
|
+
import { getWalletType } from './util';
|
|
21
|
+
import DidAddress from '../did-address';
|
|
22
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
23
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
25
|
+
export default function InstallFromUrl({
|
|
26
|
+
defaultUrl,
|
|
27
|
+
onCancel,
|
|
28
|
+
onSuccess,
|
|
29
|
+
onError,
|
|
30
|
+
mode,
|
|
31
|
+
handleText
|
|
32
|
+
}) {
|
|
33
|
+
const {
|
|
34
|
+
api
|
|
35
|
+
} = useNodeContext();
|
|
36
|
+
const {
|
|
37
|
+
api: $api
|
|
38
|
+
} = useSessionContext();
|
|
39
|
+
const [loading, setLoading] = useState(false);
|
|
40
|
+
const [error, setError] = useState('');
|
|
41
|
+
const {
|
|
42
|
+
t
|
|
43
|
+
} = useLocaleContext();
|
|
44
|
+
const initMeta = {
|
|
45
|
+
dist: {}
|
|
46
|
+
};
|
|
47
|
+
const [url, setUrl] = useState(defaultUrl);
|
|
48
|
+
const [activeStep, setActiveStep] = useState(defaultUrl ? 1 : 0);
|
|
49
|
+
const [meta, setMeta] = useState(initMeta);
|
|
50
|
+
const [isConnectOpen, setConnectOpen] = useState(false);
|
|
51
|
+
const [params, setParams] = useState({});
|
|
52
|
+
const isComponentMode = mode === 'component';
|
|
53
|
+
// if mode is component , we need to always show the step, that means the user can return to the previous step
|
|
54
|
+
const alwayShowSteps = isComponentMode ? true : !defaultUrl;
|
|
55
|
+
const onGetMeta = async () => {
|
|
56
|
+
setMeta(initMeta);
|
|
57
|
+
setError(null);
|
|
58
|
+
setLoading(true);
|
|
59
|
+
try {
|
|
60
|
+
const decoded = decodeURIComponent(url.trim());
|
|
61
|
+
// validate
|
|
62
|
+
try {
|
|
63
|
+
new URL(decoded); // eslint-disable-line no-new
|
|
64
|
+
} catch {
|
|
65
|
+
throw new Error('Invalid URL');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// request
|
|
69
|
+
const {
|
|
70
|
+
meta: newer,
|
|
71
|
+
inStore,
|
|
72
|
+
registryUrl
|
|
73
|
+
} = await api.getBlockletMetaFromUrl({
|
|
74
|
+
input: {
|
|
75
|
+
url: decoded
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
setMeta(newer);
|
|
79
|
+
setParams({
|
|
80
|
+
inStore,
|
|
81
|
+
registryUrl,
|
|
82
|
+
inputUrl: url.trim()
|
|
83
|
+
});
|
|
84
|
+
} catch (err) {
|
|
85
|
+
console.error(err);
|
|
86
|
+
const errMsg = `Blocklet Install failed: ${formatError(err)}`;
|
|
87
|
+
setError(errMsg);
|
|
88
|
+
onError(err);
|
|
89
|
+
} finally {
|
|
90
|
+
setLoading(false);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
const onConfirm = () => {
|
|
94
|
+
if (isComponentMode) {
|
|
95
|
+
onSuccess({
|
|
96
|
+
meta,
|
|
97
|
+
...params
|
|
98
|
+
});
|
|
99
|
+
onCancel();
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
setLoading(true);
|
|
103
|
+
setConnectOpen(true);
|
|
104
|
+
};
|
|
105
|
+
const onEndInstall = () => {
|
|
106
|
+
setLoading(false);
|
|
107
|
+
setConnectOpen(false);
|
|
108
|
+
onSuccess({
|
|
109
|
+
meta,
|
|
110
|
+
...params
|
|
111
|
+
});
|
|
112
|
+
onCancel();
|
|
113
|
+
};
|
|
114
|
+
const onCancelInstall = () => {
|
|
115
|
+
setLoading(false);
|
|
116
|
+
setConnectOpen(false);
|
|
117
|
+
};
|
|
118
|
+
useEffect(() => {
|
|
119
|
+
if (defaultUrl) {
|
|
120
|
+
onGetMeta();
|
|
121
|
+
}
|
|
122
|
+
}, [defaultUrl]); // eslint-disable-line
|
|
123
|
+
|
|
124
|
+
const rows = [{
|
|
125
|
+
name: t('common.name'),
|
|
126
|
+
value: getDisplayName({
|
|
127
|
+
meta
|
|
128
|
+
}, true)
|
|
129
|
+
}, {
|
|
130
|
+
name: t('common.version'),
|
|
131
|
+
value: meta.version
|
|
132
|
+
}, {
|
|
133
|
+
name: t('common.did'),
|
|
134
|
+
value: /*#__PURE__*/_jsx(DidAddress, {
|
|
135
|
+
did: meta.did
|
|
136
|
+
})
|
|
137
|
+
}, {
|
|
138
|
+
name: t('common.author'),
|
|
139
|
+
value: formatPerson(meta.author)
|
|
140
|
+
}, {
|
|
141
|
+
name: t('blocklet.dist.downloadLink'),
|
|
142
|
+
value: meta.dist.tarball
|
|
143
|
+
}];
|
|
144
|
+
const getStep1Body = () => {
|
|
145
|
+
if (loading) {
|
|
146
|
+
return /*#__PURE__*/_jsx("div", {
|
|
147
|
+
style: {
|
|
148
|
+
height: 200,
|
|
149
|
+
width: '100%',
|
|
150
|
+
display: 'flex',
|
|
151
|
+
alignItems: 'center',
|
|
152
|
+
justifyContent: 'center',
|
|
153
|
+
flexDirection: 'column'
|
|
154
|
+
},
|
|
155
|
+
children: /*#__PURE__*/_jsx(Spinner, {})
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
if (meta.did) {
|
|
159
|
+
return /*#__PURE__*/_jsx("div", {
|
|
160
|
+
style: {
|
|
161
|
+
paddingLeft: '10%'
|
|
162
|
+
},
|
|
163
|
+
children: rows.map(row => {
|
|
164
|
+
if (row.name === t('common.did')) {
|
|
165
|
+
return /*#__PURE__*/_jsx(InfoRow, {
|
|
166
|
+
valueComponent: "div",
|
|
167
|
+
nameWidth: 120,
|
|
168
|
+
name: row.name,
|
|
169
|
+
nameFormatter: () => t('common.did'),
|
|
170
|
+
children: row.value
|
|
171
|
+
}, row.name);
|
|
172
|
+
}
|
|
173
|
+
return /*#__PURE__*/_jsx(InfoRow, {
|
|
174
|
+
valueComponent: "div",
|
|
175
|
+
nameWidth: 120,
|
|
176
|
+
name: row.name,
|
|
177
|
+
children: row.value
|
|
178
|
+
}, row.name);
|
|
179
|
+
})
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
return null;
|
|
183
|
+
};
|
|
184
|
+
const steps = [{
|
|
185
|
+
label: t('blocklet.fromUrl.step0'),
|
|
186
|
+
body: /*#__PURE__*/_jsx(Typography, {
|
|
187
|
+
component: "div",
|
|
188
|
+
children: /*#__PURE__*/_jsx(TextField, {
|
|
189
|
+
label: t('blocklet.fromUrl.label'),
|
|
190
|
+
autoComplete: "off",
|
|
191
|
+
variant: "outlined",
|
|
192
|
+
name: "url",
|
|
193
|
+
"data-cy": "blocklet-url-input",
|
|
194
|
+
fullWidth: true,
|
|
195
|
+
autoFocus: true,
|
|
196
|
+
style: {
|
|
197
|
+
marginBottom: 32
|
|
198
|
+
},
|
|
199
|
+
margin: "dense",
|
|
200
|
+
helperText: t('blocklet.fromUrl.description'),
|
|
201
|
+
value: url,
|
|
202
|
+
onChange: e => {
|
|
203
|
+
setError(null);
|
|
204
|
+
setUrl(e.target.value);
|
|
205
|
+
},
|
|
206
|
+
disabled: loading,
|
|
207
|
+
onKeyPress: e => {
|
|
208
|
+
if (e.key === 'Enter') {
|
|
209
|
+
e.preventDefault();
|
|
210
|
+
onGetMeta();
|
|
211
|
+
setActiveStep(1);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
})
|
|
215
|
+
}),
|
|
216
|
+
cancel: t('common.cancel'),
|
|
217
|
+
confirm: t('common.next'),
|
|
218
|
+
onCancel,
|
|
219
|
+
onConfirm: () => {
|
|
220
|
+
onGetMeta();
|
|
221
|
+
setActiveStep(1);
|
|
222
|
+
}
|
|
223
|
+
}, {
|
|
224
|
+
label: t('blocklet.fromUrl.step1'),
|
|
225
|
+
body: getStep1Body(),
|
|
226
|
+
cancel: alwayShowSteps ? t('common.pre') : t('common.cancel'),
|
|
227
|
+
confirm: handleText?.confirm || t('blocklet.fromUrl.confirm'),
|
|
228
|
+
onCancel: () => {
|
|
229
|
+
if (alwayShowSteps) {
|
|
230
|
+
setActiveStep(s => s - 1);
|
|
231
|
+
} else {
|
|
232
|
+
onCancel();
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
onConfirm: () => {
|
|
236
|
+
onConfirm();
|
|
237
|
+
}
|
|
238
|
+
}];
|
|
239
|
+
const step = steps[activeStep];
|
|
240
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
241
|
+
children: [/*#__PURE__*/_jsxs(Dialog, {
|
|
242
|
+
title: handleText?.title || t('blocklet.fromUrl.title'),
|
|
243
|
+
fullWidth: true,
|
|
244
|
+
maxWidth: "md",
|
|
245
|
+
onClose: () => step.onCancel(),
|
|
246
|
+
showCloseButton: activeStep === 0,
|
|
247
|
+
disableEscapeKeyDown: true,
|
|
248
|
+
open: true,
|
|
249
|
+
actions: /*#__PURE__*/_jsxs(_Fragment, {
|
|
250
|
+
children: [step.cancel && /*#__PURE__*/_jsx(Button, {
|
|
251
|
+
onClick: e => {
|
|
252
|
+
e.stopPropagation();
|
|
253
|
+
setError(null);
|
|
254
|
+
step.onCancel();
|
|
255
|
+
},
|
|
256
|
+
color: "inherit",
|
|
257
|
+
children: step.cancel || t('common.cancel')
|
|
258
|
+
}), /*#__PURE__*/_jsxs(Button, {
|
|
259
|
+
onClick: e => {
|
|
260
|
+
e.stopPropagation();
|
|
261
|
+
step.onConfirm();
|
|
262
|
+
},
|
|
263
|
+
color: "primary",
|
|
264
|
+
"data-cy": "install-blocklet-next-step",
|
|
265
|
+
disabled: loading || !url || error,
|
|
266
|
+
variant: "contained",
|
|
267
|
+
autoFocus: true,
|
|
268
|
+
style: {
|
|
269
|
+
marginLeft: 8
|
|
270
|
+
},
|
|
271
|
+
children: [loading && activeStep === 0 && /*#__PURE__*/_jsx(Spinner, {
|
|
272
|
+
size: 16
|
|
273
|
+
}), step.confirm]
|
|
274
|
+
})]
|
|
275
|
+
}),
|
|
276
|
+
children: [alwayShowSteps && /*#__PURE__*/_jsx(Stepper, {
|
|
277
|
+
alternativeLabel: true,
|
|
278
|
+
activeStep: activeStep,
|
|
279
|
+
children: steps.map(({
|
|
280
|
+
label
|
|
281
|
+
}) => /*#__PURE__*/_jsx(Step, {
|
|
282
|
+
children: /*#__PURE__*/_jsx(StepLabel, {
|
|
283
|
+
children: label
|
|
284
|
+
})
|
|
285
|
+
}, label))
|
|
286
|
+
}), /*#__PURE__*/_jsx(DialogContentText, {
|
|
287
|
+
component: "div",
|
|
288
|
+
style: {
|
|
289
|
+
marginTop: 24
|
|
290
|
+
},
|
|
291
|
+
children: step.body
|
|
292
|
+
}), !!error && /*#__PURE__*/_jsx(Alert, {
|
|
293
|
+
type: "error",
|
|
294
|
+
style: {
|
|
295
|
+
width: '100%',
|
|
296
|
+
marginTop: 8
|
|
297
|
+
},
|
|
298
|
+
children: error
|
|
299
|
+
})]
|
|
300
|
+
}), meta && isConnectOpen && /*#__PURE__*/_jsx(DidConnect, {
|
|
301
|
+
popup: true,
|
|
302
|
+
open: true,
|
|
303
|
+
forceConnected: false,
|
|
304
|
+
className: "launch-from-url-auth",
|
|
305
|
+
action: "launch-free-blocklet-by-session",
|
|
306
|
+
checkFn: $api.get,
|
|
307
|
+
checkTimeout: 5 * 60 * 1000,
|
|
308
|
+
onSuccess: onEndInstall,
|
|
309
|
+
extraParams: {
|
|
310
|
+
title: meta.title,
|
|
311
|
+
wt: getWalletType(meta),
|
|
312
|
+
blockletMetaUrl: decodeURIComponent(url.trim())
|
|
313
|
+
},
|
|
314
|
+
messages: {
|
|
315
|
+
title: t('setup.keyPair.title'),
|
|
316
|
+
scan: t('setup.keyPair.scan'),
|
|
317
|
+
confirm: t('setup.keyPair.confirm'),
|
|
318
|
+
success: t('setup.keyPair.success')
|
|
319
|
+
},
|
|
320
|
+
onClose: onCancelInstall
|
|
321
|
+
})]
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
InstallFromUrl.propTypes = {
|
|
325
|
+
defaultUrl: PropTypes.string,
|
|
326
|
+
onCancel: PropTypes.func.isRequired,
|
|
327
|
+
onSuccess: PropTypes.func.isRequired,
|
|
328
|
+
onError: PropTypes.func,
|
|
329
|
+
mode: PropTypes.oneOf(['install', 'component']),
|
|
330
|
+
handleText: PropTypes.object
|
|
331
|
+
};
|
|
332
|
+
InstallFromUrl.defaultProps = {
|
|
333
|
+
onError: () => {},
|
|
334
|
+
defaultUrl: '',
|
|
335
|
+
mode: 'install',
|
|
336
|
+
handleText: {}
|
|
337
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import Box from '@mui/material/Box';
|
|
3
|
+
import FormControl from '@mui/material/FormControl';
|
|
4
|
+
import Select from '@mui/material/Select';
|
|
5
|
+
import MenuItem from '@mui/material/MenuItem';
|
|
6
|
+
import useLocalStorage from 'react-use/lib/useLocalStorage';
|
|
7
|
+
import { LogTerminalGroup } from '../logs/log-terminal';
|
|
8
|
+
import DownloadLog from '../logs/download';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* - heights:
|
|
12
|
+
* - header: 64
|
|
13
|
+
* - footer:
|
|
14
|
+
* - xs: 57 + 64
|
|
15
|
+
* - sm: 109 + 64
|
|
16
|
+
* - main content top:
|
|
17
|
+
* - xs: 211 + 32 + 16
|
|
18
|
+
* - md: 160 + 32 + 16
|
|
19
|
+
* - content height:
|
|
20
|
+
* - xs (Mobile) = 100vh - 444
|
|
21
|
+
* - sm (Mobile) = 100vh - 508
|
|
22
|
+
* - md (PC) = 100vh - 445
|
|
23
|
+
*/
|
|
24
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
25
|
+
export default function BlockletLog({
|
|
26
|
+
blocklet,
|
|
27
|
+
...rest
|
|
28
|
+
}) {
|
|
29
|
+
const initialData = ['Tip: this tab will only show runtime logs. Please go to "Blocklet Server" to view other lifecycle logs of the blocklet (install/start/stop...)', '\r\n\r\n'];
|
|
30
|
+
const logs = (blocklet?.children || []).map(x => ({
|
|
31
|
+
did: x.meta.did,
|
|
32
|
+
name: x.meta.title,
|
|
33
|
+
types: ['error', 'info', 'access', 'stdout', 'stderr']
|
|
34
|
+
}));
|
|
35
|
+
|
|
36
|
+
// format: `{componentId},{defaultTypeIndex}`
|
|
37
|
+
const [config, setConfig] = useLocalStorage(`blocklet-log-${blocklet.meta.did}`, '');
|
|
38
|
+
|
|
39
|
+
// eslint-disable-next-line prefer-const
|
|
40
|
+
let [componentId, defaultTypeIndex] = config.split(',');
|
|
41
|
+
if (!logs.find(x => x.did === componentId)) {
|
|
42
|
+
componentId = logs[0]?.did;
|
|
43
|
+
}
|
|
44
|
+
const onSelectChange = e => {
|
|
45
|
+
setConfig([e.target.value, defaultTypeIndex].join(','));
|
|
46
|
+
};
|
|
47
|
+
const componentSelect = /*#__PURE__*/_jsx(FormControl, {
|
|
48
|
+
sx: {
|
|
49
|
+
minWidth: 240
|
|
50
|
+
},
|
|
51
|
+
children: /*#__PURE__*/_jsx(Select, {
|
|
52
|
+
value: componentId,
|
|
53
|
+
onChange: onSelectChange,
|
|
54
|
+
size: "small",
|
|
55
|
+
children: logs.map(x => /*#__PURE__*/_jsx(MenuItem, {
|
|
56
|
+
value: x.did,
|
|
57
|
+
children: x.name
|
|
58
|
+
}, x.did))
|
|
59
|
+
})
|
|
60
|
+
});
|
|
61
|
+
const log = logs.find(item => item.did === componentId) || logs[0] || blocklet.meta;
|
|
62
|
+
const onTypeChange = type => {
|
|
63
|
+
const index = log.types.indexOf(type);
|
|
64
|
+
setConfig([componentId, index || 0].join(','));
|
|
65
|
+
};
|
|
66
|
+
return /*#__PURE__*/_jsx(Box, {
|
|
67
|
+
height: {
|
|
68
|
+
xs: 'calc(100vh - 444px)',
|
|
69
|
+
sm: 'calc(100vh - 508px)',
|
|
70
|
+
md: 'calc(100vh - 445px)'
|
|
71
|
+
},
|
|
72
|
+
...rest,
|
|
73
|
+
children: /*#__PURE__*/_jsx(LogTerminalGroup, {
|
|
74
|
+
logId: log === blocklet.meta ? `blocklet-${blocklet.meta.did}` : `blocklet-${blocklet.meta.did}/${log.did}`,
|
|
75
|
+
initialData: initialData,
|
|
76
|
+
prepend: componentSelect,
|
|
77
|
+
postpend: /*#__PURE__*/_jsx(DownloadLog, {
|
|
78
|
+
id: blocklet.meta.did,
|
|
79
|
+
name: blocklet.meta.name
|
|
80
|
+
}),
|
|
81
|
+
name: log.name,
|
|
82
|
+
types: log.types,
|
|
83
|
+
defaultTypeIndex: defaultTypeIndex,
|
|
84
|
+
onTypeChange: onTypeChange
|
|
85
|
+
}, log.did)
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
BlockletLog.propTypes = {
|
|
89
|
+
blocklet: PropTypes.object.isRequired
|
|
90
|
+
};
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import Box from '@mui/material/Box';
|
|
3
|
+
import Alert from '@arcblock/ux/lib/Alert';
|
|
4
|
+
import Button from '@arcblock/ux/lib/Button';
|
|
5
|
+
import { APP_STRUCT_VERSION, DEFAULT_DID_DOMAIN, DEFAULT_IP_DOMAIN_SUFFIX } from '@abtnode/constant';
|
|
6
|
+
import DidConnect from '@arcblock/did-connect/lib/Connect';
|
|
7
|
+
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
8
|
+
import { getDisplayName, forEachBlockletSync } from '@blocklet/meta/lib/util';
|
|
9
|
+
import Toast from '@arcblock/ux/lib/Toast';
|
|
10
|
+
import { useNodeContext } from '../contexts/node';
|
|
11
|
+
import { useBlockletContext } from '../contexts/blocklet';
|
|
12
|
+
import { useSessionContext } from '../contexts/session';
|
|
13
|
+
import { formatError } from '../util';
|
|
14
|
+
import { getWalletType } from './util';
|
|
15
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
|
+
const findDuplicate = blocklet => {
|
|
18
|
+
const map = {};
|
|
19
|
+
let duplicate = null;
|
|
20
|
+
forEachBlockletSync(blocklet, component => {
|
|
21
|
+
if (map[component.meta.bundleDid]) {
|
|
22
|
+
duplicate = getDisplayName(component, true);
|
|
23
|
+
} else if (component.meta.bundleDid) {
|
|
24
|
+
map[component.meta.bundleDid] = true;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
return duplicate;
|
|
28
|
+
};
|
|
29
|
+
const getNewHref = (location, blocklet, inService) => {
|
|
30
|
+
const {
|
|
31
|
+
hostname,
|
|
32
|
+
href
|
|
33
|
+
} = location;
|
|
34
|
+
if (!blocklet) {
|
|
35
|
+
return href;
|
|
36
|
+
}
|
|
37
|
+
if (inService) {
|
|
38
|
+
const ipRegex = /\d+[-.]\d+[-.]\d+[-.]\d+/;
|
|
39
|
+
const match = ipRegex.exec(hostname);
|
|
40
|
+
if (!match) {
|
|
41
|
+
return href;
|
|
42
|
+
}
|
|
43
|
+
const ip = match[0];
|
|
44
|
+
const didDomain = (blocklet.site?.domainAliases || []).map(x => x.value).filter(Boolean).find(x => x.endsWith(DEFAULT_DID_DOMAIN)) || '';
|
|
45
|
+
const base32Did = didDomain.replace(`.${DEFAULT_DID_DOMAIN}`, '');
|
|
46
|
+
if (!base32Did) {
|
|
47
|
+
return href;
|
|
48
|
+
}
|
|
49
|
+
return href.replace(hostname, `${base32Did}-${ip}.${DEFAULT_IP_DOMAIN_SUFFIX}`);
|
|
50
|
+
}
|
|
51
|
+
return href.replace(blocklet.meta.bundleDid, blocklet.appPid);
|
|
52
|
+
};
|
|
53
|
+
export default function BlockletMigration() {
|
|
54
|
+
const {
|
|
55
|
+
t
|
|
56
|
+
} = useLocaleContext();
|
|
57
|
+
const {
|
|
58
|
+
api
|
|
59
|
+
} = useSessionContext();
|
|
60
|
+
const {
|
|
61
|
+
blocklet
|
|
62
|
+
} = useBlockletContext();
|
|
63
|
+
const {
|
|
64
|
+
inService
|
|
65
|
+
} = useNodeContext();
|
|
66
|
+
const [openConnect, setOpenConnect] = useState(false);
|
|
67
|
+
const [leftSec, setLeftSec] = useState(5);
|
|
68
|
+
const needMigration = blocklet && blocklet.structVersion !== APP_STRUCT_VERSION;
|
|
69
|
+
const onMigrate = () => {
|
|
70
|
+
try {
|
|
71
|
+
if (blocklet.status === 'running') {
|
|
72
|
+
Toast.error(t('blocklet.migrate.tip.running'));
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const duplicate = findDuplicate(blocklet);
|
|
76
|
+
if (duplicate) {
|
|
77
|
+
Toast.error(t('blocklet.migrate.tip.duplicate', {
|
|
78
|
+
name: duplicate
|
|
79
|
+
}));
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
setOpenConnect(true);
|
|
83
|
+
} catch (error) {
|
|
84
|
+
Toast.error(formatError(error));
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
const onSuccess = () => {
|
|
88
|
+
const newHref = getNewHref(window.location, blocklet, inService);
|
|
89
|
+
setTimeout(() => {
|
|
90
|
+
window.location.href = newHref;
|
|
91
|
+
}, 5000);
|
|
92
|
+
setLeftSec(5);
|
|
93
|
+
setInterval(() => {
|
|
94
|
+
setLeftSec(sec => sec - 1);
|
|
95
|
+
}, 1000);
|
|
96
|
+
};
|
|
97
|
+
const onClose = () => setOpenConnect(false);
|
|
98
|
+
return [needMigration && /*#__PURE__*/_jsxs(Alert, {
|
|
99
|
+
type: "warning",
|
|
100
|
+
style: {
|
|
101
|
+
margin: '12px 0'
|
|
102
|
+
},
|
|
103
|
+
children: [/*#__PURE__*/_jsxs(Box, {
|
|
104
|
+
display: "flex",
|
|
105
|
+
alignItems: "center",
|
|
106
|
+
children: [/*#__PURE__*/_jsx(Button, {
|
|
107
|
+
variant: "contained",
|
|
108
|
+
size: "small",
|
|
109
|
+
color: "primary",
|
|
110
|
+
onClick: () => onMigrate(),
|
|
111
|
+
style: {
|
|
112
|
+
marginRight: 8
|
|
113
|
+
},
|
|
114
|
+
children: t('blocklet.migrate.intro.l1')
|
|
115
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
116
|
+
children: t('blocklet.migrate.intro.l2')
|
|
117
|
+
})]
|
|
118
|
+
}), ['l3', 'l4', 'l5', 'l6'].map(x => /*#__PURE__*/_jsx(Box, {
|
|
119
|
+
display: "flex",
|
|
120
|
+
alignItems: "center",
|
|
121
|
+
children: t(`blocklet.migrate.intro.${x}`)
|
|
122
|
+
}, x))]
|
|
123
|
+
}, "alert"), blocklet && /*#__PURE__*/_jsx(DidConnect, {
|
|
124
|
+
popup: true,
|
|
125
|
+
open: openConnect,
|
|
126
|
+
saveConnect: false,
|
|
127
|
+
forceConnected: false,
|
|
128
|
+
action: "migrate-app-to-struct-v2",
|
|
129
|
+
checkFn: api.get,
|
|
130
|
+
checkTimeout: 5 * 60 * 1000,
|
|
131
|
+
onSuccess: onSuccess,
|
|
132
|
+
extraParams: {
|
|
133
|
+
appDid: blocklet.appDid,
|
|
134
|
+
did: blocklet.meta.did,
|
|
135
|
+
wt: getWalletType(blocklet, true),
|
|
136
|
+
title: getDisplayName(blocklet)
|
|
137
|
+
},
|
|
138
|
+
messages: {
|
|
139
|
+
title: t('blocklet.migrate.title'),
|
|
140
|
+
scan: t('blocklet.migrate.scan'),
|
|
141
|
+
confirm: t('blocklet.migrate.confirm'),
|
|
142
|
+
success: leftSec >= 0 ? t('blocklet.migrate.success', {
|
|
143
|
+
sec: leftSec
|
|
144
|
+
}) : 'Redirecting...'
|
|
145
|
+
},
|
|
146
|
+
onClose: onClose
|
|
147
|
+
}, "connect")];
|
|
148
|
+
}
|
|
149
|
+
BlockletMigration.propTypes = {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import Tag from '../tag';
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
export default function BlockletMode({
|
|
5
|
+
mode,
|
|
6
|
+
...rest
|
|
7
|
+
}) {
|
|
8
|
+
if (mode === 'development') {
|
|
9
|
+
return /*#__PURE__*/_jsx(Tag, {
|
|
10
|
+
type: "primary",
|
|
11
|
+
...rest,
|
|
12
|
+
children: "DEV"
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
BlockletMode.propTypes = {
|
|
18
|
+
mode: PropTypes.string.isRequired
|
|
19
|
+
};
|