@abtnode/ux 1.8.35 → 1.8.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/blocklet/actions.js +1 -3
- package/lib/blocklet/agreement-app.js +28 -0
- package/lib/blocklet/agreement.js +72 -0
- package/lib/blocklet/avatar.js +1 -10
- package/lib/blocklet/component/add.js +1083 -0
- package/lib/blocklet/component/configuration.js +1 -1
- package/lib/blocklet/component/environment.js +1 -1
- package/lib/blocklet/component/index.js +9 -11
- package/lib/blocklet/component/select-store.js +151 -0
- package/lib/blocklet/component/setting.js +1 -1
- package/lib/blocklet/component/store-blocklet-list.js +203 -0
- package/lib/blocklet/configuration.js +2 -2
- package/lib/blocklet/install-from-url.js +362 -0
- package/lib/blocklet/preferences/index.js +168 -0
- package/lib/blocklet/purchase/common.js +103 -0
- package/lib/blocklet/purchase/component-purchase.js +251 -0
- package/lib/blocklet/purchase/index.js +13 -0
- package/lib/blocklet/router/rule-list.js +1 -1
- package/lib/blocklet/util.js +4 -16
- package/lib/blocklet/version.js +2 -2
- package/lib/hooks/blocklet.js +26 -10
- package/lib/locales/en.js +2 -0
- package/lib/locales/zh.js +2 -0
- package/lib/schema-form/index.js +1 -1
- package/lib/store/add.js +185 -0
- package/lib/store/delete.js +102 -0
- package/lib/store/item.js +84 -0
- package/lib/util/api.js +21 -0
- package/lib/util/constants.js +10 -0
- package/lib/util/index.js +24 -8
- package/package.json +10 -7
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ComponentPurchase = ComponentPurchase;
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _urlJoin = _interopRequireDefault(require("url-join"));
|
|
10
|
+
var _util = require("@blocklet/meta/lib/util");
|
|
11
|
+
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
12
|
+
var _Connect = _interopRequireDefault(require("@arcblock/did-connect/lib/Connect"));
|
|
13
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
14
|
+
var _pWaitFor = _interopRequireDefault(require("p-wait-for"));
|
|
15
|
+
var _toast = _interopRequireDefault(require("../../toast"));
|
|
16
|
+
var _node = require("../../contexts/node");
|
|
17
|
+
var _util2 = require("../../util");
|
|
18
|
+
var _api = require("../../util/api");
|
|
19
|
+
var _common = require("./common");
|
|
20
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
21
|
+
const _excluded = ["mode"];
|
|
22
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
+
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; }
|
|
24
|
+
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; }
|
|
25
|
+
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; }
|
|
26
|
+
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; }
|
|
27
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
28
|
+
function ComponentPurchase(_ref) {
|
|
29
|
+
let {
|
|
30
|
+
meta,
|
|
31
|
+
onCancel,
|
|
32
|
+
mode,
|
|
33
|
+
handlePaySuccess
|
|
34
|
+
} = _ref;
|
|
35
|
+
const {
|
|
36
|
+
t,
|
|
37
|
+
locale
|
|
38
|
+
} = (0, _context.useLocaleContext)();
|
|
39
|
+
const {
|
|
40
|
+
info
|
|
41
|
+
} = (0, _node.useNodeContext)();
|
|
42
|
+
const webWalletUrl = (0, _util2.getWebWalletUrl)(info);
|
|
43
|
+
const [nw, setNw] = (0, _react.useState)(null);
|
|
44
|
+
const baseUrl = new URL(meta === null || meta === void 0 ? void 0 : meta.registryUrl).origin;
|
|
45
|
+
const name = (0, _util.getDisplayName)({
|
|
46
|
+
meta
|
|
47
|
+
});
|
|
48
|
+
const handleConnectSuccess = async (result, decrypt) => {
|
|
49
|
+
const success = async _ref2 => {
|
|
50
|
+
let {
|
|
51
|
+
downloadTokenList
|
|
52
|
+
} = _ref2;
|
|
53
|
+
handlePaySuccess({
|
|
54
|
+
downloadTokenList
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
const failure = async errorMessage => {
|
|
58
|
+
_toast.default.error(errorMessage);
|
|
59
|
+
onCancel(errorMessage);
|
|
60
|
+
};
|
|
61
|
+
async function handleConnectSessionStatus(url) {
|
|
62
|
+
return (0, _pWaitFor.default)(() => {
|
|
63
|
+
return _api.api.get(url).then(async _ref3 => {
|
|
64
|
+
let {
|
|
65
|
+
data
|
|
66
|
+
} = _ref3;
|
|
67
|
+
const downloadTokenList = data === null || data === void 0 ? void 0 : data.downloadTokenList;
|
|
68
|
+
if (data.status === 'succeed') {
|
|
69
|
+
if (downloadTokenList && downloadTokenList.length) {
|
|
70
|
+
await success({
|
|
71
|
+
downloadTokenList
|
|
72
|
+
});
|
|
73
|
+
} else {
|
|
74
|
+
await failure(t('blocklet.component.missDownloadTokenTip'));
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
if (data.status === 'error') {
|
|
80
|
+
console.error('vc error: ', data);
|
|
81
|
+
await failure(data === null || data === void 0 ? void 0 : data.error);
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
return false;
|
|
85
|
+
});
|
|
86
|
+
}, {
|
|
87
|
+
interval: 1000
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
if (mode === 'purchase' && nw) {
|
|
91
|
+
const {
|
|
92
|
+
statusUrl
|
|
93
|
+
} = (0, _util2.extractStatusUrlFromNextWorkflow)(nw);
|
|
94
|
+
// poll status url, to get download token
|
|
95
|
+
await handleConnectSessionStatus(statusUrl);
|
|
96
|
+
} else {
|
|
97
|
+
await success({
|
|
98
|
+
downloadTokenList: result.downloadTokenList && decrypt(result.downloadTokenList)
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
(0, _react.useEffect)(() => {
|
|
103
|
+
// only purchase mode has nw
|
|
104
|
+
if (mode === 'purchase') {
|
|
105
|
+
const nextWorkflowUrl = new URL(baseUrl);
|
|
106
|
+
nextWorkflowUrl.pathname = '/api/did/verify-purchase-blocklet/token';
|
|
107
|
+
nextWorkflowUrl.searchParams.set('serverDid', info.did);
|
|
108
|
+
nextWorkflowUrl.searchParams.set('blockletDid', meta === null || meta === void 0 ? void 0 : meta.did);
|
|
109
|
+
try {
|
|
110
|
+
_api.api.get(nextWorkflowUrl.href).then(_ref4 => {
|
|
111
|
+
let {
|
|
112
|
+
data
|
|
113
|
+
} = _ref4;
|
|
114
|
+
const url = "".concat(data.url);
|
|
115
|
+
setNw(url);
|
|
116
|
+
});
|
|
117
|
+
} catch (error) {
|
|
118
|
+
console.error('get next workflow url error: ', error);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return () => {
|
|
122
|
+
setNw(null);
|
|
123
|
+
};
|
|
124
|
+
}, [mode]); // eslint-disable-line
|
|
125
|
+
|
|
126
|
+
// If nw does not exist, then connect should not be render
|
|
127
|
+
if (mode === 'purchase' && !nw) {
|
|
128
|
+
return '';
|
|
129
|
+
}
|
|
130
|
+
const modePropsMap = {
|
|
131
|
+
verify: {
|
|
132
|
+
action: 'verify-purchase-blocklet',
|
|
133
|
+
checkFn: _api.axios.create({
|
|
134
|
+
baseURL: baseUrl
|
|
135
|
+
}).get,
|
|
136
|
+
extraParams: {
|
|
137
|
+
serverDid: info.did,
|
|
138
|
+
blockletDid: meta === null || meta === void 0 ? void 0 : meta.did
|
|
139
|
+
},
|
|
140
|
+
messages: {
|
|
141
|
+
title: t('store.purchase.verify.auth.title', {
|
|
142
|
+
name
|
|
143
|
+
}),
|
|
144
|
+
scan: t('store.purchase.verify.auth.scan'),
|
|
145
|
+
confirm: t('store.purchase.verify.auth.confirm'),
|
|
146
|
+
success: t('store.purchase.verify.auth.success')
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
purchase: {
|
|
150
|
+
action: 'acquire-asset',
|
|
151
|
+
checkFn: _api.axios.create({
|
|
152
|
+
baseURL: (0, _urlJoin.default)(baseUrl, '/store')
|
|
153
|
+
}).get,
|
|
154
|
+
extraParams: {
|
|
155
|
+
factory: meta.nftFactory,
|
|
156
|
+
nw
|
|
157
|
+
},
|
|
158
|
+
messages: {
|
|
159
|
+
title: t('store.purchase.auth.title', {
|
|
160
|
+
name
|
|
161
|
+
}),
|
|
162
|
+
scan: t('store.purchase.auth.scan'),
|
|
163
|
+
confirm: t('store.purchase.auth.confirm'),
|
|
164
|
+
success: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
165
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
|
|
166
|
+
children: t('store.purchase.auth.success')
|
|
167
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
|
|
168
|
+
children: t('blocklet.component.purchaseComponentSecondCheckTip')
|
|
169
|
+
})]
|
|
170
|
+
})
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Connect.default, _objectSpread({
|
|
175
|
+
open: true,
|
|
176
|
+
locale: locale,
|
|
177
|
+
popup: false,
|
|
178
|
+
saveConnect: false,
|
|
179
|
+
className: "connect",
|
|
180
|
+
baseUrl: baseUrl,
|
|
181
|
+
onSuccess: handleConnectSuccess,
|
|
182
|
+
cancelWhenScanned: onCancel,
|
|
183
|
+
onClose: onCancel,
|
|
184
|
+
checkTimeout: 60 * 5000,
|
|
185
|
+
webWalletUrl: webWalletUrl,
|
|
186
|
+
disableClose: true,
|
|
187
|
+
showDownload: false
|
|
188
|
+
}, modePropsMap[mode]));
|
|
189
|
+
}
|
|
190
|
+
ComponentPurchase.propTypes = _objectSpread(_objectSpread({}, _common.commonProps), {}, {
|
|
191
|
+
handlePaySuccess: _propTypes.default.func,
|
|
192
|
+
mode: _propTypes.default.oneOf(['verify', 'purchase']).isRequired
|
|
193
|
+
});
|
|
194
|
+
ComponentPurchase.defaultProps = {
|
|
195
|
+
handlePaySuccess: () => {}
|
|
196
|
+
};
|
|
197
|
+
const ComponentPurchaseSelect = /*#__PURE__*/(0, _react.forwardRef)((_ref5, ref) => {
|
|
198
|
+
let {
|
|
199
|
+
mode
|
|
200
|
+
} = _ref5,
|
|
201
|
+
rest = _objectWithoutProperties(_ref5, _excluded);
|
|
202
|
+
const [action, setAction] = (0, _react.useState)(mode !== 'both' ? mode : 'verify');
|
|
203
|
+
const [step, setStep] = (0, _react.useState)(mode !== 'both' ? 2 : 1);
|
|
204
|
+
const onSelect = async act => {
|
|
205
|
+
if (act === action) {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
setAction(act);
|
|
209
|
+
};
|
|
210
|
+
const onNext = async () => {
|
|
211
|
+
if (!action) {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
if (step === 2) {
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
setStep(2);
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
// expose the func and activeStep
|
|
221
|
+
(0, _react.useImperativeHandle)(ref, () => ({
|
|
222
|
+
onNext,
|
|
223
|
+
getCurrentStep: () => {
|
|
224
|
+
return step;
|
|
225
|
+
}
|
|
226
|
+
}));
|
|
227
|
+
if (step === 1) {
|
|
228
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
229
|
+
style: {
|
|
230
|
+
maxWidth: 520
|
|
231
|
+
},
|
|
232
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_common.CustomSelect, {
|
|
233
|
+
action: action,
|
|
234
|
+
onNext: null,
|
|
235
|
+
onSelect: onSelect
|
|
236
|
+
})
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(ComponentPurchase, _objectSpread(_objectSpread({}, rest), {}, {
|
|
240
|
+
mode: action
|
|
241
|
+
}));
|
|
242
|
+
});
|
|
243
|
+
ComponentPurchaseSelect.propTypes = {
|
|
244
|
+
mode: _propTypes.default.oneOf(['both', 'verify', 'purchase']).isRequired,
|
|
245
|
+
ref: _propTypes.default.any
|
|
246
|
+
};
|
|
247
|
+
ComponentPurchaseSelect.defaultProps = {
|
|
248
|
+
ref: {}
|
|
249
|
+
};
|
|
250
|
+
var _default = ComponentPurchaseSelect;
|
|
251
|
+
exports.default = _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "ComponentPurchaseSelect", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _componentPurchase.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _componentPurchase = _interopRequireDefault(require("./component-purchase"));
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -166,7 +166,7 @@ RuleList.propTypes = {
|
|
|
166
166
|
RuleList.defaultProps = {
|
|
167
167
|
hasPermission: false
|
|
168
168
|
};
|
|
169
|
-
const RuleListInDaemon = (0, _permission.withPermission)(RuleList, '
|
|
169
|
+
const RuleListInDaemon = (0, _permission.withPermission)(RuleList, 'mutate_blocklets');
|
|
170
170
|
const RuleListInService = (0, _permission.withPermission)(RuleList, '', _util.BlockletAdminRoles);
|
|
171
171
|
function RuleListWithPermission(props) {
|
|
172
172
|
const {
|
package/lib/blocklet/util.js
CHANGED
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.downloadExportedSource = downloadExportedSource;
|
|
7
7
|
exports.fixBlocklet = exports.ensureDomainAliases = void 0;
|
|
8
8
|
exports.genExportedMeta = genExportedMeta;
|
|
9
|
-
exports.
|
|
9
|
+
exports.getLaunchAgreementUrl = void 0;
|
|
10
10
|
exports.getNameByTitle = getNameByTitle;
|
|
11
11
|
exports.getServerUrl = void 0;
|
|
12
12
|
var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
|
|
@@ -112,21 +112,9 @@ const getServerUrl = function getServerUrl(info) {
|
|
|
112
112
|
return encodeURI ? encodeURIComponent((0, _urlJoin.default)(window.location.origin, adminPath)) : (0, _urlJoin.default)(window.location.origin, adminPath);
|
|
113
113
|
};
|
|
114
114
|
exports.getServerUrl = getServerUrl;
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
const
|
|
118
|
-
const metaUrl = (0, _urlJoin.default)(info === null || info === void 0 ? void 0 : info.blockletRegistry, "/api/blocklets/".concat(meta.did, "/blocklet.json"));
|
|
119
|
-
return {
|
|
120
|
-
serverUrl,
|
|
121
|
-
metaUrl
|
|
122
|
-
};
|
|
123
|
-
};
|
|
124
|
-
exports.getLaunchURL = getLaunchURL;
|
|
125
|
-
const getLaunchAgreementUrl = (meta, info) => {
|
|
126
|
-
const {
|
|
127
|
-
metaUrl,
|
|
128
|
-
serverUrl
|
|
129
|
-
} = getLaunchURL(meta, info);
|
|
115
|
+
const getLaunchAgreementUrl = (meta, info, storeUrl) => {
|
|
116
|
+
const serverUrl = getServerUrl(info);
|
|
117
|
+
const metaUrl = (0, _urlJoin.default)(storeUrl, "/api/blocklets/".concat(meta.did, "/blocklet.json"));
|
|
130
118
|
const url = new URL((0, _urlJoin.default)(serverUrl, '/launch-blocklet/agreement'));
|
|
131
119
|
url.searchParams.set('blocklet_meta_url', metaUrl);
|
|
132
120
|
url.searchParams.set('from', window.location.href);
|
package/lib/blocklet/version.js
CHANGED
|
@@ -89,7 +89,7 @@ function Version(_ref) {
|
|
|
89
89
|
const input = {
|
|
90
90
|
did: blocklet.meta.did,
|
|
91
91
|
version: newVersionBlocklet.version,
|
|
92
|
-
|
|
92
|
+
storeUrl: newVersionBlocklet.registryUrl || ''
|
|
93
93
|
};
|
|
94
94
|
await (0, _util2.sleep)(2000);
|
|
95
95
|
await api.upgradeBlocklet({
|
|
@@ -165,7 +165,7 @@ Version.defaultProps = {
|
|
|
165
165
|
checkUpgrade: true,
|
|
166
166
|
hasPermission: false
|
|
167
167
|
};
|
|
168
|
-
const BlockletVersionInDaemon = (0, _permission.withPermission)(Version, '
|
|
168
|
+
const BlockletVersionInDaemon = (0, _permission.withPermission)(Version, 'mutate_blocklets');
|
|
169
169
|
const BlockletVersionInService = (0, _permission.withPermission)(Version, '', _util2.BlockletAdminRoles);
|
|
170
170
|
function BlockletVersion(props) {
|
|
171
171
|
const {
|
package/lib/hooks/blocklet.js
CHANGED
|
@@ -18,7 +18,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
18
18
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
19
19
|
// eslint-disable-next-line import/prefer-default-export
|
|
20
20
|
function useBlocklet(_ref) {
|
|
21
|
-
var _blocklet$site, _blocklet$site$domain, _blocklet$meta, _blocklet$meta2, _blocklet$meta3, _blocklet$meta4, _blocklet$meta5, _blocklet$meta6, _blocklet$meta7, _blocklet$meta8;
|
|
21
|
+
var _blocklet$site, _blocklet$site$domain, _blocklet$meta, _blocklet$meta2, _blocklet$meta3, _blocklet$meta4, _blocklet$meta5, _blocklet$meta6, _blocklet$meta7, _blocklet$meta8, _blocklet$meta9;
|
|
22
22
|
let {
|
|
23
23
|
did,
|
|
24
24
|
client,
|
|
@@ -109,6 +109,23 @@ function useBlocklet(_ref) {
|
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
};
|
|
112
|
+
const handleRefresh = data => {
|
|
113
|
+
var _data$meta;
|
|
114
|
+
if ((data === null || data === void 0 ? void 0 : (_data$meta = data.meta) === null || _data$meta === void 0 ? void 0 : _data$meta.did) === blocklet.meta.did) {
|
|
115
|
+
refreshBlocklet({
|
|
116
|
+
showError: false
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
const handleRefreshWithoutRuntime = data => {
|
|
121
|
+
var _data$meta2;
|
|
122
|
+
if ((data === null || data === void 0 ? void 0 : (_data$meta2 = data.meta) === null || _data$meta2 === void 0 ? void 0 : _data$meta2.did) === blocklet.meta.did) {
|
|
123
|
+
refreshBlocklet({
|
|
124
|
+
attachRuntimeInfo: false,
|
|
125
|
+
showError: false
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
};
|
|
112
129
|
const refreshDomainStatus = () => {
|
|
113
130
|
if (did && domainListStr) {
|
|
114
131
|
client.checkDomains({
|
|
@@ -131,15 +148,14 @@ function useBlocklet(_ref) {
|
|
|
131
148
|
[data.domain]: _objectSpread(_objectSpread({}, pre[data.domain]), data)
|
|
132
149
|
}));
|
|
133
150
|
}, [blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta = blocklet.meta) === null || _blocklet$meta === void 0 ? void 0 : _blocklet$meta.did, !disableSubscription]);
|
|
134
|
-
useSubscription(_constant.BlockletEvents.statusChange, ()
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
useSubscription(_constant.BlockletEvents.
|
|
138
|
-
useSubscription(_constant.BlockletEvents.
|
|
139
|
-
useSubscription(_constant.BlockletEvents.
|
|
140
|
-
useSubscription(_constant.BlockletEvents.
|
|
141
|
-
useSubscription(_constant.BlockletEvents.
|
|
142
|
-
useSubscription(_constant.BlockletEvents.updated, refreshBlocklet, [blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta8 = blocklet.meta) === null || _blocklet$meta8 === void 0 ? void 0 : _blocklet$meta8.did, !disableSubscription]);
|
|
151
|
+
useSubscription(_constant.BlockletEvents.statusChange, handleRefreshWithoutRuntime, [blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta2 = blocklet.meta) === null || _blocklet$meta2 === void 0 ? void 0 : _blocklet$meta2.did, !disableSubscription]); // eslint-disable-line prettier/prettier
|
|
152
|
+
useSubscription(_constant.BlockletEvents.storeChange, handleRefreshWithoutRuntime, [blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta3 = blocklet.meta) === null || _blocklet$meta3 === void 0 ? void 0 : _blocklet$meta3.did, !disableSubscription]);
|
|
153
|
+
useSubscription(_constant.BlockletEvents.started, handleRefresh, [blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta4 = blocklet.meta) === null || _blocklet$meta4 === void 0 ? void 0 : _blocklet$meta4.did, !disableSubscription]);
|
|
154
|
+
useSubscription(_constant.BlockletEvents.startFailed, handleRefresh, [blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta5 = blocklet.meta) === null || _blocklet$meta5 === void 0 ? void 0 : _blocklet$meta5.did, !disableSubscription]);
|
|
155
|
+
useSubscription(_constant.BlockletEvents.installed, handleRefresh, [blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta6 = blocklet.meta) === null || _blocklet$meta6 === void 0 ? void 0 : _blocklet$meta6.did, !disableSubscription]);
|
|
156
|
+
useSubscription(_constant.BlockletEvents.upgraded, handleRefresh, [blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta7 = blocklet.meta) === null || _blocklet$meta7 === void 0 ? void 0 : _blocklet$meta7.did, !disableSubscription]);
|
|
157
|
+
useSubscription(_constant.BlockletEvents.downgraded, handleRefresh, [blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta8 = blocklet.meta) === null || _blocklet$meta8 === void 0 ? void 0 : _blocklet$meta8.did, !disableSubscription]);
|
|
158
|
+
useSubscription(_constant.BlockletEvents.updated, handleRefresh, [blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta9 = blocklet.meta) === null || _blocklet$meta9 === void 0 ? void 0 : _blocklet$meta9.did, !disableSubscription]);
|
|
143
159
|
const data = blocklet ? (0, _merge.default)(blocklet, {
|
|
144
160
|
site: {
|
|
145
161
|
domainAliases: blocklet.site.domainAliases.map(x => {
|
package/lib/locales/en.js
CHANGED
package/lib/locales/zh.js
CHANGED
package/lib/schema-form/index.js
CHANGED
|
@@ -224,4 +224,4 @@ SchemaForm.defaultProps = {
|
|
|
224
224
|
style: {},
|
|
225
225
|
disabled: false
|
|
226
226
|
};
|
|
227
|
-
const StyledFormWrapper = (0, _styled.default)(_formWrapper.default)(_templateObject || (_templateObject = _taggedTemplateLiteral(["
|
|
227
|
+
const StyledFormWrapper = (0, _styled.default)(_formWrapper.default)(_templateObject || (_templateObject = _taggedTemplateLiteral([""])));
|
package/lib/store/add.js
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = AddStore;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _styles = require("@mui/styles");
|
|
10
|
+
var _Spinner = _interopRequireDefault(require("@arcblock/ux/lib/Spinner"));
|
|
11
|
+
var _Dialog = _interopRequireDefault(require("@arcblock/ux/lib/Dialog"));
|
|
12
|
+
var _DialogContentText = _interopRequireDefault(require("@mui/material/DialogContentText"));
|
|
13
|
+
var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
|
|
14
|
+
var _TextField = _interopRequireDefault(require("@mui/material/TextField"));
|
|
15
|
+
var _ListItem = _interopRequireDefault(require("@mui/material/ListItem"));
|
|
16
|
+
var _Add = _interopRequireDefault(require("@mui/icons-material/Add"));
|
|
17
|
+
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
18
|
+
var _Button = _interopRequireDefault(require("@arcblock/ux/lib/Button"));
|
|
19
|
+
var _Alert = _interopRequireDefault(require("@arcblock/ux/lib/Alert"));
|
|
20
|
+
var _node = require("../contexts/node");
|
|
21
|
+
var _util = require("../util");
|
|
22
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
23
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
24
|
+
const useStyles = (0, _styles.makeStyles)(theme => ({
|
|
25
|
+
addMenuItemRoot: {
|
|
26
|
+
justifyContent: 'center',
|
|
27
|
+
color: theme.palette.primary.main,
|
|
28
|
+
lineHeight: '3.2'
|
|
29
|
+
}
|
|
30
|
+
}));
|
|
31
|
+
function AddStore(_ref) {
|
|
32
|
+
let {
|
|
33
|
+
disabled,
|
|
34
|
+
storeList,
|
|
35
|
+
teamDid,
|
|
36
|
+
onAdd
|
|
37
|
+
} = _ref;
|
|
38
|
+
const {
|
|
39
|
+
api
|
|
40
|
+
} = (0, _node.useNodeContext)();
|
|
41
|
+
const [loading, setLoading] = (0, _react.useState)(false);
|
|
42
|
+
const [disable, setDisable] = (0, _react.useState)(true);
|
|
43
|
+
const [open, setOpen] = (0, _react.useState)(false);
|
|
44
|
+
const [url, setUrl] = (0, _react.useState)('');
|
|
45
|
+
const [error, setError] = (0, _react.useState)('');
|
|
46
|
+
const {
|
|
47
|
+
t
|
|
48
|
+
} = (0, _context.useLocaleContext)();
|
|
49
|
+
const classes = useStyles();
|
|
50
|
+
const onConfirm = async () => {
|
|
51
|
+
setLoading(true);
|
|
52
|
+
try {
|
|
53
|
+
const {
|
|
54
|
+
isNew,
|
|
55
|
+
decoded
|
|
56
|
+
} = (0, _util.isNewStoreUrl)(url, storeList);
|
|
57
|
+
if (!isNew) {
|
|
58
|
+
throw new Error(t('store.blockletRegistry.haveSameRegistry'));
|
|
59
|
+
}
|
|
60
|
+
await api.addBlockletStore({
|
|
61
|
+
input: {
|
|
62
|
+
teamDid,
|
|
63
|
+
url: decoded
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
onAdd(decoded);
|
|
67
|
+
setOpen(false);
|
|
68
|
+
} catch (err) {
|
|
69
|
+
const errMsg = "".concat(t('store.blockletRegistry.addFailed'), " ").concat((0, _util.formatError)(err));
|
|
70
|
+
setError(errMsg);
|
|
71
|
+
} finally {
|
|
72
|
+
setLoading(false);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
76
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_ListItem.default, {
|
|
77
|
+
button: true,
|
|
78
|
+
disabled: disabled,
|
|
79
|
+
className: classes.addMenuItemRoot,
|
|
80
|
+
onClick: () => {
|
|
81
|
+
setOpen(true);
|
|
82
|
+
},
|
|
83
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Add.default, {
|
|
84
|
+
font: true
|
|
85
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
|
86
|
+
variant: "inherit",
|
|
87
|
+
children: t('store.blockletRegistry.addRegistry')
|
|
88
|
+
})]
|
|
89
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Dialog.default, {
|
|
90
|
+
title: t('store.blockletRegistry.addRegistry'),
|
|
91
|
+
fullWidth: true,
|
|
92
|
+
maxWidth: "md",
|
|
93
|
+
open: open,
|
|
94
|
+
onClose: () => setOpen(false),
|
|
95
|
+
PaperProps: {
|
|
96
|
+
style: {
|
|
97
|
+
minHeight: 'auto'
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
actions: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
101
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
|
|
102
|
+
onClick: e => {
|
|
103
|
+
e.stopPropagation();
|
|
104
|
+
setOpen(false);
|
|
105
|
+
},
|
|
106
|
+
color: "inherit",
|
|
107
|
+
children: t('common.cancel')
|
|
108
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Button.default, {
|
|
109
|
+
onClick: e => {
|
|
110
|
+
e.stopPropagation();
|
|
111
|
+
onConfirm();
|
|
112
|
+
},
|
|
113
|
+
color: "primary",
|
|
114
|
+
"data-cy": "install-blocklet-next-step",
|
|
115
|
+
disabled: loading || !url || disable,
|
|
116
|
+
variant: "contained",
|
|
117
|
+
autoFocus: true,
|
|
118
|
+
children: [loading && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Spinner.default, {
|
|
119
|
+
size: [16, 10]
|
|
120
|
+
}), t('common.confirm')]
|
|
121
|
+
})]
|
|
122
|
+
}),
|
|
123
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
124
|
+
style: {
|
|
125
|
+
paddingTop: 12,
|
|
126
|
+
overflowY: 'hidden'
|
|
127
|
+
},
|
|
128
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_DialogContentText.default, {
|
|
129
|
+
component: "div",
|
|
130
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
|
131
|
+
component: "div",
|
|
132
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_TextField.default, {
|
|
133
|
+
label: t('store.blockletRegistry.registryUrl'),
|
|
134
|
+
autoComplete: "off",
|
|
135
|
+
variant: "outlined",
|
|
136
|
+
name: "url",
|
|
137
|
+
fullWidth: true,
|
|
138
|
+
value: url,
|
|
139
|
+
onChange: e => {
|
|
140
|
+
setError(null);
|
|
141
|
+
let isDisabled = false;
|
|
142
|
+
if (!e.target.value.trim()) {
|
|
143
|
+
isDisabled = true;
|
|
144
|
+
}
|
|
145
|
+
if (!e.target.value.trim()) {
|
|
146
|
+
setError(t('store.blockletRegistry.registryUrlEmpty'));
|
|
147
|
+
}
|
|
148
|
+
setUrl(e.target.value);
|
|
149
|
+
setDisable(isDisabled);
|
|
150
|
+
},
|
|
151
|
+
disabled: loading,
|
|
152
|
+
onKeyPress: e => {
|
|
153
|
+
if (e.key === 'Enter') {
|
|
154
|
+
e.preventDefault();
|
|
155
|
+
if (!e.target.value.trim()) {
|
|
156
|
+
setError(t('store.blockletRegistry.registryUrlEmpty'));
|
|
157
|
+
} else {
|
|
158
|
+
onConfirm();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
})
|
|
163
|
+
})
|
|
164
|
+
})
|
|
165
|
+
}), !!error && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Alert.default, {
|
|
166
|
+
type: "error",
|
|
167
|
+
style: {
|
|
168
|
+
width: '100%'
|
|
169
|
+
},
|
|
170
|
+
children: error
|
|
171
|
+
})]
|
|
172
|
+
})]
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
AddStore.propTypes = {
|
|
176
|
+
teamDid: _propTypes.default.string.isRequired,
|
|
177
|
+
disabled: _propTypes.default.bool,
|
|
178
|
+
storeList: _propTypes.default.array,
|
|
179
|
+
onAdd: _propTypes.default.func
|
|
180
|
+
};
|
|
181
|
+
AddStore.defaultProps = {
|
|
182
|
+
disabled: false,
|
|
183
|
+
storeList: [],
|
|
184
|
+
onAdd: () => {}
|
|
185
|
+
};
|