@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.
Files changed (202) hide show
  1. package/es/actions.js +97 -0
  2. package/es/analytics/card.js +92 -0
  3. package/es/analytics/chart.js +96 -0
  4. package/es/analytics/cpu.js +36 -0
  5. package/es/analytics/disk.js +111 -0
  6. package/es/analytics/memory.js +72 -0
  7. package/es/analytics/runtime.js +173 -0
  8. package/es/analytics/traffic.js +259 -0
  9. package/es/blocklet/access/config-access.js +307 -0
  10. package/es/blocklet/access/index.js +216 -0
  11. package/es/blocklet/actions.js +474 -0
  12. package/es/blocklet/add-cert.js +177 -0
  13. package/es/blocklet/agreement-app.js +21 -0
  14. package/es/blocklet/agreement.js +127 -0
  15. package/es/blocklet/app-avatar.js +57 -0
  16. package/es/blocklet/audit-logs.js +259 -0
  17. package/es/blocklet/blocklet-source.js +48 -0
  18. package/es/blocklet/bundle-avatar.js +64 -0
  19. package/es/blocklet/component/add.js +1308 -0
  20. package/es/blocklet/component/configuration.js +122 -0
  21. package/es/blocklet/component/delete.js +134 -0
  22. package/es/blocklet/component/environment.js +370 -0
  23. package/es/blocklet/component/index.js +975 -0
  24. package/es/blocklet/component/line.js +20 -0
  25. package/es/blocklet/component/navigation/locale-tabs.js +225 -0
  26. package/es/blocklet/component/navigation/navigation-actions.js +112 -0
  27. package/es/blocklet/component/navigation/navigation-dialog.js +607 -0
  28. package/es/blocklet/component/navigation/navigation-preview.js +101 -0
  29. package/es/blocklet/component/navigation/simple-select.js +124 -0
  30. package/es/blocklet/component/select-store.js +155 -0
  31. package/es/blocklet/component/setting.js +109 -0
  32. package/es/blocklet/component/sortable-tree.js +126 -0
  33. package/es/blocklet/component/space-connector.js +199 -0
  34. package/es/blocklet/component/space-selector.js +178 -0
  35. package/es/blocklet/component/start.js +101 -0
  36. package/es/blocklet/component/store-blocklet-list.js +200 -0
  37. package/es/blocklet/component/switch-control.js +57 -0
  38. package/es/blocklet/config-navigation.js +331 -0
  39. package/es/blocklet/configuration.js +603 -0
  40. package/es/blocklet/disk-info.js +75 -0
  41. package/es/blocklet/icons.js +18 -0
  42. package/es/blocklet/install-from-url.js +337 -0
  43. package/es/blocklet/log.js +90 -0
  44. package/es/blocklet/migration.js +149 -0
  45. package/es/blocklet/mode.js +19 -0
  46. package/es/blocklet/notification/email.js +257 -0
  47. package/es/blocklet/notification/index.js +49 -0
  48. package/es/blocklet/oauth/auth0.js +145 -0
  49. package/es/blocklet/oauth/common-settings.js +133 -0
  50. package/es/blocklet/oauth/federated-detail-dialog.js +175 -0
  51. package/es/blocklet/oauth/federated-invite-dialog.js +83 -0
  52. package/es/blocklet/oauth/federated-join-dialog.js +111 -0
  53. package/es/blocklet/oauth/federated-site-list.js +338 -0
  54. package/es/blocklet/oauth/federated.js +81 -0
  55. package/es/blocklet/oauth/index.js +69 -0
  56. package/es/blocklet/overview.js +293 -0
  57. package/es/blocklet/page-group.js +19 -0
  58. package/es/blocklet/preferences/app-sk.js +142 -0
  59. package/es/blocklet/preferences/index.js +305 -0
  60. package/es/blocklet/purchase/common.js +95 -0
  61. package/es/blocklet/purchase/component-purchase.js +237 -0
  62. package/es/blocklet/purchase/index.js +4 -0
  63. package/es/blocklet/router/action/add-domain-alias.js +167 -0
  64. package/es/blocklet/router/action/add-rule.js +211 -0
  65. package/es/blocklet/router/action/config-routing-rule.js +232 -0
  66. package/es/blocklet/router/action/delete-domain-alias.js +99 -0
  67. package/es/blocklet/router/action/delete-rule.js +108 -0
  68. package/es/blocklet/router/action/update-rule.js +209 -0
  69. package/es/blocklet/router/domain-actions.js +64 -0
  70. package/es/blocklet/router/domain-status.js +88 -0
  71. package/es/blocklet/router/rule-actions.js +66 -0
  72. package/es/blocklet/router/rule-list.js +190 -0
  73. package/es/blocklet/router/util.js +131 -0
  74. package/es/blocklet/runtime-info.js +68 -0
  75. package/es/blocklet/status.js +91 -0
  76. package/es/blocklet/storage/action.js +134 -0
  77. package/es/blocklet/storage/backups.js +241 -0
  78. package/es/blocklet/storage/connect-to.js +373 -0
  79. package/es/blocklet/storage/connected.js +198 -0
  80. package/es/blocklet/storage/delete.js +113 -0
  81. package/es/blocklet/storage/disconnect.js +243 -0
  82. package/es/blocklet/storage/index.js +19 -0
  83. package/es/blocklet/storage/item.js +558 -0
  84. package/es/blocklet/storage/preview-nft.js +286 -0
  85. package/es/blocklet/transfer-owner.js +198 -0
  86. package/es/blocklet/types.js +18 -0
  87. package/es/blocklet/util.js +145 -0
  88. package/es/blocklet/version.js +141 -0
  89. package/es/card-selector.js +134 -0
  90. package/es/certificate.js +105 -0
  91. package/es/chain.js +13 -0
  92. package/es/click-to-copy.js +22 -0
  93. package/es/confirm.js +149 -0
  94. package/es/contexts/audit-log.js +152 -0
  95. package/es/contexts/blocklet.js +10 -0
  96. package/es/contexts/deleting-blocklets.js +70 -0
  97. package/es/contexts/node.js +17 -0
  98. package/es/contexts/session.js +8 -0
  99. package/es/contexts/team.js +10 -0
  100. package/es/delete-confirm.js +121 -0
  101. package/es/did-address.js +46 -0
  102. package/es/dot.js +14 -0
  103. package/es/exchange-passport.js +102 -0
  104. package/es/form/form-select-input.js +184 -0
  105. package/es/form/form-text-input.js +178 -0
  106. package/es/form/form-wrapper.js +88 -0
  107. package/es/form/input-triggers.js +98 -0
  108. package/es/form/required.js +8 -0
  109. package/es/hooks/blocklet.js +229 -0
  110. package/es/hooks/confirm.js +90 -0
  111. package/es/hooks/mobile-width.js +11 -0
  112. package/es/hooks/url-evaluation.js +155 -0
  113. package/es/hooks/use-app-logo.js +16 -0
  114. package/es/hooks/use-backup-progress.js +31 -0
  115. package/es/hooks/use-blocklet-info-for-connect-did-spaces.js +50 -0
  116. package/es/hooks/use-bundle-logo.js +27 -0
  117. package/es/hooks/use-navigation.js +347 -0
  118. package/es/hooks/use-passport-id.js +14 -0
  119. package/es/hooks/use-subscription.js +22 -0
  120. package/es/icons/empty-space-nft.svg +59 -0
  121. package/es/icons/empty-spaces-nft.svg +58 -0
  122. package/es/icons/long-arrow.svg +5 -0
  123. package/es/icons/space-connected.svg +3 -0
  124. package/es/icons/space-disconnect.svg +3 -0
  125. package/es/index.js +3 -0
  126. package/es/invitation/invitation-app.js +58 -0
  127. package/es/invitation/invitation-login.js +68 -0
  128. package/es/invitation/invitation-passport.js +144 -0
  129. package/es/invitation/invitation-receive.js +138 -0
  130. package/es/invitation/invitation-success.js +93 -0
  131. package/es/invitation/invitation-user.js +90 -0
  132. package/es/invitation/invitation.js +90 -0
  133. package/es/issue-passport.js +142 -0
  134. package/es/launch-blocklet/content-layout.js +58 -0
  135. package/es/launch-blocklet/page-header.js +43 -0
  136. package/es/layout/addon.js +114 -0
  137. package/es/layout/feedback.js +55 -0
  138. package/es/locales/en.js +1534 -0
  139. package/es/locales/index.js +9 -0
  140. package/es/locales/zh.js +1537 -0
  141. package/es/logs/clock.js +11 -0
  142. package/es/logs/download.js +132 -0
  143. package/es/logs/log-terminal.js +253 -0
  144. package/es/lost-passport.js +452 -0
  145. package/es/nav-logo.js +219 -0
  146. package/es/passport-tag.js +43 -0
  147. package/es/permission.js +57 -0
  148. package/es/relative-time.js +53 -0
  149. package/es/result-message.js +11 -0
  150. package/es/schema-form/color-input.js +98 -0
  151. package/es/schema-form/common-prop-types.js +13 -0
  152. package/es/schema-form/index.js +215 -0
  153. package/es/schema-form/passport-input.js +54 -0
  154. package/es/schema-form/text-input.js +57 -0
  155. package/es/store/add.js +179 -0
  156. package/es/store/delete.js +96 -0
  157. package/es/store/item.js +76 -0
  158. package/es/subscription.js +144 -0
  159. package/es/table-icons.js +34 -0
  160. package/es/table.js +52 -0
  161. package/es/tag.js +21 -0
  162. package/es/team/members/actions.js +89 -0
  163. package/es/team/members/index.js +636 -0
  164. package/es/team/members/invitations.js +188 -0
  165. package/es/team/members/invite-member.js +208 -0
  166. package/es/team/members/issue-passport.js +152 -0
  167. package/es/team/members/member.js +408 -0
  168. package/es/team/members/passport-issuances.js +155 -0
  169. package/es/team/members/passports.js +364 -0
  170. package/es/team/members/toggle-user-approval.js +122 -0
  171. package/es/team/members/transfer-node.js +256 -0
  172. package/es/team/members/util.js +14 -0
  173. package/es/team/passports/color.js +126 -0
  174. package/es/team/passports/detail.js +312 -0
  175. package/es/team/passports/index.js +282 -0
  176. package/es/team/passports/mutate-role.js +198 -0
  177. package/es/team/passports/trusted-factories.js +221 -0
  178. package/es/team/passports/trusted-factory.js +343 -0
  179. package/es/team/passports/trusted-issuer.js +296 -0
  180. package/es/team/passports/trusted-issuers.js +226 -0
  181. package/es/team/search-input.js +46 -0
  182. package/es/team/styles/dialog.js +72 -0
  183. package/es/team/styles/list-header.js +31 -0
  184. package/es/util/api.js +6 -0
  185. package/es/util/constants.js +2 -0
  186. package/es/util/index.js +598 -0
  187. package/es/util/mode.js +4 -0
  188. package/es/util/space-gateway.js +51 -0
  189. package/es/util/spaces.js +151 -0
  190. package/es/who-can-access/config.js +38 -0
  191. package/es/wrap-locale.js +15 -0
  192. package/lib/blocklet/component/space-connector.js +1 -1
  193. package/lib/blocklet/component/space-selector.js +1 -1
  194. package/lib/blocklet/storage/backups.js +1 -1
  195. package/lib/blocklet/storage/connect-to.js +1 -1
  196. package/lib/blocklet/storage/connected.js +1 -1
  197. package/lib/blocklet/storage/disconnect.js +1 -1
  198. package/lib/blocklet/storage/index.js +1 -1
  199. package/lib/blocklet/storage/item.js +1 -1
  200. package/lib/invitation/invitation-receive.js +1 -1
  201. package/lib/team/passports/trusted-factory.js +1 -1
  202. package/package.json +81 -18
