@abtnode/ux 1.16.28-beta-8acda0e6 → 1.16.28-beta-6917161a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/actions.js +8 -6
- package/lib/blocklet/component/add-component/add-component-core.js +3 -2
- package/lib/blocklet/component/component-cell-mount-poin.js +164 -0
- package/lib/blocklet/component/component-cell.js +83 -84
- package/lib/blocklet/component/configuration.js +52 -36
- package/lib/blocklet/component/index.js +29 -38
- package/lib/blocklet/publish/create-release/header.js +36 -31
- package/lib/blocklet/publish/create-release/index.js +54 -21
- package/lib/blocklet/publish/create-release/release-stepper.js +4 -4
- package/lib/blocklet/publish/create-release/{resources.js → resource-select.js} +4 -4
- package/lib/blocklet/publish/create-release/resource-upload.js +105 -0
- package/lib/blocklet/publish/project-list.js +6 -0
- package/lib/blocklet/publish/utils/validate-params.js +4 -4
- package/lib/blocklet/router/action/add-rule.js +31 -18
- package/lib/blocklet/router/rule-actions.js +8 -1
- package/lib/locales/ar.js +12 -5
- package/lib/locales/de.js +11 -4
- package/lib/locales/en.js +7 -4
- package/lib/locales/es.js +11 -4
- package/lib/locales/fr.js +11 -4
- package/lib/locales/hi.js +11 -4
- package/lib/locales/i18n.db +0 -0
- package/lib/locales/id.js +11 -4
- package/lib/locales/ja.js +11 -4
- package/lib/locales/ko.js +11 -4
- package/lib/locales/pt.js +11 -4
- package/lib/locales/ru.js +11 -4
- package/lib/locales/th.js +11 -4
- package/lib/locales/vi.js +11 -4
- package/lib/locales/zh-tw.js +11 -4
- package/lib/locales/zh.js +7 -4
- package/package.json +7 -7
|
@@ -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(
|
|
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
|
-
}),
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
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
|
}
|
|
@@ -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 './
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
return
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
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('
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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: [
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
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
|
})
|
|
@@ -8,7 +8,7 @@ export default function ReleaseStepper({
|
|
|
8
8
|
steps,
|
|
9
9
|
activeStep,
|
|
10
10
|
setActiveStep,
|
|
11
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
152
|
+
hasSelectedResources: PropTypes.bool.isRequired,
|
|
153
153
|
paramsErrTip: PropTypes.shape({
|
|
154
154
|
projectId: PropTypes.string,
|
|
155
155
|
blockletVersion: PropTypes.string,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import styled from '@emotion/styled';
|
|
2
2
|
import classnames from 'classnames';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
|
-
import { useEffect, useRef } from 'react';
|
|
4
|
+
import React, { useEffect, useRef } from 'react';
|
|
5
5
|
import useSetState from 'react-use/lib/useSetState';
|
|
6
6
|
import { joinURL } from 'ufo';
|
|
7
7
|
import { Box } from '@mui/material';
|
|
@@ -90,7 +90,7 @@ const getNodeIdDependencies = (node, nodeIds) => {
|
|
|
90
90
|
};
|
|
91
91
|
return getDependencies(node, {});
|
|
92
92
|
};
|
|
93
|
-
export default function
|
|
93
|
+
export default function ResourceSelect({
|
|
94
94
|
app,
|
|
95
95
|
component,
|
|
96
96
|
projectId,
|
|
@@ -257,7 +257,7 @@ export default function Resources({
|
|
|
257
257
|
})]
|
|
258
258
|
});
|
|
259
259
|
}
|
|
260
|
-
|
|
260
|
+
ResourceSelect.propTypes = {
|
|
261
261
|
component: PropTypes.object.isRequired,
|
|
262
262
|
app: PropTypes.object.isRequired,
|
|
263
263
|
projectId: PropTypes.string.isRequired,
|
|
@@ -276,7 +276,7 @@ Resources.propTypes = {
|
|
|
276
276
|
selectedResourceIds: PropTypes.array.isRequired,
|
|
277
277
|
setSelectedResourceIds: PropTypes.func.isRequired
|
|
278
278
|
};
|
|
279
|
-
|
|
279
|
+
ResourceSelect.defaultProps = {
|
|
280
280
|
error: '',
|
|
281
281
|
release: {
|
|
282
282
|
id: ''
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import { UNOWNED_DID, WELLKNOWN_SERVICE_PATH_PREFIX } from '@abtnode/constant';
|
|
3
|
+
import React, { Suspense, useRef, lazy } from 'react';
|
|
4
|
+
import { Stack, Box, Button, Typography } from '@mui/material';
|
|
5
|
+
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
6
|
+
import Toast from '@arcblock/ux/lib/Toast/index';
|
|
7
|
+
import EmptySpinner from '../../../empty-spinner';
|
|
8
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
+
const allowedFileTypes = ['.zip', '.gz'];
|
|
10
|
+
const maxFileSize = 1024 * 1024 * 100; // 100 MB
|
|
11
|
+
|
|
12
|
+
// eslint-disable-next-line import/no-unresolved
|
|
13
|
+
const UploaderComponent = /*#__PURE__*/lazy(() => import('@blocklet/uploader/react').then(res => ({
|
|
14
|
+
default: res.Uploader
|
|
15
|
+
})));
|
|
16
|
+
export default function ResourceUpload({
|
|
17
|
+
app,
|
|
18
|
+
projectId,
|
|
19
|
+
readOnly,
|
|
20
|
+
params,
|
|
21
|
+
setParams
|
|
22
|
+
}) {
|
|
23
|
+
const {
|
|
24
|
+
t
|
|
25
|
+
} = useLocaleContext();
|
|
26
|
+
const uploaderRef = useRef(null);
|
|
27
|
+
const checkCanUpload = () => {
|
|
28
|
+
if (readOnly) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
if (!projectId || projectId === UNOWNED_DID) {
|
|
32
|
+
Toast.error(t('blocklet.publish.errorTip.noFirstDid'));
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
return true;
|
|
36
|
+
};
|
|
37
|
+
const uploadPrefix = `${WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${app.meta.did}/${projectId}/resource/upload`;
|
|
38
|
+
return /*#__PURE__*/_jsxs(Box, {
|
|
39
|
+
sx: {
|
|
40
|
+
mt: 3
|
|
41
|
+
},
|
|
42
|
+
children: [/*#__PURE__*/_jsx(Typography, {
|
|
43
|
+
gutterBottom: true,
|
|
44
|
+
children: t('blocklet.publish.resourceUpload')
|
|
45
|
+
}), /*#__PURE__*/_jsxs(Stack, {
|
|
46
|
+
direction: "row",
|
|
47
|
+
alignItems: "center",
|
|
48
|
+
spacing: 1,
|
|
49
|
+
sx: {
|
|
50
|
+
flex: 1,
|
|
51
|
+
cursor: readOnly ? 'default' : 'pointer'
|
|
52
|
+
},
|
|
53
|
+
children: [!!params.uploadedResource && /*#__PURE__*/_jsx(Typography, {
|
|
54
|
+
component: "a",
|
|
55
|
+
href: `${uploadPrefix}/params.uploadedResource`,
|
|
56
|
+
children: params.uploadedResource
|
|
57
|
+
}), !readOnly && /*#__PURE__*/_jsx(Button, {
|
|
58
|
+
variant: "outlined",
|
|
59
|
+
size: "small",
|
|
60
|
+
onClick: () => {
|
|
61
|
+
if (!checkCanUpload()) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
uploaderRef.current?.open();
|
|
65
|
+
},
|
|
66
|
+
children: params.uploadedResource ? t('common.change') : t('common.upload')
|
|
67
|
+
})]
|
|
68
|
+
}), /*#__PURE__*/_jsx(Suspense, {
|
|
69
|
+
fallback: /*#__PURE__*/_jsx(EmptySpinner, {}),
|
|
70
|
+
children: /*#__PURE__*/_jsx(UploaderComponent, {
|
|
71
|
+
ref: uploaderRef,
|
|
72
|
+
popup: true,
|
|
73
|
+
onUploadFinish: result => {
|
|
74
|
+
setParams({
|
|
75
|
+
uploadedResource: result.data.filename
|
|
76
|
+
});
|
|
77
|
+
uploaderRef.current?.close();
|
|
78
|
+
},
|
|
79
|
+
plugins: ['ImageEditor'],
|
|
80
|
+
installerProps: {
|
|
81
|
+
disabled: true
|
|
82
|
+
},
|
|
83
|
+
apiPathProps: {
|
|
84
|
+
uploader: uploadPrefix,
|
|
85
|
+
disableMediaKitPrefix: true
|
|
86
|
+
},
|
|
87
|
+
coreProps: {
|
|
88
|
+
restrictions: {
|
|
89
|
+
allowedFileTypes,
|
|
90
|
+
maxFileSize,
|
|
91
|
+
maxNumberOfFiles: 1
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}, "uploader-resource")
|
|
95
|
+
})]
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
ResourceUpload.propTypes = {
|
|
99
|
+
app: PropTypes.object.isRequired,
|
|
100
|
+
projectId: PropTypes.string.isRequired,
|
|
101
|
+
readOnly: PropTypes.bool.isRequired,
|
|
102
|
+
params: PropTypes.object.isRequired,
|
|
103
|
+
setParams: PropTypes.func.isRequired
|
|
104
|
+
};
|
|
105
|
+
ResourceUpload.defaultProps = {};
|
|
@@ -182,6 +182,9 @@ export default function ProjectList({
|
|
|
182
182
|
name: 'blockletDid',
|
|
183
183
|
options: {
|
|
184
184
|
customBodyRender: did => {
|
|
185
|
+
if (!did) {
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
185
188
|
return /*#__PURE__*/_jsx(DidAddress, {
|
|
186
189
|
size: 14,
|
|
187
190
|
compact: true,
|
|
@@ -195,6 +198,9 @@ export default function ProjectList({
|
|
|
195
198
|
name: 'createdBy',
|
|
196
199
|
options: {
|
|
197
200
|
customBodyRender: did => {
|
|
201
|
+
if (!did) {
|
|
202
|
+
return null;
|
|
203
|
+
}
|
|
198
204
|
return /*#__PURE__*/_jsx(DidAddress, {
|
|
199
205
|
onClick: () => {
|
|
200
206
|
navigate(`/.well-known/service/admin/members?did=${did}`);
|
|
@@ -3,7 +3,7 @@ import { UNOWNED_DID } from '@abtnode/constant';
|
|
|
3
3
|
import semver from 'semver';
|
|
4
4
|
export const validateParams = ({
|
|
5
5
|
params,
|
|
6
|
-
|
|
6
|
+
hasSelectedResources,
|
|
7
7
|
projectId,
|
|
8
8
|
status,
|
|
9
9
|
t
|
|
@@ -21,7 +21,7 @@ export const validateParams = ({
|
|
|
21
21
|
message: t('blocklet.publish.errorTip.noDid')
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
|
-
if (!
|
|
24
|
+
if (!params.uploadedResource && !hasSelectedResources) {
|
|
25
25
|
errors.push({
|
|
26
26
|
param: 'blockletResources',
|
|
27
27
|
message: t('blocklet.publish.errorTip.noResource')
|
|
@@ -56,7 +56,7 @@ export const validateParams = ({
|
|
|
56
56
|
};
|
|
57
57
|
export const validateParamsStep = ({
|
|
58
58
|
params,
|
|
59
|
-
|
|
59
|
+
hasSelectedResources,
|
|
60
60
|
step,
|
|
61
61
|
t,
|
|
62
62
|
projectId
|
|
@@ -73,7 +73,7 @@ export const validateParamsStep = ({
|
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
if (step === 2) {
|
|
76
|
-
if (!
|
|
76
|
+
if (!params.uploadedResource && !hasSelectedResources) {
|
|
77
77
|
return t('blocklet.publish.errorTip.noResource');
|
|
78
78
|
}
|
|
79
79
|
}
|