@abtnode/ux 1.16.29-next-680cf137 → 1.16.30-beta-00e8bdd1

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 (44) hide show
  1. package/lib/blocklet/component/blocklet-owner-info.js +35 -0
  2. package/lib/blocklet/component/component-info-dialog.js +7 -2
  3. package/lib/blocklet/component/environment.js +16 -6
  4. package/lib/blocklet/component/index.js +30 -27
  5. package/lib/blocklet/configuration.js +2 -34
  6. package/lib/blocklet/disk-info.js +66 -55
  7. package/lib/blocklet/install-from-url.js +9 -3
  8. package/lib/blocklet/publish/create-release/blocklets.js +5 -5
  9. package/lib/blocklet/publish/create-release/branding.js +14 -11
  10. package/lib/blocklet/publish/create-release/connect-store-button.js +11 -10
  11. package/lib/blocklet/publish/create-release/header.js +136 -123
  12. package/lib/blocklet/publish/create-release/index.js +16 -16
  13. package/lib/blocklet/publish/create-release/project-setting.js +182 -0
  14. package/lib/blocklet/publish/create-release/resource-select.js +16 -12
  15. package/lib/blocklet/publish/hooks/use-want-to-connect-store.js +6 -2
  16. package/lib/blocklet/publish/utils/get-studio-store-list.js +3 -0
  17. package/lib/blocklet/publish/utils/parse-resource-relate-components.js +31 -0
  18. package/lib/blocklet/storage/auto-check-update.js +2 -2
  19. package/lib/blocklet/storage/connected.js +1 -3
  20. package/lib/blocklet/storage/disconnect.js +1 -7
  21. package/lib/contexts/blocklet-auto-check-update.js +54 -0
  22. package/lib/contexts/blocklet-storage.js +0 -19
  23. package/lib/hooks/blocklet.js +17 -5
  24. package/lib/locales/ar.js +8 -2
  25. package/lib/locales/de.js +8 -2
  26. package/lib/locales/en.js +6 -0
  27. package/lib/locales/es.js +8 -2
  28. package/lib/locales/fr.js +8 -2
  29. package/lib/locales/hi.js +8 -2
  30. package/lib/locales/i18n.db +0 -0
  31. package/lib/locales/id.js +8 -2
  32. package/lib/locales/ja.js +8 -2
  33. package/lib/locales/ko.js +8 -2
  34. package/lib/locales/pt.js +8 -2
  35. package/lib/locales/ru.js +8 -2
  36. package/lib/locales/th.js +8 -2
  37. package/lib/locales/vi.js +8 -2
  38. package/lib/locales/zh-tw.js +8 -2
  39. package/lib/locales/zh.js +8 -2
  40. package/lib/team/members/invite-member.js +16 -3
  41. package/lib/team/members/issue-passport.js +17 -2
  42. package/lib/team/members/member.js +59 -23
  43. package/lib/util/index.js +0 -14
  44. package/package.json +20 -20
@@ -1,29 +1,31 @@
1
1
  import { UNOWNED_DID, WELLKNOWN_SERVICE_PATH_PREFIX } from '@abtnode/constant';
2
+ import Dialog from '@arcblock/ux/lib/Dialog';
2
3
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
3
- import { Box, Breadcrumbs, Button, Typography, Dialog as MaterialDialog, IconButton, useMediaQuery } from '@mui/material';
4
- import styled from '@emotion/styled';
5
- import { Link, useNavigate } from 'react-router-dom';
6
- import PropTypes from 'prop-types';
7
- import { joinURL } from 'ufo';
4
+ import Toast from '@arcblock/ux/lib/Toast/index';
8
5
  import { PROJECT } from '@blocklet/constant';
9
- import Spinner from '@mui/material/CircularProgress';
6
+ import styled from '@emotion/styled';
7
+ import { Icon } from '@iconify/react';
10
8
  import CloudUploadRoundedIcon from '@mui/icons-material/CloudUploadRounded';
11
- import semver from 'semver';
12
- import { useState } from 'react';
13
- import Toast from '@arcblock/ux/lib/Toast/index';
14
- import pAll from 'p-all';
15
- import Dialog from '@arcblock/ux/lib/Dialog';
9
+ import { Box, Breadcrumbs, Button, ButtonGroup, IconButton, Dialog as MaterialDialog, Typography, useMediaQuery } from '@mui/material';
10
+ import Spinner from '@mui/material/CircularProgress';
16
11
  import pick from 'lodash/pick';
