@abtnode/ux 1.16.29-beta-88bdefe8 → 1.16.29-beta-a076832b

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.
@@ -211,11 +211,11 @@ function Branding({
211
211
  }
212
212
  })]
213
213
  })
214
- }), /*#__PURE__*/_jsxs(Box, {
214
+ }), /*#__PURE__*/_jsx(Box, {
215
215
  display: "flex",
216
216
  mt: 3,
217
217
  className: "section full-width",
218
- children: [/*#__PURE__*/_jsxs(Box, {
218
+ children: /*#__PURE__*/_jsxs(Box, {
219
219
  sx: {
220
220
  flex: 1
221
221
  },
@@ -303,61 +303,58 @@ function Branding({
303
303
  })]
304
304
  })]
305
305
  })]
306
- }), /*#__PURE__*/_jsx(Suspense, {
307
- fallback: /*#__PURE__*/_jsx(EmptySpinner, {}),
308
- children: /*#__PURE__*/_jsx(UploaderComponent, {
309
- ref: uploaderLogoRef,
310
- popup: true,
311
- onUploadFinish: result => {
312
- setParams({
313
- blockletLogo: result.data.filename
314
- });
315
- setInitLogoUrl('');
316
- uploaderLogoRef.current.close();
317
- },
318
- plugins: ['ImageEditor'],
319
- installerProps: {
320
- disabled: true
321
- },
322
- apiPathProps: {
323
- uploader: uploadLogoPrefix,
324
- disableMediaKitPrefix: true
325
- },
326
- coreProps: {
327
- restrictions: {
328
- allowedFileExts,
329
- maxFileSize,
330
- maxNumberOfFiles: 1
331
- }
306
+ })
307
+ }), /*#__PURE__*/_jsxs(Suspense, {
308
+ fallback: /*#__PURE__*/_jsx(EmptySpinner, {}),
309
+ children: [/*#__PURE__*/_jsx(UploaderComponent, {
310
+ ref: uploaderLogoRef,
311
+ popup: true,
312
+ onUploadFinish: result => {
313
+ setParams({
314
+ blockletLogo: result.data.filename
315
+ });
316
+ setInitLogoUrl('');
317
+ uploaderLogoRef.current.close();
318
+ },
319
+ plugins: ['ImageEditor'],
320
+ installerProps: {
321
+ disabled: true
322
+ },
323
+ apiPathProps: {
324
+ uploader: uploadLogoPrefix,
325
+ disableMediaKitPrefix: true
326
+ },
327
+ coreProps: {
328
+ restrictions: {
329
+ allowedFileExts,
330
+ maxFileSize,
331
+ maxNumberOfFiles: 1
332
332
  }
333
- }, "uploader-logo")
334
- }), /*#__PURE__*/_jsx(Suspense, {
335
- fallback: /*#__PURE__*/_jsx(EmptySpinner, {}),
336
- children: /*#__PURE__*/_jsx(UploaderComponent, {
337
- ref: uploaderScreenshotRef,
338
- popup: true,
339
- onUploadFinish: result => {
340
- const blockletScreenshots = params.blockletScreenshots || [];
341
- blockletScreenshots.push(result.data?.filename);
342
- setParams({
343
- blockletScreenshots
344
- });
345
- uploaderScreenshotRef.current.close();
346
- },
347
- plugins: ['ImageEditor'],
348
- apiPathProps: {
349
- uploader: uploadScreenshotPrefix,
350
- disableMediaKitPrefix: true
351
- },
352
- coreProps: {
353
- restrictions: {
354
- allowedFileExts,
355
- maxFileSize,
356
- maxNumberOfFiles: 5 - screenshotUrls.length
357
- }
333
+ }
334
+ }, "uploader-logo"), /*#__PURE__*/_jsx(UploaderComponent, {
335
+ ref: uploaderScreenshotRef,
336
+ popup: true,
337
+ onUploadFinish: result => {
338
+ const blockletScreenshots = params.blockletScreenshots || [];
339
+ blockletScreenshots.push(result.data?.filename);
340
+ setParams({
341
+ blockletScreenshots
342
+ });
343
+ uploaderScreenshotRef.current.close();
344
+ },
345
+ plugins: ['ImageEditor'],
346
+ apiPathProps: {
347
+ uploader: uploadScreenshotPrefix,
348
+ disableMediaKitPrefix: true
349
+ },
350
+ coreProps: {
351
+ restrictions: {
352
+ allowedFileExts,
353
+ maxFileSize,
354
+ maxNumberOfFiles: 5 - screenshotUrls.length
358
355
  }
359
- }, "uploader-screenshot")
360
- })]
356
+ }
357
+ }, "uploader-screenshot")]
361
358
  })]
362
359
  });
363
360
  }
@@ -1,16 +1,20 @@
1
1
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
2
- import { BLOCKLET_TENANT_MODES } from '@blocklet/constant';
3
2
  import AddIcon from '@mui/icons-material/Add';
4
3
  import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown';
