@blocklet/launcher-workflow 2.1.25 → 2.1.26
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/checkout.js +4 -2
- package/lib/components/plan.js +16 -3
- package/lib/locales/en.js +1 -0
- package/lib/locales/zh.js +1 -0
- package/lib/purchase.js +32 -5
- package/package.json +5 -5
package/lib/checkout.js
CHANGED
|
@@ -20,6 +20,7 @@ var _useAsync = _interopRequireDefault(require("react-use/lib/useAsync"));
|
|
|
20
20
|
var _useSetState = _interopRequireDefault(require("react-use/lib/useSetState"));
|
|
21
21
|
var _dsbridge = _interopRequireDefault(require("dsbridge"));
|
|
22
22
|
var _urlJoin = _interopRequireDefault(require("url-join"));
|
|
23
|
+
var _lodash = _interopRequireDefault(require("lodash.get"));
|
|
23
24
|
var _confirm = _interopRequireDefault(require("@arcblock/ux/lib/Dialog/confirm"));
|
|
24
25
|
var _formatError = _interopRequireDefault(require("@blocklet/launcher-util/lib/format-error"));
|
|
25
26
|
var _launchResultMessage = _interopRequireDefault(require("@blocklet/launcher-layout/lib/launch-result-message"));
|
|
@@ -166,12 +167,13 @@ function CheckoutPage(_ref) {
|
|
|
166
167
|
events.on('logout', () => {
|
|
167
168
|
const metaUrl = params.get('blocklet_meta_url');
|
|
168
169
|
_util2.launchSession.create(api, routerPrefix, metaUrl, (err, launch) => {
|
|
170
|
+
var _context$value;
|
|
169
171
|
setState({
|
|
170
172
|
sessionId: launch._id
|
|
171
173
|
});
|
|
172
174
|
params.set('sessionId', launch._id);
|
|
173
|
-
|
|
174
|
-
_util2.launchSession.select(api, routerPrefix, launch._id,
|
|
175
|
+
const type = (0, _lodash.default)((_context$value = context.value) === null || _context$value === void 0 ? void 0 : _context$value.plan, 'extra.type') || 'serverless';
|
|
176
|
+
_util2.launchSession.select(api, routerPrefix, launch._id, type, state.planId);
|
|
175
177
|
});
|
|
176
178
|
});
|
|
177
179
|
}, []);
|
package/lib/components/plan.js
CHANGED
|
@@ -14,6 +14,7 @@ var _FormControl = _interopRequireDefault(require("@mui/material/FormControl"));
|
|
|
14
14
|
var _Select = _interopRequireDefault(require("@mui/material/Select"));
|
|
15
15
|
var _useMobile = _interopRequireDefault(require("@blocklet/launcher-ux/lib/use-mobile"));
|
|
16
16
|
var _lodash = _interopRequireDefault(require("lodash.noop"));
|
|
17
|
+
var _material = require("@mui/material");
|
|
17
18
|
var _util = require("../../lib/util");
|
|
18
19
|
var _locale = require("../contexts/locale");
|
|
19
20
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
@@ -189,6 +190,7 @@ function Plan(_ref2) {
|
|
|
189
190
|
if (toc) {
|
|
190
191
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Container, {
|
|
191
192
|
className: "toc",
|
|
193
|
+
available: true,
|
|
192
194
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
193
195
|
className: "basic-toc",
|
|
194
196
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
|
@@ -243,9 +245,10 @@ function Plan(_ref2) {
|
|
|
243
245
|
console.error('parse features failed:', error);
|
|
244
246
|
}
|
|
245
247
|
const providerName = (_paymentMethods$find = paymentMethods.find(x => x._id === paymentMethod)) === null || _paymentMethods$find === void 0 ? void 0 : _paymentMethods$find.provider.name;
|
|
246
|
-
|
|
248
|
+
const content = /*#__PURE__*/(0, _jsxRuntime.jsxs)(Container, _objectSpread(_objectSpread({
|
|
247
249
|
checked: checked,
|
|
248
|
-
className: "card-container ".concat(checked ? 'checked' : '')
|
|
250
|
+
className: "card-container ".concat(checked ? 'checked' : ''),
|
|
251
|
+
available: !!plan.available
|
|
249
252
|
}, rest), {}, {
|
|
250
253
|
children: [recommend && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
251
254
|
className: "recommend-tag",
|
|
@@ -286,8 +289,18 @@ function Plan(_ref2) {
|
|
|
286
289
|
})
|
|
287
290
|
})]
|
|
288
291
|
}));
|
|
292
|
+
if (plan.available) {
|
|
293
|
+
return content;
|
|
294
|
+
}
|
|
295
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Tooltip, {
|
|
296
|
+
title: plan.reason,
|
|
297
|
+
style: {
|
|
298
|
+
cursor: 'not-allowed'
|
|
299
|
+
},
|
|
300
|
+
children: content
|
|
301
|
+
});
|
|
289
302
|
}
|
|
290
|
-
const Container = _styled.default.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n display: flex;\n position: relative;\n align-items: center;\n flex-direction: column;\n border-radius: 12px;\n overflow: hidden;\n min-height: 400px;\n white-space: nowrap;\n padding: 16px;\n\n .recommend-tag {\n display: block;\n position: absolute;\n top: 4px;\n right: 32px;\n color: #fff;\n padding: 4px 100px;\n position: absolute;\n transform: translate(50%, 50%) rotate(45deg);\n white-space: nowrap;\n background-color: #fe9344;\n transform-origin: center;\n }\n\n .toc__title {\n font-weight: bolder;\n align-items: flex-start;\n }\n\n &:not(.toc) {\n width: 280px;\n color: #000;\n background-color: ", ";\n cursor: pointer;\n }\n\n &:not(.toc, .checked):hover {\n color: #000;\n background-color: #ddf6f8;\n cursor: pointer;\n }\n\n &.checked {\n color: #fff;\n background-color: ", ";\n cursor: pointer;\n }\n\n .basic-toc {\n width: 100%;\n height: 8em;\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: flex-start;\n\n .payment-methods {\n padding-top: 3em;\n font-size: 1.1em;\n font-weight: bolder;\n\n select {\n margin-left: 1em;\n }\n }\n }\n\n .basic {\n width: 100%;\n height: 8em;\n\n .header {\n text-align: center;\n .header__title {\n color: ", ";\n }\n\n .header__name {\n font-weight: bolder;\n }\n }\n\n .price-info {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n height: 6.5em;\n\n .price {\n font-size: 1.5em;\n font-weight: bolder;\n }\n\n .period {\n color: ", ";\n }\n }\n }\n\n .features {\n display: flex;\n flex-direction: column;\n width: 100%;\n margin-top: auto;\n\n .feature {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 48px;\n text-align: center;\n\n // \u79FB\u52A8\u7AEF\u4E0D\u51CF\u5C0F\n @media (max-height: 960px) and (min-width: 640px) {\n height: 36px;\n font-size: 0.9rem;\n }\n\n @media (max-width: 900px) {\n justify-content: flex-start;\n }\n\n &:not(:last-child) {\n border-bottom: 1px solid;\n border-bottom-color: ", ";\n }\n }\n }\n"])), props => props.theme.palette.secondary.main, props => props.theme.palette.primary.main, props => props.checked ? '#ffffff' : '#9397a1', props => props.checked ? '#ffffff' : '#9397a1', props => props.checked || props.hovered ? 'rgba(255, 255, 255, 0.2)' : '#f6f6f6');
|
|
303
|
+
const Container = _styled.default.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n display: flex;\n position: relative;\n align-items: center;\n flex-direction: column;\n border-radius: 12px;\n overflow: hidden;\n min-height: 400px;\n white-space: nowrap;\n padding: 16px;\n filter: grayscale(", ");\n opacity: ", ";\n\n .recommend-tag {\n display: block;\n position: absolute;\n top: 4px;\n right: 32px;\n color: #fff;\n padding: 4px 100px;\n position: absolute;\n transform: translate(50%, 50%) rotate(45deg);\n white-space: nowrap;\n background-color: #fe9344;\n transform-origin: center;\n }\n\n .toc__title {\n font-weight: bolder;\n align-items: flex-start;\n }\n\n &:not(.toc) {\n width: 280px;\n color: #000;\n background-color: ", ";\n cursor: pointer;\n }\n\n &:not(.toc, .checked):hover {\n color: #000;\n background-color: #ddf6f8;\n cursor: pointer;\n }\n\n &.checked {\n color: #fff;\n background-color: ", ";\n cursor: pointer;\n }\n\n .basic-toc {\n width: 100%;\n height: 8em;\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: flex-start;\n\n .payment-methods {\n padding-top: 3em;\n font-size: 1.1em;\n font-weight: bolder;\n\n select {\n margin-left: 1em;\n }\n }\n }\n\n .basic {\n width: 100%;\n height: 8em;\n\n .header {\n text-align: center;\n .header__title {\n color: ", ";\n }\n\n .header__name {\n font-weight: bolder;\n }\n }\n\n .price-info {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n height: 6.5em;\n\n .price {\n font-size: 1.5em;\n font-weight: bolder;\n }\n\n .period {\n color: ", ";\n }\n }\n }\n\n .features {\n display: flex;\n flex-direction: column;\n width: 100%;\n margin-top: auto;\n\n .feature {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 48px;\n text-align: center;\n\n // \u79FB\u52A8\u7AEF\u4E0D\u51CF\u5C0F\n @media (max-height: 960px) and (min-width: 640px) {\n height: 36px;\n font-size: 0.9rem;\n }\n\n @media (max-width: 900px) {\n justify-content: flex-start;\n }\n\n &:not(:last-child) {\n border-bottom: 1px solid;\n border-bottom-color: ", ";\n }\n }\n }\n"])), props => props.available ? 0 : 1, props => props.available ? 1 : 0.4, props => props.theme.palette.secondary.main, props => props.theme.palette.primary.main, props => props.checked ? '#ffffff' : '#9397a1', props => props.checked ? '#ffffff' : '#9397a1', props => props.checked || props.hovered ? 'rgba(255, 255, 255, 0.2)' : '#f6f6f6');
|
|
291
304
|
Plan.propTypes = {
|
|
292
305
|
plan: _propTypes.default.object.isRequired,
|
|
293
306
|
paymentMethod: _propTypes.default.string.isRequired,
|
package/lib/locales/en.js
CHANGED
|
@@ -104,6 +104,7 @@ module.exports = {
|
|
|
104
104
|
morePlanPrompt: 'Flip the page to see more plans',
|
|
105
105
|
redeem: 'Select purchased space',
|
|
106
106
|
noProducts: 'No products available for purchase, please check your payment-kit config',
|
|
107
|
+
serverlessNotSupported: 'This app is not allowed in sigular and on-demand space, please select dedicated space',
|
|
107
108
|
dialog: {
|
|
108
109
|
title: 'Purchase Blocklet Space NFT',
|
|
109
110
|
scan: 'Scan the QR code below with your DID wallet to complete purchase',
|
package/lib/locales/zh.js
CHANGED
|
@@ -103,6 +103,7 @@ module.exports = {
|
|
|
103
103
|
morePlanPrompt: '翻页看更多方案',
|
|
104
104
|
redeem: '我已购买空间',
|
|
105
105
|
noProducts: '没有可购买的商品,请检查 PaymentKit 的配置',
|
|
106
|
+
serverlessNotSupported: '该应用被禁止能在单应用或者按需空间中运行,请选择专用空间',
|
|
106
107
|
dialog: {
|
|
107
108
|
title: '购买 Blocklet Server NFT',
|
|
108
109
|
scan: '用您的 DID 钱包扫描下面的二维码完成购买',
|
package/lib/purchase.js
CHANGED
|
@@ -21,6 +21,7 @@ var _reactRouterDom = require("react-router-dom");
|
|
|
21
21
|
var _useMeasure = _interopRequireDefault(require("react-use/lib/useMeasure"));
|
|
22
22
|
var _useSetState = _interopRequireDefault(require("react-use/lib/useSetState"));
|
|
23
23
|
var _urlJoin = _interopRequireDefault(require("url-join"));
|
|
24
|
+
var _lodash = _interopRequireDefault(require("lodash.get"));
|
|
24
25
|
require("@splidejs/splide/dist/css/splide.min.css");
|
|
25
26
|
var _launchResultMessage = _interopRequireDefault(require("@blocklet/launcher-layout/lib/launch-result-message"));
|
|
26
27
|
var _formatError = _interopRequireDefault(require("@blocklet/launcher-util/lib/format-error"));
|
|
@@ -187,7 +188,28 @@ function PurchasePage(_ref) {
|
|
|
187
188
|
});
|
|
188
189
|
return;
|
|
189
190
|
}
|
|
190
|
-
|
|
191
|
+
let plans = (data || []).sort((a, b) => b.weight - a.weight);
|
|
192
|
+
const {
|
|
193
|
+
components = []
|
|
194
|
+
} = (0, _lodash.default)(window, 'blockletMeta', {}) || {};
|
|
195
|
+
const supported = components.every(x => (0, _lodash.default)(x, 'meta.capabilities.serverless', true));
|
|
196
|
+
plans.forEach(x => {
|
|
197
|
+
if ((0, _lodash.default)(x, 'extra.type') === 'serverless' && !supported) {
|
|
198
|
+
x.available = false;
|
|
199
|
+
x.reason = t('purchase.serverlessNotSupported');
|
|
200
|
+
} else {
|
|
201
|
+
x.available = true;
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
plans = plans.sort((a, b) => {
|
|
205
|
+
if (b.available && !a.available) {
|
|
206
|
+
return 1;
|
|
207
|
+
}
|
|
208
|
+
if (!b.available && a.available) {
|
|
209
|
+
return -1;
|
|
210
|
+
}
|
|
211
|
+
return 0;
|
|
212
|
+
});
|
|
191
213
|
setState({
|
|
192
214
|
plans,
|
|
193
215
|
paymentMethods,
|
|
@@ -231,7 +253,7 @@ function PurchasePage(_ref) {
|
|
|
231
253
|
if (!((_state$plans = state.plans) !== null && _state$plans !== void 0 && _state$plans.length) || typeof state.perPage === 'undefined') {
|
|
232
254
|
return;
|
|
233
255
|
}
|
|
234
|
-
const index = state.plans.findIndex(x => !!x.isRecommended);
|
|
256
|
+
const index = state.plans.findIndex(x => !!x.isRecommended && x.available);
|
|
235
257
|
const pageIndex = Math.floor(index / state.perPage);
|
|
236
258
|
|
|
237
259
|
// 如果推荐 Plan 不在第一页,则将推荐 Plan 放在第一个
|
|
@@ -259,9 +281,13 @@ function PurchasePage(_ref) {
|
|
|
259
281
|
setState(getSlideConfig(tmp, state.plans.length));
|
|
260
282
|
}, [width, state.plans, isMobile]);
|
|
261
283
|
const handleSelect = planId => {
|
|
284
|
+
var _state$plans$find;
|
|
262
285
|
if (state.planId === planId) {
|
|
263
286
|
return;
|
|
264
287
|
}
|
|
288
|
+
if (((_state$plans$find = state.plans.find(x => x._id === planId)) === null || _state$plans$find === void 0 ? void 0 : _state$plans$find.available) === false) {
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
265
291
|
setState({
|
|
266
292
|
planId
|
|
267
293
|
});
|
|
@@ -291,9 +317,9 @@ function PurchasePage(_ref) {
|
|
|
291
317
|
if (!state.planId || !state.sessionId) {
|
|
292
318
|
return;
|
|
293
319
|
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
_util.launchSession.select(api, routerPrefix, state.sessionId,
|
|
320
|
+
const plan = state.plans.find(x => x._id === state.planId);
|
|
321
|
+
const type = (0, _lodash.default)(plan, 'extra.type') || 'serverless';
|
|
322
|
+
_util.launchSession.select(api, routerPrefix, state.sessionId, type, state.planId);
|
|
297
323
|
}, [state.planId, state.sessionId]);
|
|
298
324
|
const productFeatures = [];
|
|
299
325
|
if (!state.loading && ((_state$plans3 = state.plans) === null || _state$plans3 === void 0 ? void 0 : _state$plans3.length) > 0) {
|
|
@@ -423,6 +449,7 @@ function PurchasePage(_ref) {
|
|
|
423
449
|
},
|
|
424
450
|
hasTrack: false,
|
|
425
451
|
options: {
|
|
452
|
+
rewind: true,
|
|
426
453
|
pagination: true,
|
|
427
454
|
arrows: state.arrows,
|
|
428
455
|
classes: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/launcher-workflow",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.26",
|
|
4
4
|
"description": "Purchase components for Launcher UI",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
"@arcblock/license": "^2.5.52",
|
|
41
41
|
"@arcblock/react-hooks": "^2.5.52",
|
|
42
42
|
"@arcblock/ux": "^2.5.52",
|
|
43
|
-
"@blocklet/launcher-layout": "2.1.
|
|
44
|
-
"@blocklet/launcher-util": "2.1.
|
|
45
|
-
"@blocklet/launcher-ux": "2.1.
|
|
43
|
+
"@blocklet/launcher-layout": "2.1.26",
|
|
44
|
+
"@blocklet/launcher-util": "2.1.26",
|
|
45
|
+
"@blocklet/launcher-ux": "2.1.26",
|
|
46
46
|
"@blocklet/payment": "^1.12.12",
|
|
47
47
|
"@emotion/react": "^11.11.0",
|
|
48
48
|
"@emotion/styled": "^11.11.0",
|
|
@@ -75,5 +75,5 @@
|
|
|
75
75
|
"babel-plugin-inline-react-svg": "^2.0.2",
|
|
76
76
|
"jest": "^27.5.1"
|
|
77
77
|
},
|
|
78
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "835f9d82ed43b4eb75a15a35e087e5fbaf51f32a"
|
|
79
79
|
}
|