@@ -0,0 +1,1308 @@
1
+ /* eslint-disable react/no-unstable-nested-components */
2
+ import { useState, useRef, useImperativeHandle, forwardRef, useEffect } from 'react';
3
+ import PropTypes from 'prop-types';
4
+ import uniqBy from 'lodash/uniqBy';
5
+ import flatten from 'lodash/flatten';
6
+ import isEmpty from 'lodash/isEmpty';
7
+ import isNil from 'lodash/isNil';
8
+ import PageHeader from '@blocklet/launcher-layout/lib/page-header';
9
+ import Dialog from '@arcblock/ux/lib/Dialog';
10
+ import Spinner from '@mui/material/CircularProgress';
11
+ import DialogContentText from '@mui/material/DialogContentText';
12
+ import Typography from '@mui/material/Typography';
13
+ import TextField from '@mui/material/TextField';
14
+ import MenuItem from '@mui/material/MenuItem';
15
+ import AddIcon from '@mui/icons-material/Link';
16
+ import CheckIcon from '@mui/icons-material/Check';
17
+ import useMediaQuery from '@mui/material/useMediaQuery';
18
+ import styled from '@emotion/styled';
19
+ import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
20
+ import { BLOCKLET_CONFIGURABLE_KEY, BlockletStatus, BlockletEvents } from '@blocklet/constant';
21
+ import Layout from '@blocklet/launcher-layout';
22
+ import { StepProvider, useStepContext } from '@blocklet/launcher-layout/lib/context/step';
23
+ import Box from '@mui/material/Box';
24
+ import { NODE_MODES } from '@abtnode/constant';
25
+ import Button from '@arcblock/ux/lib/Button';
26
+ import Alert from '@arcblock/ux/lib/Alert';
27
+ import AnimationWaiter from '@arcblock/ux/lib/AnimationWaiter';
28
+ import ResultMessage from '@blocklet/launcher-layout/lib/launch-result-message';
29
+ import { getDisplayName, isComponentBlocklet, isFreeBlocklet, getSharedConfigObj } from '@blocklet/meta/lib/util';
30
+ import urlPathFriendly from '@blocklet/meta/lib/url-path-friendly';
31
+ import Toast from '@arcblock/ux/lib/Toast';
32
+ import { useNodeContext } from '../../contexts/node';
33
+ import { useBlockletContext } from '../../contexts/blocklet';
34
+ import { getBlockletLogoUrl, getBlockletMetaUrl, isNewStoreUrl, getStoreList, formatError, formatMountPoint } from '../../util';
35
+ import SchemaForm from '../../schema-form';
36
+ import Required from '../../form/required';
37
+ import { ComponentPurchaseSelect } from '../purchase';
38
+ import { validatePathPrefix } from '../router/util';
39
+ import Agreement from '../agreement';
40
+ import InstallFromUrl from '../install-from-url';
41
+ import SelectStore from './select-store';
42
+ import BlockletList from './store-blocklet-list';
43
+ import SpaceConnector from './space-connector';
44
+ import { jsx as _jsx } from "react/jsx-runtime";
45
+ import { jsxs as _jsxs } from "react/jsx-runtime";
46
+ import { Fragment as _Fragment } from "react/jsx-runtime";
47
+ const requirePurchase = meta => meta.inStore && isFreeBlocklet(meta) === false;
48
+ const getDIDSpaceCapability = meta => {
49
+ return meta?.capabilities?.didSpace;
50
+ };
51
+ const getDIDSpaceEndpoint = blocklet => {
52
+ return blocklet?.configs?.find(item => item.key === BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_SPACE_ENDPOINT)?.value || null;
53
+ };
54
+ const hasRequiredEnvironments = meta => (meta.environments || []).some(x => x.required);
55
+ const hasMissRequiredConfigs = (configsList, sharedValueMap) => {
56
+ return configsList?.some(item => {
57
+ return item.required && !sharedValueMap[item.key];
58
+ });
59
+ };
60
+ const getParamsName = (params = {}) => {
61
+ return params.title || params.name;
62
+ };
63
+ const StepContent = /*#__PURE__*/forwardRef(({
64
+ meta,
65
+ isMobile,
66
+ onStepChange
67
+ }, ref) => {
68
+ const {
69
+ steps,
70
+ activeStep,
71
+ setActiveStepByKey,
72
+ setActiveStepByIndex
73
+ } = useStepContext();
74
+ const {
75
+ t,
76
+ locale
77
+ } = useLocaleContext();
78
+ const step = steps[activeStep];
79
+ useEffect(() => {
80
+ onStepChange(activeStep);
81
+ }, [onStepChange, activeStep]);
82
+
83
+ // expose the func and activeStep
84
+ useImperativeHandle(ref, () => ({
85
+ setActiveStepByKey,
86
+ setActiveStepByIndex
87
+ }));
88
+ return /*#__PURE__*/_jsx(DialogContentWrapper, {
89
+ component: "div",
90
+ className: isMobile ? 'mobileStyle' : '',
91
+ children: /*#__PURE__*/_jsx(Layout, {
92
+ locale: locale,
93
+ blockletMeta: {
94
+ title: ' ',
95
+ ...meta
96
+ },
97
+ pcWidth: "100%",
98
+ pcHeight: "100%",
99
+ logoUrl: meta && meta.logo && meta.registryUrl ? getBlockletLogoUrl({
100
+ did: meta.did,
101
+ baseUrl: meta.registryUrl,
102
+ logoPath: meta.logo
103
+ }) : null,
104
+ stepTip: t('blocklet.component.add'),
105
+ children: /*#__PURE__*/_jsx(RightContent, {
106
+ children: step?.body && typeof step.body === 'function' ? step.body() : step.body
107
+ })
108
+ })
109
+ });
110
+ });
111
+ StepContent.propTypes = {
112
+ meta: PropTypes.any,
113
+ onStepChange: PropTypes.func.isRequired,
114
+ isMobile: PropTypes.bool.isRequired
115
+ };
116
+ StepContent.defaultProps = {
117
+ meta: null
118
+ };
119
+ export default function AddComponent({
120
+ blocklet,
121
+ children
122
+ }) {
123
+ const {
124
+ t,
125
+ locale
126
+ } = useLocaleContext();
127
+ const [loading, setLoading] = useState(false);
128
+ const [editingItem, setEditingItem] = useState(null);
129
+ const [error, setError] = useState('');
130
+ const [showDialog, setShowDialog] = useState('');
131
+ const [mountPointHelperText, setMountPointHelperText] = useState('');
132
+ const {
133
+ api,
134
+ ws: {
135
+ useSubscription
136
+ },
137
+ inService,
138
+ info: nodeInfo
139
+ } = useNodeContext();
140
+ const {
141
+ actions: {
142
+ refreshBlocklet: refreshApp
143
+ }
144
+ } = useBlockletContext();
145
+ const [purchaseData, setPurchaseData] = useState(null);
146
+ const [isWaitingPurchase, setIsWaitingPurchase] = useState(false);
147
+ const initParams = {
148
+ bundleDid: '',
149
+ componentDid: '',
150
+ componentName: '',
151
+ pathPrefix: '',
152
+ name: '',
153
+ title: '',
154
+ configsList: [],
155
+ configsValue: {},
156
+ hasMissRequiredConfigs: false,
157
+ hasEnvironmentsStep: false,
158
+ hasRequiredEnvironments: false,
159
+ requirePurchase: false,
160
+ didSpaceCapability: null,
161
+ installResultProps: {},
162
+ purchaseResultProps: {},
163
+ showFromUrlDialog: false
164
+ };
165
+ const [params, setParams] = useState(initParams);
166
+ const [activeStep, setActiveStep] = useState(0);
167
+ const component = useRef({});
168
+ const stepRef = useRef({});
169
+ const purchaseRef = useRef({});
170
+ const isMobile = useMediaQuery(theme => theme.breakpoints.down('md'));
171
+ const {
172
+ meta
173
+ } = component.current;
174
+ // eslint-disable-next-line no-unused-vars
175
+ const {
176
+ setActiveStepByIndex
177
+ } = stepRef.current || {};
178
+ const isServerlessMode = nodeInfo.mode === NODE_MODES.SERVERLESS;
179
+ const updateParams = obj => setParams(x => ({
180
+ ...x,
181
+ ...obj
182
+ }));
183
+ useEffect(() => {
184
+ if (params.pathPrefix) {
185
+ const {
186
+ errMsg
187
+ } = validateInput({
188
+ ...params,
189
+ pathPrefix: params.pathPrefix,
190
+ locale
191
+ });
192
+ setError(errMsg);
193
+ }
194
+ }, [params.pathPrefix]); // eslint-disable-line
195
+
196
+ useEffect(() => {
197
+ if (activeStep === 0) {
198
+ // reset params, when step change to select component
199
+ setParams(initParams);
200
+ }
201
+ }, [activeStep]); // eslint-disable-line
202
+
203
+ const getComponentName = () => {
204
+ if (component?.current?.meta) {
205
+ return getDisplayName(component.current);
206
+ }
207
+ return '';
208
+ };
209
+ const setInstallErrorResult = errorMessage => {
210
+ const update = _loading => {
211
+ updateParams({
212
+ installResultProps: {
213
+ variant: 'error',
214
+ title: getComponentName(),
215
+ subTitle: errorMessage,
216
+ footer: /*#__PURE__*/_jsx(Button, {
217
+ className: "bottom-button",
218
+ disabled: _loading,
219
+ "data-cy": "retry-install-component",
220
+ onClick: async () => {
221
+ // set button disabled and show spinner
222
+ update(true);
223
+ await onInstall(component.current.installInput);
224
+ },
225
+ children: /*#__PURE__*/_jsxs(Box, {
226
+ display: "flex",
227
+ alignItems: "center",
228
+ children: [_loading && /*#__PURE__*/_jsx(Spinner, {
229
+ size: 16,
230
+ style: {
231
+ marginRight: 8
232
+ }
233
+ }), t('common.retry')]
234
+ })
235
+ })
236
+ }
237
+ });
238
+ };
239
+ update();
240
+ };
241
+ const createBlockletEventHandler = handler => {
242
+ return b => {
243
+ if ((b?.meta?.did || b?.meta) === blocklet?.meta?.did) {
244
+ handler(b);
245
+ }
246
+ };
247
+ };
248
+ useSubscription(BlockletEvents.statusChange, createBlockletEventHandler(e => {
249
+ switch (e.status) {
250
+ case BlockletStatus.upgrading:
251
+ updateParams({
252
+ installResultProps: {
253
+ variant: 'success',
254
+ title: getComponentName(),
255
+ subTitle: t('blocklet.component.installSuccessTip')
256
+ }
257
+ });
258
+ break;
259
+ default:
260
+ }
261
+ }), [blocklet?.meta?.did]);
262
+ useSubscription(BlockletEvents.downloadFailed, createBlockletEventHandler(() => {
263
+ setInstallErrorResult(t('blocklet.component.installComponentError'));
264
+ }), [blocklet?.meta?.did]);
265
+ useSubscription(BlockletEvents.installFailed, createBlockletEventHandler(() => {
266
+ setInstallErrorResult(t('blocklet.component.installComponentError'));
267
+ }), [blocklet?.meta?.did]);
268
+ const onClose = () => {
269
+ setLoading(false);
270
+ setShowDialog(false);
271
+ setParams({});
272
+ component.current = {};
273
+ };
274
+ const onInstall = async payload => {
275
+ const {
276
+ pathPrefix: mountPoint,
277
+ bundleDid,
278
+ title,
279
+ componentName = '',
280
+ componentDid = ''
281
+ } = params;
282
+ // eslint-disable-next-line no-shadow
283
+ const {
284
+ configs = [],
285
+ registryUrl,
286
+ inStore,
287
+ inputUrl
288
+ } = component.current?.meta || {};
289
+ const downloadTokenList = component.current?.downloadTokenList;
290
+ const url = inStore ? getBlockletMetaUrl(registryUrl, bundleDid) : inputUrl;
291
+ setLoading(true);
292
+ const installInput = {
293
+ rootDid: blocklet.meta.did,
294
+ url,
295
+ mountPoint: urlPathFriendly(mountPoint),
296
+ title,
297
+ name: componentName,
298
+ did: componentDid,
299
+ // if blocklet has config, provide the configs
300
+ ...(params.hasEnvironmentsStep && configs.length > 0 ? {
301
+ configs: configs.map(item => {
302
+ return {
303
+ ...item,
304
+ value: params.configsValue[item.key] || ''
305
+ };
306
+ })
307
+ } : {}),
308
+ ...(downloadTokenList ? {
309
+ downloadTokenList
310
+ } : {}),
311
+ ...payload
312
+ };
313
+ try {
314
+ await api.installComponent({
315
+ input: installInput
316
+ });
317
+ if (registryUrl) {
318
+ const {
319
+ teamDid,
320
+ storeList
321
+ } = getStoreList({
322
+ fromBlocklet: inService,
323
+ nodeInfo,
324
+ blocklet
325
+ });
326
+ const {
327
+ isNew,
328
+ decoded
329
+ } = isNewStoreUrl(registryUrl, storeList);
330
+ if (isNew) {
331
+ await api.addBlockletStore({
332
+ input: {
333
+ teamDid,
334
+ url: decoded
335
+ }
336
+ });
337
+ }
338
+ }
339
+ updateParams({
340
+ installResultProps: {}
341
+ });
342
+
343
+ // let app state refresh fast before receive subscribe event
344
+ refreshApp({
345
+ showError: false,
346
+ attachRuntimeInfo: false
347
+ });
348
+ } catch (err) {
349
+ const errMsg = formatError(err);
350
+ Toast.error(errMsg);
351
+ console.error('installComponent error: ', err);
352
+ setInstallErrorResult(errMsg);
353
+ } finally {
354
+ setLoading(false);
355
+ component.current.installInput = installInput;
356
+ }
357
+ };
358
+ const validateInput = input => {
359
+ // FIXME: validatePathPrefix should be updated
360
+ const errMsg = validatePathPrefix({
361
+ params: {
362
+ ...input,
363
+ did: input.bundleDid
364
+ },
365
+ blocklets: [blocklet],
366
+ // blocklets: component.current?.blocklets?.map(x => ({ meta: x })) || [],
367
+ blocklet,
368
+ locale
369
+ });
370
+ return {
371
+ errMsg
372
+ };
373
+ };
374
+ const onNext = async payload => {
375
+ const {
376
+ errMsg
377
+ } = validateInput({
378
+ ...params,
379
+ locale
380
+ });
381
+ setError(errMsg);
382
+
383
+ // the step can complete, install component
384
+ if (activeStep === steps.length - 2) {
385
+ await onInstall(payload);
386
+ }
387
+ setActiveStepByIndex(x => x + 1);
388
+ };
389
+ const onCancel = () => {
390
+ setActiveStepByIndex(x => x - 1);
391
+ };
392
+ const onGeneratePurchaseData = () => {
393
+ const {
394
+ pathPrefix: mountPoint,
395
+ bundleDid,
396
+ title,
397
+ componentName = '',
398
+ componentDid = ''
399
+ } = params;
400
+
401
+ // eslint-disable-next-line no-shadow
402
+ const {
403
+ meta = {}
404
+ } = component.current || {};
405
+ const {
406
+ registryUrl,
407
+ inStore,
408
+ inputUrl
409
+ } = meta;
410
+ const url = inStore ? getBlockletMetaUrl(registryUrl, bundleDid) : inputUrl;
411
+ setPurchaseData({
412
+ meta,
413
+ installOpts: {
414
+ type: 'component',
415
+ rootDid: blocklet.meta.did,
416
+ mountPoint,
417
+ url,
418
+ title,
419
+ name: componentName,
420
+ did: componentDid
421
+ }
422
+ });
423
+ };
424
+ const onCancelPurchase = errorMessage => {
425
+ setIsWaitingPurchase(false);
426
+ updateParams({
427
+ purchaseResultProps: {
428
+ variant: 'error',
429
+ title: getComponentName(),
430
+ subTitle: errorMessage,
431
+ style: {
432
+ paddingTop: 120
433
+ },
434
+ footer: /*#__PURE__*/_jsx(Button, {
435
+ className: "bottom-button",
436
+ "data-cy": "retry-purchase-component",
437
+ onClick: () => {
438
+ updateParams({
439
+ purchaseResultProps: {}
440
+ });
441
+ },
442
+ children: t('common.retry')
443
+ })
444
+ }
445
+ });
446
+ };
447
+ const onSuccessPurchase = ({
448
+ downloadTokenList
449
+ }) => {
450
+ component.current.downloadTokenList = downloadTokenList;
451
+ setIsWaitingPurchase(false);
452
+ onNext();
453
+ };
454
+ const setConfigValue = ({
455
+ chooseParams = component.current,
456
+ componentDid: componentDidValue,
457
+ isInit = false
458
+ }) => {
459
+ // eslint-disable-next-line no-shadow
460
+ const {
461
+ meta,
462
+ registryUrl,
463
+ inStore,
464
+ inputUrl
465
+ } = chooseParams;
466
+ const {
467
+ did: bundleDid,
468
+ title,
469
+ name
470
+ } = meta;
471
+
472
+ // deleted history list
473
+ const list = (blocklet.settings?.children || []).filter(x => x.status === 'deleted' && x.meta.bundleDid === bundleDid);
474
+ const componentDid = componentDidValue || '';
475
+ const newConfigs = meta.environments?.map(item => {
476
+ const {
477
+ name: key,
478
+ validation,
479
+ ...rest
480
+ } = item;
481
+ const formatItem = {
482
+ // if the blocklet has validation, provide the validation (fix not inStore)
483
+ validation: isNil(validation) ? '' : validation
484
+ };
485
+ return {
486
+ ...rest,
487
+ key,
488
+ ...formatItem
489
+ };
490
+ });
491
+ component.current = {
492
+ ...chooseParams,
493
+ meta: {
494
+ ...meta,
495
+ // init configs from environments
496
+ configs: newConfigs,
497
+ registryUrl,
498
+ inStore,
499
+ inputUrl
500
+ }
501
+ };
502
+ let doc = {};
503
+
504
+ // if is init, should update configs
505
+ if (isInit) {
506
+ const ancestors = [blocklet];
507
+
508
+ // component config
509
+ const componentSelfConfigs = newConfigs || [];
510
+
511
+ // TODO: meta not include children environments/configs before install, waiting for next sprint to design
512
+ const componentChildrenConfigs = [];
513
+
514
+ // eslint-disable-next-line
515
+ // chooseBlocklet?.children?.map(childBlocklet => {
516
+ // // eslint-disable-next-line no-shadow
517
+ // forEachChildSync(childBlocklet, (b, { ancestors }) => {
518
+ // const ancestorDids = ancestors.slice(1).map(x => x.meta.did);
519
+
520
+ // componentChildrenConfigs.push(
521
+ // (b.configs || []).map(x => ({ ...x, childDid: ancestorDids.concat(b.meta.did) }))
522
+ // );
523
+ // });
524
+
525
+ // return false;
526
+ // });
527
+
528
+ const componentAllConfigs = uniqBy(flatten([...componentSelfConfigs, ...componentChildrenConfigs]), 'key').filter(x => !!x.key).sort((a, b) => {
529
+ if (a.required && !b.required) {
530
+ return -1;
531
+ }
532
+ if (b.required && !a.required) {
533
+ return 1;
534
+ }
535
+ return 0;
536
+ });
537
+ const sharedConfigObj = getSharedConfigObj({
538
+ configs: componentAllConfigs
539
+ }, ancestors);
540
+ const configsValue = {};
541
+ const configsList = componentAllConfigs.map(item => {
542
+ const {
543
+ default: defaultValue,
544
+ key,
545
+ ...rest
546
+ } = item;
547
+ configsValue[key] = sharedConfigObj[key] || defaultValue;
548
+ return {
549
+ ...rest,
550
+ key,
551
+ hidden: !!BLOCKLET_CONFIGURABLE_KEY[key]
552
+ };
553
+ });
554
+ doc = {
555
+ ...doc,
556
+ configsList,
557
+ configsValue,
558
+ hasMissRequiredConfigs: hasMissRequiredConfigs(configsList, configsValue)
559
+ };
560
+ }
561
+ const hasRootPath = blocklet.children.some(x => x.mountPoint === '/');
562
+
563
+ // use deleted history
564
+ const config = list.find(x => x.meta.bundleDid === bundleDid);
565
+ if (config) {
566
+ doc = {
567
+ ...doc,
568
+ pathPrefix: config.mountPoint,
569
+ title: title || '',
570
+ componentName: config.meta.name,
571
+ // use history's environments
572
+ hasEnvironmentsStep: false
573
+ };
574
+ } else {
575
+ doc = {
576
+ ...doc,
577
+ pathPrefix: hasRootPath ? `/${urlPathFriendly(name)}` : '/',
578
+ title: title || '',
579
+ componentName: '',
580
+ hasEnvironmentsStep: component.current.meta?.environments?.length > 0
581
+ };
582
+ }
583
+
584
+ // eslint-disable-next-line no-shadow
585
+ const componentRequirePurchase = requirePurchase(component.current.meta);
586
+ const componentDIDSpaceCapability = getDIDSpaceCapability(component.current.meta);
587
+ const didSpaceEndpoint = getDIDSpaceEndpoint(blocklet);
588
+ updateParams({
589
+ bundleDid,
590
+ componentDid,
591
+ ...doc,
592
+ hasRequiredEnvironments: hasRequiredEnvironments(component.current.meta),
593
+ requirePurchase: componentRequirePurchase,
594
+ didSpaceCapability: componentDIDSpaceCapability,
595
+ didSpaceEndpoint
596
+ });
597
+ if (isInit && componentRequirePurchase) {
598
+ onGeneratePurchaseData();
599
+ }
600
+ };
601
+ const steps = [{
602
+ key: 'selectComponent',
603
+ name: t('blocklet.component.selectComponent'),
604
+ body: /*#__PURE__*/_jsxs(TypographyWrapper, {
605
+ component: "div",
606
+ children: [params.showFromUrlDialog && /*#__PURE__*/_jsx(InstallFromUrl
607
+ // if not set defaultUrl, the dialog will always show step 1 when the dialog is opened
608
+ // defaultUrl={meta?.inputUrl}
609
+ , {
610
+ mode: "component",
611
+ onCancel: () => {
612
+ updateParams({
613
+ showFromUrlDialog: false
614
+ });
615
+ }
616
+ // eslint-disable-next-line no-shadow
617
+ ,
618
+ onSuccess: ({
619
+ meta,
620
+ inputUrl,
621
+ inStore,
622
+ registryUrl
623
+ }) => {
624
+ setConfigValue({
625
+ chooseParams: {
626
+ meta,
627
+ inputUrl,
628
+ inStore,
629
+ registryUrl
630
+ },
631
+ isInit: true
632
+ });
633
+ updateParams({
634
+ showFromUrlDialog: false
635
+ });
636
+ onNext();
637
+ },
638
+ handleText: {
639
+ title: t('blocklet.component.addComponentTip.fromUrl'),
640
+ confirm: t('blocklet.component.choose')
641
+ }
642
+ }), /*#__PURE__*/_jsx(SelectStore, {
643
+ extra: !isServerlessMode ? /*#__PURE__*/_jsxs(Button, {
644
+ variant: "text",
645
+ color: "primary",
646
+ "data-cy": "add-component-from-url",
647
+ onClick: () => {
648
+ updateParams({
649
+ showFromUrlDialog: true
650
+ });
651
+ },
652
+ style: {
653
+ padding: '0 2px'
654
+ },
655
+ children: [/*#__PURE__*/_jsx(AddIcon, {
656
+ style: {
657
+ fontSize: 20,
658
+ marginRight: 4
659
+ }
660
+ }), " ", t('blocklet.component.addComponentTip.fromUrl'), ' ']
661
+ }) : null,
662
+ loading: loading,
663
+ onChange: () => {
664
+ setParams({});
665
+ component.current = {};
666
+ },
667
+ children: ({
668
+ currentRegistry
669
+ }) => {
670
+ return /*#__PURE__*/_jsx(BlockletList, {
671
+ serverVersion: nodeInfo?.version,
672
+ style: isMobile ? {
673
+ // should remove other dom height/margin
674
+ height: 'calc(100vh - 56px - 80px - 32px - 40px )'
675
+ } : {
676
+ height: 'calc(100% - 40px)'
677
+ },
678
+ storeUrl: currentRegistry.url,
679
+ handleButtonClick: chooseParams => {
680
+ setConfigValue({
681
+ chooseParams: {
682
+ ...chooseParams,
683
+ inStore: true // choose from store, must be inStore
684
+ },
685
+
686
+ isInit: true
687
+ });
688
+ },
689
+ handleBlockletRender: ({
690
+ blocklet: blockletItem,
691
+ defaultRender
692
+ }) => {
693
+ const isChosen = params?.bundleDid && params?.bundleDid === blockletItem?.did;
694
+ return /*#__PURE__*/_jsxs(StoreBlockletItemWrapper, {
695
+ children: [isChosen && /*#__PURE__*/_jsx("div", {
696
+ className: "check-container",
697
+ children: /*#__PURE__*/_jsx(CheckIcon, {
698
+ className: "check-icon"
699
+ })
700
+ }), /*#__PURE__*/_jsx("div", {
701
+ className: isChosen ? 'choose-blocklet' : '',
702
+ style: {
703
+ marginLeft: 16
704
+ },
705
+ children: defaultRender
706
+ })]
707
+ });
708
+ },
709
+ extraFilter: allBlocklets => {
710
+ // only use blocklets that are component
711
+ return allBlocklets?.filter(x => {
712
+ if (!isComponentBlocklet(x)) {
713
+ return false;
714
+ }
715
+ if ((blocklet.children || []).some(y => y.meta.did === x.did)) {
716
+ return false;
717
+ }
718
+ return true;
719
+ });
720
+ }
721
+ });
722
+ }
723
+ })]
724
+ }),
725
+ cancel: t('common.cancel'),
726
+ confirm: getParamsName(params) ? t('blocklet.component.addNext', {
727
+ name: getParamsName(params)
728
+ }) : t('common.next'),
729
+ onCancel: onClose,
730
+ onConfirm: () => {
731
+ onNext();
732
+ }
733
+ }, {
734
+ key: 'agreement',
735
+ name: t('launchBlocklet.introduction'),
736
+ body: /*#__PURE__*/_jsxs(TypographyWrapper, {
737
+ component: "div",
738
+ className: "agreement-wrapper",
739
+ children: [/*#__PURE__*/_jsx(PageHeader, {
740
+ title: t('launchBlocklet.introduction'),
741
+ subTitle: t('blocklet.component.addComponentTip.introduction')
742
+ }), /*#__PURE__*/_jsx(Agreement, {
743
+ meta: meta,
744
+ onClickNext: onNext,
745
+ handleDescEle: /*#__PURE__*/_jsxs(_Fragment, {
746
+ children: [/*#__PURE__*/_jsx("p", {
747
+ children: /*#__PURE__*/_jsx("div", {
748
+ // eslint-disable-next-line
749
+ dangerouslySetInnerHTML: {
750
+ __html: t(`blocklet.component.addComponentTip.${params.requirePurchase ? 'isPurchase' : 'isFree'}`, {
751
+ name: getComponentName()
752
+ })
753
+ }
754
+ })
755
+ }), /*#__PURE__*/_jsx("p", {
756
+ children: t('blocklet.component.addComponentTip.belowInformation')
757
+ })]
758
+ })
759
+ })]
760
+ }),
761
+ cancel: t('common.pre'),
762
+ confirm: t('launchBlocklet.next'),
763
+ onCancel,
764
+ onConfirm: () => {
765
+ setIsWaitingPurchase(false);
766
+ onNext();
767
+ }
768
+ }, meta && params.requirePurchase && {
769
+ key: 'purchase',
770
+ name: /*#__PURE__*/_jsxs(_Fragment, {
771
+ children: [t('common.verifyNFT'), /*#__PURE__*/_jsx(Required, {})]
772
+ }),
773
+ body: /*#__PURE__*/_jsxs(TypographyWrapper, {
774
+ component: "div",
775
+ className: "flex-align-center",
776
+ style: {
777
+ flexDirection: 'column'
778
+ },
779
+ children: [!(purchaseRef.current?.getCurrentStep?.() === 2 || isWaitingPurchase) && /*#__PURE__*/_jsx(PageHeaderWrapper, {
780
+ title: t('common.verifyNFT'),
781
+ subTitle: t('blocklet.component.addComponentTip.verifyNFT')
782
+ }), !isEmpty(params.purchaseResultProps) ? /*#__PURE__*/_jsx("div", {
783
+ className: "flex-align-center flex-justify-center",
784
+ children: /*#__PURE__*/_jsx(ResultMessage, {
785
+ ...params.purchaseResultProps
786
+ })
787
+ }) : purchaseData && /*#__PURE__*/_jsx(ComponentPurchaseSelect, {
788
+ ref: purchaseRef,
789
+ meta: purchaseData.meta
790
+ // if select deleted history, use verify mode
791
+ ,
792
+ mode: params.componentDid ? 'verify' : 'both',
793
+ onCancel: onCancelPurchase,
794
+ installOpts: purchaseData.installOpts,
795
+ handlePaySuccess: onSuccessPurchase
796
+ })]
797
+ }),
798
+ disabled: purchaseRef.current?.getCurrentStep?.() === 2 || isWaitingPurchase,
799
+ cancel: t('common.pre'),
800
+ confirm: t('common.next'),
801
+ onConfirm: () => {
802
+ if (typeof purchaseRef.current.onNext === 'function') {
803
+ purchaseRef.current.onNext();
804
+ setIsWaitingPurchase(true);
805
+ }
806
+ },
807
+ onCancel: () => {
808
+ onCancel();
809
+ }
810
+ }, {
811
+ key: 'config',
812
+ name: t('common.config'),
813
+ error,
814
+ body: /*#__PURE__*/_jsxs(TypographyWrapper, {
815
+ component: "div",
816
+ children: [/*#__PURE__*/_jsx(PageHeaderWrapper, {
817
+ title: t('common.config'),
818
+ subTitle: t('blocklet.component.addComponentTip.config')
819
+ }), /*#__PURE__*/_jsx(TextField, {
820
+ label: t('blocklet.component.mountPoint'),
821
+ autoComplete: "off",
822
+ variant: "outlined",
823
+ name: "pathPrefix",
824
+ inputProps: {
825
+ 'data-cy': 'mount-point-input'
826
+ },
827
+ fullWidth: true,
828
+ helperText: mountPointHelperText || t('blocklet.component.mountPointTip'),
829
+ style: {
830
+ marginBottom: 32
831
+ },
832
+ margin: "normal",
833
+ value: params.pathPrefix,
834
+ onChange: e => {
835
+ const pathPrefix = e.target.value;
836
+ updateParams({
837
+ pathPrefix
838
+ });
839
+ setMountPointHelperText(t('common.slugifyHint', {
840
+ value: formatMountPoint(pathPrefix)
841
+ }));
842
+ }
843
+ }), !!error && /*#__PURE__*/_jsx(Alert, {
844
+ type: "error",
845
+ style: {
846
+ width: '100%',
847
+ marginTop: 8
848
+ },
849
+ children: error
850
+ })]
851
+ }),
852
+ cancel: t('common.pre'),
853
+ confirm: t('common.next'),
854
+ onCancel,
855
+ onConfirm: () => {
856
+ onNext();
857
+ }
858
+ }, meta && params?.hasEnvironmentsStep && {
859
+ key: 'environment',
860
+ name: /*#__PURE__*/_jsxs(_Fragment, {
861
+ children: [t('common.environment'), " ", params.hasRequiredEnvironments && /*#__PURE__*/_jsx(Required, {})]
862
+ }),
863
+ disabled: !!editingItem || params?.hasMissRequiredConfigs,
864
+ body: () => {
865
+ return /*#__PURE__*/_jsxs(TypographyWrapper, {
866
+ component: "div",
867
+ children: [/*#__PURE__*/_jsx(PageHeaderWrapper, {
868
+ title: t('common.environment'),
869
+ subTitle: t('blocklet.component.addComponentTip.environment')
870
+ }), /*#__PURE__*/_jsx(SchemaForm, {
871
+ style: {
872
+ marginTop: -12,
873
+ width: '100%'
874
+ },
875
+ schema: params.configsList,
876
+ defaultValue: params.configsValue
877
+ // eslint-disable-next-line
878
+ ,
879
+ onChange: (changeValue, {
880
+ action,
881
+ currentItem,
882
+ allValues
883
+ }) => {
884
+ if (action === 'confirm') {
885
+ updateParams({
886
+ hasMissRequiredConfigs: hasMissRequiredConfigs(params.configsList, allValues),
887
+ configsValue: allValues
888
+ });
889
+ }
890
+ if (action === 'edit') {
891
+ setEditingItem(currentItem);
892
+ } else if (['cancel', 'confirm'].includes(action)) {
893
+ setEditingItem(null);
894
+ }
895
+ }
896
+ })]
897
+ });
898
+ },
899
+ cancel: t('common.pre'),
900
+ confirm: t('common.next'),
901
+ onCancel,
902
+ onConfirm: onNext
903
+ }, meta && params?.didSpaceCapability && {
904
+ key: 'didSpace',
905
+ name: /*#__PURE__*/_jsxs(_Fragment, {
906
+ children: [t('blocklet.component.didSpaceConfig'), " ", params.didSpaceCapability === 'required' && /*#__PURE__*/_jsx(Required, {})]
907
+ }),
908
+ disabled: params.didSpaceCapability === 'required' && !params.didSpaceEndpoint,
909
+ body: () => {
910
+ return /*#__PURE__*/_jsxs(TypographyWrapper, {
911
+ component: "div",
912
+ children: [/*#__PURE__*/_jsx(PageHeaderWrapper, {
913
+ title: t('blocklet.component.didSpaceConfig'),
914
+ subTitle: t('blocklet.component.didSpaceConfigTip')
915
+ }), /*#__PURE__*/_jsx(Box, {
916
+ sx: {
917
+ mt: '36px',
918
+ '& > div': {
919
+ maxWidth: 'unset !important',
920
+ '& .MuiAutocomplete-root': {
921
+ maxWidth: 'unset !important'
922
+ }
923
+ }
924
+ },
925
+ children: /*#__PURE__*/_jsx(SpaceConnector, {
926
+ sx: {
927
+ '& .MuiFormHelperText-root': {
928
+ wordBreak: 'break-all'
929
+ }
930
+ },
931
+ helperText: params.didSpaceEndpoint && t('blocklet.component.didSpaceConnected', {
932
+ endpoint: params.didSpaceEndpoint
933
+ }),
934
+ onConnect: () => {
935
+ onNext();
936
+ }
937
+ })
938
+ })]
939
+ });
940
+ },
941
+ cancel: t('common.pre'),
942
+ confirm: t('common.next'),
943
+ onCancel,
944
+ onConfirm: onNext
945
+ }, {
946
+ key: 'install',
947
+ name: t('common.install'),
948
+ disabled: false,
949
+ loading: false,
950
+ body: /*#__PURE__*/_jsx(TypographyWrapper, {
951
+ component: "div",
952
+ className: "flex-justify-center flex-align-center",
953
+ style: {
954
+ flexDirection: 'column'
955
+ },
956
+ children: isEmpty(params.installResultProps) ? /*#__PURE__*/_jsx(AnimationWaiter, {
957
+ message: /*#__PURE__*/_jsx(MessageDiv, {
958
+ children: t('blocklet.component.installingCanCloseWindowTip')
959
+ }),
960
+ increaseSpeed: 0.3,
961
+ messageLoop: false
962
+ }) : /*#__PURE__*/_jsx("div", {
963
+ style: {
964
+ marginTop: 120
965
+ },
966
+ children: /*#__PURE__*/_jsx(ResultMessage, {
967
+ ...params.installResultProps
968
+ })
969
+ })
970
+ }),
971
+ confirm: t('common.complete'),
972
+ // onCancel: onClose,
973
+ onConfirm: () => {
974
+ onClose();
975
+ // scroll to bottom
976
+ setTimeout(() => {
977
+ const scrollDom = document.getElementsByClassName('dashboard-main')[0];
978
+ if (scrollDom) {
979
+ scrollDom.scrollTop = scrollDom.scrollHeight;
980
+ }
981
+ }, 200);
982
+ }
983
+ }].filter(item => item);
984
+ const step = steps[activeStep] || {};
985
+ const onMenuItemClick = e => {
986
+ e.stopPropagation();
987
+ // eslint-disable-next-line no-unused-expressions
988
+ setShowDialog(true);
989
+ };
990
+ const isDisabled = () => {
991
+ if (loading || step.error || !params.bundleDid) {
992
+ return true;
993
+ }
994
+ if (activeStep > 0) {
995
+ return !params.pathPrefix;
996
+ }
997
+ return false;
998
+ };
999
+
1000
+ // show close button when step is not the last one
1001
+ const showCloseButton = activeStep < steps.length - 1;
1002
+ return /*#__PURE__*/_jsxs(_Fragment, {
1003
+ children: [typeof children === 'function' ? children({
1004
+ loading,
1005
+ open: onMenuItemClick
1006
+ }) : /*#__PURE__*/_jsxs(MenuItem, {
1007
+ onClick: onMenuItemClick,
1008
+ className: "component-action",
1009
+ "data-cy": "action-add-component",
1010
+ children: [loading ? /*#__PURE__*/_jsx(Spinner, {
1011
+ size: 16
1012
+ }) : /*#__PURE__*/_jsx(AddIcon, {
1013
+ style: {
1014
+ fontSize: 18,
1015
+ marginRight: 5
1016
+ }
1017
+ }), t('blocklet.component.add')]
1018
+ }), showDialog && /*#__PURE__*/_jsx(DialogWrapper, {
1019
+ title: t('blocklet.component.addWithName', {
1020
+ name: getDisplayName(blocklet)
1021
+ }),
1022
+ maxWidth: false,
1023
+ fullWidth: false,
1024
+ PaperProps: {
1025
+ style: isMobile ? {
1026
+ width: '100%',
1027
+ height: window.innerHeight
1028
+ } : {
1029
+ maxWidth: 1350,
1030
+ minWidth: 930,
1031
+ width: '80%'
1032
+ }
1033
+ }
1034
+ // eslint-disable-next-line no-unused-vars
1035
+ ,
1036
+ onClose: (event, reason) => {
1037
+ // disable backdropClick
1038
+ if (reason === 'backdropClick') {
1039
+ return;
1040
+ }
1041
+ steps[0]?.onCancel?.();
1042
+ },
1043
+ showCloseButton: showCloseButton,
1044
+ disableEscapeKeyDown: true,
1045
+ open: true,
1046
+ actions: /*#__PURE__*/_jsxs(_Fragment, {
1047
+ children: [step.cancel && /*#__PURE__*/_jsx(Button, {
1048
+ onClick: e => {
1049
+ e.stopPropagation();
1050
+ step.onCancel();
1051
+ },
1052
+ disabled: activeStep === steps.length - 2 && loading,
1053
+ color: "inherit",
1054
+ children: step.cancel || t('common.cancel')
1055
+ }), step.confirm && /*#__PURE__*/_jsx(Button, {
1056
+ onClick: e => {
1057
+ e.stopPropagation();
1058
+ step.onConfirm();
1059
+ },
1060
+ color: "primary",
1061
+ "data-cy": "submit-confirm-next",
1062
+ disabled: loading || (typeof step.disabled === 'boolean' ? step.disabled : isDisabled()),
1063
+ variant: "contained",
1064
+ autoFocus: true,
1065
+ title: step.confirm,
1066
+ style: {
1067
+ marginLeft: 8,
1068
+ overflow: 'hidden',
1069
+ textOverflow: 'ellipsis',
1070
+ whiteSpace: 'nowrap',
1071
+ maxWidth: '280px',
1072
+ display: 'inline-block'
1073
+ },
1074
+ children: /*#__PURE__*/_jsxs(Box, {
1075
+ display: "flex",
1076
+ alignItems: "center",
1077
+ children: [(typeof step.loading === 'boolean' ? step.loading : loading) && /*#__PURE__*/_jsx(Spinner, {
1078
+ size: 16
1079
+ }), step.confirm]
1080
+ })
1081
+ })]
1082
+ }),
1083
+ children: /*#__PURE__*/_jsx(StepProvider, {
1084
+ steps: steps,
1085
+ mode: "memory",
1086
+ children: /*#__PURE__*/_jsx(StepContent, {
1087
+ ref: stepRef,
1088
+ meta: meta,
1089
+ isMobile: isMobile,
1090
+ onStepChange: newStep => {
1091
+ setActiveStep(newStep);
1092
+ }
1093
+ })
1094
+ })
1095
+ })]
1096
+ });
1097
+ }
1098
+ AddComponent.propTypes = {
1099
+ children: PropTypes.any,
1100
+ blocklet: PropTypes.object.isRequired
1101
+ };
1102
+ AddComponent.defaultProps = {
1103
+ children: null
1104
+ };
1105
+
1106
+ // FIXME: @zhanghan 下面代码中的 header:empty 用于修复 e2e-test 中的问题 core/webapp/cypress/e2e/3-blocklet-lifecycle.cy.js L70
1107
+ const DialogWrapper = styled(Dialog)`
1108
+ .MuiDialogContent-root {
1109
+ padding-left: 0;
1110
+ padding-right: 0;
1111
+ padding-bottom: 0;
1112
+ }
1113
+ .MuiDialogActions-root {
1114
+ padding: 16px 24px;
1115
+ }
1116
+ header:empty {
1117
+ display: none;
1118
+ }
1119
+ `;
1120
+ const TypographyWrapper = styled(Typography)`
1121
+ width: 100%;
1122
+ height: 100%;
1123
+ `;
1124
+ const RightContent = styled.div`
1125
+ padding: 34px 24px 24px;
1126
+ width: 100%;
1127
+ display: flex;
1128
+ flex-direction: column;
1129
+ justify-content: flex-start;
1130
+ align-items: flex-start;
1131
+
1132
+ .bottom-button {
1133
+ min-width: 200px;
1134
+ }
1135
+
1136
+ // blocklet-select-side
1137
+ aside {
1138
+ width: 140px;
1139
+ }
1140
+ `;
1141
+ const isMobileDialogContent = props => {
1142
+ if (props.isMobile) {
1143
+ return `
1144
+ height: calc(100vh - 56px - 64px - 48px);
1145
+ `;
1146
+ }
1147
+ return '';
1148
+ };
1149
+ const DialogContentWrapper = styled(DialogContentText)`
1150
+ ${({
1151
+ className
1152
+ }) => {
1153
+ // mobile extra style
1154
+ if (className === 'mobileStyle') {
1155
+ return `
1156
+ & > div{
1157
+ height: 100%;
1158
+ }
1159
+ .root-header {
1160
+ .app-name-content {
1161
+ display: none;
1162
+ }
1163
+ }
1164
+
1165
+ // content-panel
1166
+ .root-header + div{
1167
+ padding-top: 0;
1168
+ position: relative;
1169
+ & > div {
1170
+ padding-top: 0;
1171
+ }
1172
+ }
1173
+
1174
+ `;
1175
+ }
1176
+ return `
1177
+ height: 72vh;
1178
+ position: relative;
1179
+ .root-header {
1180
+ z-index: auto !important;
1181
+ position: fixed !important;
1182
+ }
1183
+ & > div {
1184
+ height: 100%;
1185
+ width: 100%;
1186
+ max-width: 100%;
1187
+ & > div {
1188
+ max-height: unset !important;
1189
+ max-width: 100%;
1190
+ & > div {
1191
+ // left-panel
1192
+ &:first-child {
1193
+ padding-top: 0;
1194
+ // padding-left: 0;
1195
+ width: 25%;
1196
+ min-width: 240px;
1197
+ & > div:first-child {
1198
+ display: none;
1199
+ }
1200
+ // step
1201
+ & > div:last-child {
1202
+ // margin-top: 32px;
1203
+ margin-top: 0;
1204
+ }
1205
+ }
1206
+ // right-panel
1207
+ &:last-child {
1208
+ padding-top: 0;
1209
+ padding-right: 24px;
1210
+ overflow-y: auto;
1211
+ .app-content {
1212
+ padding: 0 0 24px 0;
1213
+ }
1214
+ .button-container {
1215
+ padding-right: 0;
1216
+ }
1217
+ }
1218
+ }
1219
+ }
1220
+ }
1221
+
1222
+ `;
1223
+ }}
1224
+
1225
+ & .flex-justify-center {
1226
+ display: flex;
1227
+ justify-content: center;
1228
+ }
1229
+
1230
+ & .flex-align-center {
1231
+ display: flex;
1232
+ height: 100%;
1233
+ align-items: center;
1234
+ ${props => isMobileDialogContent(props)}
1235
+ }
1236
+
1237
+ & .agreement-wrapper {
1238
+ ${props => isMobileDialogContent(props)}
1239
+ max-height: 60vh;
1240
+ .eula-trigger {
1241
+ padding-right: 0;
1242
+ }
1243
+ .next-button {
1244
+ display: none;
1245
+ }
1246
+ }
1247
+
1248
+ & .connect {
1249
+ background: white;
1250
+ }
1251
+ `;
1252
+ const PageHeaderWrapper = styled(PageHeader)`
1253
+ margin-bottom: 24px;
1254
+ `;
1255
+ const StoreBlockletItemWrapper = styled.div`
1256
+ position: relative;
1257
+
1258
+ .choose-blocklet {
1259
+ background-color: rgb(236, 251, 253);
1260
+ border-color: rgb(236, 251, 253);
1261
+ border-radius: 8px;
1262
+ }
1263
+
1264
+ .check-container {
1265
+ position: absolute;
1266
+ right: 0;
1267
+ bottom: 0;
1268
+ display: flex;
1269
+ justify-content: flex-end;
1270
+ align-items: flex-end;
1271
+ width: 30px;
1272
+ height: 30px;
1273
+ border-radius: 0 0 8px 0;
1274
+ color: ${props => props.theme.palette.common.white};
1275
+ overflow: hidden;
1276
+ transition: all ease 0.3s;
1277
+ &:after {
1278
+ position: absolute;
1279
+ z-index: 0;
1280
+ display: block;
1281
+ width: 0;
1282
+ height: 0;
1283
+ border-top: transparent solid 15px;
1284
+ border-left: transparent solid 15px;
1285
+ border-bottom: ${props => props.theme.palette.primary.main} solid 15px;
1286
+ border-right: ${props => props.theme.palette.primary.main} solid 15px;
1287
+ transition: all ease 0.1s;
1288
+ content: '';
1289
+ }
1290
+
1291
+ .check-icon {
1292
+ position: relative;
1293
+ z-index: 2;
1294
+ margin: 0 1px 1px 0;
1295
+ font-size: 16px;
1296
+ transition: all ease 0.2s;
1297
+ }
1298
+ }
1299
+ `;
1300
+ const MessageDiv = styled.div`
1301
+ color: ${props => props.theme.palette.primary.main};
1302
+ .msg-before {
1303
+ display: inline-block;
1304
+ color: #aaa;
1305
+ font-size: 14px;
1306
+ margin-right: 6px;
1307
+ }
1308
+ `;