5
- import { Button, ButtonGroup, CircularProgress, ClickAwayListener, Divider, Grow, IconButton, MenuItem, MenuList, Paper, Popper, Typography } from '@mui/material';
4
+ import { Box, Button, ButtonGroup, CircularProgress, ClickAwayListener, Divider, Grow, IconButton, MenuItem, MenuList, Paper, Popper, Typography } from '@mui/material';
6
5
  import PropTypes from 'prop-types';
7
6
  import { Icon } from '@iconify/react';
8
7
  import { useRef, useState } from 'react';
9
8
  import Toast from '@arcblock/ux/lib/Toast';
10
9
  import formatError from '@abtnode/util/lib/format-error';
10
+ import { useSessionContext } from '../../../contexts/session';
11
11
  import AddStore from '../../../store/add';
12
12
  import { useNodeContext } from '../../../contexts/node';
13
13
  import ConfirmDialog from '../../../confirm';
14
+ import { useBlockletContext } from '../../../contexts/blocklet';
15
+ import ShortenLabel from '../../component/shorten-label';
16
+ import canDeleteStore from '../utils/can-delete-store';
17
+ import getStudioStoreList from '../utils/get-studio-store-list';
14
18
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
15
19
  export default function ConnectStoreButton({
16
20
  blocklet,
@@ -24,12 +28,18 @@ export default function ConnectStoreButton({
24
28
  const {
25
29
  t
26
30
  } = useLocaleContext();
31
+ const {
32
+ session
33
+ } = useSessionContext();
34
+ const {
35
+ api,
36
+ info: nodeInfo,
37
+ inService
38
+ } = useNodeContext();
39
+ const blockletContext = useBlockletContext();
27
40
  const [open, setOpen] = useState(false);
28
41
  const anchorRef = useRef(null);
29
42
  const [openAddStore, setOpenAddStore] = useState(false);
30
- const {
31
- api
32
- } = useNodeContext();
33
43
  const [deleteStore, setDeleteStore] = useState(null);
34
44
  const handleSelectStore = nextStore => {
35
45
  onChangeStore(nextStore);
@@ -59,17 +69,27 @@ export default function ConnectStoreButton({
59
69
  input: {
60
70
  teamDid: blocklet.meta.did,
61
71
  url: deleteStore.url,
62
- projectId: ''
72
+ projectId: '',
73
+ scope: deleteStore.scope || 'studio'
63
74
  }
64
75
  });
65
- setDeleteStore(null);
76
+ await blockletContext?.actions?.refreshBlocklet();
66
77
  } catch (err) {
67
78
  Toast.error(`Remove Blocklet Store Error: ${formatError(err)}`);
79
+ } finally {
80
+ setDeleteStore(null);
68
81
  }
69
82
  };
70
- const storeList = blocklet?.settings?.storeList || [];
83
+ const {
84
+ storeList
85
+ } = getStudioStoreList({
86
+ fromBlocklet: inService,
87
+ blocklet,
88
+ nodeInfo,
89
+ componentDid,
90
+ userDid: session?.user?.did
91
+ });
71
92
  const did = blocklet?.meta?.did;
72
- const manageable = !(componentDid && window.blocklet?.tenantMode === BLOCKLET_TENANT_MODES.MULTIPLE);
73
93
  return /*#__PURE__*/_jsxs(_Fragment, {
74
94
  children: [/*#__PURE__*/_jsxs(ButtonGroup, {
75
95
  disabled: disabled,
@@ -100,16 +120,16 @@ export default function ConnectStoreButton({
100
120
  },
101
121
  open: open,
102
122
  anchorEl: anchorRef.current,
123
+ placement: "bottom-end",
103
124
  role: undefined,
104
125
  transition: true,
105
126
  disablePortal: true,
106
127
  children: ({
107
- TransitionProps,
108
- placement
128
+ TransitionProps
109
129
  }) => /*#__PURE__*/_jsx(Grow, {
110
130
  ...TransitionProps,
111
131
  style: {
112
- transformOrigin: placement === 'bottom' ? 'center top' : 'center bottom'
132
+ transformOrigin: 'center top'
113
133
  },
114
134
  children: /*#__PURE__*/_jsx(Paper, {
115
135
  children: /*#__PURE__*/_jsx(ClickAwayListener, {
@@ -117,16 +137,35 @@ export default function ConnectStoreButton({
117
137
  children: /*#__PURE__*/_jsxs(MenuList, {
118
138
  id: "split-button-menu",
119
139
  autoFocusItem: true,
140
+ sx: {
141
+ maxHeight: 300,
142
+ overflowY: 'auto'
143
+ },
120
144
  children: [storeList.map(option => /*#__PURE__*/_jsxs(MenuItem, {
121
145
  selected: option.id === store.id,
122
146
  sx: {
123
- height: 40
147
+ height: 56
124
148
  },
125
149
  onClick: () => handleSelectStore(option),
126
- children: [/*#__PURE__*/_jsx(Typography, {
127
- variant: "inherit",
128
- children: option.name
129
- }), manageable && !option.protected && /*#__PURE__*/_jsx(IconButton, {
150
+ children: [/*#__PURE__*/_jsxs(Box, {
151
+ children: [/*#__PURE__*/_jsx(ShortenLabel, {
152
+ sx: {
153
+ fontSize: '16px'
154
+ },
155
+ maxLength: 24,
156
+ children: option.name
157
+ }), /*#__PURE__*/_jsx(ShortenLabel, {
158
+ sx: {
159
+ fontSize: '13px',
160
+ opacity: 0.6
161
+ },
162
+ maxLength: 30,
163
+ children: option.url
164
+ })]
165
+ }), canDeleteStore({
166
+ store: option,
167
+ userDid: session?.user?.did
168
+ }) && /*#__PURE__*/_jsx(IconButton, {
130
169
  sx: {
131
170
  ml: 1
132
171
  },
@@ -139,7 +178,7 @@ export default function ConnectStoreButton({
139
178
  icon: "ic:outline-delete"
140
179
  })
141
180
  })]
142
- }, option.url)), manageable && /*#__PURE__*/_jsx(Divider, {}), manageable && /*#__PURE__*/_jsxs(MenuItem, {
181
+ }, option.url)), /*#__PURE__*/_jsx(Divider, {}), /*#__PURE__*/_jsxs(MenuItem, {
143
182
  onClick: handleOpenAddStore,
144
183
  children: [/*#__PURE__*/_jsx(AddIcon, {
145
184
  font: true
@@ -158,7 +197,8 @@ export default function ConnectStoreButton({
158
197
  onClose: handleCloseAddStore,
159
198
  teamDid: did,
160
199
  storeList: storeList,
161
- scope: "studio"
200
+ scope: "studio",
201
+ onAdd: blockletContext?.actions?.refreshBlocklet
162
202
  }), deleteStore && /*#__PURE__*/_jsx(ConfirmDialog, {
163
203
  displayError: true,
164
204
  title: `${t('common.delete')} ${deleteStore.name}`,
@@ -4,9 +4,11 @@ import { Box, List, Alert, ListItem, ListItemText } from '@mui/material';
4
4
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
5
5
  import LaunchIcon from '@mui/icons-material/Launch';
6
6
  import { blueGrey } from '@mui/material/colors';
7
- import { BLOCKLET_TENANT_MODES } from '@blocklet/constant';
8
7
  import AddStore from '../../../store/add';
9
8
  import StoreItem from '../../../store/item';
9
+ import { useSessionContext } from '../../../contexts/session';
10
+ import { useBlockletContext } from '../../../contexts/blocklet';
11
+ import getStudioStoreList from '../utils/get-studio-store-list';
10
12
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
11
13
  function ConnectStoreList({
12
14
  blocklet,
@@ -26,7 +28,22 @@ function ConnectStoreList({
26
28
  const {
27
29
  t
28
30
  } = useLocaleContext();
29
- const storeList = blocklet?.settings?.storeList || [];
31
+ const {
32
+ actions: {
33
+ refreshBlocklet
34
+ }
35
+ } = useBlockletContext();
36
+ const {
37
+ session
38
+ } = useSessionContext();
39
+ const {
40
+ storeList
41
+ } = getStudioStoreList({
42
+ fromBlocklet: true,
43
+ blocklet,
44
+ componentDid,
45
+ userDid: session?.user?.did
46
+ });
30
47
  const connectedMap = useMemo(() => {
31
48
  if (!connectedStores?.length) {
32
49
  return {};
@@ -74,14 +91,16 @@ function ConnectStoreList({
74
91
  connectedStore: connectedMap[x.id],
75
92
  onPublish: onPublish,
76
93
  onDelete: onDelete,
94
+ scope: x.scope || 'studio',
77
95
  onOpenConnectStore: onOpenConnectStore
78
96
  })
79
97
  })
80
98
  }, x.url))
81
- }), componentDid && window.blocklet?.tenantMode === BLOCKLET_TENANT_MODES.MULTIPLE ? null : /*#__PURE__*/_jsx(AddStore, {
99
+ }), /*#__PURE__*/_jsx(AddStore, {
82
100
  teamDid: did,
83
101
  storeList: storeList,
84
- scope: "studio"
102
+ scope: "studio",
103
+ onAdd: refreshBlocklet
85
104
  })]
86
105
  });
87
106
  }
@@ -165,7 +165,7 @@ function Header({
165
165
  Toast.error(err?.response?.data?.error?.message || err.message);
166
166
  setLoading(false);
167
167
  setParamsErrTip({
168
- resources: 'Invalid save the resource'
168
+ blockletResource: 'Invalid save the resource'
169
169
  });
170
170
  return;
171
171
  }
@@ -218,7 +218,7 @@ function Header({
218
218
  }).catch(err => {
219
219
  const msg = formatError(err);
220
220
  Toast.error(msg);
221
- if (/resource.*empty/.test(msg)) {
221
+ if (/resource/.test(msg) || /zip/.test(msg)) {
222
222
  setParamsErrTip({
223
223
  blockletResource: msg
224
224
  });
@@ -132,7 +132,7 @@ export default function CreateRelease({
132
132
  const setSelectedResourceIds = useCallback((...args) => {
133
133
  _setSelectedResourceIds(...args);
134
134
  setParamsErrTip({
135
- blockletResources: ''
135
+ blockletResource: ''
136
136
  });
137
137
  // eslint-disable-next-line react-hooks/exhaustive-deps
138
138
  }, []);
@@ -521,7 +521,9 @@ export default function CreateRelease({
521
521
  readOnly: readOnly,
522
522
  projectId: projectId === UNOWNED_DID ? '' : projectId,
523
523
  params: params,
524
- setParams: setParams
524
+ error: paramsErrTip.blockletResource,
525
+ setParams: setParams,
526
+ setParamsErrTip: setParamsErrTip
525
527
  })]
526
528
  })
527
529
  })
@@ -29,7 +29,7 @@ export default function ReleaseStepper({
29
29
  return paramsErrTip?.blockletTitle || paramsErrTip?.projectId || paramsErrTip?.blockletDescription;
30
30
  }
31
31
  if (step === 2) {
32
- return paramsErrTip?.blockletResources;
32
+ return paramsErrTip?.blockletResource;
33
33
  }
34
34
  if (step >= 4) {
35
35
  return paramsErrTip?.blockletVersion || paramsErrTip?.note;
@@ -156,6 +156,6 @@ ReleaseStepper.propTypes = {
156
156
  blockletTitle: PropTypes.string,
157
157
  blockletDescription: PropTypes.string,
158
158
  note: PropTypes.string,
159
- blockletResources: PropTypes.string
159
+ blockletResource: PropTypes.string
160
160
  }).isRequired
161
161
  };
@@ -18,7 +18,9 @@ export default function ResourceUpload({
18
18
  projectId,
19
19
  readOnly,
20
20
  params,
21
- setParams
21
+ setParams,
22
+ setParamsErrTip,
23
+ error
22
24
  }) {
23
25
  const {
24
26
  t
@@ -74,6 +76,9 @@ export default function ResourceUpload({
74
76
  setParams({
75
77
  uploadedResource: result.data.filename
76
78
  });
79
+ setParamsErrTip({
80
+ blockletResource: ''
81
+ });
77
82
  uploaderRef.current?.close();
78
83
  },
79
84
  plugins: ['ImageEditor'],
@@ -92,6 +97,11 @@ export default function ResourceUpload({
92
97
  }
93
98
  }
94
99
  }, "uploader-resource")
100
+ }), !!error && /*#__PURE__*/_jsx(Box, {
101
+ color: "error.main",
102
+ mt: 1,
103
+ fontSize: 14,
104
+ children: error
95
105
  })]
96
106
  });
97
107
  }
@@ -100,6 +110,8 @@ ResourceUpload.propTypes = {
100
110
  projectId: PropTypes.string.isRequired,
101
111
  readOnly: PropTypes.bool.isRequired,
102
112
  params: PropTypes.object.isRequired,
103
- setParams: PropTypes.func.isRequired
113
+ setParams: PropTypes.func.isRequired,
114
+ error: PropTypes.string.isRequired,
115
+ setParamsErrTip: PropTypes.func.isRequired
104
116
  };
105
117
  ResourceUpload.defaultProps = {};
@@ -140,7 +140,10 @@ export default function Tree({
140
140
  }), /*#__PURE__*/_jsx(Box, {
141
141
  className: "name",
142
142
  children: node.name
143
- }), node.url && /*#__PURE__*/_jsx("a", {
143
+ }), node.url &&
144
+ /*#__PURE__*/
145
+ // eslint-disable-next-line jsx-a11y/control-has-associated-label
146
+ _jsx("a", {
144
147
  href: node.url,
145
148
  target: "_blank",
146
149
  rel: "noreferrer",
@@ -1,8 +1,12 @@
1
1
  import { BLOCKLET_STORE } from '@abtnode/constant';
2
2
  import { useCallback, useMemo, useState } from 'react';
3
+ import { useSessionContext } from '../../../contexts/session';
3
4
  const LOCAL_STORAGE_KEY = 'lastWantToConnectStoreId';
4
5
  function useWantToConnectStore(blocklet) {
5
6
  const [_wantToConnectStore, _setWantToConnectStore] = useState(null);
7
+ const {
8
+ session
9
+ } = useSessionContext();
6
10
  const setWantToConnectStore = useCallback(x => {
7
11
  _setWantToConnectStore(x);
8
12
  localStorage.setItem(LOCAL_STORAGE_KEY, x?.id);
@@ -13,8 +17,16 @@ function useWantToConnectStore(blocklet) {
13
17
  if (lastStore) {
14
18
  return lastStore;
15
19
  }
16
- return (blocklet?.settings?.storeList || []).find(x => x.id === BLOCKLET_STORE.id);
17
- }, [blocklet?.settings?.storeList]);
20
+ return (blocklet?.settings?.storeList || []).find(x => {
21
+ if (x.id !== BLOCKLET_STORE.id) {
22
+ return false;
23
+ }
24
+ if (x.scope && x.scope !== 'studio' && x.scope !== session?.user?.did) {
25
+ return false;
26
+ }
27
+ return true;
28
+ });
29
+ }, [blocklet?.settings?.storeList, session?.user?.did]);
18
30
  const wantToConnectStore = _wantToConnectStore || baseStore;
19
31
  return [wantToConnectStore, setWantToConnectStore];
20
32
  }
@@ -0,0 +1,18 @@
1
+ import { BLOCKLET_TENANT_MODES } from '@blocklet/constant';
2
+ const canDeleteStore = ({
3
+ store,
4
+ userDid
5
+ }) => {
6
+ const singleTenant = !(window.blocklet?.tenantMode === BLOCKLET_TENANT_MODES.MULTIPLE);
7
+ if (store.protected) {
8
+ return false;
9
+ }
10
+ if (store.scope && store.scope === userDid) {
11
+ return true;
12
+ }
13
+ if (singleTenant) {
14
+ return store.scope === 'studio';
15
+ }
16
+ return false;
17
+ };
18
+ export default canDeleteStore;
@@ -0,0 +1,15 @@
1
+ const getStudioStoreList = ({
2
+ fromBlocklet,
3
+ nodeInfo,
4
+ blocklet,
5
+ userDid
6
+ }) => {
7
+ const teamDid = fromBlocklet ? blocklet?.meta?.did : nodeInfo?.did;
8
+ let storeList = fromBlocklet ? blocklet?.settings?.storeList || [] : nodeInfo?.blockletRegistryList || [];
9
+ storeList = storeList.filter(x => x.protected || !x.scope || x.scope === 'studio' || x.scope === userDid);
10
+ return {
11
+ teamDid,
12
+ storeList
13
+ };
14
+ };
15
+ export default getStudioStoreList;
@@ -23,7 +23,7 @@ export const validateParams = ({
23
23
  }
24
24
  if (!params.uploadedResource && !hasSelectedResources) {
25
25
  errors.push({
26
- param: 'blockletResources',
26
+ param: 'blockletResource',
27
27
  message: t('blocklet.publish.errorTip.noResource')
28
28
  });
29
29
  }
@@ -7,8 +7,9 @@ import TextField from '@mui/material/TextField';
7
7
  import Alert from '@mui/material/Alert';
8
8
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
9
9
  import ClickToCopy from './click-to-copy';
10
+ import ShortenLabel from './blocklet/component/shorten-label';
10
11
  import Confirm from './confirm';
11
- import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
12
13
  export default function CancelConfirm({
13
14
  title,
14
15
  description,
@@ -25,7 +26,13 @@ export default function CancelConfirm({
25
26
  } = useLocaleContext();
26
27
  const confirmSetting = {
27
28
  title: () => /*#__PURE__*/_jsxs("div", {
28
- children: [title, ` (${keyName})`]
29
+ children: [title, /*#__PURE__*/_jsx(ShortenLabel, {
30
+ sx: {
31
+ fontSize: '14px'
32
+ },
33
+ maxLength: 64,
34
+ children: ` (${keyName})`
35
+ })]
29
36
  }),
30
37
  description: (params, setParams) => {
31
38
  const setValue = value => {
package/lib/locales/en.js CHANGED
@@ -1503,7 +1503,7 @@ export default {
1503
1503
  installedButStopped: 'The app is installed successfully, but cannot be started. You can start it manually after resolving blocking issues',
1504
1504
  installedButError: 'The app is successfully installed, but failed to start',
1505
1505
  restoreFailed: 'Failed to restore app, please try again',
1506
- resourceBlocklet: ''
1506
+ resourceBlocklet: 'This blocklet cannot be launched directly, but you can add it into existing application.'
1507
1507
  },
1508
1508
  steps: {
1509
1509
  introduction: 'Introduction',
package/lib/store/add.js CHANGED
@@ -48,12 +48,8 @@ export default function AddStore({
48
48
  setLoading(true);
49
49
  try {
50
50
  const {
51
- isNew,
52
51
  decoded
53
52
  } = isNewStoreUrl(url, storeList);
54
- if (!isNew) {
55
- throw new Error(t('store.blockletRegistry.haveSameRegistry'));
56
- }
57
53
  await api.addBlockletStore({
58
54
  input: {
59
55
  teamDid,
@@ -9,6 +9,8 @@ import DeleteOutlineIcon from '@mui/icons-material/DeleteOutline';
9
9
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
10
10
  import ConfirmDialog from '../confirm';
11
11
  import DeleteStore from './delete';
12
+ import canDeleteStore from '../blocklet/publish/utils/can-delete-store';
13
+ import { useSessionContext } from '../contexts/session';
12
14
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
13
15
  function ConnectActions({
14
16
  connected,
@@ -23,6 +25,9 @@ function ConnectActions({
23
25
  const {
24
26
  t
25
27
  } = useLocaleContext();
28
+ const {
29
+ session
30
+ } = useSessionContext();
26
31
  const [showDisconnectConfirm, setShowDisconnectConfirm] = useState(false);
27
32
  const handleOpenUrl = e => {
28
33
  e.stopPropagation();
@@ -93,11 +98,15 @@ function ConnectActions({
93
98
  children: x.label
94
99
  })]
95
100
  }, x.label);
96
- }), !store.protected && /*#__PURE__*/_jsx(DeleteStore, {
101
+ }), canDeleteStore({
102
+ store,
103
+ userDid: session?.user?.did
104
+ }) && /*#__PURE__*/_jsx(DeleteStore, {
97
105
  store: store,
98
106
  onDelete: onDelete,
99
107
  teamDid: teamDid,
100
108
  projectId: projectId,
109
+ scope: store.scope || 'studio',
101
110
  children: /*#__PURE__*/_jsxs(MenuItem, {
102
111
  dense: true,
103
112
  disabled: store.protected,
@@ -8,13 +8,15 @@ import { Button } from '@mui/material';
8
8
  import { useNodeContext } from '../contexts/node';
9
9
  import DelConfirm from '../delete-confirm';
10
10
  import { formatError } from '../util';
11
+ import { useBlockletContext } from '../contexts/blocklet';
11
12
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
12
13
  export default function DeleteStore({
13
14
  store,
14
15
  teamDid,
15
16
  onDelete,
16
17
  children,
17
- projectId = ''
18
+ projectId = '',
19
+ scope = ''
18
20
  }) {
19
21
  const {
20
22
  api
@@ -22,6 +24,7 @@ export default function DeleteStore({
22
24
  const {
23
25
  t
24
26
  } = useLocaleContext();
27
+ const blockletContext = useBlockletContext();
25
28
  const [loading, setLoading] = useState(false);
26
29
  const [confirmSetting, setConfirmSetting] = useState(null);
27
30
  const theme = useTheme();
@@ -36,9 +39,11 @@ export default function DeleteStore({
36
39
  input: {
37
40
  teamDid,
38
41
  url: store.url,
39
- projectId
42
+ projectId,
43
+ scope
40
44
  }
41
45
  });
46
+ await blockletContext?.actions.refreshBlocklet();
42
47
  if (onDelete && typeof onDelete === 'function') {
43
48
  onDelete();
44
49
  }
@@ -103,10 +108,12 @@ DeleteStore.propTypes = {
103
108
  teamDid: PropTypes.string.isRequired,
104
109
  store: PropTypes.object.isRequired,
105
110
  onDelete: PropTypes.func,
106
- projectId: PropTypes.string
111
+ projectId: PropTypes.string,
112
+ scope: PropTypes.string
107
113
  };
108
114
  DeleteStore.defaultProps = {
109
115
  children: null,
110
116
  projectId: '',
117
+ scope: '',
111
118
  onDelete: () => {}
112
119
  };
package/lib/store/item.js CHANGED
@@ -104,7 +104,8 @@ export default function StoreItem({
104
104
  onPublish,
105
105
  onOpenConnectStore,
106
106
  onSelectConnectStore,
107
- behavior
107
+ behavior,
108
+ scope = ''
108
109
  }) {
109
110
  const classes = useStyles();
110
111
  const {
@@ -164,14 +165,19 @@ export default function StoreItem({
164
165
  });
165
166
  };
166
167
  const handleDisconnectStore = async () => {
167
- await api.disconnectFromStore({
168
- input: {
169
- did: teamDid,
170
- storeId: store.id,
171
- projectId
172
- }
173
- });
174
- onDelete();
168
+ try {
169
+ await api.disconnectFromStore({
170
+ input: {
171
+ did: teamDid,
172
+ storeId: store.id,
173
+ projectId,
174
+ storeScope: scope
175
+ }
176
+ });
177
+ onDelete();
178
+ } catch (err) {
179
+ Toast.error(formatError(err));
180
+ }
175
181
  };
176
182
  const handleUploadToStore = () => {
177
183
  setLoading(true);
@@ -341,7 +347,8 @@ export default function StoreItem({
341
347
  }), !store.protected && /*#__PURE__*/_jsx(DeleteStore, {
342
348
  store: store,
343
349
  onDelete: onDelete,
344
- teamDid: teamDid
350
+ teamDid: teamDid,
351
+ scope: ""
345
352
  })]
346
353
  })]
347
354
  })]
@@ -367,6 +374,7 @@ StoreItem.propTypes = {
367
374
  protected: PropTypes.bool,
368
375
  connected: PropTypes.bool
369
376
  }).isRequired,
377
+ scope: PropTypes.string,
370
378
  onDelete: PropTypes.func,
371
379
  onPublish: PropTypes.func,
372
380
  onOpenConnectStore: PropTypes.func,
@@ -380,6 +388,7 @@ StoreItem.defaultProps = {
380
388
  releaseId: '',
381
389
  projectId: '',
382
390
  releaseType: '',
391
+ scope: '',
383
392
  behavior: BEHAVIOR.CONNECT,
384
393
  onPublish: () => {},
385
394
  onDelete: () => {},
@@ -141,7 +141,8 @@ export default function MemberList({
141
141
  }
142
142
  });
143
143
  const {
144
- appIdList = []
144
+ appIdList = [],
145
+ blocklet
145
146
  } = useBlockletContext();
146
147
  const {
147
148
  teamDid,
@@ -151,8 +152,7 @@ export default function MemberList({
151
152
  refresh,
152
153
  enablePassportIssuance,
153
154
  endpoint,
154
- api,
155
- blocklet
155
+ api
156
156
  } = useTeamContext();
157
157
  const {
158
158
  inService,
@@ -161,30 +161,30 @@ export default function MemberList({
161
161
  }
162
162
  } = useNodeContext();
163
163
  const appInfoList = [];
164
- if (inService && blocklet) {
164
+ if (blocklet) {
165
165
  const federatedMaster = (blocklet.settings?.federated?.sites || []).find(item => item.isMaster !== false);
166
166
  const federatedCurrent = (blocklet.settings?.federated?.sites || []).find(item => item.appId === blocklet.appDid);
167
167
  if (federatedCurrent?.status === 'approved') {
168
168
  appInfoList.push({
169
- appId: federatedMaster.appId,
170
- appName: federatedMaster.appName,
171
- appDescription: federatedMaster.appDescription,
172
- appLogo: federatedMaster.appLogo,
173
- appPid: federatedMaster.appPid,
174
- appUrl: federatedMaster.appUrl,
175
- version: federatedMaster.version,
176
- sourceAppPid: federatedMaster.appPid,
169
+ appId: federatedMaster?.appId,
170
+ appName: federatedMaster?.appName,
171
+ appDescription: federatedMaster?.appDescription,
172
+ appLogo: federatedMaster?.appLogo,
173
+ appPid: federatedMaster?.appPid,
174
+ appUrl: federatedMaster?.appUrl,
175
+ version: federatedMaster?.version,
176
+ sourceAppPid: federatedMaster?.appPid,
177
177
  provider: 'wallet'
178
178
  });
179
179
  }
180
180
  appInfoList.push({
181
- appId: federatedCurrent.appId,
182
- appName: federatedCurrent.appName,
183
- appDescription: federatedCurrent.appDescription,
184
- appLogo: federatedCurrent.appLogo,
185
- appPid: federatedCurrent.appPid,
186
- appUrl: federatedCurrent.appUrl,
187
- version: federatedCurrent.version,
181
+ appId: federatedCurrent?.appId,
182
+ appName: federatedCurrent?.appName,
183
+ appDescription: federatedCurrent?.appDescription,
184
+ appLogo: federatedCurrent?.appLogo,
185
+ appPid: federatedCurrent?.appPid,
186
+ appUrl: federatedCurrent?.appUrl,
187
+ version: federatedCurrent?.version,
188
188
  // NOTICE: null 代表该值置空
189
189
  sourceAppPid: null,
190
190
  provider: 'wallet'
package/lib/util/index.js CHANGED
@@ -18,6 +18,7 @@ import { evaluateURLs } from '@abtnode/util/lib/url-evaluation';
18
18
  import checkAccessible from '@abtnode/util/lib/url-evaluation/check-accessible-browser';
19
19
  import { BLOCKLET_MODES } from '@blocklet/constant';
20
20
  import urlPathFriendly from '@blocklet/meta/lib/url-path-friendly';
21
+ const STORE_LOGO_FILTER = 'imageFilter=convert&f=png&h=80';
21
22
  export { formatError };
22
23
  export function filesize(size, options = {}) {
23
24
  return _filesize(size, {
@@ -300,17 +301,11 @@ export const getIssuePassportLink = ({
300
301
  u.searchParams.set('id', id);
301
302
  return u.href;
302
303
  };
303
- export const formatRegistryScreenshotPath = (did, asset) => {
304
- if (asset.startsWith('/assets')) {
305
- return asset;
306
- }
307
- return `/assets/${did}/screenshots/${asset}`;
308
- };
309
304
  export const formatRegistryLogoPath = (did, asset, version = '') => {
310
305
  if (asset.startsWith('/assets')) {
311
306
  return asset;
312
307
  }
313
- return version ? `/assets/${did}/${asset}?v=${version}` : `/assets/${did}/${asset}`;
308
+ return version ? `/assets/${did}/${asset}?v=${version}&${STORE_LOGO_FILTER}` : `/assets/${did}/${asset}?${STORE_LOGO_FILTER}`;
314
309
  };
315
310
  export function getWebWalletUrl(info) {
316
311
  try {
@@ -373,7 +368,7 @@ export const getBlockletLogoUrl = ({
373
368
  if (apiPrefix) {
374
369
  apiPrefix = `/${apiPrefix}`;
375
370
  }
376
- return joinURL(apiPrefix, version ? `/blocklet/logo/${did}?v=${version}` : `/blocklet/logo/${did}`);
371
+ return joinURL(apiPrefix, version ? `/blocklet/logo/${did}?v=${version}&${STORE_LOGO_FILTER}` : `/blocklet/logo/${did}?${STORE_LOGO_FILTER}`);
377
372
  };
378
373
  export const getPathPrefix = () => window.env && window.env.apiPrefix ? window.env.apiPrefix : '/';
379
374
  export const isUrlAccessible = url => checkAccessible(joinURL(new URL(url).origin, WELLKNOWN_PING_PREFIX));
@@ -595,7 +590,7 @@ export const getStoreList = ({
595
590
  const storeList = fromBlocklet ? blocklet?.settings?.storeList || [] : nodeInfo?.blockletRegistryList || [];
596
591
  return {
597
592
  teamDid,
598
- storeList: storeList.filter(x => !x.scope || x.scope !== 'studio')
593
+ storeList: storeList.filter(x => x.protected || !x.scope)
599
594
  };
600
595
  };
601
596
  const isDidDomainOrIpEchoDomain = domain => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abtnode/ux",
3
- "version": "1.16.29-beta-88bdefe8",
3
+ "version": "1.16.29-beta-a076832b",
4
4
  "description": "UX components shared across abtnode packages",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -25,25 +25,25 @@
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-88bdefe8",
29
- "@abtnode/constant": "1.16.29-beta-88bdefe8",
30
- "@abtnode/util": "1.16.29-beta-88bdefe8",
28
+ "@abtnode/auth": "1.16.29-beta-a076832b",
29
+ "@abtnode/constant": "1.16.29-beta-a076832b",
30
+ "@abtnode/util": "1.16.29-beta-a076832b",
31
31
  "@ahooksjs/use-url-state": "^3.5.1",
32
- "@arcblock/did": "^1.18.123",
33
- "@arcblock/did-connect": "^2.10.0",
32
+ "@arcblock/did": "^1.18.124",
33
+ "@arcblock/did-connect": "^2.10.2",
34
34
  "@arcblock/did-motif": "^1.1.13",
35
- "@arcblock/icons": "^2.10.0",
36
- "@arcblock/nft-display": "2.10.0",
37
- "@arcblock/react-hooks": "^2.10.0",
38
- "@arcblock/terminal": "^2.10.0",
39
- "@arcblock/ux": "^2.10.0",
40
- "@blocklet/constant": "1.16.29-beta-88bdefe8",
41
- "@blocklet/js-sdk": "1.16.29-beta-88bdefe8",
42
- "@blocklet/launcher-layout": "2.3.22",
43
- "@blocklet/list": "^0.12.114",
44
- "@blocklet/meta": "1.16.29-beta-88bdefe8",
45
- "@blocklet/ui-react": "^2.10.0",
46
- "@blocklet/uploader": "^0.1.13",
35
+ "@arcblock/icons": "^2.10.2",
36
+ "@arcblock/nft-display": "2.10.2",
37
+ "@arcblock/react-hooks": "^2.10.2",
38
+ "@arcblock/terminal": "^2.10.2",
39
+ "@arcblock/ux": "^2.10.2",
40
+ "@blocklet/constant": "1.16.29-beta-a076832b",
41
+ "@blocklet/js-sdk": "1.16.29-beta-a076832b",
42
+ "@blocklet/launcher-layout": "2.3.24",
43
+ "@blocklet/list": "^0.13.4",
44
+ "@blocklet/meta": "1.16.29-beta-a076832b",
45
+ "@blocklet/ui-react": "^2.10.2",
46
+ "@blocklet/uploader": "^0.1.16",
47
47
  "@emotion/react": "^11.10.4",
48
48
  "@emotion/styled": "^11.10.4",
49
49
  "@iconify-icons/logos": "^1.2.36",
@@ -56,7 +56,7 @@
56
56
  "@mui/styles": "^5.15.11",
57
57
  "@mui/x-date-pickers": "^6.19.0",
58
58
  "@mui/x-tree-view": "^6.17.0",
59
- "@ocap/client": "1.18.123",
59
+ "@ocap/client": "1.18.124",
60
60
  "@uiw/react-markdown-preview": "^5.1.1",
61
61
  "ahooks": "^3.7.8",
62
62
  "axios": "^1.7.2",
@@ -108,5 +108,5 @@
108
108
  "jest": "^29.7.0",
109
109
  "jest-environment-jsdom": "^29.7.0"
110
110
  },
111
- "gitHead": "2a91288d21c8defe019e1debfc242b6ef708573e"
111
+ "gitHead": "aa0791bd43f8c7068b24bc426ce0f0e4d8a3f583"
112
112
  }