@abtnode/ux 1.16.29-beta-112566d5 → 1.16.29-beta-1fedbcdd

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.
@@ -1,14 +1,14 @@
1
- import { useMemo } from 'react';
2
- import PropTypes from 'prop-types';
3
1
  import styled from '@emotion/styled';
4
2
  import classnames from 'classnames';
5
3
  import pick from 'lodash/pick';
6
- import Checkbox from '@mui/material/Checkbox';
7
- import Box from '@mui/material/Box';
4
+ import PropTypes from 'prop-types';
5
+ import { useMemo } from 'react';
8
6
  import Datatable from '@arcblock/ux/lib/Datatable';
9
7
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
10
- import { Alert } from '@mui/material';
8
+ import Box from '@mui/material/Box';
9
+ import Checkbox from '@mui/material/Checkbox';
11
10
  import { EmptyIcon } from '@arcblock/icons';
11
+ import { Alert } from '@mui/material';
12
12
  import BlockletBundleAvatar from '../../bundle-avatar';
13
13
  import StopBox from './stop-box';
14
14
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
@@ -1,29 +1,30 @@
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, 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 { uploadResource } from './resource-select';
27
28
  import UploadedToast from './uploaded-toast';
28
29
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
29
30
  const serverEndpoint = window.env?.serverEndpoint;
@@ -90,32 +91,7 @@ function Header({
90
91
  const _params = {
91
92
  ...params
92
93
  };
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
- });
94
+ _params.blockletComponents = parseResourceRelateComponents(_params.blockletComponents, blocklet, resourceRelateComponents, disabledSelectComponents);
119
95
  _params.blockletVersion = semver.valid(_params.blockletVersion);
