@abtnode/ux 1.15.17 → 1.16.0-beta-8ee536d7

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 (154) hide show
  1. package/lib/actions.js +111 -0
  2. package/lib/blocklet/access/config-access.js +303 -0
  3. package/lib/blocklet/access/index.js +221 -0
  4. package/lib/blocklet/actions.js +438 -0
  5. package/lib/blocklet/add-cert.js +191 -0
  6. package/lib/blocklet/agreement-app.js +30 -0
  7. package/lib/blocklet/agreement.js +72 -0
  8. package/lib/blocklet/app-avatar.js +74 -0
  9. package/lib/blocklet/audit-logs.js +197 -0
  10. package/lib/blocklet/blocklet-source.js +56 -0
  11. package/lib/blocklet/bundle-avatar.js +80 -0
  12. package/lib/blocklet/component/add.js +1063 -0
  13. package/lib/blocklet/component/configuration.js +124 -0
  14. package/lib/blocklet/component/delete.js +117 -0
  15. package/lib/blocklet/component/environment.js +289 -0
  16. package/lib/blocklet/component/expiration.js +53 -0
  17. package/lib/blocklet/component/index.js +804 -0
  18. package/lib/blocklet/component/line.js +28 -0
  19. package/lib/blocklet/component/navigation/locale-tabs.js +218 -0
  20. package/lib/blocklet/component/navigation/navigation-actions.js +120 -0
  21. package/lib/blocklet/component/navigation/navigation-dialog.js +620 -0
  22. package/lib/blocklet/component/navigation/navigation-preview.js +102 -0
  23. package/lib/blocklet/component/navigation/simple-select.js +131 -0
  24. package/lib/blocklet/component/select-store.js +153 -0
  25. package/lib/blocklet/component/setting.js +151 -0
  26. package/lib/blocklet/component/sortable-tree.js +138 -0
  27. package/lib/blocklet/component/space-gateway-selector.js +174 -0
  28. package/lib/blocklet/component/store-blocklet-list.js +205 -0
  29. package/lib/blocklet/config-navigation.js +344 -0
  30. package/lib/blocklet/configuration.js +574 -0
  31. package/lib/blocklet/disk-info.js +91 -0
  32. package/lib/blocklet/icons.js +26 -0
  33. package/lib/blocklet/install-from-url.js +347 -0
  34. package/lib/blocklet/log.js +62 -0
  35. package/lib/blocklet/migration.js +153 -0
  36. package/lib/blocklet/mode.js +35 -0
  37. package/lib/blocklet/monitor.js +186 -0
  38. package/lib/blocklet/overview.js +236 -0
  39. package/lib/blocklet/preferences/app-sk.js +131 -0
  40. package/lib/blocklet/preferences/index.js +238 -0
  41. package/lib/blocklet/preferences/wallet-type.js +107 -0
  42. package/lib/blocklet/purchase/common.js +103 -0
  43. package/lib/blocklet/purchase/component-purchase.js +253 -0
  44. package/lib/blocklet/purchase/index.js +13 -0
  45. package/lib/blocklet/router/action/add-domain-alias.js +173 -0
  46. package/lib/blocklet/router/action/add-rule.js +204 -0
  47. package/lib/blocklet/router/action/config-routing-rule.js +129 -0
  48. package/lib/blocklet/router/action/delete-domain-alias.js +107 -0
  49. package/lib/blocklet/router/action/delete-rule.js +114 -0
  50. package/lib/blocklet/router/action/update-rule.js +203 -0
  51. package/lib/blocklet/router/domain-actions.js +71 -0
  52. package/lib/blocklet/router/domain-status.js +96 -0
  53. package/lib/blocklet/router/rule-actions.js +77 -0
  54. package/lib/blocklet/router/rule-list.js +181 -0
  55. package/lib/blocklet/router/util.js +146 -0
  56. package/lib/blocklet/runtime-info.js +87 -0
  57. package/lib/blocklet/status.js +105 -0
  58. package/lib/blocklet/storage.js +322 -0
  59. package/lib/blocklet/types.js +25 -0
  60. package/lib/blocklet/util.js +233 -0
  61. package/lib/blocklet/version.js +156 -0
  62. package/lib/card-selector.js +109 -0
  63. package/lib/certificate.js +110 -0
  64. package/lib/click-to-copy.js +38 -0
  65. package/lib/confirm.js +149 -0
  66. package/lib/contexts/audit-log.js +141 -0
  67. package/lib/contexts/blocklet.js +19 -0
  68. package/lib/contexts/deleting-blocklets.js +78 -0
  69. package/lib/contexts/node.js +30 -0
  70. package/lib/contexts/session.js +20 -0
  71. package/lib/contexts/team.js +19 -0
  72. package/lib/delete-confirm.js +127 -0
  73. package/lib/did-address.js +77 -0
  74. package/lib/dot.js +18 -0
  75. package/lib/form/form-text-input.js +266 -0
  76. package/lib/form/form-wrapper.js +13 -0
  77. package/lib/form/required.js +13 -0
  78. package/lib/hooks/blocklet.js +231 -0
  79. package/lib/hooks/mobile-width.js +19 -0
  80. package/lib/hooks/url-evaluation.js +168 -0
  81. package/lib/hooks/use-app-logo.js +25 -0
  82. package/lib/hooks/use-bundle-logo.js +36 -0
  83. package/lib/hooks/use-navigation.js +355 -0
  84. package/lib/hooks/use-passport-id.js +21 -0
  85. package/lib/hooks/use-subscription.js +28 -0
  86. package/lib/icons/long-arrow.svg +5 -0
  87. package/lib/index.js +0 -3
  88. package/lib/invitation/invitation-app.js +51 -0
  89. package/lib/invitation/invitation-login.js +47 -0
  90. package/lib/invitation/invitation-passport.js +130 -0
  91. package/lib/invitation/invitation-receive.js +108 -0
  92. package/lib/invitation/invitation-success.js +82 -0
  93. package/lib/invitation/invitation-user.js +79 -0
  94. package/lib/invitation/invitation.js +80 -0
  95. package/lib/issue-passport.js +84 -84
  96. package/lib/launch-blocklet/content-layout.js +33 -0
  97. package/lib/launch-blocklet/page-header.js +38 -0
  98. package/lib/layout/addon.js +100 -0
  99. package/lib/layout/feedback.js +55 -0
  100. package/lib/locales/en.js +1221 -10
  101. package/lib/locales/index.js +3 -4
  102. package/lib/locales/zh.js +1232 -15
  103. package/lib/logs/clock.js +19 -0
  104. package/lib/logs/download.js +139 -0
  105. package/lib/logs/log-terminal.js +183 -0
  106. package/lib/lost-passport.js +207 -192
  107. package/lib/monitor/card.js +73 -0
  108. package/lib/monitor/cpu.js +109 -0
  109. package/lib/monitor/disk.js +122 -0
  110. package/lib/monitor/memory.js +144 -0
  111. package/lib/nav-logo.js +120 -0
  112. package/lib/passport-tag.js +43 -0
  113. package/lib/permission.js +70 -0
  114. package/lib/relative-time.js +61 -0
  115. package/lib/schema-form/color-input.js +105 -0
  116. package/lib/schema-form/common-prop-types.js +21 -0
  117. package/lib/schema-form/index.js +229 -0
  118. package/lib/schema-form/passport-input.js +66 -0
  119. package/lib/schema-form/text-input.js +72 -0
  120. package/lib/store/add.js +185 -0
  121. package/lib/store/delete.js +102 -0
  122. package/lib/store/item.js +84 -0
  123. package/lib/table-icons.js +42 -0
  124. package/lib/table.js +13 -0
  125. package/lib/tag.js +37 -0
  126. package/lib/team/members/actions.js +99 -0
  127. package/lib/team/members/index.js +503 -0
  128. package/lib/team/members/invitations.js +196 -0
  129. package/lib/team/members/invite-member.js +212 -0
  130. package/lib/team/members/issue-passport.js +155 -0
  131. package/lib/team/members/member.js +300 -0
  132. package/lib/team/members/passport-issuances.js +154 -0
  133. package/lib/team/members/passports.js +336 -0
  134. package/lib/team/members/toggle-user-approval.js +128 -0
  135. package/lib/team/members/transfer-node.js +262 -0
  136. package/lib/team/members/util.js +20 -0
  137. package/lib/team/passports/color.js +132 -0
  138. package/lib/team/passports/detail.js +271 -0
  139. package/lib/team/passports/index.js +233 -0
  140. package/lib/team/passports/mutate-role.js +204 -0
  141. package/lib/team/passports/trusted-issuer.js +297 -0
  142. package/lib/team/passports/trusted-issuers.js +240 -0
  143. package/lib/team/search-input.js +38 -0
  144. package/lib/team/styles/dialog.js +13 -0
  145. package/lib/team/styles/list-header.js +13 -0
  146. package/lib/toast.js +86 -0
  147. package/lib/util/api.js +21 -0
  148. package/lib/util/constants.js +10 -0
  149. package/lib/util/index.js +703 -0
  150. package/lib/util/locales.js +28 -0
  151. package/lib/util/mode.js +11 -0
  152. package/lib/who-can-access/config.js +46 -0
  153. package/lib/wrap-locale.js +12 -13
  154. package/package.json +71 -17
