@abtnode/ux 1.16.14-beta-c308dc3b → 1.16.14-beta-963cb583
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 +1313 -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/selected/index.js +94 -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 +372 -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 +146 -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 +1541 -0
- package/es/locales/index.js +9 -0
- package/es/locales/zh.js +1544 -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 +55 -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 +127 -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 +160 -0
- package/es/who-can-access/config.js +38 -0
- package/es/wrap-locale.js +15 -0
- package/lib/blocklet/component/add.js +5 -0
- package/lib/blocklet/component/selected/index.js +47 -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 +6 -7
- 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/card-selector.js +14 -14
- package/lib/invitation/invitation-passport.js +7 -6
- package/lib/invitation/invitation-receive.js +1 -1
- package/lib/locales/en.js +12 -5
- package/lib/locales/zh.js +10 -3
- package/lib/lost-passport.js +2 -2
- package/lib/schema-form/passport-input.js +12 -11
- package/lib/team/passports/color.js +14 -14
- package/lib/team/passports/trusted-factory.js +1 -1
- package/lib/util/spaces.js +13 -1
- package/package.json +88 -21
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
import React, { useState, useContext } from 'react'; // eslint-disable-line
|
|
2
|
+
import styled from '@emotion/styled';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import Iframe from 'react-iframe';
|
|
5
|
+
import joinUrl from 'url-join';
|
|
6
|
+
import { WELLKNOWN_SERVICE_PATH_PREFIX } from '@abtnode/constant';
|
|
7
|
+
import { Grid, Box } from '@mui/material';
|
|
8
|
+
import GeneralIcon from '@mui/icons-material/TuneRounded';
|
|
9
|
+
import KeyIcon from '@mui/icons-material/Key';
|
|
10
|
+
import LoginIcon from '@mui/icons-material/Login';
|
|
11
|
+
import NotificationsNoneIcon from '@mui/icons-material/NotificationsNone';
|
|
12
|
+
import SettingsOutlinedIcon from '@mui/icons-material/SettingsOutlined';
|
|
13
|
+
import ChevronRightIcon from '@mui/icons-material/ChevronRight';
|
|
14
|
+
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
|
15
|
+
import { useSearchParams } from 'react-router-dom';
|
|
16
|
+
import { LocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
17
|
+
import Tabs from '@arcblock/ux/lib/Tabs';
|
|
18
|
+
import { getDisplayName } from '@blocklet/meta/lib/util';
|
|
19
|
+
import BlockletBundleAvatar from '../bundle-avatar';
|
|
20
|
+
import BlockletAppAvatar from '../app-avatar';
|
|
21
|
+
import BlockletConfiguration from '../configuration';
|
|
22
|
+
import BlockletNotification from '../notification';
|
|
23
|
+
import Access from '../access/index';
|
|
24
|
+
import { useNodeContext } from '../../contexts/node';
|
|
25
|
+
import OAuth from '../oauth';
|
|
26
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
27
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
28
|
+
const addComponentTabs = ({
|
|
29
|
+
tabs,
|
|
30
|
+
blocklet,
|
|
31
|
+
ancestors = [],
|
|
32
|
+
depth = 1,
|
|
33
|
+
t
|
|
34
|
+
}) => {
|
|
35
|
+
const key = [...ancestors.map(x => x.meta.did), blocklet.meta.did].join('/');
|
|
36
|
+
const isContainer = !ancestors?.length;
|
|
37
|
+
tabs.push({
|
|
38
|
+
label: /*#__PURE__*/_jsxs(Box, {
|
|
39
|
+
pl: Math.max(1, depth - 1) * 2,
|
|
40
|
+
display: "flex",
|
|
41
|
+
alignItems: "center",
|
|
42
|
+
justifyContent: "flex-start",
|
|
43
|
+
children: [isContainer ? /*#__PURE__*/_jsx(BlockletAppAvatar, {
|
|
44
|
+
size: 24,
|
|
45
|
+
blocklet: blocklet
|
|
46
|
+
}) : /*#__PURE__*/_jsx(BlockletBundleAvatar, {
|
|
47
|
+
size: 24,
|
|
48
|
+
blocklet: blocklet,
|
|
49
|
+
ancestors: ancestors
|
|
50
|
+
}), /*#__PURE__*/_jsx(Box, {
|
|
51
|
+
ml: "16px",
|
|
52
|
+
children: /*#__PURE__*/_jsx(Box, {
|
|
53
|
+
style: {
|
|
54
|
+
color: '#222'
|
|
55
|
+
},
|
|
56
|
+
children: isContainer ? t('blocklet.component.container') : getDisplayName(blocklet, true)
|
|
57
|
+
})
|
|
58
|
+
})]
|
|
59
|
+
}, key),
|
|
60
|
+
value: key
|
|
61
|
+
});
|
|
62
|
+
if (blocklet.children.length > 0) {
|
|
63
|
+
blocklet.children.forEach(x => {
|
|
64
|
+
addComponentTabs({
|
|
65
|
+
tabs,
|
|
66
|
+
blocklet: x,
|
|
67
|
+
ancestors: [...ancestors, blocklet],
|
|
68
|
+
depth: depth + 1,
|
|
69
|
+
t
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
export default function BlockletPreferences({
|
|
75
|
+
blocklet,
|
|
76
|
+
onUpdate,
|
|
77
|
+
...rest
|
|
78
|
+
}) {
|
|
79
|
+
const {
|
|
80
|
+
t
|
|
81
|
+
} = useContext(LocaleContext);
|
|
82
|
+
const {
|
|
83
|
+
info,
|
|
84
|
+
inService
|
|
85
|
+
} = useNodeContext();
|
|
86
|
+
const [expandPref, setExpandPref] = useState(true);
|
|
87
|
+
const [searchParams, setSearchParams] = useSearchParams();
|
|
88
|
+
const current = searchParams.get('tab') || 'general';
|
|
89
|
+
const tabs = [{
|
|
90
|
+
label: /*#__PURE__*/_jsxs(Box, {
|
|
91
|
+
display: "flex",
|
|
92
|
+
alignItems: "center",
|
|
93
|
+
"data-cy": "configuration-tab-general",
|
|
94
|
+
children: [/*#__PURE__*/_jsx(GeneralIcon, {
|
|
95
|
+
sx: {
|
|
96
|
+
fontSize: 24
|
|
97
|
+
}
|
|
98
|
+
}), /*#__PURE__*/_jsx(Box, {
|
|
99
|
+
ml: "16px",
|
|
100
|
+
children: /*#__PURE__*/_jsx(Box, {
|
|
101
|
+
style: {
|
|
102
|
+
color: '#222'
|
|
103
|
+
},
|
|
104
|
+
children: t('common.general')
|
|
105
|
+
})
|
|
106
|
+
})]
|
|
107
|
+
}, "general"),
|
|
108
|
+
value: 'general'
|
|
109
|
+
}, {
|
|
110
|
+
label: /*#__PURE__*/_jsxs(Box, {
|
|
111
|
+
display: "flex",
|
|
112
|
+
alignItems: "center",
|
|
113
|
+
"data-cy": "configuration-tab-access",
|
|
114
|
+
children: [/*#__PURE__*/_jsx(KeyIcon, {
|
|
115
|
+
sx: {
|
|
116
|
+
fontSize: 24
|
|
117
|
+
}
|
|
118
|
+
}), /*#__PURE__*/_jsx(Box, {
|
|
119
|
+
ml: "16px",
|
|
120
|
+
children: /*#__PURE__*/_jsx(Box, {
|
|
121
|
+
style: {
|
|
122
|
+
color: '#222'
|
|
123
|
+
},
|
|
124
|
+
children: t('common.access')
|
|
125
|
+
})
|
|
126
|
+
})]
|
|
127
|
+
}, "access"),
|
|
128
|
+
value: 'access'
|
|
129
|
+
}, {
|
|
130
|
+
label: /*#__PURE__*/_jsxs(Box, {
|
|
131
|
+
display: "flex",
|
|
132
|
+
alignItems: "center",
|
|
133
|
+
"data-cy": "configuration-tab-oauth",
|
|
134
|
+
children: [/*#__PURE__*/_jsx(LoginIcon, {
|
|
135
|
+
sx: {
|
|
136
|
+
fontSize: 24
|
|
137
|
+
}
|
|
138
|
+
}), /*#__PURE__*/_jsx(Box, {
|
|
139
|
+
ml: "16px",
|
|
140
|
+
children: /*#__PURE__*/_jsx(Box, {
|
|
141
|
+
style: {
|
|
142
|
+
color: '#222'
|
|
143
|
+
},
|
|
144
|
+
children: t('common.login')
|
|
145
|
+
})
|
|
146
|
+
})]
|
|
147
|
+
}, "oauth"),
|
|
148
|
+
value: 'oauth'
|
|
149
|
+
}, {
|
|
150
|
+
label: /*#__PURE__*/_jsxs(Box, {
|
|
151
|
+
display: "flex",
|
|
152
|
+
alignItems: "center",
|
|
153
|
+
"data-cy": "configuration-tab-notification",
|
|
154
|
+
children: [/*#__PURE__*/_jsx(NotificationsNoneIcon, {
|
|
155
|
+
sx: {
|
|
156
|
+
fontSize: 24
|
|
157
|
+
}
|
|
158
|
+
}), /*#__PURE__*/_jsx(Box, {
|
|
159
|
+
ml: "16px",
|
|
160
|
+
children: /*#__PURE__*/_jsx(Box, {
|
|
161
|
+
style: {
|
|
162
|
+
color: '#222'
|
|
163
|
+
},
|
|
164
|
+
children: t('common.notification')
|
|
165
|
+
})
|
|
166
|
+
})]
|
|
167
|
+
}, "notification"),
|
|
168
|
+
value: 'notification'
|
|
169
|
+
}, {
|
|
170
|
+
label: /*#__PURE__*/_jsxs(Box, {
|
|
171
|
+
display: "flex",
|
|
172
|
+
alignItems: "center",
|
|
173
|
+
"data-cy": "configuration-tab-preference",
|
|
174
|
+
children: [/*#__PURE__*/_jsx(Box, {
|
|
175
|
+
ml: -2,
|
|
176
|
+
style: {
|
|
177
|
+
transform: 'translateY(2px)'
|
|
178
|
+
},
|
|
179
|
+
children: expandPref ? /*#__PURE__*/_jsx(ExpandMoreIcon, {
|
|
180
|
+
fontSize: "inherit"
|
|
181
|
+
}) : /*#__PURE__*/_jsx(ChevronRightIcon, {
|
|
182
|
+
fontSize: "inherit"
|
|
183
|
+
})
|
|
184
|
+
}), /*#__PURE__*/_jsx(SettingsOutlinedIcon, {
|
|
185
|
+
sx: {
|
|
186
|
+
fontSize: 24
|
|
187
|
+
}
|
|
188
|
+
}), /*#__PURE__*/_jsx(Box, {
|
|
189
|
+
ml: "16px",
|
|
190
|
+
children: /*#__PURE__*/_jsx(Box, {
|
|
191
|
+
style: {
|
|
192
|
+
color: '#222'
|
|
193
|
+
},
|
|
194
|
+
children: t('common.preferences')
|
|
195
|
+
})
|
|
196
|
+
})]
|
|
197
|
+
}, "preference"),
|
|
198
|
+
value: 'preference'
|
|
199
|
+
}];
|
|
200
|
+
if (expandPref) {
|
|
201
|
+
addComponentTabs({
|
|
202
|
+
tabs,
|
|
203
|
+
blocklet,
|
|
204
|
+
t
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
const onTabChange = x => {
|
|
208
|
+
if (x === 'preference') {
|
|
209
|
+
setExpandPref(!expandPref);
|
|
210
|
+
} else {
|
|
211
|
+
setSearchParams(prev => {
|
|
212
|
+
if (x === 'general') {
|
|
213
|
+
prev.delete('tab');
|
|
214
|
+
} else {
|
|
215
|
+
prev.set('tab', x);
|
|
216
|
+
}
|
|
217
|
+
return prev;
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
let content = null;
|
|
222
|
+
if (current === 'general') {
|
|
223
|
+
content = /*#__PURE__*/_jsx(BlockletConfiguration, {
|
|
224
|
+
blocklet: blocklet,
|
|
225
|
+
onUpdate: onUpdate
|
|
226
|
+
});
|
|
227
|
+
} else if (current === 'access') {
|
|
228
|
+
content = /*#__PURE__*/_jsx(Access, {});
|
|
229
|
+
} else if (current === 'oauth') {
|
|
230
|
+
content = /*#__PURE__*/_jsx(OAuth, {});
|
|
231
|
+
} else if (current === 'notification') {
|
|
232
|
+
content = /*#__PURE__*/_jsx(BlockletNotification, {});
|
|
233
|
+
} else {
|
|
234
|
+
// eslint-disable-next-line no-nested-ternary
|
|
235
|
+
const pathPrefix = inService ? WELLKNOWN_SERVICE_PATH_PREFIX : process.env.NODE_ENV === 'production' ? info.routing.adminPath : '';
|
|
236
|
+
const urlSearchParams = new URLSearchParams();
|
|
237
|
+
if (!inService) {
|
|
238
|
+
urlSearchParams.set('authKey', '__sst');
|
|
239
|
+
}
|
|
240
|
+
urlSearchParams.set('schemaKey', joinUrl(window.location.origin, pathPrefix, `/api/preferences?id=${encodeURIComponent(current)}`));
|
|
241
|
+
content = /*#__PURE__*/_jsx(Iframe, {
|
|
242
|
+
url: `${joinUrl(window.location.origin, pathPrefix, '/hosted/form-collector/')}?${urlSearchParams.toString()}`,
|
|
243
|
+
width: "100%",
|
|
244
|
+
height: "100%",
|
|
245
|
+
frameBorder: 0,
|
|
246
|
+
styles: {
|
|
247
|
+
border: 0
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
return /*#__PURE__*/_jsx(Div, {
|
|
252
|
+
...rest,
|
|
253
|
+
children: /*#__PURE__*/_jsxs(Grid, {
|
|
254
|
+
container: true,
|
|
255
|
+
spacing: 4,
|
|
256
|
+
columns: 24,
|
|
257
|
+
children: [/*#__PURE__*/_jsx(Grid, {
|
|
258
|
+
item: true,
|
|
259
|
+
sm: 7,
|
|
260
|
+
md: 5,
|
|
261
|
+
children: /*#__PURE__*/_jsx(Tabs, {
|
|
262
|
+
tabs: tabs,
|
|
263
|
+
current: current,
|
|
264
|
+
orientation: "vertical",
|
|
265
|
+
onChange: onTabChange,
|
|
266
|
+
sx: {
|
|
267
|
+
borderRight: 1,
|
|
268
|
+
height: '100%',
|
|
269
|
+
borderColor: 'divider'
|
|
270
|
+
}
|
|
271
|
+
})
|
|
272
|
+
}), /*#__PURE__*/_jsx(Grid, {
|
|
273
|
+
item: true,
|
|
274
|
+
sm: 17,
|
|
275
|
+
md: 19,
|
|
276
|
+
children: /*#__PURE__*/_jsx(Box, {
|
|
277
|
+
style: {
|
|
278
|
+
minHeight: '66vh',
|
|
279
|
+
height: '100%',
|
|
280
|
+
position: 'relative',
|
|
281
|
+
overflow: 'hidden'
|
|
282
|
+
},
|
|
283
|
+
children: content
|
|
284
|
+
})
|
|
285
|
+
})]
|
|
286
|
+
})
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
BlockletPreferences.propTypes = {
|
|
290
|
+
blocklet: PropTypes.object.isRequired,
|
|
291
|
+
onUpdate: PropTypes.func
|
|
292
|
+
};
|
|
293
|
+
BlockletPreferences.defaultProps = {
|
|
294
|
+
onUpdate: () => {}
|
|
295
|
+
};
|
|
296
|
+
const Div = styled.div`
|
|
297
|
+
.MuiTab-root {
|
|
298
|
+
text-align: left;
|
|
299
|
+
align-items: flex-start;
|
|
300
|
+
font-weight: normal;
|
|
301
|
+
}
|
|
302
|
+
.Mui-selected {
|
|
303
|
+
font-weight: bold;
|
|
304
|
+
}
|
|
305
|
+
`;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { makeStyles } from '@mui/styles';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import List from '@mui/material/List';
|
|
4
|
+
import ListItem from '@mui/material/ListItem';
|
|
5
|
+
import ListItemText from '@mui/material/ListItemText';
|
|
6
|
+
import ListItemIcon from '@mui/material/ListItemIcon';
|
|
7
|
+
import IconPurchase from '@mui/icons-material/ShoppingCart';
|
|
8
|
+
import IconVerify from '@mui/icons-material/VerifiedUser';
|
|
9
|
+
import Button from '@arcblock/ux/lib/Button';
|
|
10
|
+
import colors from '@arcblock/ux/lib/Colors';
|
|
11
|
+
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
15
|
+
const commonProps = {
|
|
16
|
+
meta: PropTypes.object.isRequired,
|
|
17
|
+
onCancel: PropTypes.func.isRequired
|
|
18
|
+
};
|
|
19
|
+
const useStyles = makeStyles(() => ({
|
|
20
|
+
dialogAuth: {
|
|
21
|
+
padding: '0 0 24px !important',
|
|
22
|
+
'& .auth-title': {
|
|
23
|
+
textAlign: 'center !important',
|
|
24
|
+
marginBottom: '4px !important'
|
|
25
|
+
},
|
|
26
|
+
'& .auth-tip--scan': {
|
|
27
|
+
textAlign: 'center !important'
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
iconRoot: {
|
|
31
|
+
minWidth: 48
|
|
32
|
+
}
|
|
33
|
+
}));
|
|
34
|
+
function CustomSelect({
|
|
35
|
+
action,
|
|
36
|
+
onSelect,
|
|
37
|
+
onNext
|
|
38
|
+
}) {
|
|
39
|
+
const classes = useStyles();
|
|
40
|
+
const {
|
|
41
|
+
t
|
|
42
|
+
} = useLocaleContext();
|
|
43
|
+
const options = [{
|
|
44
|
+
action: 'purchase',
|
|
45
|
+
title: t('store.purchase.purchase.title'),
|
|
46
|
+
description: t('store.purchase.purchase.description')
|
|
47
|
+
}, {
|
|
48
|
+
action: 'verify',
|
|
49
|
+
title: t('store.purchase.verify.title'),
|
|
50
|
+
description: t('store.purchase.verify.description')
|
|
51
|
+
}];
|
|
52
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
53
|
+
children: [/*#__PURE__*/_jsx(List, {
|
|
54
|
+
className: classes.tabPanel,
|
|
55
|
+
children: options.map(x => /*#__PURE__*/_jsxs(ListItem, {
|
|
56
|
+
button: true,
|
|
57
|
+
selected: action === x.action,
|
|
58
|
+
onClick: () => onSelect(x.action),
|
|
59
|
+
children: [/*#__PURE__*/_jsx(ListItemIcon, {
|
|
60
|
+
className: classes.iconRoot,
|
|
61
|
+
children: x.action === 'purchase' ? /*#__PURE__*/_jsx(IconPurchase, {
|
|
62
|
+
style: {
|
|
63
|
+
color: action === 'purchase' ? colors.primary.main : '#AAA',
|
|
64
|
+
fontSize: 32
|
|
65
|
+
}
|
|
66
|
+
}) : /*#__PURE__*/_jsx(IconVerify, {
|
|
67
|
+
style: {
|
|
68
|
+
color: action === 'verify' ? colors.primary.main : '#AAA',
|
|
69
|
+
fontSize: 32
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
}), /*#__PURE__*/_jsx(ListItemText, {
|
|
73
|
+
primary: x.title,
|
|
74
|
+
secondary: x.description
|
|
75
|
+
})]
|
|
76
|
+
}, x.action))
|
|
77
|
+
}), onNext && /*#__PURE__*/_jsx(Button, {
|
|
78
|
+
fullWidth: true,
|
|
79
|
+
disabled: !action,
|
|
80
|
+
variant: "contained",
|
|
81
|
+
color: "primary",
|
|
82
|
+
style: {
|
|
83
|
+
marginTop: 16
|
|
84
|
+
},
|
|
85
|
+
onClick: onNext,
|
|
86
|
+
children: t('common.next')
|
|
87
|
+
})]
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
CustomSelect.propTypes = {
|
|
91
|
+
action: PropTypes.oneOf(['both', 'purchase', 'verify']).isRequired,
|
|
92
|
+
onSelect: PropTypes.func.isRequired,
|
|
93
|
+
onNext: PropTypes.func.isRequired
|
|
94
|
+
};
|
|
95
|
+
export { useStyles, commonProps, CustomSelect };
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
/* eslint-disable react/jsx-one-expression-per-line */
|
|
2
|
+
import { useState, useEffect, useImperativeHandle, forwardRef } from 'react';
|
|
3
|
+
import joinUrl from 'url-join';
|
|
4
|
+
import { getDisplayName } from '@blocklet/meta/lib/util';
|
|
5
|
+
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
6
|
+
import DidConnect from '@arcblock/did-connect/lib/Connect';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import pWaitFor from 'p-wait-for';
|
|
9
|
+
import Toast from '@arcblock/ux/lib/Toast';
|
|
10
|
+
import { useNodeContext } from '../../contexts/node';
|
|
11
|
+
import { getWebWalletUrl, extractStatusUrlFromNextWorkflow } from '../../util';
|
|
12
|
+
import { api as $api, axios } from '../../util/api';
|
|
13
|
+
import { commonProps, CustomSelect } from './common';
|
|
14
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
16
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
|
+
export function ComponentPurchase({
|
|
18
|
+
meta,
|
|
19
|
+
onCancel,
|
|
20
|
+
mode,
|
|
21
|
+
handlePaySuccess
|
|
22
|
+
}) {
|
|
23
|
+
const {
|
|
24
|
+
t,
|
|
25
|
+
locale
|
|
26
|
+
} = useLocaleContext();
|
|
27
|
+
const {
|
|
28
|
+
info
|
|
29
|
+
} = useNodeContext();
|
|
30
|
+
const webWalletUrl = getWebWalletUrl(info);
|
|
31
|
+
const [nw, setNw] = useState(null);
|
|
32
|
+
const baseUrl = new URL(meta?.registryUrl).origin;
|
|
33
|
+
const name = getDisplayName({
|
|
34
|
+
meta
|
|
35
|
+
});
|
|
36
|
+
const handleConnectSuccess = async (result, decrypt) => {
|
|
37
|
+
const success = ({
|
|
38
|
+
downloadTokenList
|
|
39
|
+
}) => {
|
|
40
|
+
handlePaySuccess({
|
|
41
|
+
downloadTokenList
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
const failure = errorMessage => {
|
|
45
|
+
Toast.error(errorMessage);
|
|
46
|
+
onCancel(errorMessage);
|
|
47
|
+
};
|
|
48
|
+
function handleConnectSessionStatus(url) {
|
|
49
|
+
return pWaitFor(() => {
|
|
50
|
+
return $api.get(url).then(async ({
|
|
51
|
+
data
|
|
52
|
+
}) => {
|
|
53
|
+
const downloadTokenList = data?.downloadTokenList;
|
|
54
|
+
if (data.status === 'succeed') {
|
|
55
|
+
if (downloadTokenList && downloadTokenList.length) {
|
|
56
|
+
await success({
|
|
57
|
+
downloadTokenList
|
|
58
|
+
});
|
|
59
|
+
} else {
|
|
60
|
+
await failure(t('blocklet.component.missDownloadTokenTip'));
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
if (data.status === 'error') {
|
|
66
|
+
console.error('vc error: ', data);
|
|
67
|
+
await failure(data?.error);
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
return false;
|
|
71
|
+
});
|
|
72
|
+
}, {
|
|
73
|
+
interval: 1000
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
if (mode === 'purchase' && nw) {
|
|
77
|
+
const {
|
|
78
|
+
statusUrl
|
|
79
|
+
} = extractStatusUrlFromNextWorkflow(nw);
|
|
80
|
+
// poll status url, to get download token
|
|
81
|
+
await handleConnectSessionStatus(statusUrl);
|
|
82
|
+
} else {
|
|
83
|
+
await success({
|
|
84
|
+
downloadTokenList: result.downloadTokenList && decrypt(result.downloadTokenList)
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
// only purchase mode has nw
|
|
90
|
+
if (mode === 'purchase') {
|
|
91
|
+
const nextWorkflowUrl = new URL(baseUrl);
|
|
92
|
+
nextWorkflowUrl.pathname = '/api/did/verify-purchase-blocklet/token';
|
|
93
|
+
nextWorkflowUrl.searchParams.set('serverDid', info.did);
|
|
94
|
+
nextWorkflowUrl.searchParams.set('blockletDid', meta?.did);
|
|
95
|
+
try {
|
|
96
|
+
$api.get(nextWorkflowUrl.href).then(({
|
|
97
|
+
data
|
|
98
|
+
}) => {
|
|
99
|
+
const url = `${data.url}`;
|
|
100
|
+
setNw(url);
|
|
101
|
+
});
|
|
102
|
+
} catch (error) {
|
|
103
|
+
console.error('get next workflow url error: ', error);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return () => {
|
|
107
|
+
setNw(null);
|
|
108
|
+
};
|
|
109
|
+
}, [mode]); // eslint-disable-line
|
|
110
|
+
|
|
111
|
+
// If nw does not exist, then connect should not be render
|
|
112
|
+
if (mode === 'purchase' && !nw) {
|
|
113
|
+
return '';
|
|
114
|
+
}
|
|
115
|
+
const modePropsMap = {
|
|
116
|
+
verify: {
|
|
117
|
+
action: 'verify-purchase-blocklet',
|
|
118
|
+
checkFn: axios.create({
|
|
119
|
+
baseURL: baseUrl
|
|
120
|
+
}).get,
|
|
121
|
+
extraParams: {
|
|
122
|
+
serverDid: info.did,
|
|
123
|
+
blockletDid: meta?.did
|
|
124
|
+
},
|
|
125
|
+
messages: {
|
|
126
|
+
title: t('store.purchase.verify.auth.title', {
|
|
127
|
+
name
|
|
128
|
+
}),
|
|
129
|
+
scan: t('store.purchase.verify.auth.scan'),
|
|
130
|
+
confirm: t('store.purchase.verify.auth.confirm'),
|
|
131
|
+
success: t('store.purchase.verify.auth.success')
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
purchase: {
|
|
135
|
+
action: 'acquire-asset',
|
|
136
|
+
checkFn: axios.create({
|
|
137
|
+
baseURL: joinUrl(baseUrl, '/store')
|
|
138
|
+
}).get,
|
|
139
|
+
extraParams: {
|
|
140
|
+
factory: meta.nftFactory,
|
|
141
|
+
nw
|
|
142
|
+
},
|
|
143
|
+
messages: {
|
|
144
|
+
title: t('store.purchase.auth.title', {
|
|
145
|
+
name
|
|
146
|
+
}),
|
|
147
|
+
scan: t('store.purchase.auth.scan'),
|
|
148
|
+
confirm: t('store.purchase.auth.confirm'),
|
|
149
|
+
success: /*#__PURE__*/_jsxs(_Fragment, {
|
|
150
|
+
children: [/*#__PURE__*/_jsx("p", {
|
|
151
|
+
children: t('store.purchase.auth.success')
|
|
152
|
+
}), /*#__PURE__*/_jsx("p", {
|
|
153
|
+
children: t('blocklet.component.purchaseComponentSecondCheckTip')
|
|
154
|
+
})]
|
|
155
|
+
})
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
return /*#__PURE__*/_jsx(DidConnect, {
|
|
160
|
+
open: true,
|
|
161
|
+
locale: locale,
|
|
162
|
+
popup: false,
|
|
163
|
+
saveConnect: false,
|
|
164
|
+
className: "connect",
|
|
165
|
+
baseUrl: baseUrl,
|
|
166
|
+
onSuccess: handleConnectSuccess,
|
|
167
|
+
cancelWhenScanned: onCancel,
|
|
168
|
+
onClose: onCancel,
|
|
169
|
+
checkTimeout: 60 * 5000,
|
|
170
|
+
webWalletUrl: webWalletUrl,
|
|
171
|
+
disableClose: true,
|
|
172
|
+
showDownload: false,
|
|
173
|
+
...modePropsMap[mode]
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
ComponentPurchase.propTypes = {
|
|
177
|
+
...commonProps,
|
|
178
|
+
handlePaySuccess: PropTypes.func,
|
|
179
|
+
mode: PropTypes.oneOf(['verify', 'purchase']).isRequired
|
|
180
|
+
};
|
|
181
|
+
ComponentPurchase.defaultProps = {
|
|
182
|
+
handlePaySuccess: () => {}
|
|
183
|
+
};
|
|
184
|
+
const ComponentPurchaseSelect = /*#__PURE__*/forwardRef(({
|
|
185
|
+
mode,
|
|
186
|
+
...rest
|
|
187
|
+
}, ref) => {
|
|
188
|
+
const [action, setAction] = useState(mode !== 'both' ? mode : 'verify');
|
|
189
|
+
const [step, setStep] = useState(mode !== 'both' ? 2 : 1);
|
|
190
|
+
const onSelect = act => {
|
|
191
|
+
if (act === action) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
setAction(act);
|
|
195
|
+
};
|
|
196
|
+
const onNext = () => {
|
|
197
|
+
if (!action) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
if (step === 2) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
setStep(2);
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
// expose the func and activeStep
|
|
207
|
+
useImperativeHandle(ref, () => ({
|
|
208
|
+
onNext,
|
|
209
|
+
getCurrentStep: () => {
|
|
210
|
+
return step;
|
|
211
|
+
}
|
|
212
|
+
}));
|
|
213
|
+
if (step === 1) {
|
|
214
|
+
return /*#__PURE__*/_jsx("div", {
|
|
215
|
+
style: {
|
|
216
|
+
maxWidth: 520
|
|
217
|
+
},
|
|
218
|
+
children: /*#__PURE__*/_jsx(CustomSelect, {
|
|
219
|
+
action: action,
|
|
220
|
+
onNext: null,
|
|
221
|
+
onSelect: onSelect
|
|
222
|
+
})
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
return /*#__PURE__*/_jsx(ComponentPurchase, {
|
|
226
|
+
...rest,
|
|
227
|
+
mode: action
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
ComponentPurchaseSelect.propTypes = {
|
|
231
|
+
mode: PropTypes.oneOf(['both', 'verify', 'purchase']).isRequired,
|
|
232
|
+
ref: PropTypes.any
|
|
233
|
+
};
|
|
234
|
+
ComponentPurchaseSelect.defaultProps = {
|
|
235
|
+
ref: {}
|
|
236
|
+
};
|
|
237
|
+
export default ComponentPurchaseSelect;
|