@abtnode/ux 1.16.13-beta-0086a35d → 1.16.13-beta-714bec78

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.
@@ -35,6 +35,7 @@ var _util = require("@blocklet/meta/lib/util");
35
35
  var _urlPathFriendly = _interopRequireDefault(require("@blocklet/meta/lib/url-path-friendly"));
36
36
  var _Toast = _interopRequireDefault(require("@arcblock/ux/lib/Toast"));
37
37
  var _node = require("../../contexts/node");
38
+ var _blocklet = require("../../contexts/blocklet");
38
39
  var _util2 = require("../../util");
39
40
  var _schemaForm = _interopRequireDefault(require("../../schema-form"));
40
41
  var _required = _interopRequireDefault(require("../../form/required"));
@@ -156,6 +157,11 @@ function AddComponent(_ref2) {
156
157
  inService,
157
158
  info: nodeInfo
158
159
  } = (0, _node.useNodeContext)();
160
+ const {
161
+ actions: {
162
+ refreshBlocklet: refreshApp
163
+ }
164
+ } = (0, _blocklet.useBlockletContext)();
159
165
  const [purchaseData, setPurchaseData] = (0, _react.useState)(null);
160
166
  const [isWaitingPurchase, setIsWaitingPurchase] = (0, _react.useState)(false);
161
167
  const initParams = {
@@ -218,24 +224,36 @@ function AddComponent(_ref2) {
218
224
  return '';
219
225
  };
220
226
  const setInstallErrorResult = errorMessage => {
221
- updateParams({
222
- installResultProps: {
223
- variant: 'error',
224
- title: getComponentName(),
225
- subTitle: errorMessage,
226
- footer: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
227
- className: "bottom-button",
228
- "data-cy": "retry-install-component",
229
- onClick: () => {
230
- updateParams({
231
- installResultProps: {}
232
- });
233
- onInstall(component.current.installInput);
234
- },
235
- children: t('common.retry')
236
- })
237
- }
238
- });
227
+ const update = _loading => {
228
+ updateParams({
229
+ installResultProps: {
230
+ variant: 'error',
231
+ title: getComponentName(),
232
+ subTitle: errorMessage,
233
+ footer: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
234
+ className: "bottom-button",
235
+ disabled: _loading,
236
+ "data-cy": "retry-install-component",
237
+ onClick: async () => {
238
+ // set button disabled and show spinner
239
+ update(true);
240
+ await onInstall(component.current.installInput);
241
+ },
242
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
243
+ display: "flex",
244
+ alignItems: "center",
245
+ children: [_loading && /*#__PURE__*/(0, _jsxRuntime.jsx)(_CircularProgress.default, {
246
+ size: 16,
247
+ style: {
248
+ marginRight: 8
249
+ }
250
+ }), t('common.retry')]
251
+ })
252
+ })
253
+ }
254
+ });
255
+ };
256
+ update();
239
257
  };
240
258
  const createBlockletEventHandler = handler => {
241
259
  return b => {
@@ -332,6 +350,15 @@ function AddComponent(_ref2) {
332
350
  });
333
351
  }
334
352
  }
353
+ updateParams({
354
+ installResultProps: {}
355
+ });
356
+
357
+ // let app state refresh fast before receive subscribe event
358
+ refreshApp({
359
+ showError: false,
360
+ attachRuntimeInfo: false
361
+ });
335
362
  } catch (err) {
336
363
  const errMsg = (0, _util2.formatError)(err);
337
364
  _Toast.default.error(errMsg);
@@ -357,7 +384,7 @@ function AddComponent(_ref2) {
357
384
  errMsg
358
385
  };
359
386
  };