17
- import { Icon } from '@iconify/react';
18
- import ConnectStoreList from './connect-store-list';
19
- import { validateParams } from '../utils/validate-params';
20
- import { waitGetConnectedStore } from '../utils/wait-connect';
21
- import uploadImageToProject from '../utils/upload-image-to-project';
22
- import { uploadResource } from './resource-select';
12
+ import pAll from 'p-all';
13
+ import PropTypes from 'prop-types';
14
+ import { useState } from 'react';
15
+ import { Link, useNavigate } from 'react-router-dom';
16
+ import semver from 'semver';
17
+ import { joinURL } from 'ufo';
23
18
  import ClickToCopy from '../../../click-to-copy';
24
- import { formatError } from '../../../util';
25
19
  import { useNodeContext } from '../../../contexts/node';
20
+ import { formatError } from '../../../util';
26
21
  import ShortenLabel from '../../component/shorten-label';
22
+ import parseResourceRelateComponents from '../utils/parse-resource-relate-components';
23
+ import uploadImageToProject from '../utils/upload-image-to-project';
24
+ import { validateParams } from '../utils/validate-params';
25
+ import { waitGetConnectedStore } from '../utils/wait-connect';
26
+ import ConnectStoreList from './connect-store-list';
27
+ import ProjectSetting from './project-setting';
28
+ import { uploadResource } from './resource-select';
27
29
  import UploadedToast from './uploaded-toast';
28
30
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
29
31
  const serverEndpoint = window.env?.serverEndpoint;
