@abtnode/ux 1.16.30-beta-b7f31b10 → 1.16.30-beta-2876881d
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/blocklet/actions.js +5 -51
- package/lib/blocklet/{storage/auto-check-update.js → auto-check-update.js} +17 -5
- package/lib/blocklet/component/index.js +28 -31
- package/lib/blocklet/icons.js +3 -1
- package/lib/blocklet/notification/push-kit.js +24 -20
- package/lib/blocklet/publish/create-release/connect-store-button.js +1 -1
- package/lib/blocklet/publish/create-release/header.js +57 -105
- package/lib/blocklet/publish/create-release/install-button.js +140 -0
- package/lib/blocklet/storage/auto-backup.js +1 -1
- package/lib/contexts/blocklet-storage.js +1 -9
- package/lib/locales/ar.js +4 -3
- package/lib/locales/de.js +4 -3
- package/lib/locales/en.js +1 -0
- package/lib/locales/es.js +4 -3
- package/lib/locales/fr.js +4 -3
- package/lib/locales/hi.js +4 -3
- package/lib/locales/i18n.db +0 -0
- package/lib/locales/id.js +4 -3
- package/lib/locales/ja.js +4 -3
- package/lib/locales/ko.js +4 -3
- package/lib/locales/pt.js +4 -3
- package/lib/locales/ru.js +4 -3
- package/lib/locales/th.js +4 -3
- package/lib/locales/vi.js +4 -3
- package/lib/locales/zh-tw.js +4 -3
- package/lib/locales/zh.js +4 -3
- package/lib/util/index.js +21 -16
- package/package.json +8 -8
- package/lib/contexts/blocklet-auto-check-update.js +0 -54
- package/lib/hooks/use-auto-backup.js +0 -40
- package/lib/hooks/use-auto-check-update.js +0 -33
package/lib/blocklet/actions.js
CHANGED
|
@@ -28,7 +28,6 @@ import Toast from '@arcblock/ux/lib/Toast';
|
|
|
28
28
|
import Confirm from '../confirm';
|
|
29
29
|
import { useNodeContext } from '../contexts/node';
|
|
30
30
|
import { formatError, isDownloading, sleep } from '../util';
|
|
31
|
-
import joinUrlKeepSearch from '../util/join-url-keep-search';
|
|
32
31
|
import Icons from './icons';
|
|
33
32
|
import { getServerUrl } from './util';
|
|
34
33
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -86,14 +85,6 @@ export default function BlockletActions({
|
|
|
86
85
|
const {
|
|
87
86
|
inService
|
|
88
87
|
} = node;
|
|
89
|
-
const handleOpenDashboard = () => {
|
|
90
|
-
const mountPoint = `/${blocklet.mountPoint || '/'}`.replace(/\/+/g, '/');
|
|
91
|
-
const href = getComponentUrl?.({
|
|
92
|
-
mountPoint,
|
|
93
|
-
blocklet
|
|
94
|
-
});
|
|
95
|
-
window.open(joinUrlKeepSearch(href, '.well-known/service/admin'));
|
|
96
|
-
};
|
|
97
88
|
const createHandler = (action, fn, requireUserConfirm = false) => async () => {
|
|
98
89
|
const onConfirm = async params => {
|
|
99
90
|
onStart({
|
|
@@ -362,52 +353,15 @@ export default function BlockletActions({
|
|
|
362
353
|
}, isDownloading(blocklet.status) ? cancelDownloadAction : removeAction, {
|
|
363
354
|
separator: true
|
|
364
355
|
}, !inService ? {
|
|
365
|
-
action: 'dashboard',
|
|
366
|
-
icon: ({
|
|
367
|
-
style,
|
|
368
|
-
...restProps
|
|
369
|
-
}) => /*#__PURE__*/_jsx(Icons.Dashboard, {
|
|
370
|
-
...restProps,
|
|
371
|
-
style: {
|
|
372
|
-
...style,
|
|
373
|
-
width: '26px',
|
|
374
|
-
height: '26px',
|
|
375
|
-
paddingRight: '3px'
|
|
376
|
-
}
|
|
377
|
-
}),
|
|
378
|
-
name: t('sidebar.dashboard'),
|
|
379
|
-
handler: handleOpenDashboard,
|
|
380
|
-
disabled: disableStart || blocklet.status !== 'running'
|
|
381
|
-
} : null, {
|
|
382
|
-
separator: true
|
|
383
|
-
}, {
|
|
384
|
-
onlyInMenu: true,
|
|
385
|
-
action: 'config',
|
|
386
|
-
icon: Icons.Config,
|
|
387
|
-
name: t('common.config'),
|
|
388
|
-
handler: () => {
|
|
389
|
-
navigate(`/blocklets/${blocklet.meta.did}/configuration`);
|
|
390
|
-
},
|
|
391
|
-
disabled: isDownloading(blocklet.status)
|
|
392
|
-
}, {
|
|
393
|
-
onlyInMenu: true,
|
|
394
|
-
action: 'team',
|
|
395
|
-
icon: Icons.Group,
|
|
396
|
-
name: t('common.manageTeam'),
|
|
397
|
-
handler: () => {
|
|
398
|
-
navigate(`/blocklets/${blocklet.meta.did}/members`);
|
|
399
|
-
},
|
|
400
|
-
disabled: isDownloading(blocklet.status)
|
|
401
|
-
}, {
|
|
402
356
|
onlyInMenu: true,
|
|
403
|
-
action: '
|
|
404
|
-
icon: Icons.
|
|
405
|
-
name: t('common.
|
|
357
|
+
action: 'overview',
|
|
358
|
+
icon: Icons.Overview,
|
|
359
|
+
name: t('common.overview'),
|
|
406
360
|
handler: () => {
|
|
407
|
-
navigate(`/
|
|
361
|
+
navigate(`/blocklets/${blocklet.meta.did}/overview`);
|
|
408
362
|
},
|
|
409
363
|
disabled: isDownloading(blocklet.status)
|
|
410
|
-
}].filter(Boolean);
|
|
364
|
+
} : null].filter(Boolean);
|
|
411
365
|
if (variant === 'menu') {
|
|
412
366
|
return /*#__PURE__*/_jsxs(Div, {
|
|
413
367
|
"data-cy": "blocklet-actions",
|
|
@@ -4,8 +4,9 @@ import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
|
4
4
|
import Toast from '@arcblock/ux/lib/Toast';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import Tooltip from '@mui/material/Tooltip';
|
|
7
|
-
import SwitchControl from '
|
|
8
|
-
import {
|
|
7
|
+
import SwitchControl from './component/switch-control';
|
|
8
|
+
import { useBlockletContext } from '../contexts/blocklet';
|
|
9
|
+
import { useNodeContext } from '../contexts/node';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* @description
|
|
@@ -23,9 +24,20 @@ function AutoCheckUpdate({
|
|
|
23
24
|
t
|
|
24
25
|
} = useLocaleContext();
|
|
25
26
|
const {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
api
|
|
28
|
+
} = useNodeContext();
|
|
29
|
+
const {
|
|
30
|
+
blocklet
|
|
31
|
+
} = useBlockletContext();
|
|
32
|
+
const autoCheckUpdate = blocklet?.settings?.autoCheckUpdate;
|
|
33
|
+
const updateAutoCheckUpdate = async value => {
|
|
34
|
+
await api.updateAutoCheckUpdate({
|
|
35
|
+
input: {
|
|
36
|
+
did: blocklet.meta.did,
|
|
37
|
+
autoCheckUpdate: value
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
};
|
|
29
41
|
const configAutoBackup = async () => {
|
|
30
42
|
try {
|
|
31
43
|
const enabled = !autoCheckUpdate?.enabled;
|
|
@@ -23,7 +23,7 @@ import Empty from '@arcblock/ux/lib/Empty';
|
|
|
23
23
|
import { forEachChildSync, isInProgress } from '@blocklet/meta/lib/util';
|
|
24
24
|
import Toast from '@arcblock/ux/lib/Toast';
|
|
25
25
|
import { useDeletingBlockletContext } from '../../contexts/deleting-blocklets';
|
|
26
|
-
import AutoCheckUpdate from '../
|
|
26
|
+
import AutoCheckUpdate from '../auto-check-update';
|
|
27
27
|
import { useNodeContext } from '../../contexts/node';
|
|
28
28
|
import { formatError, sleep, BlockletAdminRoles } from '../../util';
|
|
29
29
|
import Permission from '../../permission';
|
|
@@ -37,7 +37,6 @@ import ComponentCell, { StyledBadge, StyledComponentRow } from './component-cell
|
|
|
37
37
|
import OptionalComponentCell from './optional-component-cell';
|
|
38
38
|
import AddComponentDialog from './add-component/add-component-dialog';
|
|
39
39
|
import Actions from '../../actions';
|
|
40
|
-
import { BlockletAutoCheckUpdateProvider } from '../../contexts/blocklet-auto-check-update';
|
|
41
40
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
42
41
|
export default function BlockletComponent({
|
|
43
42
|
blocklet,
|
|
@@ -249,35 +248,33 @@ export default function BlockletComponent({
|
|
|
249
248
|
children: [components?.length ? `${t('common.components')} (${components.length})` : `${t('common.components')}`, !needMigration && /*#__PURE__*/_jsx(Permission, {
|
|
250
249
|
permission: inService ? '' : 'mutate_blocklets',
|
|
251
250
|
role: inService ? BlockletAdminRoles : [],
|
|
252
|
-
children: /*#__PURE__*/_jsx(
|
|
253
|
-
children: /*#__PURE__*/_jsx(
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
}), t('blocklet.component.checkUpdateTitle')]
|
|
280
|
-
})
|
|
251
|
+
children: /*#__PURE__*/_jsx(AutoCheckUpdate, {
|
|
252
|
+
children: /*#__PURE__*/_jsx(StyledBadge, {
|
|
253
|
+
top: 1.2,
|
|
254
|
+
right: 0.4,
|
|
255
|
+
color: "error",
|
|
256
|
+
badgeContent: "",
|
|
257
|
+
variant: "dot",
|
|
258
|
+
invisible: !showUpdateDot,
|
|
259
|
+
children: /*#__PURE__*/_jsxs(Button, {
|
|
260
|
+
disabled: loading || isInProgress(blocklet.status),
|
|
261
|
+
color: "secondary",
|
|
262
|
+
onClick: () => {
|
|
263
|
+
checkForUpdates();
|
|
264
|
+
},
|
|
265
|
+
"data-cy": "check-for-updates",
|
|
266
|
+
children: [/*#__PURE__*/_jsx(Box, {
|
|
267
|
+
ml: 0.5,
|
|
268
|
+
mr: 0.5,
|
|
269
|
+
display: "flex",
|
|
270
|
+
children: loading ? /*#__PURE__*/_jsx(Spinner, {
|
|
271
|
+
size: 16
|
|
272
|
+
}) : /*#__PURE__*/_jsx(UpdateIcon, {
|
|
273
|
+
style: {
|
|
274
|
+
fontSize: '1em'
|
|
275
|
+
}
|
|
276
|
+
})
|
|
277
|
+
}), t('blocklet.component.checkUpdateTitle')]
|
|
281
278
|
})
|
|
282
279
|
})
|
|
283
280
|
})
|
package/lib/blocklet/icons.js
CHANGED
|
@@ -8,6 +8,7 @@ import Log from '@mui/icons-material/Receipt';
|
|
|
8
8
|
import Group from '@mui/icons-material/Group';
|
|
9
9
|
import Cancel from '@mui/icons-material/NotInterested';
|
|
10
10
|
import Dashboard from '@arcblock/icons/lib/Dashboard';
|
|
11
|
+
import Overview from '@mui/icons-material/ViewInAr';
|
|
11
12
|
export default {
|
|
12
13
|
Start,
|
|
13
14
|
Stop,
|
|
@@ -18,5 +19,6 @@ export default {
|
|
|
18
19
|
Log,
|
|
19
20
|
Group,
|
|
20
21
|
Cancel,
|
|
21
|
-
Dashboard
|
|
22
|
+
Dashboard,
|
|
23
|
+
Overview
|
|
22
24
|
};
|
|
@@ -84,28 +84,30 @@ function NotificationPushKit() {
|
|
|
84
84
|
await onSubmit(data, event, false);
|
|
85
85
|
}
|
|
86
86
|
const appUrl = (blocklet?.configs || []).find(x => x.key === 'BLOCKLET_APP_URL')?.value;
|
|
87
|
+
const logo = withQuery(joinURL(appUrl, '/.well-known/service/blocklet/logo'), {
|
|
88
|
+
v: blocklet?.meta?.version,
|
|
89
|
+
t: new Date(blocklet?.updatedAt || 0).getTime()
|
|
90
|
+
});
|
|
91
|
+
const notification = {
|
|
92
|
+
type: 'passthrough',
|
|
93
|
+
passthroughType: 'messageStatus',
|
|
94
|
+
data: {
|
|
95
|
+
message: {
|
|
96
|
+
title: 'Test push-kit notification',
|
|
97
|
+
body: 'This is message from push-kit config test',
|
|
98
|
+
sender: {
|
|
99
|
+
did: blocklet?.appDid,
|
|
100
|
+
fullName: blocklet?.meta?.title,
|
|
101
|
+
avatar: logo
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
};
|
|
87
106
|
await api.sendPush({
|
|
88
107
|
input: {
|
|
89
108
|
did,
|
|
90
109
|
receiver: pageState.testReceiver,
|
|
91
|
-
notification: JSON.stringify(
|
|
92
|
-
type: 'passthrough',
|
|
93
|
-
passthroughType: 'messageStatus',
|
|
94
|
-
data: {
|
|
95
|
-
message: {
|
|
96
|
-
title: 'Test push-kit notification',
|
|
97
|
-
body: 'This is message from push-kit config test',
|
|
98
|
-
sender: {
|
|
99
|
-
did: blocklet?.appDid,
|
|
100
|
-
fullName: blocklet?.meta?.title,
|
|
101
|
-
avatar: withQuery(joinURL(appUrl, '/.well-known/service/blocklet/logo'), {
|
|
102
|
-
v: blocklet?.meta?.version,
|
|
103
|
-
t: new Date(blocklet?.updatedAt || 0).getTime()
|
|
104
|
-
})
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
})
|
|
110
|
+
notification: JSON.stringify(notification)
|
|
109
111
|
}
|
|
110
112
|
});
|
|
111
113
|
Toast.success(t('notification.pushKit.testSuccess'));
|
|
@@ -114,7 +116,8 @@ function NotificationPushKit() {
|
|
|
114
116
|
}
|
|
115
117
|
});
|
|
116
118
|
const showTestEmailModal = useMemoizedFn((data, event) => {
|
|
117
|
-
|
|
119
|
+
// 保持展示上一次的数据,不做重置
|
|
120
|
+
// pageState.testReceiver = '';
|
|
118
121
|
pageState.testReceiverError = '';
|
|
119
122
|
confirmApi.open({
|
|
120
123
|
title: t('notification.pushKit.testSend'),
|
|
@@ -122,7 +125,8 @@ function NotificationPushKit() {
|
|
|
122
125
|
content: () => {
|
|
123
126
|
return /*#__PURE__*/_jsx(Box, {
|
|
124
127
|
sx: {
|
|
125
|
-
width: '
|
|
128
|
+
width: '450px',
|
|
129
|
+
maxWidth: '100%'
|
|
126
130
|
},
|
|
127
131
|
children: /*#__PURE__*/_jsx(TextField, {
|
|
128
132
|
sx: {
|
|
@@ -6,12 +6,12 @@ import { PROJECT } from '@blocklet/constant';
|
|
|
6
6
|
import styled from '@emotion/styled';
|
|
7
7
|
import { Icon } from '@iconify/react';
|
|
8
8
|
import CloudUploadRoundedIcon from '@mui/icons-material/CloudUploadRounded';
|
|
9
|
-
import { Box, Breadcrumbs, Button, ButtonGroup,
|
|
9
|
+
import { Box, Breadcrumbs, Button, ButtonGroup, Dialog as MaterialDialog, Typography, useMediaQuery } from '@mui/material';
|
|
10
10
|
import Spinner from '@mui/material/CircularProgress';
|
|
11
11
|
import pick from 'lodash/pick';
|
|
12
12
|
import pAll from 'p-all';
|
|
13
13
|
import PropTypes from 'prop-types';
|
|
14
|
-
import { useState } from 'react';
|
|
14
|
+
import { useState, useMemo } from 'react';
|
|
15
15
|
import { Link, useNavigate } from 'react-router-dom';
|
|
16
16
|
import semver from 'semver';
|
|
17
17
|
import { joinURL } from 'ufo';
|
|
@@ -27,6 +27,7 @@ import ConnectStoreList from './connect-store-list';
|
|
|
27
27
|
import ProjectSetting from './project-setting';
|
|
28
28
|
import { uploadResource } from './resource-select';
|
|
29
29
|
import UploadedToast from './uploaded-toast';
|
|
30
|
+
import InstallButton from './install-button';
|
|
30
31
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
31
32
|
const serverEndpoint = window.env?.serverEndpoint;
|
|
32
33
|
function Header({
|
|
@@ -66,7 +67,15 @@ function Header({
|
|
|
66
67
|
const [showSetting, setShowSetting] = useState(false);
|
|
67
68
|
const [installResourceTip, setInstallResourceTip] = useState();
|
|
68
69
|
const isMobile = useMediaQuery(theme => theme.breakpoints.down('md'));
|
|
69
|
-
const releaseType =
|
|
70
|
+
const releaseType = useMemo(() => {
|
|
71
|
+
if (params?.blockletComponents?.length > 0) {
|
|
72
|
+
const res = params?.blockletComponents.find(x => {
|
|
73
|
+
return x.included;
|
|
74
|
+
});
|
|
75
|
+
return res ? 'resource' : 'pack';
|
|
76
|
+
}
|
|
77
|
+
return 'resource';
|
|
78
|
+
}, [params?.blockletComponents]);
|
|
70
79
|
const onPublish = () => {
|
|
71
80
|
window.parent.postMessage({
|
|
72
81
|
event: 'studioDialog.uploaded',
|
|
@@ -249,97 +258,12 @@ function Header({
|
|
|
249
258
|
const handleShowSetting = () => {
|
|
250
259
|
setShowSetting(true);
|
|
251
260
|
};
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
url.searchParams.set('blocklet_meta_url', blockletMetaUrl);
|
|
259
|
-
installButton = isMobile ? /*#__PURE__*/_jsx(IconButton, {
|
|
260
|
-
component: "a",
|
|
261
|
-
disabled: loading,
|
|
262
|
-
href: url.href,
|
|
263
|
-
target: "_blank",
|
|
264
|
-
rel: "noreferrer",
|
|
265
|
-
color: "primary",
|
|
266
|
-
sx: {
|
|
267
|
-
mr: 1
|
|
268
|
-
},
|
|
269
|
-
onClick: () => setInstallResourceTip(blockletMetaUrl),
|
|
270
|
-
children: /*#__PURE__*/_jsx(Icon, {
|
|
271
|
-
icon: "ic:baseline-install-desktop"
|
|
272
|
-
})
|
|
273
|
-
}) : /*#__PURE__*/_jsx(Button, {
|
|
274
|
-
href: url.href,
|
|
275
|
-
disabled: loading,
|
|
276
|
-
target: "_blank",
|
|
277
|
-
rel: "noreferrer",
|
|
278
|
-
variant: "outlined",
|
|
279
|
-
sx: {
|
|
280
|
-
mr: 1
|
|
281
|
-
},
|
|
282
|
-
onClick: () => setInstallResourceTip(blockletMetaUrl),
|
|
283
|
-
children: t('common.install')
|
|
284
|
-
});
|
|
285
|
-
} else {
|
|
286
|
-
installButton = /*#__PURE__*/_jsxs(_Fragment, {
|
|
287
|
-
children: [isMobile ? /*#__PURE__*/_jsx(IconButton, {
|
|
288
|
-
disabled: loading,
|
|
289
|
-
color: "primary",
|
|
290
|
-
sx: {
|
|
291
|
-
mr: 1
|
|
292
|
-
},
|
|
293
|
-
onClick: () => setInstallResourceTip(blockletMetaUrl),
|
|
294
|
-
children: /*#__PURE__*/_jsx(Icon, {
|
|
295
|
-
icon: "ic:baseline-install-desktop"
|
|
296
|
-
})
|
|
297
|
-
}) : /*#__PURE__*/_jsx(Button, {
|
|
298
|
-
disabled: loading,
|
|
299
|
-
variant: "outlined",
|
|
300
|
-
sx: {
|
|
301
|
-
mr: 1
|
|
302
|
-
},
|
|
303
|
-
onClick: () => setInstallResourceTip(blockletMetaUrl),
|
|
304
|
-
children: t('blocklet.publish.copyInstallUrl')
|
|
305
|
-
}), /*#__PURE__*/_jsx(MaterialDialog, {
|
|
306
|
-
fullWidth: true,
|
|
307
|
-
maxWidth: "sm",
|
|
308
|
-
open: installResourceTip,
|
|
309
|
-
onClose: () => setInstallResourceTip(''),
|
|
310
|
-
children: /*#__PURE__*/_jsxs(Box, {
|
|
311
|
-
sx: {
|
|
312
|
-
py: 5,
|
|
313
|
-
px: 4,
|
|
314
|
-
wordBreak: 'break-all'
|
|
315
|
-
},
|
|
316
|
-
children: [/*#__PURE__*/_jsx(Typography, {
|
|
317
|
-
variant: "h6",
|
|
318
|
-
sx: {
|
|
319
|
-
mb: 2
|
|
320
|
-
},
|
|
321
|
-
children: t('blocklet.publish.installResourceTip')
|
|
322
|
-
}), /*#__PURE__*/_jsx(ClickToCopy, {
|
|
323
|
-
children: installResourceTip
|
|
324
|
-
}), /*#__PURE__*/_jsxs(Typography, {
|
|
325
|
-
sx: {
|
|
326
|
-
mt: 2
|
|
327
|
-
},
|
|
328
|
-
children: [t('blocklet.publish.installResourceTip2'), /*#__PURE__*/_jsx("a", {
|
|
329
|
-
style: {
|
|
330
|
-
marginLeft: 4
|
|
331
|
-
},
|
|
332
|
-
href: "https://www.arcblock.io/docs/blocklet-developer/R3weqCy7WPI8ggudt0C2alWv",
|
|
333
|
-
target: "_blank",
|
|
334
|
-
rel: "noreferrer",
|
|
335
|
-
children: t('blocklet.publish.installResourceHelp')
|
|
336
|
-
})]
|
|
337
|
-
})]
|
|
338
|
-
})
|
|
339
|
-
})]
|
|
340
|
-
});
|
|
341
|
-
}
|
|
342
|
-
}
|
|
261
|
+
const blockletMetaUrl = joinURL(serverEndpoint, `/api/project/${blocklet.meta.did}/${projectId}/${releaseId}/release/blocklet.json`);
|
|
262
|
+
const url = new URL(serverEndpoint);
|
|
263
|
+
url.pathname = joinURL(url.pathname, '/launch-blocklet/agreement');
|
|
264
|
+
url.searchParams.set('blocklet_meta_url', blockletMetaUrl);
|
|
265
|
+
const installUrl = url.href;
|
|
266
|
+
const handleSetTip = () => setInstallResourceTip(blockletMetaUrl);
|
|
343
267
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
344
268
|
children: [/*#__PURE__*/_jsx(Content, {
|
|
345
269
|
className: "sticky-header",
|
|
@@ -393,20 +317,44 @@ function Header({
|
|
|
393
317
|
})
|
|
394
318
|
})]
|
|
395
319
|
}), isPublished && /*#__PURE__*/_jsxs(_Fragment, {
|
|
396
|
-
children: [
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
320
|
+
children: [/*#__PURE__*/_jsx(MaterialDialog, {
|
|
321
|
+
fullWidth: true,
|
|
322
|
+
maxWidth: "sm",
|
|
323
|
+
open: installResourceTip,
|
|
324
|
+
onClose: () => setInstallResourceTip(''),
|
|
325
|
+
children: /*#__PURE__*/_jsxs(Box, {
|
|
326
|
+
sx: {
|
|
327
|
+
py: 5,
|
|
328
|
+
px: 4,
|
|
329
|
+
wordBreak: 'break-all'
|
|
330
|
+
},
|
|
331
|
+
children: [/*#__PURE__*/_jsx(Typography, {
|
|
332
|
+
variant: "h6",
|
|
333
|
+
sx: {
|
|
334
|
+
mb: 2
|
|
335
|
+
},
|
|
336
|
+
children: t('blocklet.publish.installResourceTip')
|
|
337
|
+
}), /*#__PURE__*/_jsx(ClickToCopy, {
|
|
338
|
+
children: installResourceTip
|
|
339
|
+
}), /*#__PURE__*/_jsxs(Typography, {
|
|
340
|
+
sx: {
|
|
341
|
+
mt: 2
|
|
342
|
+
},
|
|
343
|
+
children: [t('blocklet.publish.installResourceTip2'), /*#__PURE__*/_jsx("a", {
|
|
344
|
+
style: {
|
|
345
|
+
marginLeft: 4
|
|
346
|
+
},
|
|
347
|
+
href: "https://www.arcblock.io/docs/blocklet-developer/R3weqCy7WPI8ggudt0C2alWv",
|
|
348
|
+
target: "_blank",
|
|
349
|
+
rel: "noreferrer",
|
|
350
|
+
children: t('blocklet.publish.installResourceHelp')
|
|
351
|
+
})]
|
|
352
|
+
})]
|
|
353
|
+
})
|
|
405
354
|
}), /*#__PURE__*/_jsxs(ButtonGroup, {
|
|
406
355
|
disabled: loading,
|
|
407
356
|
variant: "contained",
|
|
408
357
|
children: [/*#__PURE__*/_jsxs(Button, {
|
|
409
|
-
variant: "contained",
|
|
410
358
|
onClick: () => setShowStoreDialog(true),
|
|
411
359
|
children: [loading ? /*#__PURE__*/_jsx(Spinner, {
|
|
412
360
|
size: 14,
|
|
@@ -420,8 +368,12 @@ function Header({
|
|
|
420
368
|
mr: 1
|
|
421
369
|
}
|
|
422
370
|
}), isMobile ? t('common.upload') : t('blocklet.publish.connectOrUpload')]
|
|
371
|
+
}), /*#__PURE__*/_jsx(InstallButton, {
|
|
372
|
+
isPack: releaseType === 'pack',
|
|
373
|
+
downloadUrl: joinURL(`${WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${blocklet.meta.did}/${projectId}/${releaseId}/download/${(release.files || [])[0]}`),
|
|
374
|
+
installUrl: installUrl,
|
|
375
|
+
handleSetTip: handleSetTip
|
|
423
376
|
}), /*#__PURE__*/_jsx(Button, {
|
|
424
|
-
variant: "contained",
|
|
425
377
|
onClick: handleShowSetting,
|
|
426
378
|
children: /*#__PURE__*/_jsx(Icon, {
|
|
427
379
|
icon: "mage:settings-fill",
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
2
|
+
import { Box, Button, ClickAwayListener, Grow, MenuItem, MenuList, Paper, Popper, Typography } from '@mui/material';
|
|
3
|
+
import { Icon } from '@iconify/react';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import { useRef, useState } from 'react';
|
|
6
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
7
|
+
export default function InstallButton({
|
|
8
|
+
downloadUrl,
|
|
9
|
+
installUrl,
|
|
10
|
+
handleSetTip,
|
|
11
|
+
isPack,
|
|
12
|
+
disabled
|
|
13
|
+
}) {
|
|
14
|
+
const {
|
|
15
|
+
t
|
|
16
|
+
} = useLocaleContext();
|
|
17
|
+
const [open, setOpen] = useState(false);
|
|
18
|
+
const anchorRef = useRef(null);
|
|
19
|
+
const handleToggle = () => {
|
|
20
|
+
setOpen(!open);
|
|
21
|
+
};
|
|
22
|
+
const handleClose = event => {
|
|
23
|
+
if (anchorRef.current && anchorRef.current.contains(event.target)) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
setOpen(false);
|
|
27
|
+
};
|
|
28
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
29
|
+
children: [/*#__PURE__*/_jsx(Button, {
|
|
30
|
+
disabled: disabled,
|
|
31
|
+
ref: anchorRef,
|
|
32
|
+
onClick: handleToggle,
|
|
33
|
+
children: /*#__PURE__*/_jsx(Box, {
|
|
34
|
+
component: Icon,
|
|
35
|
+
sx: {
|
|
36
|
+
fontSize: 18
|
|
37
|
+
},
|
|
38
|
+
icon: "bxs:download"
|
|
39
|
+
})
|
|
40
|
+
}), /*#__PURE__*/_jsx(Popper, {
|
|
41
|
+
sx: {
|
|
42
|
+
zIndex: 10
|
|
43
|
+
},
|
|
44
|
+
open: open,
|
|
45
|
+
anchorEl: anchorRef.current,
|
|
46
|
+
placement: "bottom-end",
|
|
47
|
+
role: undefined,
|
|
48
|
+
transition: true,
|
|
49
|
+
disablePortal: true,
|
|
50
|
+
children: ({
|
|
51
|
+
TransitionProps
|
|
52
|
+
}) => /*#__PURE__*/_jsx(Grow, {
|
|
53
|
+
...TransitionProps,
|
|
54
|
+
style: {
|
|
55
|
+
transformOrigin: 'center top'
|
|
56
|
+
},
|
|
57
|
+
children: /*#__PURE__*/_jsx(Paper, {
|
|
58
|
+
children: /*#__PURE__*/_jsx(ClickAwayListener, {
|
|
59
|
+
onClickAway: handleClose,
|
|
60
|
+
children: /*#__PURE__*/_jsxs(MenuList, {
|
|
61
|
+
id: "split-button-menu",
|
|
62
|
+
autoFocusItem: true,
|
|
63
|
+
sx: {
|
|
64
|
+
maxHeight: 300,
|
|
65
|
+
overflowY: 'auto',
|
|
66
|
+
zIndex: 10
|
|
67
|
+
},
|
|
68
|
+
children: [isPack && /*#__PURE__*/_jsx(Box, {
|
|
69
|
+
component: "a",
|
|
70
|
+
href: installUrl,
|
|
71
|
+
target: "_blank",
|
|
72
|
+
rel: "noreferrer",
|
|
73
|
+
sx: {
|
|
74
|
+
textDecoration: 'none'
|
|
75
|
+
},
|
|
76
|
+
children: /*#__PURE__*/_jsxs(MenuItem, {
|
|
77
|
+
sx: {
|
|
78
|
+
color: '#333'
|
|
79
|
+
},
|
|
80
|
+
children: [/*#__PURE__*/_jsx(Box, {
|
|
81
|
+
component: Icon,
|
|
82
|
+
sx: {
|
|
83
|
+
mr: 1
|
|
84
|
+
},
|
|
85
|
+
icon: "ic:round-install-desktop"
|
|
86
|
+
}), /*#__PURE__*/_jsx(Typography, {
|
|
87
|
+
variant: "inherit",
|
|
88
|
+
children: t('blocklet.publish.installToThisServer')
|
|
89
|
+
})]
|
|
90
|
+
})
|
|
91
|
+
}), /*#__PURE__*/_jsxs(MenuItem, {
|
|
92
|
+
onClick: handleSetTip,
|
|
93
|
+
children: [/*#__PURE__*/_jsx(Box, {
|
|
94
|
+
component: Icon,
|
|
95
|
+
sx: {
|
|
96
|
+
mr: 1
|
|
97
|
+
},
|
|
98
|
+
icon: "iconamoon:copy"
|
|
99
|
+
}), /*#__PURE__*/_jsx(Typography, {
|
|
100
|
+
variant: "inherit",
|
|
101
|
+
children: t('blocklet.publish.copyInstallUrl')
|
|
102
|
+
})]
|
|
103
|
+
}), /*#__PURE__*/_jsx(Box, {
|
|
104
|
+
component: "a",
|
|
105
|
+
href: downloadUrl,
|
|
106
|
+
target: "_blank",
|
|
107
|
+
rel: "noreferrer",
|
|
108
|
+
sx: {
|
|
109
|
+
textDecoration: 'none'
|
|
110
|
+
},
|
|
111
|
+
children: /*#__PURE__*/_jsxs(MenuItem, {
|
|
112
|
+
sx: {
|
|
113
|
+
color: '#333'
|
|
114
|
+
},
|
|
115
|
+
children: [/*#__PURE__*/_jsx(Box, {
|
|
116
|
+
component: Icon,
|
|
117
|
+
sx: {
|
|
118
|
+
mr: 1
|
|
119
|
+
},
|
|
120
|
+
icon: "ph:download"
|
|
121
|
+
}), /*#__PURE__*/_jsx(Typography, {
|
|
122
|
+
variant: "inherit",
|
|
123
|
+
children: t('common.download')
|
|
124
|
+
})]
|
|
125
|
+
})
|
|
126
|
+
})]
|
|
127
|
+
})
|
|
128
|
+
})
|
|
129
|
+
})
|
|
130
|
+
})
|
|
131
|
+
})]
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
InstallButton.propTypes = {
|
|
135
|
+
disabled: PropTypes.bool.isRequired,
|
|
136
|
+
isPack: PropTypes.bool.isRequired,
|
|
137
|
+
downloadUrl: PropTypes.string.isRequired,
|
|
138
|
+
installUrl: PropTypes.string.isRequired,
|
|
139
|
+
handleSetTip: PropTypes.func.isRequired
|
|
140
|
+
};
|