@abtnode/ux 1.16.28-next-5a717317 → 1.16.28

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 (59) hide show
  1. package/lib/actions.js +8 -6
  2. package/lib/analytics/traffic.js +4 -10
  3. package/lib/blocklet/authentication/federated/federated-detail-dialog.js +2 -2
  4. package/lib/blocklet/blocklet-source.js +2 -2
  5. package/lib/blocklet/component/add-component/add-component-core.js +3 -2
  6. package/lib/blocklet/component/component-cell-mount-poin.js +164 -0
  7. package/lib/blocklet/component/component-cell.js +83 -84
  8. package/lib/blocklet/component/configuration.js +52 -36
  9. package/lib/blocklet/component/did-space/connect-to.js +4 -4
  10. package/lib/blocklet/component/index.js +29 -38
  11. package/lib/blocklet/component/navigation/navigation-dialog.js +2 -3
  12. package/lib/blocklet/component/space-connector.js +3 -3
  13. package/lib/blocklet/component/space-selector.js +2 -2
  14. package/lib/blocklet/component/store-blocklet-list.js +3 -3
  15. package/lib/blocklet/logo-uploader.js +2 -2
  16. package/lib/blocklet/notification/push-kit.js +1 -1
  17. package/lib/blocklet/preferences/index.js +3 -3
  18. package/lib/blocklet/publish/create-release/header.js +36 -31
  19. package/lib/blocklet/publish/create-release/index.js +54 -21
  20. package/lib/blocklet/publish/create-release/keep-now-resources.js +15 -0
  21. package/lib/blocklet/publish/create-release/release-stepper.js +4 -4
  22. package/lib/blocklet/publish/create-release/{resources.js → resource-select.js} +8 -7
  23. package/lib/blocklet/publish/create-release/resource-upload.js +105 -0
  24. package/lib/blocklet/publish/project-list.js +6 -0
  25. package/lib/blocklet/publish/release-list.js +4 -4
  26. package/lib/blocklet/publish/utils/validate-params.js +4 -4
  27. package/lib/blocklet/purchase/component-purchase.js +2 -2
  28. package/lib/blocklet/router/action/add-rule.js +31 -18
  29. package/lib/blocklet/router/rule-actions.js +8 -1
  30. package/lib/blocklet/storage/connect-to.js +4 -4
  31. package/lib/blocklet/storage/item.js +3 -3
  32. package/lib/blocklet/util.js +4 -4
  33. package/lib/hooks/url-evaluation.js +2 -2
  34. package/lib/hooks/use-app-logo.js +4 -4
  35. package/lib/hooks/use-bundle-logo.js +4 -4
  36. package/lib/invitation/invitation-receive.js +1 -1
  37. package/lib/locales/ar.js +12 -5
  38. package/lib/locales/de.js +11 -4
  39. package/lib/locales/en.js +11 -4
  40. package/lib/locales/es.js +11 -4
  41. package/lib/locales/fr.js +11 -4
  42. package/lib/locales/hi.js +11 -4
  43. package/lib/locales/i18n.db +0 -0
  44. package/lib/locales/id.js +11 -4
  45. package/lib/locales/ja.js +11 -4
  46. package/lib/locales/ko.js +11 -4
  47. package/lib/locales/pt.js +11 -4
  48. package/lib/locales/ru.js +11 -4
  49. package/lib/locales/th.js +11 -4
  50. package/lib/locales/vi.js +11 -4
  51. package/lib/locales/zh-tw.js +12 -5
  52. package/lib/locales/zh.js +12 -5
  53. package/lib/store/connect-actions.js +2 -2
  54. package/lib/store/item.js +2 -2
  55. package/lib/team/members/util.js +3 -3
  56. package/lib/util/index.js +18 -18
  57. package/lib/util/join-url-keep-search.js +2 -2
  58. package/lib/util/spaces.js +4 -2
  59. package/package.json +19 -20
@@ -3,7 +3,7 @@ import React, { useState } from 'react';
3
3
  import Button from '@arcblock/ux/lib/Button';
4
4
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
5
5
  import DidConnect from '@arcblock/did-connect/lib/Connect';