360
- const onNext = payload => {
387
+ const onNext = async payload => {
361
388
  const {
362
389
  errMsg
363
390
  } = validateInput(_objectSpread(_objectSpread({}, params), {}, {
@@ -367,10 +394,7 @@ function AddComponent(_ref2) {
367
394
 
368
395
  // the step can complete, install component
369
396
  if (activeStep === steps.length - 2) {
370
- updateParams({
371
- installResultProps: {}
372
- });
373
- onInstall(payload);
397
+ await onInstall(payload);
374
398
  }
375
399
  setActiveStepByIndex(x => x + 1);
376
400
  };
@@ -1033,16 +1057,17 @@ function AddComponent(_ref2) {
1033
1057
  e.stopPropagation();
1034
1058
  step.onCancel();
1035
1059
  },
1060
+ disabled: activeStep === steps.length - 2 && loading,
1036
1061
  color: "inherit",
1037
1062
  children: step.cancel || t('common.cancel')
1038
- }), step.confirm && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Button.default, {
1063
+ }), step.confirm && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
1039
1064
  onClick: e => {
1040
1065
  e.stopPropagation();
1041
1066
  step.onConfirm();
1042
1067
  },
1043
1068
  color: "primary",
1044
1069
  "data-cy": "submit-confirm-next",
1045
- disabled: typeof step.disabled === 'boolean' ? step.disabled : isDisabled(),
1070
+ disabled: loading || (typeof step.disabled === 'boolean' ? step.disabled : isDisabled()),
1046
1071
  variant: "contained",
1047
1072
  autoFocus: true,
1048
1073
  title: step.confirm,
@@ -1054,9 +1079,13 @@ function AddComponent(_ref2) {
1054
1079
  maxWidth: '200px',
1055
1080
  display: 'inline-block'
1056
1081
  },
1057
- children: [(typeof step.loading === 'boolean' ? step.loading : loading) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_CircularProgress.default, {
1058
- size: 16
1059
- }), step.confirm]
1082
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
1083
+ display: "flex",
1084
+ alignItems: "center",
1085
+ children: [(typeof step.loading === 'boolean' ? step.loading : loading) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_CircularProgress.default, {
1086
+ size: 16
1087
+ }), step.confirm]
1088
+ })
1060
1089
  })]
1061
1090
  }),
1062
1091
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_step.StepProvider, {
@@ -328,7 +328,7 @@ function ComponentItem(_ref) {
328
328
  marginLeft: 4
329
329
  },
330
330
  mode: blocklet.mode || ''
331
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_status.default, {
331
+ }), status !== 'unknown' && /*#__PURE__*/(0, _jsxRuntime.jsx)(_status.default, {
332
332
  style: {
333
333
  marginLeft: 4
334
334
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abtnode/ux",
3
- "version": "1.16.13-beta-0086a35d",
3
+ "version": "1.16.13-beta-714bec78",
4
4
  "description": "UX components shared across abtnode packages",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -23,9 +23,9 @@
23
23
  "author": "linchen <linchen1987@foxmail.com> (http://github.com/linchen1987)",
24
24
  "license": "Apache-2.0",
25
25
  "dependencies": {
26
- "@abtnode/auth": "1.16.13-beta-0086a35d",
27
- "@abtnode/constant": "1.16.13-beta-0086a35d",
28
- "@abtnode/util": "1.16.13-beta-0086a35d",
26
+ "@abtnode/auth": "1.16.13-beta-714bec78",
27
+ "@abtnode/constant": "1.16.13-beta-714bec78",
28
+ "@abtnode/util": "1.16.13-beta-714bec78",
29
29
  "@ahooksjs/use-url-state": "^3.5.1",
30
30
  "@arcblock/did": "^1.18.84",
31
31
  "@arcblock/did-connect": "^2.5.54",
@@ -34,10 +34,10 @@
34
34
  "@arcblock/react-hooks": "^2.5.54",
35
35
  "@arcblock/terminal": "^2.5.54",
36
36
  "@arcblock/ux": "^2.5.54",
37
- "@blocklet/constant": "1.16.13-beta-0086a35d",
37
+ "@blocklet/constant": "1.16.13-beta-714bec78",
38
38
  "@blocklet/launcher-layout": "2.1.26",
39
39
  "@blocklet/list": "^0.12.4",
40
- "@blocklet/meta": "1.16.13-beta-0086a35d",
40
+ "@blocklet/meta": "1.16.13-beta-714bec78",
41
41
  "@blocklet/ui-react": "^2.5.54",
42
42
  "@emotion/react": "^11.10.4",
43
43
  "@emotion/styled": "^11.10.4",
@@ -95,5 +95,5 @@
95
95
  "@babel/preset-react": "^7.18.6",
96
96
  "babel-plugin-inline-react-svg": "^1.1.2"
97
97
  },
98
- "gitHead": "cbf5c99e7cadf9fef4d77673cb45b44ef26436cf"
98
+ "gitHead": "6f447ce64c37e20b871c4b2cbb81085bd509b84f"
99
99
  }