120
96
  if (!_params.blockletVersion) {
121
97
  Toast.error('Invalid Blocklet Version');
@@ -273,31 +249,34 @@ function Header({
273
249
  const url = new URL(serverEndpoint);
274
250
  url.pathname = joinURL(url.pathname, '/launch-blocklet/agreement');
275
251
  url.searchParams.set('blocklet_meta_url', blockletMetaUrl);
276
- installButton = /*#__PURE__*/_jsx("a", {
252
+ installButton = isMobile ? /*#__PURE__*/_jsx(IconButton, {
253
+ component: "a",
277
254
  href: url.href,
278
255
  target: "_blank",
279
256
  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')
257
+ color: "primary",
258
+ sx: {
259
+ mr: 1
260
+ },
261
+ onClick: () => setInstallResourceTip(blockletMetaUrl),
262
+ children: /*#__PURE__*/_jsx(Icon, {
263
+ icon: "ic:baseline-install-desktop"
296
264
  })
265
+ }) : /*#__PURE__*/_jsx(Button, {
266
+ href: url.href,
267
+ target: "_blank",
268
+ rel: "noreferrer",
269
+ variant: "outlined",
270
+ sx: {
271
+ mr: 1
272
+ },
273
+ onClick: () => setInstallResourceTip(blockletMetaUrl),
274
+ children: t('common.install')
297
275
  });
298
276
  } else {
299
277
  installButton = /*#__PURE__*/_jsxs(_Fragment, {
300
278
  children: [isMobile ? /*#__PURE__*/_jsx(IconButton, {
279
+ disabled: loading,
301
280
  color: "primary",
302
281
  sx: {
303
282
  mr: 1
@@ -307,6 +286,7 @@ function Header({
307
286
  icon: "ic:baseline-install-desktop"
308
287
  })
309
288
  }) : /*#__PURE__*/_jsx(Button, {
289
+ disabled: loading,
310
290
  variant: "outlined",
311
291
  sx: {
312
292
  mr: 1
@@ -397,15 +377,15 @@ function Header({
397
377
  color: "inherit"
398
378
  }), t('blocklet.publish.createRelease')]
399
379
  }), isPublished && /*#__PURE__*/_jsxs(_Fragment, {
400
- children: [installButton, /*#__PURE__*/_jsx("a", {
380
+ children: [installButton, isMobile ? null : /*#__PURE__*/_jsx(Button, {
381
+ component: "a",
382
+ disabled: loading,
401
383
  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
- })
384
+ variant: "outlined",
385
+ sx: {
386
+ mr: 1
387
+ },
388
+ children: t('common.download')
409
389
  }), /*#__PURE__*/_jsxs(Button, {
410
390
  disabled: loading,
411
391
  variant: "contained",
@@ -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
  });
@@ -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
  }
@@ -0,0 +1,31 @@
1
+ const parseResourceRelateComponents = (nowBlockletComponents, blocklet, resourceRelateComponents, disabledSelectComponents) => {
2
+ const blockletComponents = [...nowBlockletComponents];
3
+ const componentMaps = (blocklet?.children || []).reduce((acc, curr) => {
4
+ acc[curr.meta.did] = true;
5
+ return acc;
6
+ }, {});
7
+ Object.keys(resourceRelateComponents).forEach(blockletDid => {
8
+ if (!componentMaps[blockletDid]) {
9
+ return;
10
+ }
11
+ let included = false;
12
+ if (!disabledSelectComponents) {
13
+ blockletComponents.forEach(item => {
14
+ if (item.did === blockletDid) {
15
+ item.included = true;
16
+ item.required = true;
17
+ included = true;
18
+ }
19
+ });
20
+ }
21
+ if (!included) {
22
+ blockletComponents.push({
23
+ did: blockletDid,
24
+ included: true,
25
+ required: true
26
+ });
27
+ }
28
+ });
29
+ return blockletComponents;
30
+ };
31
+ export default parseResourceRelateComponents;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abtnode/ux",
3
- "version": "1.16.29-beta-112566d5",
3
+ "version": "1.16.29-beta-1fedbcdd",
4
4
  "description": "UX components shared across abtnode packages",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -25,24 +25,24 @@
25
25
  "author": "linchen <linchen1987@foxmail.com> (http://github.com/linchen1987)",
26
26
  "license": "Apache-2.0",
27
27
  "dependencies": {
28
- "@abtnode/auth": "1.16.29-beta-112566d5",
29
- "@abtnode/constant": "1.16.29-beta-112566d5",
30
- "@abtnode/util": "1.16.29-beta-112566d5",
28
+ "@abtnode/auth": "1.16.29-beta-1fedbcdd",
29
+ "@abtnode/constant": "1.16.29-beta-1fedbcdd",
30
+ "@abtnode/util": "1.16.29-beta-1fedbcdd",
31
31
  "@ahooksjs/use-url-state": "^3.5.1",
32
32
  "@arcblock/did": "^1.18.126",
33
- "@arcblock/did-connect": "^2.10.5",
33
+ "@arcblock/did-connect": "^2.10.7",
34
34
  "@arcblock/did-motif": "^1.1.13",
35
- "@arcblock/icons": "^2.10.5",
36
- "@arcblock/nft-display": "2.10.5",
37
- "@arcblock/react-hooks": "^2.10.5",
38
- "@arcblock/terminal": "^2.10.5",
39
- "@arcblock/ux": "^2.10.5",
40
- "@blocklet/constant": "1.16.29-beta-112566d5",
41
- "@blocklet/js-sdk": "1.16.29-beta-112566d5",
42
- "@blocklet/launcher-layout": "2.3.30",
35
+ "@arcblock/icons": "^2.10.7",
36
+ "@arcblock/nft-display": "2.10.7",
37
+ "@arcblock/react-hooks": "^2.10.7",
38
+ "@arcblock/terminal": "^2.10.7",
39
+ "@arcblock/ux": "^2.10.7",
40
+ "@blocklet/constant": "1.16.29-beta-1fedbcdd",
41
+ "@blocklet/js-sdk": "1.16.29-beta-1fedbcdd",
42
+ "@blocklet/launcher-layout": "2.3.33",
43
43
  "@blocklet/list": "^0.13.9",
44
- "@blocklet/meta": "1.16.29-beta-112566d5",
45
- "@blocklet/ui-react": "^2.10.5",
44
+ "@blocklet/meta": "1.16.29-beta-1fedbcdd",
45
+ "@blocklet/ui-react": "^2.10.7",
46
46
  "@blocklet/uploader": "0.1.19",
47
47
  "@emotion/react": "^11.10.4",
48
48
  "@emotion/styled": "^11.10.4",
@@ -108,5 +108,5 @@
108
108
  "jest": "^29.7.0",
109
109
  "jest-environment-jsdom": "^29.7.0"
110
110
  },
111
- "gitHead": "4c6213560b79dc862b0b5e48b50f65c39de54aef"
111
+ "gitHead": "e66e220d775e821c85b8bd6286342c202ad143f0"
112
112
  }