6
- import joinUrl from 'url-join';
6
+ import { joinURL } from 'ufo';
7
7
  import toast from '@arcblock/ux/lib/Toast';
8
8
  import SplitButton from '@arcblock/ux/lib/SplitButton';
9
9
  import Dialog from '@arcblock/ux/lib/Dialog';
@@ -62,7 +62,7 @@ function ConnectTo({
62
62
  checkTimeout: 1000 * 300,
63
63
  prefix: '/api/did',
64
64
  checkFn: axios.create({
65
- baseURL: joinUrl(window.location.origin, getPathPrefix())
65
+ baseURL: joinURL(window.location.origin, getPathPrefix())
66
66
  }).get,
67
67
  messages: {
68
68
  title: t('storage.spaces.provideNFT.title', {
@@ -191,10 +191,10 @@ function ConnectTo({
191
191
  setAuthorizeConnect(preValue => ({
192
192
  ...preValue,
193
193
  open: true,
194
- prefix: joinUrl(didSpacesCoreUrl, 'space/api/did'),
194
+ prefix: joinURL(didSpacesCoreUrl, 'space/api/did'),
195
195
  baseUrl: new URL(didSpacesCoreUrl).origin,
196
196
  checkFn: axios.create({
197
- baseURL: joinUrl(didSpacesCoreUrl, 'space')
197
+ baseURL: joinURL(didSpacesCoreUrl, 'space')
198
198
  }).get,
199
199
  extraParams: {
200
200
  appDid: blockletInfo.appDid,
@@ -7,11 +7,10 @@ import DialogContent from '@mui/material/DialogContent';
7
7
  import DialogTitle from '@mui/material/DialogTitle';
8
8
  import DialogActions from '@mui/material/DialogActions';
9
9
  import UpdateIcon from '@mui/icons-material/Update';
10
- import IconButton from '@mui/material/IconButton';
11
10
  import AddIcon from '@mui/icons-material/Add';
11
+ import { Icon } from '@iconify/react';
12
12
  import SettingsOutlinedIcon from '@mui/icons-material/SettingsOutlined';
13
13
  import Grid from '@mui/material/Grid';
14
- import Tooltip from '@mui/material/Tooltip';
15
14
  import ArrowForwardIcon from '@mui/icons-material/ArrowForward';
16
15
  import Checkbox from '@mui/material/Checkbox';
17
16
  import FormControlLabel from '@mui/material/FormControlLabel';
@@ -37,6 +36,7 @@ import useGetInstallComponentByUrl from '../../hooks/use-install-component-by-ur
37
36
  import ComponentCell, { StyledBadge, StyledComponentRow } from './component-cell';
38
37
  import OptionalComponentCell from './optional-component-cell';
39
38
  import AddComponentDialog from './add-component/add-component-dialog';
39
+ import Actions from '../../actions';
40
40
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
41
41
  export default function BlockletComponent({
42
42
  blocklet,
@@ -61,6 +61,8 @@ export default function BlockletComponent({
61
61
  const [updateConfirm, setUpdateConfirm] = useState(null);
62
62
  const [showSettings, setShowSettings] = useState(null);
63
63
  const [showContainer, setShowContainer] = useState(false);
64
+ const [showAddRule, setShowAddRule] = useState(false);
65
+ const [showComponentConfiguration, setShowComponentConfiguration] = useState(false);
64
66
  const [installComponentMeta, setInstallComponentMeta] = useState(null);
65
67
  const needMigration = blocklet && blocklet.structVersion !== APP_STRUCT_VERSION;
66
68
 
@@ -283,24 +285,7 @@ export default function BlockletComponent({
283
285
  children: /*#__PURE__*/_jsxs(Box, {
284
286
  display: "flex",
285
287
  alignItems: "center",
286
- children: [/*#__PURE__*/_jsx(AddRule, {
287
- children: ({
288
- open
289
- }) => /*#__PURE__*/_jsxs(Button, {
290
- disabled: loading || isInProgress(blocklet.status),
291
- variant: "text",
292
- color: "primary",
293
- "data-cy": "add-rule",
294
- className: "sm-hide-icon",
295
- onClick: open,
296
- children: [/*#__PURE__*/_jsx(AddIcon, {
297
- style: {
298
- fontSize: '1.3em',
299
- marginRight: 4
300
- }
301
- }), t('router.rule.add.title')]
302
- })
303
- }), !needMigration && /*#__PURE__*/_jsx(AddComponentButton, {
288
+ children: [!needMigration && /*#__PURE__*/_jsx(AddComponentButton, {
304
289
  blocklet: blocklet,
305
290
  serverVersion: info.version,
306
291
  children: ({
@@ -319,24 +304,20 @@ export default function BlockletComponent({
319
304
  }
320
305
  }), t('blocklet.component.add')]
321
306
  })
322
- }), !needMigration && /*#__PURE__*/_jsx(ComponentConfiguration, {
323
- blocklet: blocklet,
324
- ancestors: [],
325
- children: ({
326
- open
327
- }) => /*#__PURE__*/_jsx(Tooltip, {
328
- title: `${t('blocklet.component.container')}${t('common.config')}`,
329
- children: /*#__PURE__*/_jsx(IconButton, {
330
- onClick: open,
331
- size: "small",
332
- color: "primary",
333
- children: /*#__PURE__*/_jsx(SettingsOutlinedIcon, {
334
- style: {
335
- fontSize: 18
336
- }
337
- })
338
- })
339
- }, "config")
307
+ }), /*#__PURE__*/_jsx(Actions, {
308
+ "data-cy": "component-actions",
309
+ actions: [{
310
+ icon: /*#__PURE__*/_jsx(Icon, {
311
+ icon: "fluent:link-20-filled"
312
+ }),
313
+ onClick: () => setShowAddRule(true),
314
+ text: t('router.rule.add.title'),
315
+ disabled: loading || isInProgress(blocklet.status)
316
+ }, !needMigration && {
317
+ icon: /*#__PURE__*/_jsx(SettingsOutlinedIcon, {}),
318
+ text: `${t('blocklet.component.container')}`,
319
+ onClick: () => setShowComponentConfiguration(true)
320
+ }].filter(Boolean)
340
321
  })]
341
322
  })
342
323
  })]
@@ -490,6 +471,16 @@ export default function BlockletComponent({
490
471
  blocklet: blocklet,
491
472
  showDialog: !!parseInstallComponentMeta,
492
473
  setShowDialog: () => setInstallComponentMeta(null)
474
+ }), showAddRule && /*#__PURE__*/_jsx(AddRule, {
475
+ hiddenChildren: true,
476
+ open: true,
477
+ onClose: () => setShowAddRule(false)
478
+ }), showComponentConfiguration && /*#__PURE__*/_jsx(ComponentConfiguration, {
479
+ open: true,
480
+ onClose: () => setShowComponentConfiguration(false),
481
+ hiddenChildren: true,
482
+ blocklet: blocklet,
483
+ ancestors: []
493
484
  })]
494
485
  });
495
486
  }
@@ -23,8 +23,7 @@ import { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRe
23
23
  import { Controller, useForm } from 'react-hook-form';
24
24
  import { Icon, loadIcon } from '@iconify/react';
25
25
  import { isMatchSection, checkLink, flattenNavigation } from '@blocklet/meta/lib/parse-navigation-from-blocklet';
26
- import urljoin from 'url-join';
27
- import { withoutTrailingSlash } from 'ufo/dist/index.mjs';
26
+ import { joinURL, withoutTrailingSlash } from 'ufo';
28
27
  import isAbsoluteUrl from 'is-absolute-url';
29
28
  import { SUPPORTED_LANGUAGES } from '@blocklet/constant';
30
29
  import LocaleTabs from './locale-tabs';
@@ -169,7 +168,7 @@ const NavigationDialog = /*#__PURE__*/forwardRef(function NavigationDialog({
169
168
  return withoutTrailingSlash(stringLink);
170
169
  }
171
170
  const selectedLink = isObject(selectedOption.link) ? selectedOption.link[state.locale] : selectedOption.link;
172
- return withoutTrailingSlash(urljoin(stringLink, selectedLink || '/'));
171
+ return withoutTrailingSlash(joinURL(stringLink, selectedLink || '/'));
173
172
  }
174
173
  return null;
175
174
  }, [components, state.locale, selectedOption, watchComponent]);
@@ -4,7 +4,7 @@ import { LocaleContext } from '@arcblock/ux/lib/Locale/context';
4
4
  import { BLOCKLET_CONFIGURABLE_KEY, DID_SPACES } from '@blocklet/constant';
5
5
  import axios from 'axios';
6
6
  import PropTypes from 'prop-types';
7
- import joinUrl from 'url-join';
7
+ import { joinURL } from 'ufo';
8
8
  import { isEmpty } from 'lodash';
9
9
  import Typography from '@mui/material/Typography';
10
10
  import Toast from '@arcblock/ux/lib/Toast';
@@ -118,10 +118,10 @@ const SpaceConnector = /*#__PURE__*/forwardRef(({
118
118
  ...preValue,
119
119
  action: 'one-click-authorization',
120
120
  checkTimeout: 1000 * 300,
121
- prefix: joinUrl(gatewayUrl, 'space/api/did'),
121
+ prefix: joinURL(gatewayUrl, 'space/api/did'),
122
122
  baseUrl: new URL(gatewayUrl).origin,
123
123
  checkFn: axios.create({
124
- baseURL: joinUrl(gatewayUrl, 'space')
124
+ baseURL: joinURL(gatewayUrl, 'space')
125
125
  }).get,
126
126
  extraParams: {
127
127
  appDid: blocklet.appDid,
@@ -1,7 +1,7 @@
1
1
  import React, { useEffect, useState } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import styled from '@emotion/styled';
4
- import joinUrl from 'url-join';
4
+ import { joinURL } from 'ufo';
5
5
  import isUrl from 'is-url';
6
6
  import useLocalStorage from 'react-use/lib/useLocalStorage';
7
7
  import Button from '@arcblock/ux/lib/Button';
@@ -40,7 +40,7 @@ function SpaceSelector({
40
40
  } = useSessionContext();
41
41
  useEffect(() => {
42
42
  if (gatewayUrl && !gatewayList.find(x => x.value === gatewayUrl)) {
43
- api.get(joinUrl(gatewayUrl, '/__blocklet__.js?type=json')).then(res => {
43
+ api.get(joinURL(gatewayUrl, '/__blocklet__.js?type=json')).then(res => {
44
44
  // FIXME: @wangshijun handle mountPoint
45
45
  setGatewayList([...gatewayList, {
46
46
  value: gatewayUrl,
@@ -3,7 +3,7 @@
3
3
  import { useEffect, useState } from 'react';
4
4
  import styled from '@emotion/styled';
5
5
  import PropTypes from 'prop-types';
6
- import joinUrl from 'url-join';
6
+ import { joinURL } from 'ufo';
7
7
  import Link from '@mui/material/Link';
8
8
  import { ErrorFallback } from '@arcblock/ux/lib/ErrorBoundary';
9
9
  import { ErrorBoundary } from 'react-error-boundary';
@@ -20,7 +20,7 @@ import { formatRegistryLogoPath } from '../../util';
20
20
  import { useBlockletContext } from '../../contexts/blocklet';
21
21
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
22
22
  const getStoreDetail = (meta, endpoint) => {
23
- return joinUrl(endpoint, `/blocklets/${meta.did}`);
23
+ return joinURL(endpoint, `/blocklets/${meta.did}`);
24
24
  };
25
25
  const displayAttributes = ({
26
26
  blocklet,
@@ -42,7 +42,7 @@ function BlockletItem({
42
42
  const {
43
43
  t
44
44
  } = useLocaleContext();
45
- let logoUrl = joinUrl(endpoint, formatRegistryLogoPath(blocklet.did, blocklet.logo || ''));
45
+ let logoUrl = joinURL(endpoint, formatRegistryLogoPath(blocklet.did, blocklet.logo || ''));
46
46
  try {
47
47
  const tempURL = new URL(logoUrl);
48
48
  tempURL.searchParams.set('v', blocklet.version || +new Date());
@@ -1,6 +1,6 @@
1
1
  import React, { lazy, useRef } from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import joinUrl from 'url-join';
3
+ import { joinURL } from 'ufo';
4
4
  import styled from '@emotion/styled';
5
5
  import noop from 'lodash/noop';
6
6
  import Box from '@mui/material/Box';
@@ -52,7 +52,7 @@ export default function LogoUploader({
52
52
  disabled: true
53
53
  },
54
54
  apiPathProps: {
55
- uploader: joinUrl(prefix, uploadPrefix, type, did),
55
+ uploader: joinURL(prefix, uploadPrefix, type, did),
56
56
  disableMediaKitPrefix: true
57
57
  },
58
58
  coreProps: {
@@ -85,7 +85,7 @@ function NotificationPushKit() {
85
85
  await api.sendPush({
86
86
  input: {
87
87
  did,
88
- receiver: 'z1b9wxs47TXpA5s6VMoGFBk933tF7ujzFDt',
88
+ receiver: pageState.testReceiver,
89
89
  notification: JSON.stringify({
90
90
  title: 'Test push-kit notification',
91
91
  body: 'This is message from push-kit config test',
@@ -2,7 +2,7 @@ import React, { useState, useContext } from 'react';
2
2
  import styled from '@emotion/styled';
3
3
  import PropTypes from 'prop-types';
4
4
  import Iframe from 'react-iframe';
5
- import joinUrl from 'url-join';
5
+ import { joinURL } from 'ufo';
6
6
  import { WELLKNOWN_SERVICE_PATH_PREFIX } from '@abtnode/constant';
7
7
  import { Grid, Box } from '@mui/material';
8
8
  import GeneralIcon from '@mui/icons-material/TuneRounded';
@@ -236,9 +236,9 @@ export default function BlockletPreferences({
236
236
  if (!inService) {
237
237
  urlSearchParams.set('authKey', '__sst');
238
238
  }
239
- urlSearchParams.set('schemaKey', joinUrl(window.location.origin, pathPrefix, `/api/preferences?id=${encodeURIComponent(current)}`));
239
+ urlSearchParams.set('schemaKey', joinURL(window.location.origin, pathPrefix, `/api/preferences?id=${encodeURIComponent(current)}`));
240
240
  content = /*#__PURE__*/_jsx(Iframe, {
241
- url: `${joinUrl(window.location.origin, pathPrefix, '/hosted/form-collector/')}?${urlSearchParams.toString()}`,
241
+ url: `${joinURL(window.location.origin, pathPrefix, '/hosted/form-collector/')}?${urlSearchParams.toString()}`,
242
242
  width: "100%",
243
243
  height: "100%",
244
244
  frameBorder: 0,
@@ -19,7 +19,7 @@ import ConnectStoreList from './connect-store-list';
19
19
  import { validateParams } from '../utils/validate-params';
20
20
  import { waitGetConnectedStore } from '../utils/wait-connect';
21
21
  import uploadImageToProject from '../utils/upload-image-to-project';
22
- import { uploadResource } from './resources';
22
+ import { uploadResource } from './resource-select';
23
23
  import ClickToCopy from '../../../click-to-copy';
24
24
  import { formatError } from '../../../util';
25
25
  import { useNodeContext } from '../../../contexts/node';
@@ -44,7 +44,7 @@ function Header({
44
44
  resourceRelateComponents,
45
45
  disabledSelectComponents,
46
46
  saveSelectedEventsRef,
47
- isSelectedResources,
47
+ hasSelectedResources,
48
48
  initLogoUrl,
49
49
  setLoading,
50
50
  releaseUsedLast,
@@ -72,7 +72,7 @@ function Header({
72
72
  const onRelease = async status => {
73
73
  const errors = validateParams({
74
74
  params,
75
- isSelectedResources,
75
+ hasSelectedResources,
76
76
  projectId,
77
77
  status,
78
78
  t
@@ -140,32 +140,37 @@ function Header({
140
140
  return;
141
141
  }
142
142
  }
143
- const saveKeys = Object.keys(saveSelectedEventsRef.current);
144
- try {
145
- await pAll(saveKeys.map(x => {
146
- return () => {
147
- const item = saveSelectedEventsRef.current[x];
148
- return uploadResource({
149
- api,
150
- locale,
151
- projectId,
152
- releaseId: releaseUsedLast ? '' : releaseId,
153
- appDid: blocklet.meta.did,
154
- component: item.component,
155
- resources: item.resources,
156
- initUrl
157
- });
158
- };
159
- }), {
160
- concurrency: 2
161
- });
162
- } catch (err) {
163
- Toast.error(err?.response?.data?.error?.message || err.message);
164
- setLoading(false);
165
- setParamsErrTip({
166
- resources: 'Invalid save the resource'
167
- });
168
- return;
143
+ if (params.resourceFromSelect) {
144
+ _params.uploadedResource = '';
145
+ try {
146
+ const saveKeys = Object.keys(saveSelectedEventsRef.current);
147
+ await pAll(saveKeys.map(x => {
148
+ return () => {
149
+ const item = saveSelectedEventsRef.current[x];
150
+ return uploadResource({
151
+ api,
152
+ locale,
153
+ projectId,
154
+ releaseId: releaseUsedLast ? '' : releaseId,
155
+ appDid: blocklet.meta.did,
156
+ component: item.component,
157
+ resources: item.resources,
158
+ initUrl
159
+ });
160
+ };
161
+ }), {
162
+ concurrency: 2
163
+ });
164
+ } catch (err) {
165
+ Toast.error(err?.response?.data?.error?.message || err.message);
166
+ setLoading(false);
167
+ setParamsErrTip({
168
+ resources: 'Invalid save the resource'
169
+ });
170
+ return;
171
+ }
172
+ } else {
173
+ _params.blockletComponents = [];
169
174
  }
170
175
  _params.blockletTitle = (_params.blockletTitle || '').trim();
171
176
  _params.blockletDescription = (_params.blockletDescription || '').trim();
@@ -345,7 +350,7 @@ function Header({
345
350
  mr: 0.5
346
351
  },
347
352
  color: "inherit"
348
- }), t('common.release')]
353
+ }), t('blocklet.publish.createRelease')]
349
354
  }), isPublished && /*#__PURE__*/_jsxs(_Fragment, {
350
355
  children: [installButton, /*#__PURE__*/_jsx("a", {
351
356
  href: joinURL(`${WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${blocklet.meta.did}/${projectId}/${releaseId}/download/${(release.files || [])[0]}`),
@@ -406,7 +411,7 @@ Header.propTypes = {
406
411
  resourceRelateComponents: PropTypes.object.isRequired,
407
412
  disabledSelectComponents: PropTypes.bool.isRequired,
408
413
  saveSelectedEventsRef: PropTypes.object.isRequired,
409
- isSelectedResources: PropTypes.bool.isRequired,
414
+ hasSelectedResources: PropTypes.bool.isRequired,
410
415
  initLogoUrl: PropTypes.string.isRequired,
411
416
  setLoading: PropTypes.func.isRequired,
412
417
  releaseUsedLast: PropTypes.bool.isRequired,
@@ -4,10 +4,10 @@ import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
4
4
  import Tabs from '@arcblock/ux/lib/Tabs';
5
5
  import Toast from '@arcblock/ux/lib/Toast';
6
6
  import styled from '@emotion/styled';
7
- import { Box, Tooltip, Typography, useMediaQuery } from '@mui/material';
7
+ import { Box, FormControlLabel, Radio, RadioGroup, Tooltip, Typography, useMediaQuery } from '@mui/material';
8
8
  import pick from 'lodash/pick';
9
9
  import PropTypes from 'prop-types';
10
- import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
10
+ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
11
11
  import { useParams } from 'react-router-dom';
12
12
  import useSetState from 'react-use/lib/useSetState';
13
13
  import semver from 'semver';
@@ -17,14 +17,15 @@ import { useNodeContext } from '../../../contexts/node';
17
17
  import EmptySpinner from '../../../empty-spinner';
18
18
  import { formatError } from '../../../util';
19
19
  import Blocklets from './blocklets';
20
- import Resources from './resources';
20
+ import ResourceSelect from './resource-select';
21
21
  import Branding from './branding';
22
22
  import Header from './header';
23
23
  import Introduction from './introduction';
24
24
  import ReleaseStepper from './release-stepper';
25
25
  import StopBox from './stop-box';
26
26
  import Version from './version';
27
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
27
+ import ResourceUpload from './resource-upload';
28
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
28
29
  const addComponentTabs = ({
29
30
  tabs,
30
31
  blocklet,
@@ -52,7 +53,7 @@ const addComponentTabs = ({
52
53
  });
53
54
  };
54
55
  const pickParams = (baseParams, app) => {
55
- const params = pick(baseParams, ['blockletVersion', 'blockletTitle', 'blockletDescription', 'blockletLogo', 'blockletIntroduction', 'blockletScreenshots', 'connectedStores', 'blockletComponents', 'lastReleaseId', 'note']);
56
+ const params = pick(baseParams, ['blockletVersion', 'blockletTitle', 'blockletDescription', 'blockletLogo', 'blockletIntroduction', 'blockletScreenshots', 'connectedStores', 'blockletComponents', 'lastReleaseId', 'uploadedResource', 'note']);
56
57
  if (!params.blockletComponents) {
57
58
  params.blockletComponents = (app.children || []).map(x => ({
58
59
  did: x.meta.did,
@@ -65,6 +66,7 @@ const pickParams = (baseParams, app) => {
65
66
  included: true
66
67
  }));
67
68
  }
69
+ params.resourceFromSelect = !params.uploadedResource;
68
70
  return params;
69
71
  };
70
72
  const stepsToLabel = {
@@ -100,7 +102,9 @@ export default function CreateRelease({
100
102
  const [params, setParams] = useSetState({
101
103
  blockletScreenshots: [],
102
104
  publishedStoreIds: [],
103
- connectedStores: []
105
+ connectedStores: [],
106
+ uploadedResource: '',
107
+ resourceFromSelect: true
104
108
  });
105
109
  const [paramsErrTip, setParamsErrTip] = useSetState({});
106
110
  const [loading, setLoading] = useState(false);
@@ -272,7 +276,7 @@ export default function CreateRelease({
272
276
  }
273
277
  }
274
278
  }, [setParams, projectId, initUrl, mode]);
275
- const isSelectedResources = useMemo(() => {
279
+ const hasSelectedResources = useMemo(() => {
276
280
  return !!Object.keys(selectedResourceIds).find(key => {
277
281
  if (selectedResourceIds[key].length) {
278
282
  return true;
@@ -339,7 +343,7 @@ export default function CreateRelease({
339
343
  resourceRelateComponents: resourceRelateComponents,
340
344
  resourceItem: resourceItem,
341
345
  saveSelectedEventsRef: saveSelectedEventsRef,
342
- isSelectedResources: isSelectedResources,
346
+ hasSelectedResources: hasSelectedResources,
343
347
  releaseUsedLast: releaseUsedLast,
344
348
  setReleaseUsedLast: setReleaseUsedLast,
345
349
  setRelease: setRelease
@@ -361,7 +365,7 @@ export default function CreateRelease({
361
365
  steps: steps,
362
366
  viewMode: mode === 'view',
363
367
  params: params,
364
- isSelectedResources: isSelectedResources,
368
+ hasSelectedResources: hasSelectedResources || params.uploadedResource,
365
369
  paramsErrTip: paramsErrTip,
366
370
  activeStep: activeStep,
367
371
  setActiveStep: setActiveStep,
@@ -455,17 +459,38 @@ export default function CreateRelease({
455
459
  sx: {
456
460
  flex: 1
457
461
  },
458
- children: [!componentDid && /*#__PURE__*/_jsx(Tabs, {
459
- tabs: tabs,
460
- current: tab,
461
- onChange: onTabChange,
462
- sx: {
463
- ml: -2,
464
- mt: -1.5,
465
- maxWidth: isMobile ? window.innerWidth - 24 : '100%'
466
- }
467
- }), /*#__PURE__*/_jsx(Box, {
468
- children: /*#__PURE__*/_jsx(Resources, {
462
+ children: [/*#__PURE__*/_jsxs(RadioGroup, {
463
+ onChange: () => setParams({
464
+ resourceFromSelect: !params.resourceFromSelect
465
+ }),
466
+ children: [/*#__PURE__*/_jsx(FormControlLabel, {
467
+ value: "select",
468
+ disabled: readOnly,
469
+ control: /*#__PURE__*/_jsx(Radio, {
470
+ size: "small",
471
+ checked: params.resourceFromSelect
472
+ }),
473
+ label: t('blocklet.publish.resourceSelect')
474
+ }), /*#__PURE__*/_jsx(FormControlLabel, {
475
+ value: "select",
476
+ disabled: readOnly,
477
+ control: /*#__PURE__*/_jsx(Radio, {
478
+ size: "small",
479
+ checked: !params.resourceFromSelect
480
+ }),
481
+ label: t('blocklet.publish.resourceUpload')
482
+ })]
483
+ }), params.resourceFromSelect && /*#__PURE__*/_jsxs(_Fragment, {
484
+ children: [!componentDid && /*#__PURE__*/_jsx(Tabs, {
485
+ tabs: tabs,
486
+ current: tab,
487
+ onChange: onTabChange,
488
+ sx: {
489
+ ml: -2,
490
+ mt: 2,
491
+ maxWidth: isMobile ? window.innerWidth - 24 : '100%'
492
+ }
493
+ }), /*#__PURE__*/_jsx(ResourceSelect, {
469
494
  loading: loading,
470
495
  initialResources: initialResources,
471
496
  saveSelectedEventsRef: saveSelectedEventsRef,
@@ -478,13 +503,21 @@ export default function CreateRelease({
478
503
  component: resourceItem,
479
504
  componentDid: componentDid,
480
505
  initUrl: initUrl,
506
+ params: params,
507
+ setParams: setParams,
481
508
  projectId: projectId === UNOWNED_DID ? '' : projectId,
482
509
  releaseUsedLast: releaseUsedLast,
483
510
  release: {
484
511
  ...release,
485
512
  id: releaseId
486
513
  }
487
- })
514
+ })]
515
+ }), !params.resourceFromSelect && /*#__PURE__*/_jsx(ResourceUpload, {
516
+ app: blocklet,
517
+ readOnly: readOnly,
518
+ projectId: projectId === UNOWNED_DID ? '' : projectId,
519
+ params: params,
520
+ setParams: setParams
488
521
  })]
489
522
  })
490
523
  })
@@ -0,0 +1,15 @@
1
+ function keepNowResources(trees, list) {
2
+ const listSet = new Set(list || []);
3
+ const result = [];
4
+ function traverse(tree) {
5
+ if (listSet.has(tree?.id)) {
6
+ result.push(tree?.id);
7
+ }
8
+ if (tree?.children) {
9
+ tree.children.forEach(traverse);
10
+ }
11
+ }
12
+ (trees || []).forEach(traverse);
13
+ return result;
14
+ }
15
+ export default keepNowResources;
@@ -8,7 +8,7 @@ export default function ReleaseStepper({
8
8
  steps,
9
9
  activeStep,
10
10
  setActiveStep,
11
- isSelectedResources,
11
+ hasSelectedResources,
12
12
  params,
13
13
  loading,
14
14
  paramsErrTip,
@@ -37,7 +37,7 @@ export default function ReleaseStepper({
37
37
  return '';
38
38
  };
39
39
  const readOnly = viewMode || validateParams({
40
- isSelectedResources,
40
+ hasSelectedResources,
41
41
  params,
42
42
  projectId,
43
43
  t
@@ -57,7 +57,7 @@ export default function ReleaseStepper({
57
57
  children: steps.map((step, index) => {
58
58
  const labelProps = {};
59
59
  const ok = loading || !validateParamsStep({
60
- isSelectedResources,
60
+ hasSelectedResources,
61
61
  params,
62
62
  projectId,
63
63
  step: index,
@@ -149,7 +149,7 @@ ReleaseStepper.propTypes = {
149
149
  viewMode: PropTypes.string.isRequired,
150
150
  loading: PropTypes.bool.isRequired,
151
151
  projectId: PropTypes.string.isRequired,
152
- isSelectedResources: PropTypes.bool.isRequired,
152
+ hasSelectedResources: PropTypes.bool.isRequired,
153
153
  paramsErrTip: PropTypes.shape({
154
154
  projectId: PropTypes.string,
155
155
  blockletVersion: PropTypes.string,