@@ -0,0 +1,1063 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = AddComponent;
7
+ var _react = require("react");
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+ var _uniqBy = _interopRequireDefault(require("lodash/uniqBy"));
10
+ var _flatten = _interopRequireDefault(require("lodash/flatten"));
11
+ var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
12
+ var _isNil = _interopRequireDefault(require("lodash/isNil"));
13
+ var _pageHeader = _interopRequireDefault(require("@blocklet/launcher-layout/lib/page-header"));
14
+ var _Dialog = _interopRequireDefault(require("@arcblock/ux/lib/Dialog"));
15
+ var _CircularProgress = _interopRequireDefault(require("@mui/material/CircularProgress"));
16
+ var _DialogContentText = _interopRequireDefault(require("@mui/material/DialogContentText"));
17
+ var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
18
+ var _TextField = _interopRequireDefault(require("@mui/material/TextField"));
19
+ var _MenuItem = _interopRequireDefault(require("@mui/material/MenuItem"));
20
+ var _Link = _interopRequireDefault(require("@mui/icons-material/Link"));
21
+ var _Check = _interopRequireDefault(require("@mui/icons-material/Check"));
22
+ var _useMediaQuery = _interopRequireDefault(require("@mui/material/useMediaQuery"));
23
+ var _styled = _interopRequireDefault(require("@emotion/styled"));
24
+ var _context = require("@arcblock/ux/lib/Locale/context");
25
+ var _constant = require("@blocklet/constant");
26
+ var _launcherLayout = _interopRequireDefault(require("@blocklet/launcher-layout"));
27
+ var _step = require("@blocklet/launcher-layout/lib/context/step");
28
+ var _constant2 = require("@abtnode/constant");
29
+ var _Button = _interopRequireDefault(require("@arcblock/ux/lib/Button"));
30
+ var _Alert = _interopRequireDefault(require("@arcblock/ux/lib/Alert"));
31
+ var _AnimationWaiter = _interopRequireDefault(require("@arcblock/ux/lib/AnimationWaiter"));
32
+ var _launchResultMessage = _interopRequireDefault(require("@blocklet/launcher-layout/lib/launch-result-message"));
33
+ var _util = require("@blocklet/meta/lib/util");
34
+ var _urlFriendly = _interopRequireDefault(require("@blocklet/meta/lib/url-friendly"));
35
+ var _node = require("../../contexts/node");
36
+ var _util2 = require("../../util");
37
+ var _toast = _interopRequireDefault(require("../../toast"));
38
+ var _schemaForm = _interopRequireDefault(require("../../schema-form"));
39
+ var _required = _interopRequireDefault(require("../../form/required"));
40
+ var _purchase = require("../purchase");
41
+ var _util3 = require("../router/util");
42
+ var _agreement = _interopRequireDefault(require("../agreement"));
43
+ var _installFromUrl = _interopRequireDefault(require("../install-from-url"));
44
+ var _selectStore = _interopRequireDefault(require("./select-store"));
45
+ var _storeBlockletList = _interopRequireDefault(require("./store-blocklet-list"));
46
+ var _jsxRuntime = require("react/jsx-runtime");
47
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7;
48
+ const _excluded = ["name", "validation"],
49
+ _excluded2 = ["default", "key"];
50
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
51
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
52
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
53
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
54
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
55
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
56
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
57
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
58
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
59
+ const requirePurchase = meta => meta.inStore && (0, _util.isFreeBlocklet)(meta) === false;
60
+ const hasRequiredEnvironments = meta => (meta.environments || []).some(x => x.required);
61
+ const hasMissRequiredConfigs = (configsList, sharedValueMap) => {
62
+ return configsList === null || configsList === void 0 ? void 0 : configsList.some(item => {
63
+ return item.required && !sharedValueMap[item.key];
64
+ });
65
+ };
66
+ const getParamsName = function getParamsName() {
67
+ let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
68
+ return params.title || params.name;
69
+ };
70
+ const StepContent = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
71
+ let {
72
+ meta,
73
+ isMobile,
74
+ onStepChange
75
+ } = _ref;
76
+ const {
77
+ steps,
78
+ activeStep,
79
+ setActiveStepByKey,
80
+ setActiveStepByIndex
81
+ } = (0, _step.useStepContext)();
82
+ const {
83
+ t,
84
+ locale
85
+ } = (0, _context.useLocaleContext)();
86
+ const step = steps[activeStep];
87
+ (0, _react.useEffect)(() => {
88
+ onStepChange(activeStep);
89
+ }, [onStepChange, activeStep]);
90
+
91
+ // expose the func and activeStep
92
+ (0, _react.useImperativeHandle)(ref, () => ({
93
+ setActiveStepByKey,
94
+ setActiveStepByIndex
95
+ }));
96
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(DialogContentWrapper, {
97
+ component: "div",
98
+ className: isMobile ? 'mobileStyle' : '',
99
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_launcherLayout.default, {
100
+ locale: locale,
101
+ blockletMeta: _objectSpread({
102
+ title: ' '
103
+ }, meta),
104
+ pcWidth: "100%",
105
+ pcHeight: "100%",
106
+ logoUrl: meta && meta.logo && meta.registryUrl ? (0, _util2.getBlockletLogoUrl)({
107
+ did: meta.did,
108
+ baseUrl: meta.registryUrl,
109
+ logoPath: meta.logo
110
+ }) : null,
111
+ stepTip: t('blocklet.component.add'),
112
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(RightContent, {
113
+ children: step !== null && step !== void 0 && step.body && typeof step.body === 'function' ? step.body() : step.body
114
+ })
115
+ })
116
+ });
117
+ });
118
+ StepContent.propTypes = {
119
+ meta: _propTypes.default.any,
120
+ onStepChange: _propTypes.default.func.isRequired,
121
+ isMobile: _propTypes.default.bool.isRequired
122
+ };
123
+ StepContent.defaultProps = {
124
+ meta: null
125
+ };
126
+ function AddComponent(_ref2) {
127
+ var _blocklet$meta2, _blocklet$meta3, _blocklet$meta4, _purchaseRef$current, _purchaseRef$current$, _purchaseRef$current2, _purchaseRef$current3;
128
+ let {
129
+ blocklet,
130
+ children
131
+ } = _ref2;
132
+ const {
133
+ t,
134
+ locale
135
+ } = (0, _context.useLocaleContext)();
136
+ const [loading, setLoading] = (0, _react.useState)(false);
137
+ const [editingItem, setEditingItem] = (0, _react.useState)(null);
138
+ const [error, setError] = (0, _react.useState)('');
139
+ const [showDialog, setShowDialog] = (0, _react.useState)('');
140
+ const [mountPointHelperText, setMountPointHelperText] = (0, _react.useState)('');
141
+ const {
142
+ api,
143
+ ws: {
144
+ useSubscription
145
+ },
146
+ inService,
147
+ info: nodeInfo
148
+ } = (0, _node.useNodeContext)();
149
+ const [purchaseData, setPurchaseData] = (0, _react.useState)(null);
150
+ const [isWaitingPurchase, setIsWaitingPurchase] = (0, _react.useState)(false);
151
+ const initParams = {
152
+ bundleDid: '',
153
+ componentDid: '',
154
+ componentName: '',
155
+ pathPrefix: '',
156
+ name: '',
157
+ title: '',
158
+ configsList: [],
159
+ configsValue: {},
160
+ hasMissRequiredConfigs: false,
161
+ hasEnvironmentsStep: false,
162
+ hasRequiredEnvironments: false,
163
+ requirePurchase: false,
164
+ installResultProps: {},
165
+ purchaseResultProps: {},
166
+ showFromUrlDialog: false
167
+ };
168
+ const [params, setParams] = (0, _react.useState)(initParams);
169
+ const [activeStep, setActiveStep] = (0, _react.useState)(0);
170
+ const component = (0, _react.useRef)({});
171
+ const stepRef = (0, _react.useRef)({});
172
+ const purchaseRef = (0, _react.useRef)({});
173
+ const isMobile = (0, _useMediaQuery.default)(theme => theme.breakpoints.down('md'));
174
+ const {
175
+ meta
176
+ } = component.current;
177
+ // eslint-disable-next-line no-unused-vars
178
+ const {
179
+ setActiveStepByIndex
180
+ } = stepRef.current || {};
181
+ const isServerlessMode = nodeInfo.mode === _constant2.NODE_MODES.SERVERLESS;
182
+ const updateParams = obj => setParams(x => _objectSpread(_objectSpread({}, x), obj));
183
+ (0, _react.useEffect)(() => {
184
+ if (params.pathPrefix) {
185
+ const {
186
+ errMsg
187
+ } = validateInput(_objectSpread(_objectSpread({}, params), {}, {
188
+ pathPrefix: params.pathPrefix,
189
+ locale
190
+ }));
191
+ setError(errMsg);
192
+ }
193
+ }, [params.pathPrefix]); // eslint-disable-line
194
+
195
+ (0, _react.useEffect)(() => {
196
+ if (activeStep === 0) {
197
+ // reset params, when step change to select component
198
+ setParams(initParams);
199
+ }
200
+ }, [activeStep]); // eslint-disable-line
201
+
202
+ const getComponentName = () => {
203
+ var _component$current;
204
+ if (component !== null && component !== void 0 && (_component$current = component.current) !== null && _component$current !== void 0 && _component$current.meta) {
205
+ return (0, _util.getDisplayName)(component.current);
206
+ }
207
+ return '';
208
+ };
209
+ const setInstallErrorResult = errorMessage => {
210
+ updateParams({
211
+ installResultProps: {
212
+ variant: 'error',
213
+ title: getComponentName(),
214
+ subTitle: errorMessage,
215
+ footer: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
216
+ className: "bottom-button",
217
+ "data-cy": "retry-install-component",
218
+ onClick: () => {
219
+ updateParams({
220
+ installResultProps: {}
221
+ });
222
+ onInstall(component.current.installInput);
223
+ },
224
+ children: t('common.retry')
225
+ })
226
+ }
227
+ });
228
+ };
229
+ const createBlockletEventHandler = handler => {
230
+ return b => {
231
+ var _b$meta, _blocklet$meta;
232
+ if (((b === null || b === void 0 ? void 0 : (_b$meta = b.meta) === null || _b$meta === void 0 ? void 0 : _b$meta.did) || (b === null || b === void 0 ? void 0 : b.meta)) === (blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta = blocklet.meta) === null || _blocklet$meta === void 0 ? void 0 : _blocklet$meta.did)) {
233
+ handler(b);
234
+ }
235
+ };
236
+ };
237
+ useSubscription(_constant.BlockletEvents.statusChange, createBlockletEventHandler(e => {
238
+ switch (e.status) {
239
+ case _constant.BlockletStatus.upgrading:
240
+ updateParams({
241
+ installResultProps: {
242
+ variant: 'success',
243
+ title: getComponentName(),
244
+ subTitle: t('blocklet.component.installSuccessTip')
245
+ }
246
+ });
247
+ break;
248
+ default:
249
+ }
250
+ }), [blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta2 = blocklet.meta) === null || _blocklet$meta2 === void 0 ? void 0 : _blocklet$meta2.did]);
251
+ useSubscription(_constant.BlockletEvents.downloadFailed, createBlockletEventHandler(() => {
252
+ setInstallErrorResult(t('blocklet.component.installComponentError'));
253
+ }), [blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta3 = blocklet.meta) === null || _blocklet$meta3 === void 0 ? void 0 : _blocklet$meta3.did]);
254
+ useSubscription(_constant.BlockletEvents.installFailed, createBlockletEventHandler(() => {
255
+ setInstallErrorResult(t('blocklet.component.installComponentError'));
256
+ }), [blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta4 = blocklet.meta) === null || _blocklet$meta4 === void 0 ? void 0 : _blocklet$meta4.did]);
257
+ const onClose = () => {
258
+ setLoading(false);
259
+ setShowDialog(false);
260
+ setParams({});
261
+ component.current = {};
262
+ };
263
+ const onInstall = async payload => {
264
+ var _component$current2, _component$current3;
265
+ const {
266
+ pathPrefix: mountPoint,
267
+ bundleDid,
268
+ title,
269
+ componentName = '',
270
+ componentDid = ''
271
+ } = params;
272
+ // eslint-disable-next-line no-shadow
273
+ const {
274
+ configs = [],
275
+ registryUrl,
276
+ inStore,
277
+ inputUrl
278
+ } = ((_component$current2 = component.current) === null || _component$current2 === void 0 ? void 0 : _component$current2.meta) || {};
279
+ const downloadTokenList = (_component$current3 = component.current) === null || _component$current3 === void 0 ? void 0 : _component$current3.downloadTokenList;
280
+ const url = inStore ? (0, _util2.getBlockletMetaUrl)(registryUrl, bundleDid) : inputUrl;
281
+ setLoading(true);
282
+ const installInput = _objectSpread(_objectSpread(_objectSpread({
283
+ rootDid: blocklet.meta.did,
284
+ url,
285
+ mountPoint: (0, _urlFriendly.default)(mountPoint),
286
+ title,
287
+ name: componentName,
288
+ did: componentDid
289
+ }, params.hasEnvironmentsStep && configs.length > 0 ? {
290
+ configs: configs.map(item => {
291
+ return _objectSpread(_objectSpread({}, item), {}, {
292
+ value: params.configsValue[item.key] || ''
293
+ });
294
+ })
295
+ } : {}), downloadTokenList ? {
296
+ downloadTokenList
297
+ } : {}), payload);
298
+ try {
299
+ await api.installComponent({
300
+ input: installInput
301
+ });
302
+ if (registryUrl) {
303
+ const {
304
+ teamDid,
305
+ storeList
306
+ } = (0, _util2.getStoreList)({
307
+ fromBlocklet: inService,
308
+ nodeInfo,
309
+ blocklet
310
+ });
311
+ const {
312
+ isNew,
313
+ decoded
314
+ } = (0, _util2.isNewStoreUrl)(registryUrl, storeList);
315
+ if (isNew) {
316
+ await api.addBlockletStore({
317
+ input: {
318
+ teamDid,
319
+ url: decoded
320
+ }
321
+ });
322
+ }
323
+ }
324
+ } catch (err) {
325
+ const errMsg = (0, _util2.formatError)(err);
326
+ _toast.default.error(errMsg);
327
+ console.error('installComponent error: ', err);
328
+ setInstallErrorResult(errMsg);
329
+ } finally {
330
+ setLoading(false);
331
+ component.current.installInput = installInput;
332
+ }
333
+ };
334
+ const validateInput = input => {
335
+ // FIXME: validatePathPrefix should be updated
336
+ const errMsg = (0, _util3.validatePathPrefix)({
337
+ params: _objectSpread(_objectSpread({}, input), {}, {
338
+ did: input.bundleDid
339
+ }),
340
+ blocklets: [blocklet],
341
+ // blocklets: component.current?.blocklets?.map(x => ({ meta: x })) || [],
342
+ blocklet,
343
+ locale
344
+ });
345
+ return {
346
+ errMsg
347
+ };
348
+ };
349
+ const onNext = payload => {
350
+ const {
351
+ errMsg
352
+ } = validateInput(_objectSpread(_objectSpread({}, params), {}, {
353
+ locale
354
+ }));
355
+ setError(errMsg);
356
+
357
+ // the step can complete, install component
358
+ if (activeStep === steps.length - 2) {
359
+ updateParams({
360
+ installResultProps: {}
361
+ });
362
+ onInstall(payload);
363
+ }
364
+ setActiveStepByIndex(x => x + 1);
365
+ };
366
+ const _onCancel = () => {
367
+ setActiveStepByIndex(x => x - 1);
368
+ };
369
+ const onGeneratePurchaseData = async () => {
370
+ const {
371
+ pathPrefix: mountPoint,
372
+ bundleDid,
373
+ title,
374
+ componentName = '',
375
+ componentDid = ''
376
+ } = params;
377
+
378
+ // eslint-disable-next-line no-shadow
379
+ const {
380
+ meta = {}
381
+ } = component.current || {};
382
+ const {
383
+ registryUrl,
384
+ inStore,
385
+ inputUrl
386
+ } = meta;
387
+ const url = inStore ? (0, _util2.getBlockletMetaUrl)(registryUrl, bundleDid) : inputUrl;
388
+ setPurchaseData({
389
+ meta,
390
+ installOpts: {
391
+ type: 'component',
392
+ rootDid: blocklet.meta.did,
393
+ mountPoint,
394
+ url,
395
+ title,
396
+ name: componentName,
397
+ did: componentDid
398
+ }
399
+ });
400
+ };
401
+ const onCancelPurchase = errorMessage => {
402
+ setIsWaitingPurchase(false);
403
+ updateParams({
404
+ purchaseResultProps: {
405
+ variant: 'error',
406
+ title: getComponentName(),
407
+ subTitle: errorMessage,
408
+ style: {
409
+ paddingTop: 120
410
+ },
411
+ footer: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
412
+ className: "bottom-button",
413
+ "data-cy": "retry-purchase-component",
414
+ onClick: () => {
415
+ updateParams({
416
+ purchaseResultProps: {}
417
+ });
418
+ },
419
+ children: t('common.retry')
420
+ })
421
+ }
422
+ });
423
+ };
424
+ const onSuccessPurchase = _ref3 => {
425
+ let {
426
+ downloadTokenList
427
+ } = _ref3;
428
+ component.current.downloadTokenList = downloadTokenList;
429
+ setIsWaitingPurchase(false);
430
+ onNext();
431
+ };
432
+ const setConfigValue = _ref4 => {
433
+ var _blocklet$settings, _meta$environments;
434
+ let {
435
+ chooseParams = component.current,
436
+ componentDid: componentDidValue,
437
+ isInit = false
438
+ } = _ref4;
439
+ // eslint-disable-next-line no-shadow
440
+ const {
441
+ meta,
442
+ registryUrl,
443
+ inStore,
444
+ inputUrl
445
+ } = chooseParams;
446
+ const {
447
+ did: bundleDid,
448
+ title,
449
+ name
450
+ } = meta;
451
+
452
+ // deleted history list
453
+ const list = (((_blocklet$settings = blocklet.settings) === null || _blocklet$settings === void 0 ? void 0 : _blocklet$settings.children) || []).filter(x => x.status === 'deleted' && x.meta.bundleDid === bundleDid);
454
+ const componentDid = componentDidValue || '';
455
+ const newConfigs = (_meta$environments = meta.environments) === null || _meta$environments === void 0 ? void 0 : _meta$environments.map(item => {
456
+ const {
457
+ name: key,
458
+ validation
459
+ } = item,
460
+ rest = _objectWithoutProperties(item, _excluded);
461
+ const formatItem = {
462
+ // if the blocklet has validation, provide the validation (fix not inStore)
463
+ validation: (0, _isNil.default)(validation) ? '' : validation
464
+ };
465
+ return _objectSpread(_objectSpread({}, rest), {}, {
466
+ key
467
+ }, formatItem);
468
+ });
469
+ component.current = _objectSpread(_objectSpread({}, chooseParams), {}, {
470
+ meta: _objectSpread(_objectSpread({}, meta), {}, {
471
+ // init configs from environments
472
+ configs: newConfigs,
473
+ registryUrl,
474
+ inStore,
475
+ inputUrl
476
+ })
477
+ });
478
+ let doc = {};
479
+
480
+ // if is init, should update configs
481
+ if (isInit) {
482
+ const ancestors = [blocklet];
483
+
484
+ // component config
485
+ const componentSelfConfigs = newConfigs || [];
486
+
487
+ // TODO: meta not include children environments/configs before install, waiting for next sprint to design
488
+ const componentChildrenConfigs = [];
489
+
490
+ // eslint-disable-next-line
491
+ // chooseBlocklet?.children?.map(childBlocklet => {
492
+ // // eslint-disable-next-line no-shadow
493
+ // forEachChildSync(childBlocklet, (b, { ancestors }) => {
494
+ // const ancestorDids = ancestors.slice(1).map(x => x.meta.did);
495
+
496
+ // componentChildrenConfigs.push(
497
+ // (b.configs || []).map(x => ({ ...x, childDid: ancestorDids.concat(b.meta.did) }))
498
+ // );
499
+ // });
500
+
501
+ // return false;
502
+ // });
503
+
504
+ const componentAllConfigs = (0, _uniqBy.default)((0, _flatten.default)([...componentSelfConfigs, ...componentChildrenConfigs]), 'key').filter(x => !!x.key).sort((a, b) => {
505
+ if (a.required && !b.required) {
506
+ return -1;
507
+ }
508
+ if (b.required && !a.required) {
509
+ return 1;
510
+ }
511
+ return 0;
512
+ });
513
+ const sharedConfigObj = (0, _util.getSharedConfigObj)({
514
+ configs: componentAllConfigs
515
+ }, ancestors);
516
+ const configsValue = {};
517
+ const configsList = componentAllConfigs.map(item => {
518
+ const {
519
+ default: defaultValue,
520
+ key
521
+ } = item,
522
+ rest = _objectWithoutProperties(item, _excluded2);
523
+ configsValue[key] = sharedConfigObj[key] || defaultValue;
524
+ return _objectSpread(_objectSpread({}, rest), {}, {
525
+ key,
526
+ hidden: !!_constant.BLOCKLET_CONFIGURABLE_KEY[key]
527
+ });
528
+ });
529
+ doc = _objectSpread(_objectSpread({}, doc), {}, {
530
+ configsList,
531
+ configsValue,
532
+ hasMissRequiredConfigs: hasMissRequiredConfigs(configsList, configsValue)
533
+ });
534
+ }
535
+ const hasRootPath = blocklet.children.some(x => x.mountPoint === '/');
536
+
537
+ // use deleted history
538
+ const config = list.find(x => x.meta.bundleDid === bundleDid);
539
+ if (config) {
540
+ doc = _objectSpread(_objectSpread({}, doc), {}, {
541
+ pathPrefix: config.mountPoint,
542
+ title: config.meta.title,
543
+ componentName: config.meta.name,
544
+ // use history's environments
545
+ hasEnvironmentsStep: false
546
+ });
547
+ } else {
548
+ var _component$current$me, _component$current$me2;
549
+ doc = _objectSpread(_objectSpread({}, doc), {}, {
550
+ pathPrefix: hasRootPath ? "/".concat((0, _urlFriendly.default)(name)) : '/',
551
+ title: title || '',
552
+ componentName: '',
553
+ hasEnvironmentsStep: ((_component$current$me = component.current.meta) === null || _component$current$me === void 0 ? void 0 : (_component$current$me2 = _component$current$me.environments) === null || _component$current$me2 === void 0 ? void 0 : _component$current$me2.length) > 0
554
+ });
555
+ }
556
+
557
+ // eslint-disable-next-line no-shadow
558
+ const componentRequirePurchase = requirePurchase(component.current.meta);
559
+ updateParams(_objectSpread(_objectSpread({
560
+ bundleDid,
561
+ componentDid
562
+ }, doc), {}, {
563
+ hasRequiredEnvironments: hasRequiredEnvironments(component.current.meta),
564
+ requirePurchase: componentRequirePurchase
565
+ }));
566
+ if (isInit && componentRequirePurchase) {
567
+ onGeneratePurchaseData();
568
+ }
569
+ };
570
+ const steps = [{
571
+ key: 'selectComponent',
572
+ name: t('blocklet.component.selectComponent'),
573
+ body: /*#__PURE__*/(0, _jsxRuntime.jsxs)(TypographyWrapper, {
574
+ component: "div",
575
+ children: [params.showFromUrlDialog && /*#__PURE__*/(0, _jsxRuntime.jsx)(_installFromUrl.default
576
+ // if not set defaultUrl, the dialog will always show step 1 when the dialog is opened
577
+ // defaultUrl={meta?.inputUrl}
578
+ , {
579
+ mode: "component",
580
+ onCancel: () => {
581
+ updateParams({
582
+ showFromUrlDialog: false
583
+ });
584
+ }
585
+ // eslint-disable-next-line no-shadow
586
+ ,
587
+ onSuccess: _ref5 => {
588
+ let {
589
+ meta,
590
+ inputUrl,
591
+ inStore,
592
+ registryUrl
593
+ } = _ref5;
594
+ setConfigValue({
595
+ chooseParams: {
596
+ meta,
597
+ inputUrl,
598
+ inStore,
599
+ registryUrl
600
+ },
601
+ isInit: true
602
+ });
603
+ updateParams({
604
+ showFromUrlDialog: false
605
+ });
606
+ onNext();
607
+ },
608
+ handleText: {
609
+ title: t('blocklet.component.addComponentTip.fromUrl'),
610
+ confirm: t('blocklet.component.choose')
611
+ }
612
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_selectStore.default, {
613
+ extra: !isServerlessMode ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Button.default, {
614
+ variant: "text",
615
+ color: "primary",
616
+ "data-cy": "add-component-from-url",
617
+ onClick: () => {
618
+ updateParams({
619
+ showFromUrlDialog: true
620
+ });
621
+ },
622
+ style: {
623
+ padding: '0 2px'
624
+ },
625
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Link.default, {
626
+ style: {
627
+ fontSize: 20,
628
+ marginRight: 4
629
+ }
630
+ }), " ", t('blocklet.component.addComponentTip.fromUrl'), ' ']
631
+ }) : null,
632
+ loading: loading,
633
+ onChange: () => {
634
+ setParams({});
635
+ component.current = {};
636
+ },
637
+ children: _ref6 => {
638
+ let {
639
+ currentRegistry
640
+ } = _ref6;
641
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_storeBlockletList.default, {
642
+ style: isMobile ? {
643
+ // should remove other dom height/margin
644
+ height: 'calc(100vh - 56px - 80px - 32px - 40px )'
645
+ } : {
646
+ height: 'calc(100% - 40px)'
647
+ },
648
+ storeUrl: currentRegistry.url,
649
+ handleButtonClick: chooseParams => {
650
+ setConfigValue({
651
+ chooseParams: _objectSpread(_objectSpread({}, chooseParams), {}, {
652
+ inStore: true // choose from store, must be inStore
653
+ }),
654
+
655
+ isInit: true
656
+ });
657
+ },
658
+ handleBlockletRender: _ref7 => {
659
+ let {
660
+ blocklet: blockletItem,
661
+ defaultRender
662
+ } = _ref7;
663
+ const isChosen = (params === null || params === void 0 ? void 0 : params.bundleDid) && (params === null || params === void 0 ? void 0 : params.bundleDid) === (blockletItem === null || blockletItem === void 0 ? void 0 : blockletItem.did);
664
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(StoreBlockletItemWrapper, {
665
+ children: [isChosen && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
666
+ className: "check-container",
667
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Check.default, {
668
+ className: "check-icon"
669
+ })
670
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
671
+ className: isChosen ? 'choose-blocklet' : '',
672
+ style: {
673
+ marginLeft: 16
674
+ },
675
+ children: defaultRender
676
+ })]
677
+ });
678
+ },
679
+ extraFilter: allBlocklets => {
680
+ // only use blocklets that are component
681
+ return allBlocklets === null || allBlocklets === void 0 ? void 0 : allBlocklets.filter(x => {
682
+ if (!(0, _util.isComponentBlocklet)(x)) {
683
+ return false;
684
+ }
685
+ if ((blocklet.children || []).some(y => y.meta.did === x.did)) {
686
+ return false;
687
+ }
688
+ return true;
689
+ });
690
+ }
691
+ });
692
+ }
693
+ })]
694
+ }),
695
+ cancel: t('common.cancel'),
696
+ confirm: getParamsName(params) ? t('blocklet.component.addNext', {
697
+ name: getParamsName(params)
698
+ }) : t('common.next'),
699
+ onCancel: onClose,
700
+ onConfirm: () => {
701
+ onNext();
702
+ }
703
+ }, {
704
+ key: 'agreement',
705
+ name: t('launchBlocklet.introduction'),
706
+ body: /*#__PURE__*/(0, _jsxRuntime.jsxs)(TypographyWrapper, {
707
+ component: "div",
708
+ className: "agreement-wrapper",
709
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_pageHeader.default, {
710
+ title: t('launchBlocklet.introduction'),
711
+ subTitle: t('blocklet.component.addComponentTip.introduction')
712
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_agreement.default, {
713
+ meta: meta,
714
+ onClickNext: onNext,
715
+ handleDescEle: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
716
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
717
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
718
+ // eslint-disable-next-line
719
+ dangerouslySetInnerHTML: {
720
+ __html: t("blocklet.component.addComponentTip.".concat(params.requirePurchase ? 'isPurchase' : 'isFree'), {
721
+ name: getComponentName()
722
+ })
723
+ }
724
+ })
725
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
726
+ children: t('blocklet.component.addComponentTip.belowInformation')
727
+ })]
728
+ })
729
+ })]
730
+ }),
731
+ cancel: t('common.pre'),
732
+ confirm: t('launchBlocklet.next'),
733
+ onCancel: _onCancel,
734
+ onConfirm: () => {
735
+ setIsWaitingPurchase(false);
736
+ onNext();
737
+ }
738
+ }, meta && params.requirePurchase && {
739
+ key: 'purchase',
740
+ name: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
741
+ children: [t('common.verifyNFT'), /*#__PURE__*/(0, _jsxRuntime.jsx)(_required.default, {})]
742
+ }),
743
+ body: /*#__PURE__*/(0, _jsxRuntime.jsxs)(TypographyWrapper, {
744
+ component: "div",
745
+ className: "flex-align-center",
746
+ style: {
747
+ flexDirection: 'column'
748
+ },
749
+ children: [!(((_purchaseRef$current = purchaseRef.current) === null || _purchaseRef$current === void 0 ? void 0 : (_purchaseRef$current$ = _purchaseRef$current.getCurrentStep) === null || _purchaseRef$current$ === void 0 ? void 0 : _purchaseRef$current$.call(_purchaseRef$current)) === 2 || isWaitingPurchase) && /*#__PURE__*/(0, _jsxRuntime.jsx)(PageHeaderWrapper, {
750
+ title: t('common.verifyNFT'),
751
+ subTitle: t('blocklet.component.addComponentTip.verifyNFT')
752
+ }), !(0, _isEmpty.default)(params.purchaseResultProps) ? /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
753
+ className: "flex-align-center flex-justify-center",
754
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_launchResultMessage.default, _objectSpread({}, params.purchaseResultProps))
755
+ }) : purchaseData && /*#__PURE__*/(0, _jsxRuntime.jsx)(_purchase.ComponentPurchaseSelect, {
756
+ ref: purchaseRef,
757
+ meta: purchaseData.meta
758
+ // if select deleted history, use verify mode
759
+ ,
760
+ mode: params.componentDid ? 'verify' : 'both',
761
+ onCancel: onCancelPurchase,
762
+ installOpts: purchaseData.installOpts,
763
+ handlePaySuccess: onSuccessPurchase
764
+ })]
765
+ }),
766
+ disabled: ((_purchaseRef$current2 = purchaseRef.current) === null || _purchaseRef$current2 === void 0 ? void 0 : (_purchaseRef$current3 = _purchaseRef$current2.getCurrentStep) === null || _purchaseRef$current3 === void 0 ? void 0 : _purchaseRef$current3.call(_purchaseRef$current2)) === 2 || isWaitingPurchase,
767
+ cancel: t('common.pre'),
768
+ confirm: t('common.next'),
769
+ onConfirm: () => {
770
+ if (typeof purchaseRef.current.onNext === 'function') {
771
+ purchaseRef.current.onNext();
772
+ setIsWaitingPurchase(true);
773
+ }
774
+ },
775
+ onCancel: () => {
776
+ _onCancel();
777
+ }
778
+ }, {
779
+ key: 'config',
780
+ name: t('common.config'),
781
+ error,
782
+ body: /*#__PURE__*/(0, _jsxRuntime.jsxs)(TypographyWrapper, {
783
+ component: "div",
784
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(PageHeaderWrapper, {
785
+ title: t('common.config'),
786
+ subTitle: t('blocklet.component.addComponentTip.config')
787
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_TextField.default, {
788
+ label: t('blocklet.component.mountPoint'),
789
+ autoComplete: "off",
790
+ variant: "outlined",
791
+ name: "pathPrefix",
792
+ inputProps: {
793
+ 'data-cy': 'mount-point-input'
794
+ },
795
+ fullWidth: true,
796
+ helperText: mountPointHelperText || t('blocklet.component.mountPointTip'),
797
+ style: {
798
+ marginBottom: 32
799
+ },
800
+ margin: "normal",
801
+ value: params.pathPrefix,
802
+ onChange: e => {
803
+ const pathPrefix = e.target.value;
804
+ updateParams({
805
+ pathPrefix
806
+ });
807
+ setMountPointHelperText(t('common.slugifyHint', {
808
+ value: (0, _util2.formatMountPoint)(pathPrefix)
809
+ }));
810
+ }
811
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_TextField.default, {
812
+ label: t('common.title'),
813
+ autoComplete: "off",
814
+ variant: "outlined",
815
+ fullWidth: true,
816
+ style: {
817
+ marginBottom: 32
818
+ },
819
+ margin: "normal",
820
+ value: params.title,
821
+ onChange: e => {
822
+ const title = e.target.value;
823
+ setParams(_objectSpread(_objectSpread({}, params), {}, {
824
+ title
825
+ }));
826
+ }
827
+ }), !!error && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Alert.default, {
828
+ type: "error",
829
+ style: {
830
+ width: '100%',
831
+ marginTop: 8
832
+ },
833
+ children: error
834
+ })]
835
+ }),
836
+ cancel: t('common.pre'),
837
+ confirm: t('common.next'),
838
+ onCancel: _onCancel,
839
+ onConfirm: () => {
840
+ onNext();
841
+ }
842
+ }, meta && (params === null || params === void 0 ? void 0 : params.hasEnvironmentsStep) && {
843
+ key: 'environment',
844
+ name: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
845
+ children: [t('common.environment'), " ", params.hasRequiredEnvironments && /*#__PURE__*/(0, _jsxRuntime.jsx)(_required.default, {})]
846
+ }),
847
+ disabled: !!editingItem || (params === null || params === void 0 ? void 0 : params.hasMissRequiredConfigs),
848
+ body: () => {
849
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(TypographyWrapper, {
850
+ component: "div",
851
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(PageHeaderWrapper, {
852
+ title: t('common.environment'),
853
+ subTitle: t('blocklet.component.addComponentTip.environment')
854
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_schemaForm.default, {
855
+ style: {
856
+ marginTop: -12,
857
+ width: '100%'
858
+ },
859
+ schema: params.configsList,
860
+ defaultValue: params.configsValue
861
+ // eslint-disable-next-line
862
+ ,
863
+ onChange: (changeValue, _ref8) => {
864
+ let {
865
+ action,
866
+ currentItem,
867
+ allValues
868
+ } = _ref8;
869
+ if (action === 'confirm') {
870
+ updateParams({
871
+ hasMissRequiredConfigs: hasMissRequiredConfigs(params.configsList, allValues),
872
+ configsValue: allValues
873
+ });
874
+ }
875
+ if (action === 'edit') {
876
+ setEditingItem(currentItem);
877
+ } else if (['cancel', 'confirm'].includes(action)) {
878
+ setEditingItem(null);
879
+ }
880
+ }
881
+ })]
882
+ });
883
+ },
884
+ cancel: t('common.pre'),
885
+ confirm: t('common.next'),
886
+ onCancel: _onCancel,
887
+ onConfirm: onNext
888
+ }, {
889
+ key: 'install',
890
+ name: t('common.install'),
891
+ disabled: false,
892
+ loading: false,
893
+ body: /*#__PURE__*/(0, _jsxRuntime.jsx)(TypographyWrapper, {
894
+ component: "div",
895
+ className: "flex-justify-center flex-align-center",
896
+ style: {
897
+ flexDirection: 'column'
898
+ },
899
+ children: (0, _isEmpty.default)(params.installResultProps) ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_AnimationWaiter.default, {
900
+ message: /*#__PURE__*/(0, _jsxRuntime.jsx)(MessageDiv, {
901
+ children: t('blocklet.component.installingCanCloseWindowTip')
902
+ }),
903
+ increaseSpeed: 0.3,
904
+ messageLoop: false
905
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
906
+ style: {
907
+ marginTop: 120
908
+ },
909
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_launchResultMessage.default, _objectSpread({}, params.installResultProps))
910
+ })
911
+ }),
912
+ confirm: t('common.complete'),
913
+ // onCancel: onClose,
914
+ onConfirm: () => {
915
+ onClose();
916
+ // scroll to bottom
917
+ setTimeout(() => {
918
+ const scrollDom = document.getElementsByClassName('dashboard-main')[0];
919
+ if (scrollDom) {
920
+ scrollDom.scrollTop = scrollDom.scrollHeight;
921
+ }
922
+ }, 200);
923
+ }
924
+ }].filter(item => item);
925
+ const step = steps[activeStep] || {};
926
+ const onMenuItemClick = e => {
927
+ e.stopPropagation();
928
+ // eslint-disable-next-line no-unused-expressions
929
+ setShowDialog(true);
930
+ };
931
+ const isDisabled = () => {
932
+ if (loading || step.error || !params.bundleDid) {
933
+ return true;
934
+ }
935
+ if (activeStep > 0) {
936
+ return !params.pathPrefix;
937
+ }
938
+ return false;
939
+ };
940
+
941
+ // show close button when step is not the last one
942
+ const showCloseButton = activeStep < steps.length - 1;
943
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
944
+ children: [typeof children === 'function' ? children({
945
+ loading,
946
+ open: onMenuItemClick
947
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_MenuItem.default, {
948
+ onClick: onMenuItemClick,
949
+ className: "component-action",
950
+ "data-cy": "action-add-component",
951
+ children: [loading ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_CircularProgress.default, {
952
+ size: 16
953
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_Link.default, {
954
+ style: {
955
+ fontSize: 18,
956
+ marginRight: 5
957
+ }
958
+ }), t('blocklet.component.add')]
959
+ }), showDialog && /*#__PURE__*/(0, _jsxRuntime.jsx)(DialogWrapper, {
960
+ title: t('blocklet.component.addWithName', {
961
+ name: (0, _util.getDisplayName)(blocklet)
962
+ }),
963
+ maxWidth: false,
964
+ fullWidth: false,
965
+ PaperProps: {
966
+ style: isMobile ? {
967
+ width: '100%',
968
+ height: window.innerHeight
969
+ } : {
970
+ maxWidth: 1350,
971
+ minWidth: 930,
972
+ width: '80%'
973
+ }
974
+ }
975
+ // eslint-disable-next-line no-unused-vars
976
+ ,
977
+ onClose: (event, reason) => {
978
+ var _steps$, _steps$$onCancel;
979
+ // disable backdropClick
980
+ if (reason === 'backdropClick') {
981
+ return;
982
+ }
983
+ (_steps$ = steps[0]) === null || _steps$ === void 0 ? void 0 : (_steps$$onCancel = _steps$.onCancel) === null || _steps$$onCancel === void 0 ? void 0 : _steps$$onCancel.call(_steps$);
984
+ },
985
+ showCloseButton: showCloseButton,
986
+ disableEscapeKeyDown: true,
987
+ open: true,
988
+ actions: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
989
+ children: [step.cancel && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
990
+ onClick: e => {
991
+ e.stopPropagation();
992
+ step.onCancel();
993
+ },
994
+ color: "inherit",
995
+ children: step.cancel || t('common.cancel')
996
+ }), step.confirm && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Button.default, {
997
+ onClick: e => {
998
+ e.stopPropagation();
999
+ step.onConfirm();
1000
+ },
1001
+ color: "primary",
1002
+ "data-cy": "submit-confirm-next",
1003
+ disabled: typeof step.disabled === 'boolean' ? step.disabled : isDisabled(),
1004
+ variant: "contained",
1005
+ autoFocus: true,
1006
+ title: step.confirm,
1007
+ style: {
1008
+ marginLeft: 8,
1009
+ overflow: 'hidden',
1010
+ textOverflow: 'ellipsis',
1011
+ whiteSpace: 'nowrap',
1012
+ maxWidth: '200px',
1013
+ display: 'inline-block'
1014
+ },
1015
+ children: [(typeof step.loading === 'boolean' ? step.loading : loading) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_CircularProgress.default, {
1016
+ size: 16
1017
+ }), step.confirm]
1018
+ })]
1019
+ }),
1020
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_step.StepProvider, {
1021
+ steps: steps,
1022
+ mode: "memory",
1023
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(StepContent, {
1024
+ ref: stepRef,
1025
+ meta: meta,
1026
+ isMobile: isMobile,
1027
+ onStepChange: newStep => {
1028
+ setActiveStep(newStep);
1029
+ }
1030
+ })
1031
+ })
1032
+ })]
1033
+ });
1034
+ }
1035
+ AddComponent.propTypes = {
1036
+ children: _propTypes.default.any,
1037
+ blocklet: _propTypes.default.object.isRequired
1038
+ };
1039
+ AddComponent.defaultProps = {
1040
+ children: null
1041
+ };
1042
+ const DialogWrapper = (0, _styled.default)(_Dialog.default)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .MuiDialogContent-root {\n padding-left: 0;\n padding-right: 0;\n padding-bottom: 0;\n }\n .MuiDialogActions-root {\n padding: 16px 24px;\n }\n"])));
1043
+ const TypographyWrapper = (0, _styled.default)(_Typography.default)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n width: 100%;\n height: 100%;\n"])));
1044
+ const RightContent = _styled.default.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n padding: 34px 24px 24px;\n width: 100%;\n display: flex;\n flex-direction: column;\n justify-content: flex-start;\n align-items: flex-start;\n\n .bottom-button {\n min-width: 200px;\n }\n\n // blocklet-select-side\n aside {\n width: 140px;\n }\n"])));
1045
+ const isMobileDialogContent = props => {
1046
+ if (props.isMobile) {
1047
+ return "\n height: calc(100vh - 56px - 64px - 48px);\n ";
1048
+ }
1049
+ return '';
1050
+ };
1051
+ const DialogContentWrapper = (0, _styled.default)(_DialogContentText.default)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n ", "\n\n & .flex-justify-center {\n display: flex;\n justify-content: center;\n }\n\n & .flex-align-center {\n display: flex;\n height: 100%;\n align-items: center;\n ", "\n }\n\n & .agreement-wrapper {\n ", "\n max-height: 60vh;\n .eula-trigger {\n padding-right: 0;\n }\n .next-button {\n display: none;\n }\n }\n\n & .connect {\n background: white;\n }\n"])), _ref9 => {
1052
+ let {
1053
+ className
1054
+ } = _ref9;
1055
+ // mobile extra style
1056
+ if (className === 'mobileStyle') {
1057
+ return "\n & > div{\n height: 100%;\n }\n .root-header {\n .app-name-content {\n display: none;\n }\n }\n\n // content-panel\n .root-header + div{\n padding-top: 0;\n position: relative;\n & > div {\n padding-top: 0;\n }\n }\n\n ";
1058
+ }
1059
+ return "\n height: 72vh;\n position: relative;\n .root-header {\n z-index: auto !important;\n position: fixed !important;\n }\n & > div {\n height: 100%;\n width: 100%;\n max-width: 100%;\n & > div {\n max-height: unset !important;\n max-width: 100%;\n & > div {\n // left-panel\n &:first-child {\n padding-top: 0;\n // padding-left: 0;\n width: 25%;\n min-width: 240px;\n & > div:first-child {\n display: none;\n }\n // step\n & > div:last-child {\n // margin-top: 32px;\n margin-top: 0;\n }\n }\n // right-panel\n &:last-child {\n padding-top: 0;\n padding-right: 24px;\n overflow-y: auto;\n .app-content {\n padding: 0 0 24px 0;\n }\n .button-container {\n padding-right: 0;\n }\n }\n }\n }\n }\n\n ";
1060
+ }, props => isMobileDialogContent(props), props => isMobileDialogContent(props));
1061
+ const PageHeaderWrapper = (0, _styled.default)(_pageHeader.default)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n margin-bottom: 24px;\n"])));
1062
+ const StoreBlockletItemWrapper = _styled.default.div(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n position: relative;\n\n .choose-blocklet {\n background-color: rgb(236, 251, 253);\n border-color: rgb(236, 251, 253);\n border-radius: 8px;\n }\n\n .check-container {\n position: absolute;\n right: 0;\n bottom: 0;\n display: flex;\n justify-content: flex-end;\n align-items: flex-end;\n width: 30px;\n height: 30px;\n border-radius: 0 0 8px 0;\n color: ", ";\n overflow: hidden;\n transition: all ease 0.3s;\n &:after {\n position: absolute;\n z-index: 0;\n display: block;\n width: 0;\n height: 0;\n border-top: transparent solid 15px;\n border-left: transparent solid 15px;\n border-bottom: ", " solid 15px;\n border-right: ", " solid 15px;\n transition: all ease 0.1s;\n content: '';\n }\n\n .check-icon {\n position: relative;\n z-index: 2;\n margin: 0 1px 1px 0;\n font-size: 16px;\n transition: all ease 0.2s;\n }\n }\n"])), props => props.theme.palette.common.white, props => props.theme.palette.primary.main, props => props.theme.palette.primary.main);
1063
+ const MessageDiv = _styled.default.div(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n color: ", ";\n .msg-before {\n display: inline-block;\n color: #aaa;\n font-size: 14px;\n margin-right: 6px;\n }\n"])), props => props.theme.palette.primary.main);