@@ -61,6 +63,7 @@ function Header({
61
63
  } = useNodeContext();
62
64
  const navigate = useNavigate();
63
65
  const [showStoreDialog, setShowStoreDialog] = useState(false);
66
+ const [showSetting, setShowSetting] = useState(false);
64
67
  const [installResourceTip, setInstallResourceTip] = useState();
65
68
  const isMobile = useMediaQuery(theme => theme.breakpoints.down('md'));
66
69
  const releaseType = params?.blockletComponents?.length > 0 ? 'pack' : 'resource';
@@ -90,32 +93,7 @@ function Header({
90
93
  const _params = {
91
94
  ...params
92
95
  };
93
- const componentMaps = (blocklet?.children || []).reduce((acc, curr) => {
94
- acc[curr.meta.did] = true;
95
- return acc;
96
- }, {});
97
- Object.keys(resourceRelateComponents).forEach(blockletDid => {
98
- if (!componentMaps[blockletDid]) {
99
- return;
100
- }
101
- let included = false;
102
- if (!disabledSelectComponents) {
103
- _params.blockletComponents.forEach(item => {
104
- if (item.did === blockletDid) {
105
- item.included = true;
106
- item.required = true;
107
- included = true;
108
- }
109
- });
110
- }
111
- if (!included) {
112
- _params.blockletComponents.push({
113
- did: blockletDid,
114
- included: true,
115
- required: true
116
- });
117
- }
118
- });
96
+ _params.blockletComponents = parseResourceRelateComponents(_params.blockletComponents, blocklet, resourceRelateComponents, disabledSelectComponents);
119
97
  _params.blockletVersion = semver.valid(_params.blockletVersion);
120
98
  if (!_params.blockletVersion) {
121
99
  Toast.error('Invalid Blocklet Version');
@@ -222,35 +200,37 @@ function Header({
222
200
  }
223
201
  });
224
202
  const newReleased = lastProject.project.lastReleaseId;
225
- await pAll(lastProject.project.connectedStores.map(store => {
226
- return async () => {
227
- try {
228
- // eslint-disable-next-line no-await-in-loop
229
- const res = await api.publishToStore({
230
- input: {
231
- did: blocklet.meta.did,
232
- storeId: store.storeId,
203
+ if (params.autoUpload) {
204
+ await pAll(lastProject.project.connectedStores.map(store => {
205
+ return async () => {
206
+ try {
207
+ // eslint-disable-next-line no-await-in-loop
208
+ const res = await api.publishToStore({
209
+ input: {
210
+ did: blocklet.meta.did,
211
+ storeId: store.storeId,
212
+ storeName: store.storeName,
213
+ projectId,
214
+ releaseId: newReleased,
215
+ type: releaseType
216
+ }
217
+ });
218
+ Toast.success( /*#__PURE__*/_jsx(UploadedToast, {
233
219
  storeName: store.storeName,
234
- projectId,
235
- releaseId: newReleased,
236
- type: releaseType
237
- }
238
- });
239
- Toast.success( /*#__PURE__*/_jsx(UploadedToast, {
240
- storeName: store.storeName,
241
- storeUrl: store.storeUrl,
242
- developerDid: store.developerDid,
243
- published: res.url === 'published'
244
- }), {
245
- duration: 10000
246
- });
247
- } catch (err) {
248
- Toast.error(formatError(err));
249
- }
250
- };
251
- }), {
252
- concurrency: 4
253
- });
220
+ storeUrl: store.storeUrl,
221
+ developerDid: store.developerDid,
222
+ published: res.url === 'published'
223
+ }), {
224
+ duration: 10000
225
+ });
226
+ } catch (err) {
227
+ Toast.error(formatError(err));
228
+ }
229
+ };
230
+ }), {
231
+ concurrency: 4
232
+ });
233
+ }
254
234
  onPublish?.();
255
235
  navigate(`../${projectId}/view/${newReleased}`, {
256
236
  replace: true
@@ -266,6 +246,9 @@ function Header({
266
246
  await waitGetConnectedStore(api, param);
267
247
  getData();
268
248
  };
249
+ const handleShowSetting = () => {
250
+ setShowSetting(true);
251
+ };
269
252
  let installButton = null;
270
253
  if (isPublished && serverEndpoint) {
271
254
  const blockletMetaUrl = joinURL(serverEndpoint, `/api/project/${blocklet.meta.did}/${projectId}/${releaseId}/release/blocklet.json`);
@@ -273,31 +256,36 @@ function Header({
273
256
  const url = new URL(serverEndpoint);
274
257
  url.pathname = joinURL(url.pathname, '/launch-blocklet/agreement');
275
258
  url.searchParams.set('blocklet_meta_url', blockletMetaUrl);
276
- installButton = /*#__PURE__*/_jsx("a", {
259
+ installButton = isMobile ? /*#__PURE__*/_jsx(IconButton, {
260
+ component: "a",
261
+ disabled: loading,
277
262
  href: url.href,
278
263
  target: "_blank",
279
264
  rel: "noreferrer",
280
- children: isMobile ? /*#__PURE__*/_jsx(IconButton, {
281
- color: "primary",
282
- sx: {
283
- mr: 1
284
- },
285
- onClick: () => setInstallResourceTip(blockletMetaUrl),
286
- children: /*#__PURE__*/_jsx(Icon, {
287
- icon: "ic:baseline-install-desktop"
288
- })
289
- }) : /*#__PURE__*/_jsx(Button, {
290
- variant: "outlined",
291
- sx: {
292
- mr: 1
293
- },
294
- onClick: () => setInstallResourceTip(blockletMetaUrl),
295
- children: t('common.install')
265
+ color: "primary",
266
+ sx: {
267
+ mr: 1
268
+ },
269
+ onClick: () => setInstallResourceTip(blockletMetaUrl),
270
+ children: /*#__PURE__*/_jsx(Icon, {
271
+ icon: "ic:baseline-install-desktop"
296
272
  })
273
+ }) : /*#__PURE__*/_jsx(Button, {
274
+ href: url.href,
275
+ disabled: loading,
276
+ target: "_blank",
277
+ rel: "noreferrer",
278
+ variant: "outlined",
279
+ sx: {
280
+ mr: 1
281
+ },
282
+ onClick: () => setInstallResourceTip(blockletMetaUrl),
283
+ children: t('common.install')
297
284
  });
298
285
  } else {
299
286
  installButton = /*#__PURE__*/_jsxs(_Fragment, {
300
287
  children: [isMobile ? /*#__PURE__*/_jsx(IconButton, {
288
+ disabled: loading,
301
289
  color: "primary",
302
290
  sx: {
303
291
  mr: 1
@@ -307,6 +295,7 @@ function Header({
307
295
  icon: "ic:baseline-install-desktop"
308
296
  })
309
297
  }) : /*#__PURE__*/_jsx(Button, {
298
+ disabled: loading,
310
299
  variant: "outlined",
311
300
  sx: {
312
301
  mr: 1
@@ -382,46 +371,63 @@ function Header({
382
371
  })]
383
372
  }), /*#__PURE__*/_jsx(Box, {
384
373
  flex: "1"
385
- }), !isPublished && /*#__PURE__*/_jsxs(Button, {
386
- variant: "contained",
374
+ }), !isPublished && /*#__PURE__*/_jsxs(ButtonGroup, {
387
375
  disabled: loading,
388
- style: {
389
- marginRight: 12
390
- },
391
- onClick: () => onRelease(PROJECT.RELEASE_STATUS.published),
392
- children: [loading && /*#__PURE__*/_jsx(Spinner, {
393
- size: 14,
394
- sx: {
395
- mr: 0.5
396
- },
397
- color: "inherit"
398
- }), t('blocklet.publish.createRelease')]
399
- }), isPublished && /*#__PURE__*/_jsxs(_Fragment, {
400
- children: [installButton, /*#__PURE__*/_jsx("a", {
401
- href: joinURL(`${WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${blocklet.meta.did}/${projectId}/${releaseId}/download/${(release.files || [])[0]}`),
402
- children: isMobile ? null : /*#__PURE__*/_jsx(Button, {
403
- variant: "outlined",
404
- sx: {
405
- mr: 1
406
- },
407
- children: t('common.download')
408
- })
409
- }), /*#__PURE__*/_jsxs(Button, {
410
- disabled: loading,
376
+ variant: "contained",
377
+ children: [/*#__PURE__*/_jsxs(Button, {
411
378
  variant: "contained",
412
- onClick: () => setShowStoreDialog(true),
413
- children: [loading ? /*#__PURE__*/_jsx(Spinner, {
379
+ onClick: () => onRelease(PROJECT.RELEASE_STATUS.published),
380
+ children: [loading && /*#__PURE__*/_jsx(Spinner, {
414
381
  size: 14,
415
382
  sx: {
416
- mr: 1
383
+ mr: 0.5
417
384
  },
418
385
  color: "inherit"
419
- }) : /*#__PURE__*/_jsx(CloudUploadRoundedIcon, {
420
- sx: {
421
- fontSize: '1.3em',
422
- mr: 1
423
- }
424
- }), isMobile ? t('common.upload') : t('blocklet.publish.connectOrUpload')]
386
+ }), t('blocklet.publish.createRelease')]
387
+ }), /*#__PURE__*/_jsx(Button, {
388
+ variant: "contained",
389
+ onClick: handleShowSetting,
390
+ children: /*#__PURE__*/_jsx(Icon, {
391
+ icon: "mage:settings-fill",
392
+ fontSize: "16px"
393
+ })
394
+ })]
395
+ }), isPublished && /*#__PURE__*/_jsxs(_Fragment, {
396
+ children: [installButton, isMobile ? null : /*#__PURE__*/_jsx(Button, {
397
+ component: "a",
398
+ disabled: loading,
399
+ href: joinURL(`${WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${blocklet.meta.did}/${projectId}/${releaseId}/download/${(release.files || [])[0]}`),
400
+ variant: "outlined",
401
+ sx: {
402
+ mr: 1
403
+ },
404
+ children: t('common.download')
405
+ }), /*#__PURE__*/_jsxs(ButtonGroup, {
406
+ disabled: loading,
407
+ variant: "contained",
408
+ children: [/*#__PURE__*/_jsxs(Button, {
409
+ variant: "contained",
410
+ onClick: () => setShowStoreDialog(true),
411
+ children: [loading ? /*#__PURE__*/_jsx(Spinner, {
412
+ size: 14,
413
+ sx: {
414
+ mr: 1
415
+ },
416
+ color: "inherit"
417
+ }) : /*#__PURE__*/_jsx(CloudUploadRoundedIcon, {
418
+ sx: {
419
+ fontSize: '1.3em',
420
+ mr: 1
421
+ }
422
+ }), isMobile ? t('common.upload') : t('blocklet.publish.connectOrUpload')]
423
+ }), /*#__PURE__*/_jsx(Button, {
424
+ variant: "contained",
425
+ onClick: handleShowSetting,
426
+ children: /*#__PURE__*/_jsx(Icon, {
427
+ icon: "mage:settings-fill",
428
+ fontSize: "16px"
429
+ })
430
+ })]
425
431
  })]
426
432
  })]
427
433
  })
@@ -445,6 +451,13 @@ function Header({
445
451
  connectedStores: params.connectedStores || [],
446
452
  publishedStoreIds: release?.publishedStoreIds
447
453
  })
454
+ }), /*#__PURE__*/_jsx(ProjectSetting, {
455
+ did: blocklet?.meta?.did,
456
+ params: params,
457
+ projectId: projectId,
458
+ open: showSetting,
459
+ setParams: setParams,
460
+ onClose: () => setShowSetting(false)
448
461
  })]
449
462
  });
450
463
  }
@@ -54,7 +54,7 @@ const addComponentTabs = ({
54
54
  });
55
55
  };
56
56
  const pickParams = (baseParams, app) => {
57
- const params = pick(baseParams, ['blockletVersion', 'blockletTitle', 'blockletDescription', 'blockletLogo', 'blockletIntroduction', 'blockletScreenshots', 'connectedStores', 'blockletComponents', 'lastReleaseId', 'uploadedResource', 'note']);
57
+ const params = pick(baseParams, ['blockletVersion', 'blockletTitle', 'blockletDescription', 'blockletLogo', 'blockletIntroduction', 'blockletScreenshots', 'connectedStores', 'blockletComponents', 'lastReleaseId', 'uploadedResource', 'autoUpload', 'possibleSameStore', 'note']);
58
58
  if (!params.blockletComponents) {
59
59
  params.blockletComponents = (app.children || []).map(x => ({
60
60
  did: x.meta.did,
@@ -122,6 +122,18 @@ export default function CreateRelease({
122
122
  const [resourceComponentsMap, _setResourceComponentsMap] = useSetState({});
123
123
  const dependentComponentsMode = initUrl?.searchParams.get('dependentComponentsMode');
124
124
  const disabledSelectComponents = dependentComponentsMode === 'readonly';
125
+ const resourceRelateComponents = useMemo(() => {
126
+ const result = {};
127
+ Object.keys(resourceComponentsMap).forEach(key => {
128
+ const item = resourceComponentsMap[key];
129
+ if (item) {
130
+ item.forEach(k => {
131
+ result[k] = true;
132
+ });
133
+ }
134
+ });
135
+ return result;
136
+ }, [resourceComponentsMap]);
125
137
  const setResourceComponentsMap = useCallback(setter => {
126
138
  if (disabledSelectComponents) {
127
139
  setParams({
@@ -146,7 +158,7 @@ export default function CreateRelease({
146
158
  });
147
159
  }
148
160
  }, [projectId, setParamsErrTip]);
149
- const projectType = useMemo(() => params?.blockletComponents?.some(x => x.included) || params?.uploadedResource ? 'pack' : 'resource', [params?.blockletComponents, params?.uploadedResource]);
161
+ const projectType = useMemo(() => params?.blockletComponents?.some(x => x.included) || Object.keys(resourceRelateComponents).length || params?.uploadedResource ? 'pack' : 'resource', [params?.blockletComponents, params?.uploadedResource, resourceRelateComponents]);
150
162
  const tabs = [];
151
163
  const resourceComponents = (blocklet?.children || []).filter(x => x.meta.resource?.exportApi).filter(x => !componentDid || x.meta.did === componentDid);
152
164
  resourceComponents.forEach(item => {
@@ -160,18 +172,6 @@ export default function CreateRelease({
160
172
  const [tab, setTab] = useState(tabs[0]?.value);
161
173
  const isPublished = !releaseUsedLast && release?.status === 'published';
162
174
  const readOnly = isPublished;
163
- const resourceRelateComponents = useMemo(() => {
164
- const result = {};
165
- Object.keys(resourceComponentsMap).forEach(key => {
166
- const item = resourceComponentsMap[key];
167
- if (item) {
168
- item.forEach(k => {
169
- result[k] = true;
170
- });
171
- }
172
- });
173
- return result;
174
- }, [resourceComponentsMap]);
175
175
  const updateParamsByUrl = useMemoizedFn(() => {
176
176
  if (!initUrl) {
177
177
  return;
@@ -183,7 +183,7 @@ export default function CreateRelease({
183
183
  blockletTitle: old?.blockletTitle || initUrl.searchParams.get('title'),
184
184
  blockletDescription: old?.blockletDescription || initUrl.searchParams.get('description'),
185
185
  blockletIntroduction: old?.blockletIntroduction || initUrl.searchParams.get('introduction') || initUrl.searchParams.get('description'),
186
- blockletComponents: old?.blockletComponents || JSON.parse(initUrl.searchParams.get('components') || '[]'),
186
+ blockletComponents: old?.blockletComponents?.length ? old?.blockletComponents : JSON.parse(initUrl.searchParams.get('components') || '[]'),
187
187
  note: old?.note || initUrl.searchParams.get('note') || 'No note'
188
188
  };
189
189
  });
@@ -308,7 +308,7 @@ export default function CreateRelease({
308
308
  }
309
309
  const resourceItem = resourceComponents.find(x => x.meta.did === tab);
310
310
  const allResourceComponentsStop = resourceComponents.every(x => x.status !== 'running');
311
- if (allResourceComponentsStop) {
311
+ if (allResourceComponentsStop && resourceComponents?.length) {
312
312
  return /*#__PURE__*/_jsx(StopBox, {
313
313
  children: t('blocklet.publish.allComponentsNotRunning')
314
314
  });
@@ -0,0 +1,182 @@
1
+ import { UNOWNED_DID } from '@abtnode/constant';
2
+ import Dialog from '@arcblock/ux/lib/Dialog';
3
+ import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
4
+ import IOSSwitch from '@arcblock/ux/lib/Switch';
5
+ import Toast from '@arcblock/ux/lib/Toast/index';
6
+ import { Icon } from '@iconify/react';
7
+ import { Box, Button, Typography } from '@mui/material';
8
+ import Spinner from '@mui/material/CircularProgress';
9
+ import PropTypes from 'prop-types';
10
+ import { useEffect, useState } from 'react';
11
+ import { useNodeContext } from '../../../contexts/node';
12
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
13
+ function ProjectSetting({
14
+ did,
15
+ params,
16
+ setParams,
17
+ projectId,
18
+ open,
19
+ onClose
20
+ }) {
21
+ const {
22
+ t
23
+ } = useLocaleContext();
24
+ const [loading, setLoading] = useState(false);
25
+ const {
26
+ api
27
+ } = useNodeContext();
28
+ const [autoUpload, setAutoUpload] = useState(false);
29
+ const [possibleSameStore, setPossibleSameStore] = useState(false);
30
+ const handleClose = () => {
31
+ setAutoUpload(params.autoUpload);
32
+ setPossibleSameStore(params.possibleSameStore);
33
+ setLoading(false);
34
+ onClose(false);
35
+ };
36
+ const handleSubmit = async () => {
37
+ setLoading(true);
38
+ try {
39
+ await api.updateProject({
40
+ input: {
41
+ did,
42
+ projectId,
43
+ blockletTitle: params.blockletTitle,
44
+ blockletDescription: params.blockletDescription,
45
+ blockletIntroduction: params.blockletIntroduction,
46
+ autoUpload: !!autoUpload,
47
+ possibleSameStore: !!possibleSameStore
48
+ }
49
+ });
50
+ setParams({
51
+ autoUpload,
52
+ possibleSameStore
53
+ });
54
+ onClose(false);
55
+ } catch (err) {
56
+ Toast.error(err.message);
57
+ }
58
+ setLoading(false);
59
+ };
60
+ useEffect(() => {
61
+ setAutoUpload(params.autoUpload);
62
+ setPossibleSameStore(params.possibleSameStore);
63
+ }, [params]);
64
+ const hasProject = !!(projectId && projectId !== UNOWNED_DID);
65
+ return /*#__PURE__*/_jsx(Dialog, {
66
+ title: t('blocklet.publish.projectSettings'),
67
+ disableEscapeKeyDown: true,
68
+ disablePortal: false,
69
+ fullWidth: true,
70
+ open: open,
71
+ onClose: handleClose,
72
+ actions: /*#__PURE__*/_jsxs(_Fragment, {
73
+ children: [/*#__PURE__*/_jsx(Button, {
74
+ onClick: e => {
75
+ e.stopPropagation();
76
+ onClose();
77
+ },
78
+ color: "inherit",
79
+ children: t('common.cancel')
80
+ }), hasProject && /*#__PURE__*/_jsxs(Button, {
81
+ onClick: e => {
82
+ e.stopPropagation();
83
+ handleSubmit();
84
+ },
85
+ color: "primary",
86
+ "data-cy": "install-blocklet-next-step",
87
+ disabled: loading,
88
+ variant: "contained",
89
+ autoFocus: true,
90
+ children: [loading && /*#__PURE__*/_jsx(Spinner, {
91
+ size: 16
92
+ }), t('common.confirm')]
93
+ })]
94
+ }),
95
+ children: !hasProject ? /*#__PURE__*/_jsxs(Box, {
96
+ sx: {
97
+ display: 'flex',
98
+ flexDirection: 'column',
99
+ alignItems: 'center'
100
+ },
101
+ children: [/*#__PURE__*/_jsx(Box, {
102
+ component: Icon,
103
+ icon: "ph:empty",
104
+ sx: {
105
+ fontSize: 40,
106
+ mb: 3,
107
+ opacity: 0.6
108
+ }
109
+ }), /*#__PURE__*/_jsx(Typography, {
110
+ variant: "body1",
111
+ sx: {
112
+ flex: 1
113
+ },
114
+ children: t('blocklet.publish.needProjectId')
115
+ })]
116
+ }) : /*#__PURE__*/_jsxs(Box, {
117
+ component: "label",
118
+ sx: {
119
+ display: 'flex',
120
+ flexDirection: 'column',
121
+ gap: 2
122
+ },
123
+ children: [/*#__PURE__*/_jsxs(Box, {
124
+ sx: {
125
+ display: 'flex',
126
+ flexDirection: 'row',
127
+ alignItems: 'center'
128
+ },
129
+ children: [/*#__PURE__*/_jsx(Box, {
130
+ component: Icon,
131
+ icon: "ph:upload",
132
+ sx: {
133
+ fontSize: 24,
134
+ mr: 2
135
+ }
136
+ }), /*#__PURE__*/_jsx(Typography, {
137
+ variant: "body1",
138
+ sx: {
139
+ flex: 1
140
+ },
141
+ children: t('blocklet.publish.autoUploadTip')
142
+ }), /*#__PURE__*/_jsx(IOSSwitch, {
143
+ checked: autoUpload,
144
+ onChange: (_, x) => setAutoUpload(x)
145
+ })]
146
+ }), /*#__PURE__*/_jsxs(Box, {
147
+ component: "label",
148
+ sx: {
149
+ display: 'flex',
150
+ flexDirection: 'row',
151
+ alignItems: 'center'
152
+ },
153
+ children: [/*#__PURE__*/_jsx(Box, {
154
+ component: Icon,
155
+ icon: "fluent-mdl2:merge-duplicate",
156
+ sx: {
157
+ fontSize: 24,
158
+ mr: 2
159
+ }
160
+ }), /*#__PURE__*/_jsx(Typography, {
161
+ variant: "body1",
162
+ sx: {
163
+ flex: 1
164
+ },
165
+ children: t('blocklet.publish.possibleSameStoreTip')
166
+ }), /*#__PURE__*/_jsx(IOSSwitch, {
167
+ checked: possibleSameStore,
168
+ onChange: (_, x) => setPossibleSameStore(x)
169
+ })]
170
+ })]
171
+ })
172
+ });
173
+ }
174
+ ProjectSetting.propTypes = {
175
+ did: PropTypes.string.isRequired,
176
+ params: PropTypes.object.isRequired,
177
+ open: PropTypes.bool.isRequired,
178
+ onClose: PropTypes.func.isRequired,
179
+ setParams: PropTypes.func.isRequired,
180
+ projectId: PropTypes.string.isRequired
181
+ };
182
+ export default ProjectSetting;
@@ -1,20 +1,21 @@
1
+ import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
2
+ import { hasStartEngine } from '@blocklet/meta/lib/engine';
1
3
  import styled from '@emotion/styled';
4
+ import { Box } from '@mui/material';
2
5
  import classnames from 'classnames';
6
+ import pAll from 'p-all';
3
7
  import PropTypes from 'prop-types';
4
8
  import React, { useEffect, useRef } from 'react';
5
9
  import useSetState from 'react-use/lib/useSetState';
6
10
  import { joinURL } from 'ufo';
7
- import { Box } from '@mui/material';
8
- import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
9
- import { hasStartEngine } from '@blocklet/meta/lib/engine';
10
- import pAll from 'p-all';
11
- import Toast from '@arcblock/ux/lib/Toast/index';
12
11
  import { EmptyIcon } from '@arcblock/icons';
12
+ import Toast from '@arcblock/ux/lib/Toast/index';
13
+ import { getDisplayName } from '@blocklet/meta/lib/util';
13
14
  import { useNodeContext } from '../../../contexts/node';
14
15
  import { axios } from '../../../util/api';
16
+ import keepNowResources from './keep-now-resources';
15
17
  import StopBox from './stop-box';
16
18
  import Tree from './tree';
17
- import keepNowResources from './keep-now-resources';
18
19
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
19
20
  const fillParent = (nodes, parentId) => {
20
21
  nodes.forEach(node => {
@@ -32,7 +33,7 @@ const parseUrl = (component, projectId, releaseId, locale, initUrl) => {
32
33
  const {
33
34
  exportApi = '/'
34
35
  } = component?.meta.resource || {};
35
- const urlObj = new URL(joinURL('http://127.0.0.1', component.mountPoint, exportApi || '/').replace(/\/+/g, '/'));
36
+ const urlObj = new URL(joinURL('http://127.0.0.1', component?.mountPoint, exportApi || '/').replace(/\/+/g, '/'));
36
37
  urlObj.searchParams.set('projectId', projectId);
37
38
  urlObj.searchParams.set('releaseId', releaseId);
38
39
  urlObj.searchParams.set('local', locale);
@@ -159,7 +160,7 @@ export default function ResourceSelect({
159
160
  return;
160
161
  }
161
162
  // If the component does not have a mount point or does not start the engine, the resource is not requested
162
- if (!child?.mountPoint || !hasStartEngine(child?.meta)) {
163
+ if (!child?.mountPoint || !hasStartEngine(child?.meta) || !child?.meta?.resource?.exportApi) {
163
164
  return;
164
165
  }
165
166
  try {
@@ -203,12 +204,15 @@ export default function ResourceSelect({
203
204
  }, [releaseId, projectId, readOnly, locale, initUrl, setResources]);
204
205
  useEffect(() => {
205
206
  if (initialResources && Object.keys(initialResources).length) {
206
- app.children.forEach(child => {
207
+ pAll(app.children.map(async child => {
207
208
  const list = initialResources[child.meta.did];
208
209
  if (list?.length) {
210
+ const resTree = await axios.get(parseUrl(child, projectId, releaseId, locale, initUrl));
211
+ const tree = fillParent(resTree?.data?.resources || []);
209
212
  setSelectedResourceIds({
210
213
  [child.meta.did]: list
211
214
  });
215
+ setSelectedComponentsMapByIds(child.meta.did, tree, list);
212
216
  if (!readOnly) {
213
217
  saveSelectedEventsRef.current[child?.meta.did] = {
214
218
  resources: list,
@@ -216,7 +220,7 @@ export default function ResourceSelect({
216
220
  };
217
221
  }
218
222
  }
219
- });
223
+ }));
220
224
  }
221
225
  // eslint-disable-next-line react-hooks/exhaustive-deps
222
226
  }, [app, initialResources, readOnly]);
@@ -225,14 +229,14 @@ export default function ResourceSelect({
225
229
  Empty = /*#__PURE__*/_jsx(StopBox, {
226
230
  Icon: EmptyIcon,
227
231
  children: t('blocklet.publish.resourceEmptyTip', {
228
- name: component.meta.title
232
+ name: getDisplayName(component)
229
233
  })
230
234
  });
231
235
  }
232
236
  if (component?.status !== 'running') {
233
237
  Empty = /*#__PURE__*/_jsx(StopBox, {
234
238
  children: t('blocklet.publish.componentNotRunning', {
235
- name: component.meta.title
239
+ name: getDisplayName(component)
236
240
  })
237
241
  });
238
242
  }