@abtnode/ux 1.16.27-beta-d1555a79 → 1.16.27-beta-595ed831
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/audit-logs.js +4 -1
- package/lib/blocklet/component/add-component/add-component-core.js +200 -281
- package/lib/blocklet/component/add-component/step-connect.js +9 -3
- package/lib/blocklet/component/related-components-dialog.js +1 -0
- package/lib/blocklet/component/store-blocklet-list.js +52 -7
- package/lib/blocklet/publish/connect-store-list.js +8 -4
- package/lib/blocklet/publish/create-release.js +145 -72
- package/lib/blocklet/publish/hooks/use-want-to-connect-store.js +21 -0
- package/lib/blocklet/publish/resource.js +73 -41
- package/lib/blocklet/publish/select-components.js +31 -11
- package/lib/blocklet/publish/stop-box.js +35 -0
- package/lib/blocklet/publish/utils/upload-image-to-project.js +73 -0
- package/lib/blocklet/publish/{wait-connect.js → utils/wait-connect.js} +2 -2
- package/lib/hooks/use-promise-window-open.js +31 -0
- package/lib/locales/ar.js +6 -3
- package/lib/locales/de.js +6 -3
- package/lib/locales/en.js +5 -2
- package/lib/locales/es.js +6 -3
- package/lib/locales/fr.js +6 -3
- package/lib/locales/hi.js +6 -3
- package/lib/locales/i18n.db +0 -0
- package/lib/locales/id.js +6 -3
- package/lib/locales/ja.js +6 -3
- package/lib/locales/ko.js +6 -3
- package/lib/locales/pt.js +6 -3
- package/lib/locales/ru.js +6 -3
- package/lib/locales/th.js +6 -3
- package/lib/locales/vi.js +6 -3
- package/lib/locales/zh-tw.js +7 -4
- package/lib/locales/zh.js +6 -3
- package/lib/store/item.js +38 -31
- package/package.json +18 -17
|
@@ -137,6 +137,7 @@ export default function RelatedComponentsDialog({
|
|
|
137
137
|
}
|
|
138
138
|
},
|
|
139
139
|
onClick: () => {
|
|
140
|
+
// FIXME: @zhanghan 不能使用 homepage 来获得最终地址
|
|
140
141
|
window.open(`${component.bundleSource?.store || component.meta.homepage}/blocklets/${component.meta.did}`, '_blank');
|
|
141
142
|
},
|
|
142
143
|
children: [component.meta.title, /*#__PURE__*/_jsx(Box, {
|
|
@@ -8,13 +8,16 @@ import Link from '@mui/material/Link';
|
|
|
8
8
|
import { ErrorFallback } from '@arcblock/ux/lib/ErrorBoundary';
|
|
9
9
|
import { ErrorBoundary } from 'react-error-boundary';
|
|
10
10
|
import InnerList from '@blocklet/list';
|
|
11
|
+
import UpgradeIcon from '@mui/icons-material/Upgrade';
|
|
11
12
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
12
13
|
import Blocklet, { ActionButton } from '@arcblock/ux/lib/Blocklet';
|
|
13
14
|
import Spinner from '@mui/material/CircularProgress';
|
|
14
15
|
import Button from '@arcblock/ux/lib/Button';
|
|
16
|
+
import semver from 'semver';
|
|
15
17
|
import { isFreeBlocklet } from '@blocklet/meta/lib/util';
|
|
16
18
|
import Toast from '@arcblock/ux/lib/Toast';
|
|
17
19
|
import { formatRegistryLogoPath } from '../../util';
|
|
20
|
+
import { useBlockletContext } from '../../contexts/blocklet';
|
|
18
21
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
22
|
const getStoreDetail = (meta, endpoint) => {
|
|
20
23
|
return joinUrl(endpoint, `/blocklets/${meta.did}`);
|
|
@@ -55,7 +58,6 @@ function BlockletItem({
|
|
|
55
58
|
}
|
|
56
59
|
return true;
|
|
57
60
|
};
|
|
58
|
-
const btnTxt = requirePurchase(blocklet) ? t('common.purchase') : t('blocklet.component.choose');
|
|
59
61
|
const onAction = async e => {
|
|
60
62
|
e.preventDefault();
|
|
61
63
|
e.stopPropagation();
|
|
@@ -72,6 +74,40 @@ function BlockletItem({
|
|
|
72
74
|
setLoading(false);
|
|
73
75
|
}
|
|
74
76
|
};
|
|
77
|
+
const {
|
|
78
|
+
blocklet: pageBlocklet
|
|
79
|
+
} = useBlockletContext();
|
|
80
|
+
const getCurrentVersion = () => {
|
|
81
|
+
const exist = (pageBlocklet?.children || []).find(x => x.meta.bundleDid === blocklet.did);
|
|
82
|
+
const currentVersion = exist.meta.version;
|
|
83
|
+
return currentVersion;
|
|
84
|
+
};
|
|
85
|
+
const getInstallOrUpgrade = () => {
|
|
86
|
+
const exist = (pageBlocklet?.children || []).find(x => x.meta.bundleDid === blocklet.did);
|
|
87
|
+
if (exist) {
|
|
88
|
+
try {
|
|
89
|
+
const currentVersion = exist.meta.version;
|
|
90
|
+
const targetVersion = blocklet.version;
|
|
91
|
+
if (semver.gt(targetVersion, currentVersion)) {
|
|
92
|
+
return 'upgrade';
|
|
93
|
+
}
|
|
94
|
+
} catch {
|
|
95
|
+
// 如果比对版本报错,则还是允许安装
|
|
96
|
+
return 'install';
|
|
97
|
+
}
|
|
98
|
+
return 'disable';
|
|
99
|
+
}
|
|
100
|
+
return 'install';
|
|
101
|
+
};
|
|
102
|
+
const actionType = getInstallOrUpgrade();
|
|
103
|
+
let btnTxt = t('blocklet.component.choose');
|
|
104
|
+
if (actionType === 'upgrade') {
|
|
105
|
+
btnTxt = t('blocklet.component.upgrade');
|
|
106
|
+
} else if (actionType === 'disable') {
|
|
107
|
+
btnTxt = t('blocklet.component.installed');
|
|
108
|
+
} else if (requirePurchase(blocklet)) {
|
|
109
|
+
btnTxt = t('common.purchase');
|
|
110
|
+
}
|
|
75
111
|
return /*#__PURE__*/_jsx(Link, {
|
|
76
112
|
href: getStoreDetail(blocklet, endpoint),
|
|
77
113
|
style: {
|
|
@@ -100,21 +136,26 @@ function BlockletItem({
|
|
|
100
136
|
alignItems: 'center'
|
|
101
137
|
},
|
|
102
138
|
children: /*#__PURE__*/_jsx(ActionButton, {
|
|
103
|
-
children: /*#__PURE__*/
|
|
139
|
+
children: /*#__PURE__*/_jsxs(Button, {
|
|
104
140
|
onClick: onAction,
|
|
105
141
|
size: "small",
|
|
106
|
-
disabled: loading,
|
|
142
|
+
disabled: loading || actionType === 'disable',
|
|
107
143
|
variant: "outlined",
|
|
108
144
|
color: "primary",
|
|
109
145
|
"data-cy": "install-blocklet",
|
|
110
|
-
|
|
146
|
+
title: actionType === 'upgrade' ? `${getCurrentVersion()} -> ${blocklet.version}` : '',
|
|
147
|
+
children: [loading ? /*#__PURE__*/_jsxs(_Fragment, {
|
|
111
148
|
children: [/*#__PURE__*/_jsx(Spinner, {
|
|
112
149
|
size: 16,
|
|
113
150
|
style: {
|
|
114
151
|
marginRight: 3
|
|
115
152
|
}
|
|
116
153
|
}), btnTxt]
|
|
117
|
-
}) : btnTxt
|
|
154
|
+
}) : btnTxt, actionType === 'upgrade' ? /*#__PURE__*/_jsx(UpgradeIcon, {
|
|
155
|
+
style: {
|
|
156
|
+
fontSize: '1.2rem'
|
|
157
|
+
}
|
|
158
|
+
}) : null]
|
|
118
159
|
}, blocklet.did)
|
|
119
160
|
})
|
|
120
161
|
})
|
|
@@ -142,6 +183,7 @@ export default function BlockletList({
|
|
|
142
183
|
resourceType,
|
|
143
184
|
resourceDid,
|
|
144
185
|
showResourcesSwitch,
|
|
186
|
+
showCategory,
|
|
145
187
|
...rest
|
|
146
188
|
}) {
|
|
147
189
|
const {
|
|
@@ -175,6 +217,7 @@ export default function BlockletList({
|
|
|
175
217
|
children: /*#__PURE__*/_jsx("div", {
|
|
176
218
|
...rest,
|
|
177
219
|
children: initialized && /*#__PURE__*/_jsx(InnerList, {
|
|
220
|
+
showCategory: showCategory,
|
|
178
221
|
showResourcesSwitch: showResourcesSwitch,
|
|
179
222
|
blockletRender: blockletRenderProps => {
|
|
180
223
|
const defaultProps = {
|
|
@@ -211,7 +254,8 @@ BlockletList.propTypes = {
|
|
|
211
254
|
serverVersion: PropTypes.string,
|
|
212
255
|
resourceType: PropTypes.string,
|
|
213
256
|
resourceDid: PropTypes.string,
|
|
214
|
-
showResourcesSwitch: PropTypes.bool
|
|
257
|
+
showResourcesSwitch: PropTypes.bool,
|
|
258
|
+
showCategory: PropTypes.bool
|
|
215
259
|
};
|
|
216
260
|
BlockletList.defaultProps = {
|
|
217
261
|
handleButtonClick: null,
|
|
@@ -221,7 +265,8 @@ BlockletList.defaultProps = {
|
|
|
221
265
|
serverVersion: '',
|
|
222
266
|
resourceType: '',
|
|
223
267
|
resourceDid: '',
|
|
224
|
-
showResourcesSwitch: true
|
|
268
|
+
showResourcesSwitch: true,
|
|
269
|
+
showCategory: true
|
|
225
270
|
};
|
|
226
271
|
const StyledBlocklet = styled(Blocklet)`
|
|
227
272
|
.ms-highlight {
|
|
@@ -19,7 +19,8 @@ function ConnectStoreList({
|
|
|
19
19
|
onPublish,
|
|
20
20
|
onDelete,
|
|
21
21
|
projectType,
|
|
22
|
-
componentDid
|
|
22
|
+
componentDid,
|
|
23
|
+
onOpenConnectStore
|
|
23
24
|
}) {
|
|
24
25
|
const {
|
|
25
26
|
t
|
|
@@ -50,7 +51,8 @@ function ConnectStoreList({
|
|
|
50
51
|
published: publishedStoreIds?.indexOf(x.id) > -1,
|
|
51
52
|
connectedStore: connectedMap[x.id],
|
|
52
53
|
onPublish: onPublish,
|
|
53
|
-
onDelete: onDelete
|
|
54
|
+
onDelete: onDelete,
|
|
55
|
+
onOpenConnectStore: onOpenConnectStore
|
|
54
56
|
})
|
|
55
57
|
})
|
|
56
58
|
}, x.url)), !!storeList?.length && /*#__PURE__*/_jsx(Alert, {
|
|
@@ -89,13 +91,15 @@ ConnectStoreList.propTypes = {
|
|
|
89
91
|
publishedStoreIds: PropTypes.arrayOf(PropTypes.string),
|
|
90
92
|
connectedStores: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
91
93
|
projectType: PropTypes.string,
|
|
92
|
-
componentDid: PropTypes.string
|
|
94
|
+
componentDid: PropTypes.string,
|
|
95
|
+
onOpenConnectStore: PropTypes.func
|
|
93
96
|
};
|
|
94
97
|
ConnectStoreList.defaultProps = {
|
|
95
98
|
projectType: '',
|
|
96
99
|
componentDid: '',
|
|
97
100
|
publishedStoreIds: [],
|
|
98
101
|
onPublish: () => {},
|
|
99
|
-
onDelete: () => {}
|
|
102
|
+
onDelete: () => {},
|
|
103
|
+
onOpenConnectStore: () => {}
|
|
100
104
|
};
|
|
101
105
|
export default ConnectStoreList;
|
|
@@ -26,7 +26,7 @@ import Tabs from '@arcblock/ux/lib/Tabs';
|
|
|
26
26
|
import Dialog from '@arcblock/ux/lib/Dialog';
|
|
27
27
|
import Alert from '@arcblock/ux/lib/Alert';
|
|
28
28
|
import { PROJECT } from '@blocklet/constant';
|
|
29
|
-
import { WELLKNOWN_SERVICE_PATH_PREFIX, UNOWNED_DID
|
|
29
|
+
import { WELLKNOWN_SERVICE_PATH_PREFIX, UNOWNED_DID } from '@abtnode/constant';
|
|
30
30
|
import BlockletBundleAvatar from '../bundle-avatar';
|
|
31
31
|
import { useNodeContext } from '../../contexts/node';
|
|
32
32
|
import { useBlockletContext } from '../../contexts/blocklet';
|
|
@@ -36,8 +36,12 @@ import { formatError } from '../../util';
|
|
|
36
36
|
import Resource, { uploadResource } from './resource';
|
|
37
37
|
import SelectComponents from './select-components';
|
|
38
38
|
import ConnectStoreList from './connect-store-list';
|
|
39
|
-
import { createMessageId, waitGetConnectedByStudio, waitGetConnectedStore } from './wait-connect';
|
|
39
|
+
import { createMessageId, waitGetConnectedByStudio, waitGetConnectedStore } from './utils/wait-connect';
|
|
40
40
|
import ConnectStoreButton from './connect-store-button';
|
|
41
|
+
import uploadImageToProject from './utils/upload-image-to-project';
|
|
42
|
+
import useWantToConnectStore from './hooks/use-want-to-connect-store';
|
|
43
|
+
import usePromiseWindowOpen from '../../hooks/use-promise-window-open';
|
|
44
|
+
import StopBox from './stop-box';
|
|
41
45
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
42
46
|
const allowedFileTypes = ['image/*', '.jpg', '.jpeg', '.png', '.gif', '.svg'];
|
|
43
47
|
const maxFileSize = 1024 * 1024 * 10; // 10 MB
|
|
@@ -161,9 +165,23 @@ export default function CreateRelease({
|
|
|
161
165
|
const [initialResources, setInitialResources] = useState({});
|
|
162
166
|
const [releaseUsedLast, setReleaseUsedLast] = useState(false);
|
|
163
167
|
const saveSelectedEventsRef = useRef({});
|
|
164
|
-
const [
|
|
165
|
-
const
|
|
166
|
-
const
|
|
168
|
+
const [initLogoUrl, setInitLogoUrl] = useState('');
|
|
169
|
+
const [wantToConnectStore, setWantToConnectStore] = useWantToConnectStore(blocklet);
|
|
170
|
+
const [resourceComponentsMap, _setResourceComponentsMap] = useSetState({});
|
|
171
|
+
const dependentComponentsMode = initUrl?.searchParams.get('dependentComponentsMode');
|
|
172
|
+
const disabledSelectComponents = dependentComponentsMode === 'readonly';
|
|
173
|
+
const setResourceComponentsMap = useCallback(setter => {
|
|
174
|
+
if (disabledSelectComponents) {
|
|
175
|
+
setParams({
|
|
176
|
+
blockletComponents: []
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
_setResourceComponentsMap(setter);
|
|
180
|
+
}, [disabledSelectComponents, _setResourceComponentsMap, setParams]);
|
|
181
|
+
const openWindow = usePromiseWindowOpen({
|
|
182
|
+
onOpen: () => setLoading(true),
|
|
183
|
+
onClose: () => setLoading(false)
|
|
184
|
+
});
|
|
167
185
|
const releaseId = inputReleaseId === 'create' ? params?.lastReleaseId || '' : inputReleaseId;
|
|
168
186
|
const mode = inputReleaseId === 'create' ? 'create' : 'edit';
|
|
169
187
|
const projectType = useMemo(() => params?.blockletComponents?.some(x => x.included) ? 'pack' : 'resource', [params?.blockletComponents]);
|
|
@@ -180,6 +198,18 @@ export default function CreateRelease({
|
|
|
180
198
|
const [tab, setTab] = useState(tabs[0]?.value);
|
|
181
199
|
const isPublished = !releaseUsedLast && release?.status === 'published';
|
|
182
200
|
const readOnly = isPublished;
|
|
201
|
+
const resourceRelateComponents = useMemo(() => {
|
|
202
|
+
const result = {};
|
|
203
|
+
Object.keys(resourceComponentsMap).forEach(key => {
|
|
204
|
+
const item = resourceComponentsMap[key];
|
|
205
|
+
if (item) {
|
|
206
|
+
item.forEach(k => {
|
|
207
|
+
result[k] = true;
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
return result;
|
|
212
|
+
}, [resourceComponentsMap]);
|
|
183
213
|
const getRelease = async () => {
|
|
184
214
|
try {
|
|
185
215
|
const res = await api.getRelease({
|
|
@@ -279,6 +309,32 @@ export default function CreateRelease({
|
|
|
279
309
|
const _params = {
|
|
280
310
|
...params
|
|
281
311
|
};
|
|
312
|
+
const componentMaps = (blocklet?.children || []).reduce((acc, curr) => {
|
|
313
|
+
acc[curr.meta.did] = true;
|
|
314
|
+
return acc;
|
|
315
|
+
}, {});
|
|
316
|
+
Object.keys(resourceRelateComponents).forEach(blockletDid => {
|
|
317
|
+
if (!componentMaps[blockletDid]) {
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
let included = false;
|
|
321
|
+
if (!disabledSelectComponents) {
|
|
322
|
+
_params.blockletComponents.forEach(item => {
|
|
323
|
+
if (item.did === blockletDid) {
|
|
324
|
+
item.included = true;
|
|
325
|
+
item.required = true;
|
|
326
|
+
included = true;
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
if (!included) {
|
|
331
|
+
_params.blockletComponents.push({
|
|
332
|
+
did: blockletDid,
|
|
333
|
+
included: true,
|
|
334
|
+
required: true
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
});
|
|
282
338
|
_params.blockletVersion = semver.valid(_params.blockletVersion);
|
|
283
339
|
if (!_params.blockletVersion) {
|
|
284
340
|
Toast.error('Invalid Blocklet Version');
|
|
@@ -287,6 +343,22 @@ export default function CreateRelease({
|
|
|
287
343
|
});
|
|
288
344
|
return;
|
|
289
345
|
}
|
|
346
|
+
if (initLogoUrl) {
|
|
347
|
+
try {
|
|
348
|
+
const filename = await uploadImageToProject({
|
|
349
|
+
did: blocklet.meta.did,
|
|
350
|
+
projectId,
|
|
351
|
+
imageUrl: initLogoUrl
|
|
352
|
+
});
|
|
353
|
+
_params.blockletLogo = filename;
|
|
354
|
+
setParams({
|
|
355
|
+
blockletLogo: filename
|
|
356
|
+
});
|
|
357
|
+
} catch (err) {
|
|
358
|
+
Toast.error(err.message);
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
290
362
|
const saveKeys = Object.keys(saveSelectedEventsRef.current);
|
|
291
363
|
if (!saveKeys.length) {
|
|
292
364
|
Toast.error('No resource selected');
|
|
@@ -372,7 +444,7 @@ export default function CreateRelease({
|
|
|
372
444
|
const onOpenConnectByStudio = async param => {
|
|
373
445
|
const timer = setTimeout(() => {
|
|
374
446
|
setLoading(false);
|
|
375
|
-
},
|
|
447
|
+
}, 20000);
|
|
376
448
|
const nextBlockletDid = await waitGetConnectedByStudio(api, param);
|
|
377
449
|
setLoading(false);
|
|
378
450
|
clearTimeout(timer);
|
|
@@ -389,37 +461,42 @@ export default function CreateRelease({
|
|
|
389
461
|
Toast.error(t('blocklet.publish.errorTip.noTitle'));
|
|
390
462
|
return;
|
|
391
463
|
}
|
|
392
|
-
setLoading(true);
|
|
393
464
|
if (!wantToConnectStore) {
|
|
394
465
|
Toast.error('No store found');
|
|
395
466
|
return;
|
|
396
467
|
}
|
|
397
468
|
const messageId = createMessageId();
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
469
|
+
openWindow(async (newWindow, open) => {
|
|
470
|
+
try {
|
|
471
|
+
const res = await api.connectByStudio({
|
|
472
|
+
input: {
|
|
473
|
+
did: blocklet?.meta?.did,
|
|
474
|
+
blockletTitle: params?.blockletTitle,
|
|
475
|
+
storeUrl: wantToConnectStore.url,
|
|
476
|
+
storeId: wantToConnectStore.id,
|
|
477
|
+
storeName: wantToConnectStore.name,
|
|
478
|
+
type: params?.blockletComponents?.length > 0 ? 'pack' : 'resource',
|
|
479
|
+
componentDid,
|
|
480
|
+
messageId,
|
|
481
|
+
tenantScope: initUrl?.searchParams.get('tenantScope') || ''
|
|
482
|
+
}
|
|
483
|
+
});
|
|
484
|
+
if (!res?.url) {
|
|
485
|
+
Toast.error('failed to connect to store');
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
open(res.url);
|
|
489
|
+
onOpenConnectByStudio({
|
|
490
|
+
did: blocklet?.meta?.did,
|
|
491
|
+
projectId: '',
|
|
492
|
+
messageId
|
|
493
|
+
});
|
|
494
|
+
} catch (err) {
|
|
495
|
+
const error = formatError(err);
|
|
496
|
+
Toast.error(error);
|
|
497
|
+
newWindow.document.write(error);
|
|
498
|
+
setLoading(false);
|
|
414
499
|
}
|
|
415
|
-
window.open(res.url);
|
|
416
|
-
onOpenConnectByStudio({
|
|
417
|
-
did: blocklet?.meta?.did,
|
|
418
|
-
projectId: '',
|
|
419
|
-
messageId
|
|
420
|
-
});
|
|
421
|
-
}).catch(err => {
|
|
422
|
-
Toast.error(formatError(err));
|
|
423
500
|
});
|
|
424
501
|
};
|
|
425
502
|
const handleChangeSelectedComponents = data => {
|
|
@@ -431,10 +508,11 @@ export default function CreateRelease({
|
|
|
431
508
|
getData();
|
|
432
509
|
}, [getData]);
|
|
433
510
|
useEffect(() => {
|
|
434
|
-
if (mode === 'create' && initUrl) {
|
|
511
|
+
if (projectId === UNOWNED_DID && mode === 'create' && initUrl) {
|
|
512
|
+
setInitLogoUrl(initUrl.searchParams.get('logo'));
|
|
435
513
|
setParams({
|
|
436
514
|
blockletTitle: initUrl.searchParams.get('title'),
|
|
437
|
-
blockletLogo: initUrl.searchParams.get('logo'),
|
|
515
|
+
// blockletLogo: initUrl.searchParams.get('logo'),
|
|
438
516
|
blockletDescription: initUrl.searchParams.get('description'),
|
|
439
517
|
blockletIntroduction: initUrl.searchParams.get('introduction'),
|
|
440
518
|
blockletComponents: JSON.parse(initUrl.searchParams.get('components') || '[]'),
|
|
@@ -448,7 +526,7 @@ export default function CreateRelease({
|
|
|
448
526
|
//
|
|
449
527
|
}
|
|
450
528
|
}
|
|
451
|
-
}, [setParams, initUrl, mode]);
|
|
529
|
+
}, [setParams, projectId, initUrl, mode]);
|
|
452
530
|
if (!params && loading) {
|
|
453
531
|
return /*#__PURE__*/_jsx(EmptySpinner, {});
|
|
454
532
|
}
|
|
@@ -459,15 +537,22 @@ export default function CreateRelease({
|
|
|
459
537
|
const uploadScreenshotPrefix = `${WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${blocklet.meta.did}/${projectId}/screenshot/upload`;
|
|
460
538
|
const logoUrl = params?.blockletLogo ? `${uploadLogoPrefix}/${params.blockletLogo}` : `${WELLKNOWN_SERVICE_PATH_PREFIX}/static/images/logo.png`;
|
|
461
539
|
const screenshotUrls = (params?.blockletScreenshots || []).filter(Boolean).map(x => `${uploadScreenshotPrefix}/${x}`);
|
|
462
|
-
const
|
|
463
|
-
const
|
|
540
|
+
const resourceItem = resourceComponents.find(x => x.meta.did === tab);
|
|
541
|
+
const allResourceComponentsStop = resourceComponents.every(x => x.status !== 'running');
|
|
542
|
+
if (allResourceComponentsStop) {
|
|
543
|
+
return /*#__PURE__*/_jsx(StopBox, {
|
|
544
|
+
children: t('blocklet.publish.allComponentsNotRunning')
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
const resourceContent = resourceItem ? /*#__PURE__*/_jsx(Box, {
|
|
464
548
|
children: /*#__PURE__*/_jsx(Resource, {
|
|
465
549
|
initialResources: initialResources,
|
|
466
550
|
saveSelectedEventsRef: saveSelectedEventsRef,
|
|
551
|
+
setResourceComponentsMap: setResourceComponentsMap,
|
|
467
552
|
error: paramsErrTip.blockletResource,
|
|
468
553
|
app: blocklet,
|
|
469
554
|
readOnly: readOnly,
|
|
470
|
-
component:
|
|
555
|
+
component: resourceItem,
|
|
471
556
|
initUrl: initUrl,
|
|
472
557
|
projectId: projectId === UNOWNED_DID ? '' : projectId,
|
|
473
558
|
releaseUsedLast: releaseUsedLast,
|
|
@@ -552,6 +637,8 @@ export default function CreateRelease({
|
|
|
552
637
|
});
|
|
553
638
|
}
|
|
554
639
|
}
|
|
640
|
+
const resourcesUrlTitle = initUrl?.searchParams.get('resourcesTitle');
|
|
641
|
+
const componentsUrlTitle = initUrl?.searchParams.get('componentsTitle');
|
|
555
642
|
return /*#__PURE__*/_jsxs(Main, {
|
|
556
643
|
...rest,
|
|
557
644
|
children: [/*#__PURE__*/_jsxs(Box, {
|
|
@@ -574,35 +661,20 @@ export default function CreateRelease({
|
|
|
574
661
|
})]
|
|
575
662
|
}), /*#__PURE__*/_jsxs(Box, {
|
|
576
663
|
display: "flex",
|
|
577
|
-
children: [!isPublished && /*#__PURE__*/_jsxs(
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
mr: 0.5
|
|
589
|
-
}
|
|
590
|
-
}), t('blocklet.publish.saveDraft')]
|
|
591
|
-
}), /*#__PURE__*/_jsxs(Button, {
|
|
592
|
-
variant: "contained",
|
|
593
|
-
disabled: loading || createLoading,
|
|
594
|
-
style: {
|
|
595
|
-
marginRight: 12
|
|
664
|
+
children: [!isPublished && /*#__PURE__*/_jsxs(Button, {
|
|
665
|
+
variant: "contained",
|
|
666
|
+
disabled: loading || createLoading,
|
|
667
|
+
style: {
|
|
668
|
+
marginRight: 12
|
|
669
|
+
},
|
|
670
|
+
onClick: () => onRelease(PROJECT.RELEASE_STATUS.published),
|
|
671
|
+
children: [createLoading === PROJECT.RELEASE_STATUS.published && /*#__PURE__*/_jsx(Spinner, {
|
|
672
|
+
size: 14,
|
|
673
|
+
sx: {
|
|
674
|
+
mr: 0.5
|
|
596
675
|
},
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
size: 14,
|
|
600
|
-
sx: {
|
|
601
|
-
mr: 0.5
|
|
602
|
-
},
|
|
603
|
-
color: "inherit"
|
|
604
|
-
}), t('common.release')]
|
|
605
|
-
})]
|
|
676
|
+
color: "inherit"
|
|
677
|
+
}), t('common.release')]
|
|
606
678
|
}), isPublished && /*#__PURE__*/_jsxs(_Fragment, {
|
|
607
679
|
children: [installButton, /*#__PURE__*/_jsx(Button, {
|
|
608
680
|
variant: "outlined",
|
|
@@ -848,7 +920,7 @@ export default function CreateRelease({
|
|
|
848
920
|
height: 80
|
|
849
921
|
},
|
|
850
922
|
alt: "Blocklet Logo",
|
|
851
|
-
src: logoUrl,
|
|
923
|
+
src: initLogoUrl || logoUrl,
|
|
852
924
|
onClick: () => !readOnly && uploaderLogoRef.current.open()
|
|
853
925
|
})
|
|
854
926
|
})]
|
|
@@ -903,13 +975,13 @@ export default function CreateRelease({
|
|
|
903
975
|
})]
|
|
904
976
|
})]
|
|
905
977
|
}), /*#__PURE__*/_jsx(UploaderComponent, {
|
|
906
|
-
id: "\u200Buploader-logo",
|
|
907
978
|
ref: uploaderLogoRef,
|
|
908
979
|
popup: true,
|
|
909
980
|
onUploadFinish: result => {
|
|
910
981
|
setParams({
|
|
911
982
|
blockletLogo: result.data.filename
|
|
912
983
|
});
|
|
984
|
+
setInitLogoUrl('');
|
|
913
985
|
uploaderLogoRef.current.close();
|
|
914
986
|
},
|
|
915
987
|
plugins: ['ImageEditor'],
|
|
@@ -928,7 +1000,6 @@ export default function CreateRelease({
|
|
|
928
1000
|
}
|
|
929
1001
|
}
|
|
930
1002
|
}, "uploader-logo"), /*#__PURE__*/_jsx(UploaderComponent, {
|
|
931
|
-
id: "\u200Buploader-screenshot",
|
|
932
1003
|
ref: uploaderScreenshotRef,
|
|
933
1004
|
popup: true,
|
|
934
1005
|
onUploadFinish: result => {
|
|
@@ -960,13 +1031,13 @@ export default function CreateRelease({
|
|
|
960
1031
|
className: "left",
|
|
961
1032
|
children: /*#__PURE__*/_jsx(Typography, {
|
|
962
1033
|
variant: "h3",
|
|
963
|
-
children: t('blocklet.publish.resourceTitle')
|
|
1034
|
+
children: resourcesUrlTitle || t('blocklet.publish.resourceTitle')
|
|
964
1035
|
})
|
|
965
1036
|
}), /*#__PURE__*/_jsxs(Box, {
|
|
966
1037
|
sx: {
|
|
967
1038
|
flex: 1
|
|
968
1039
|
},
|
|
969
|
-
children: [/*#__PURE__*/_jsx(Tabs, {
|
|
1040
|
+
children: [!componentDid && /*#__PURE__*/_jsx(Tabs, {
|
|
970
1041
|
tabs: tabs,
|
|
971
1042
|
current: tab,
|
|
972
1043
|
onChange: onTabChange,
|
|
@@ -986,7 +1057,7 @@ export default function CreateRelease({
|
|
|
986
1057
|
className: "left",
|
|
987
1058
|
children: /*#__PURE__*/_jsx(Typography, {
|
|
988
1059
|
variant: "h3",
|
|
989
|
-
children: t('common.components')
|
|
1060
|
+
children: componentsUrlTitle || t('common.components')
|
|
990
1061
|
})
|
|
991
1062
|
}), /*#__PURE__*/_jsx(Box, {
|
|
992
1063
|
sx: {
|
|
@@ -996,7 +1067,9 @@ export default function CreateRelease({
|
|
|
996
1067
|
disabled: loading || readOnly,
|
|
997
1068
|
app: blocklet,
|
|
998
1069
|
value: params?.blockletComponents || [],
|
|
999
|
-
onChange: handleChangeSelectedComponents
|
|
1070
|
+
onChange: handleChangeSelectedComponents,
|
|
1071
|
+
resourceRelateComponents: resourceRelateComponents,
|
|
1072
|
+
dependentComponentsMode: dependentComponentsMode
|
|
1000
1073
|
})
|
|
1001
1074
|
})]
|
|
1002
1075
|
}), /*#__PURE__*/_jsx(Alert, {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BLOCKLET_STORE } from '@abtnode/constant';
|
|
2
|
+
import { useCallback, useMemo, useState } from 'react';
|
|
3
|
+
const LOCAL_STORAGE_KEY = 'lastWantToConnectStoreId';
|
|
4
|
+
function useWantToConnectStore(blocklet) {
|
|
5
|
+
const [_wantToConnectStore, _setWantToConnectStore] = useState(null);
|
|
6
|
+
const setWantToConnectStore = useCallback(x => {
|
|
7
|
+
_setWantToConnectStore(x);
|
|
8
|
+
localStorage.setItem(LOCAL_STORAGE_KEY, x?.id);
|
|
9
|
+
}, [_setWantToConnectStore]);
|
|
10
|
+
const baseStore = useMemo(() => {
|
|
11
|
+
const lastStoreId = localStorage.getItem(LOCAL_STORAGE_KEY);
|
|
12
|
+
const lastStore = lastStoreId ? (blocklet?.settings?.storeList || []).find(x => x.id === lastStoreId) : null;
|
|
13
|
+
if (lastStore) {
|
|
14
|
+
return lastStore;
|
|
15
|
+
}
|
|
16
|
+
return (blocklet?.settings?.storeList || []).find(x => x.id === BLOCKLET_STORE.id);
|
|
17
|
+
}, [blocklet?.settings?.storeList]);
|
|
18
|
+
const wantToConnectStore = _wantToConnectStore || baseStore;
|
|
19
|
+
return [wantToConnectStore, setWantToConnectStore];
|
|
20
|
+
}
|
|
21
|
+
export default useWantToConnectStore;
|