@blocklet/ui-react 3.4.15 → 3.5.0
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/common/org-switch/use-org.d.ts +4 -4
- package/package.json +9 -6
- package/.aigne/doc-smith/.local/afs-storage.sqlite3 +0 -0
- package/.aigne/doc-smith/config.yaml +0 -78
- package/.aigne/doc-smith/history.yaml +0 -14
- package/.aigne/doc-smith/media-description.yaml +0 -11
- package/.aigne/doc-smith/output/structure-plan.json +0 -255
- package/.aigne/doc-smith/translation-cache.yaml +0 -11
- package/.aigne/doc-smith/upload-cache.yaml +0 -528
- package/build.config.ts +0 -24
- package/docs/_sidebar.md +0 -19
- package/docs/assets/diagram/component-installer-diagram-0.ja.jpg +0 -0
- package/docs/assets/diagram/component-installer-diagram-0.jpg +0 -0
- package/docs/assets/diagram/component-installer-diagram-0.zh-TW.jpg +0 -0
- package/docs/assets/diagram/component-installer-diagram-0.zh.jpg +0 -0
- package/docs/assets/diagram/component-management-diagram-0.ja.jpg +0 -0
- package/docs/assets/diagram/component-management-diagram-0.jpg +0 -0
- package/docs/assets/diagram/component-management-diagram-0.zh-TW.jpg +0 -0
- package/docs/assets/diagram/component-management-diagram-0.zh.jpg +0 -0
- package/docs/assets/diagram/core-concepts-diagram-0.ja.jpg +0 -0
- package/docs/assets/diagram/core-concepts-diagram-0.jpg +0 -0
- package/docs/assets/diagram/core-concepts-diagram-0.zh-TW.jpg +0 -0
- package/docs/assets/diagram/core-concepts-diagram-0.zh.jpg +0 -0
- package/docs/assets/diagram/dashboard-diagram-0.ja.jpg +0 -0
- package/docs/assets/diagram/dashboard-diagram-0.jpg +0 -0
- package/docs/assets/diagram/dashboard-diagram-0.zh-TW.jpg +0 -0
- package/docs/assets/diagram/dashboard-diagram-0.zh.jpg +0 -0
- package/docs/assets/diagram/header-diagram-0.ja.jpg +0 -0
- package/docs/assets/diagram/header-diagram-0.jpg +0 -0
- package/docs/assets/diagram/header-diagram-0.zh-TW.jpg +0 -0
- package/docs/assets/diagram/header-diagram-0.zh.jpg +0 -0
- package/docs/assets/diagram/layout-diagram-0.ja.jpg +0 -0
- package/docs/assets/diagram/layout-diagram-0.jpg +0 -0
- package/docs/assets/diagram/layout-diagram-0.zh-TW.jpg +0 -0
- package/docs/assets/diagram/layout-diagram-0.zh.jpg +0 -0
- package/docs/assets/diagram/notifications-diagram-0.ja.jpg +0 -0
- package/docs/assets/diagram/notifications-diagram-0.jpg +0 -0
- package/docs/assets/diagram/notifications-diagram-0.zh-TW.jpg +0 -0
- package/docs/assets/diagram/notifications-diagram-0.zh.jpg +0 -0
- package/docs/assets/diagram/overview-diagram-0.ja.jpg +0 -0
- package/docs/assets/diagram/overview-diagram-0.jpg +0 -0
- package/docs/assets/diagram/overview-diagram-0.zh-TW.jpg +0 -0
- package/docs/assets/diagram/overview-diagram-0.zh.jpg +0 -0
- package/docs/assets/diagram/user-center-diagram-0.ja.jpg +0 -0
- package/docs/assets/diagram/user-center-diagram-0.jpg +0 -0
- package/docs/assets/diagram/user-center-diagram-0.zh-TW.jpg +0 -0
- package/docs/assets/diagram/user-center-diagram-0.zh.jpg +0 -0
- package/docs/assets/diagram/user-management-diagram-0.ja.jpg +0 -0
- package/docs/assets/diagram/user-management-diagram-0.jpg +0 -0
- package/docs/assets/diagram/user-management-diagram-0.zh-TW.jpg +0 -0
- package/docs/assets/diagram/user-management-diagram-0.zh.jpg +0 -0
- package/docs/assets/diagram/user-sessions-diagram-0.ja.jpg +0 -0
- package/docs/assets/diagram/user-sessions-diagram-0.jpg +0 -0
- package/docs/assets/diagram/user-sessions-diagram-0.zh-TW.jpg +0 -0
- package/docs/assets/diagram/user-sessions-diagram-0.zh.jpg +0 -0
- package/docs/components-component-management-blocklet-studio.ja.md +0 -194
- package/docs/components-component-management-blocklet-studio.md +0 -194
- package/docs/components-component-management-blocklet-studio.zh-TW.md +0 -194
- package/docs/components-component-management-blocklet-studio.zh.md +0 -194
- package/docs/components-component-management-component-installer.ja.md +0 -182
- package/docs/components-component-management-component-installer.md +0 -182
- package/docs/components-component-management-component-installer.zh-TW.md +0 -182
- package/docs/components-component-management-component-installer.zh.md +0 -182
- package/docs/components-component-management.ja.md +0 -30
- package/docs/components-component-management.md +0 -30
- package/docs/components-component-management.zh-TW.md +0 -30
- package/docs/components-component-management.zh.md +0 -30
- package/docs/components-layout-dashboard.ja.md +0 -185
- package/docs/components-layout-dashboard.md +0 -187
- package/docs/components-layout-dashboard.zh-TW.md +0 -185
- package/docs/components-layout-dashboard.zh.md +0 -185
- package/docs/components-layout-footer.ja.md +0 -165
- package/docs/components-layout-footer.md +0 -165
- package/docs/components-layout-footer.zh-TW.md +0 -165
- package/docs/components-layout-footer.zh.md +0 -165
- package/docs/components-layout-header.ja.md +0 -183
- package/docs/components-layout-header.md +0 -183
- package/docs/components-layout-header.zh-TW.md +0 -183
- package/docs/components-layout-header.zh.md +0 -183
- package/docs/components-layout.ja.md +0 -31
- package/docs/components-layout.md +0 -31
- package/docs/components-layout.zh-TW.md +0 -31
- package/docs/components-layout.zh.md +0 -31
- package/docs/components-notifications.ja.md +0 -125
- package/docs/components-notifications.md +0 -125
- package/docs/components-notifications.zh-TW.md +0 -125
- package/docs/components-notifications.zh.md +0 -125
- package/docs/components-user-management-user-center.ja.md +0 -148
- package/docs/components-user-management-user-center.md +0 -147
- package/docs/components-user-management-user-center.zh-TW.md +0 -148
- package/docs/components-user-management-user-center.zh.md +0 -148
- package/docs/components-user-management-user-sessions.ja.md +0 -121
- package/docs/components-user-management-user-sessions.md +0 -123
- package/docs/components-user-management-user-sessions.zh-TW.md +0 -121
- package/docs/components-user-management-user-sessions.zh.md +0 -121
- package/docs/components-user-management.ja.md +0 -49
- package/docs/components-user-management.md +0 -51
- package/docs/components-user-management.zh-TW.md +0 -49
- package/docs/components-user-management.zh.md +0 -49
- package/docs/components-utilities-icon.ja.md +0 -106
- package/docs/components-utilities-icon.md +0 -106
- package/docs/components-utilities-icon.zh-TW.md +0 -106
- package/docs/components-utilities-icon.zh.md +0 -106
- package/docs/components-utilities.ja.md +0 -136
- package/docs/components-utilities.md +0 -136
- package/docs/components-utilities.zh-TW.md +0 -136
- package/docs/components-utilities.zh.md +0 -136
- package/docs/components.ja.md +0 -27
- package/docs/components.md +0 -27
- package/docs/components.zh-TW.md +0 -27
- package/docs/components.zh.md +0 -27
- package/docs/core-concepts.ja.md +0 -134
- package/docs/core-concepts.md +0 -135
- package/docs/core-concepts.zh-TW.md +0 -134
- package/docs/core-concepts.zh.md +0 -134
- package/docs/getting-started.ja.md +0 -132
- package/docs/getting-started.md +0 -132
- package/docs/getting-started.zh-TW.md +0 -132
- package/docs/getting-started.zh.md +0 -132
- package/docs/hooks-api.ja.md +0 -214
- package/docs/hooks-api.md +0 -214
- package/docs/hooks-api.zh-TW.md +0 -214
- package/docs/hooks-api.zh.md +0 -214
- package/docs/how-to-guides.ja.md +0 -413
- package/docs/how-to-guides.md +0 -413
- package/docs/how-to-guides.zh-TW.md +0 -413
- package/docs/how-to-guides.zh.md +0 -413
- package/docs/overview.ja.md +0 -51
- package/docs/overview.md +0 -51
- package/docs/overview.zh-TW.md +0 -51
- package/docs/overview.zh.md +0 -51
- package/glossary.md +0 -12
- package/src/@types/index.ts +0 -230
- package/src/@types/shims.d.ts +0 -18
- package/src/BlockletStudio/README.md +0 -116
- package/src/BlockletStudio/index.tsx +0 -145
- package/src/ComponentInstaller/ComponentInstaller.stories.jsx +0 -16
- package/src/ComponentInstaller/index.jsx +0 -207
- package/src/ComponentInstaller/installer-item.jsx +0 -129
- package/src/ComponentInstaller/locales.js +0 -22
- package/src/ComponentInstaller/use-component-installed.js +0 -88
- package/src/ComponentManager/components/add-component.tsx +0 -136
- package/src/ComponentManager/components/check-component.tsx +0 -3
- package/src/ComponentManager/components/publish-component.tsx +0 -90
- package/src/ComponentManager/components/resource-dialog.tsx +0 -91
- package/src/ComponentManager/index.tsx +0 -3
- package/src/ComponentManager/libs/locales.ts +0 -15
- package/src/Dashboard/Dashboard.stories.jsx +0 -20
- package/src/Dashboard/app-shell/app-badge.stories.tsx +0 -64
- package/src/Dashboard/app-shell/app-badge.tsx +0 -94
- package/src/Dashboard/app-shell/app-header.tsx +0 -104
- package/src/Dashboard/app-shell/app-info-context.tsx +0 -182
- package/src/Dashboard/app-shell/badges/app-badge-default.tsx +0 -130
- package/src/Dashboard/app-shell/badges/app-badge-did.tsx +0 -28
- package/src/Dashboard/app-shell/badges/app-badge-state.tsx +0 -40
- package/src/Dashboard/app-shell/badges/app-badge-switch.tsx +0 -72
- package/src/Dashboard/app-shell/badges/app-badge-version.tsx +0 -60
- package/src/Dashboard/app-shell/index.ts +0 -5
- package/src/Dashboard/index.jsx +0 -184
- package/src/Footer/Footer.stories.jsx +0 -33
- package/src/Footer/brand.jsx +0 -81
- package/src/Footer/copyright.jsx +0 -22
- package/src/Footer/index.jsx +0 -111
- package/src/Footer/internal-footer.jsx +0 -139
- package/src/Footer/layout/plain.jsx +0 -55
- package/src/Footer/layout/row.jsx +0 -43
- package/src/Footer/layout/standard.jsx +0 -114
- package/src/Footer/links.jsx +0 -321
- package/src/Footer/social-media.jsx +0 -55
- package/src/Header/Header.stories.jsx +0 -30
- package/src/Header/index.tsx +0 -259
- package/src/Icon/Icon.stories.jsx +0 -12
- package/src/Icon/index.tsx +0 -87
- package/src/Notifications/Snackbar.tsx +0 -261
- package/src/Notifications/hooks/use-title.tsx +0 -254
- package/src/Notifications/hooks/use-width.tsx +0 -16
- package/src/Notifications/utils.ts +0 -246
- package/src/UserCenter/assets/banner.png +0 -0
- package/src/UserCenter/components/config-inviter.tsx +0 -48
- package/src/UserCenter/components/config-profile.tsx +0 -99
- package/src/UserCenter/components/danger-zone.tsx +0 -82
- package/src/UserCenter/components/editable-field.tsx +0 -273
- package/src/UserCenter/components/fallback.tsx +0 -57
- package/src/UserCenter/components/nft-preview.tsx +0 -84
- package/src/UserCenter/components/nft.tsx +0 -279
- package/src/UserCenter/components/notification.tsx +0 -319
- package/src/UserCenter/components/passport.tsx +0 -107
- package/src/UserCenter/components/privacy.tsx +0 -120
- package/src/UserCenter/components/settings.tsx +0 -170
- package/src/UserCenter/components/status-dialog/date-picker.tsx +0 -77
- package/src/UserCenter/components/status-dialog/index.tsx +0 -293
- package/src/UserCenter/components/status-selector/duration-menu.tsx +0 -90
- package/src/UserCenter/components/status-selector/index.tsx +0 -58
- package/src/UserCenter/components/status-selector/menu-item.tsx +0 -56
- package/src/UserCenter/components/storage/action.tsx +0 -49
- package/src/UserCenter/components/storage/connected.tsx +0 -61
- package/src/UserCenter/components/storage/delete.tsx +0 -72
- package/src/UserCenter/components/storage/disconnect.tsx +0 -40
- package/src/UserCenter/components/storage/icons/empty-spaces-nft.svg +0 -1
- package/src/UserCenter/components/storage/icons/long-arrow.svg +0 -5
- package/src/UserCenter/components/storage/icons/space-connected.svg +0 -3
- package/src/UserCenter/components/storage/icons/space-disconnect.svg +0 -3
- package/src/UserCenter/components/storage/index.tsx +0 -41
- package/src/UserCenter/components/storage/preview-nft.tsx +0 -72
- package/src/UserCenter/components/third-party-login/index.tsx +0 -199
- package/src/UserCenter/components/third-party-login/third-party-item.tsx +0 -296
- package/src/UserCenter/components/user-center.tsx +0 -787
- package/src/UserCenter/components/user-info/address.tsx +0 -143
- package/src/UserCenter/components/user-info/index.tsx +0 -4
- package/src/UserCenter/components/user-info/link-preview-input.tsx +0 -274
- package/src/UserCenter/components/user-info/metadata.tsx +0 -658
- package/src/UserCenter/components/user-info/social-actions/chat.tsx +0 -43
- package/src/UserCenter/components/user-info/social-actions/follow.tsx +0 -23
- package/src/UserCenter/components/user-info/social-actions/index.tsx +0 -17
- package/src/UserCenter/components/user-info/switch-role.tsx +0 -42
- package/src/UserCenter/components/user-info/timezone-select.tsx +0 -119
- package/src/UserCenter/components/user-info/user-basic-info.tsx +0 -292
- package/src/UserCenter/components/user-info/user-info-item.tsx +0 -54
- package/src/UserCenter/components/user-info/user-info.tsx +0 -91
- package/src/UserCenter/components/user-info/user-status.tsx +0 -234
- package/src/UserCenter/components/user-info/utils.ts +0 -320
- package/src/UserCenter/components/webhook-item.tsx +0 -248
- package/src/UserCenter/index.tsx +0 -1
- package/src/UserCenter/libs/locales.ts +0 -378
- package/src/UserCenter/libs/utils.ts +0 -30
- package/src/UserSessions/components/user-session-info.tsx +0 -78
- package/src/UserSessions/components/user-sessions.tsx +0 -545
- package/src/UserSessions/index.tsx +0 -1
- package/src/UserSessions/libs/locales.ts +0 -60
- package/src/UserSessions/libs/utils.ts +0 -82
- package/src/blocklets.js +0 -195
- package/src/common/domain-warning.jsx +0 -178
- package/src/common/header-addons.jsx +0 -119
- package/src/common/link-blocker.jsx +0 -20
- package/src/common/notification-addon.jsx +0 -135
- package/src/common/org-switch/avatar-uploader.jsx +0 -271
- package/src/common/org-switch/create.jsx +0 -267
- package/src/common/org-switch/index.jsx +0 -407
- package/src/common/org-switch/locales.js +0 -52
- package/src/common/org-switch/use-org.jsx +0 -79
- package/src/common/overridable-theme-provider.jsx +0 -17
- package/src/common/wallet-hidden-topbar.js +0 -14
- package/src/common/wizard-modal.jsx +0 -200
- package/src/common/ws.js +0 -68
- package/src/contexts/config-user-space.tsx +0 -88
- package/src/contexts/user-followers.tsx +0 -54
- package/src/hooks/use-follow.tsx +0 -75
- package/src/hooks/use-mobile.tsx +0 -6
- package/src/index.ts +0 -16
- package/src/libs/constant.ts +0 -1
- package/src/libs/spaces.tsx +0 -18
- package/src/libs/with-hide-when-embed.tsx +0 -24
- package/src/types.js +0 -45
- package/src/utils.js +0 -161
- package/vite.config.mjs +0 -34
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
import { SessionContext } from '@arcblock/did-connect-react/lib/Session';
|
|
2
|
-
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
3
|
-
import { translate } from '@arcblock/ux/lib/Locale/util';
|
|
4
|
-
import SessionPermission from '@arcblock/ux/lib/SessionPermission';
|
|
5
|
-
import { Icon } from '@iconify/react';
|
|
6
|
-
import { Close as CloseIcon } from '@mui/icons-material';
|
|
7
|
-
import { Box, ClickAwayListener, Fade, IconButton, Paper } from '@mui/material';
|
|
8
|
-
import { useMemoizedFn } from 'ahooks';
|
|
9
|
-
import PropTypes from 'prop-types';
|
|
10
|
-
import { use } from 'react';
|
|
11
|
-
import InstallerItem from './installer-item';
|
|
12
|
-
import translations from './locales';
|
|
13
|
-
import useComponentInstalled from './use-component-installed';
|
|
14
|
-
|
|
15
|
-
function ComponentInstaller({
|
|
16
|
-
warnIcon = null,
|
|
17
|
-
did,
|
|
18
|
-
noPermissionMute = false,
|
|
19
|
-
onInstalled = null,
|
|
20
|
-
onError = null,
|
|
21
|
-
children,
|
|
22
|
-
closeByOutSize = false,
|
|
23
|
-
onClose = null,
|
|
24
|
-
fallback = null,
|
|
25
|
-
disabled = false,
|
|
26
|
-
roles = ['owner', 'admin'],
|
|
27
|
-
}) {
|
|
28
|
-
const { locale } = useLocaleContext();
|
|
29
|
-
const t = useMemoizedFn((key, data = {}) => {
|
|
30
|
-
return translate(translations, key, locale, 'en', data);
|
|
31
|
-
});
|
|
32
|
-
const { installed, optComponents, installStatus, definedInBlockletYML } = useComponentInstalled({
|
|
33
|
-
did,
|
|
34
|
-
onInstalled,
|
|
35
|
-
onError,
|
|
36
|
-
});
|
|
37
|
-
const sessionCtx = use(SessionContext);
|
|
38
|
-
|
|
39
|
-
const handleClose = () => {
|
|
40
|
-
onClose?.(false);
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
if (disabled) {
|
|
44
|
-
return children;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return (
|
|
48
|
-
<SessionPermission session={sessionCtx?.session} roles={roles}>
|
|
49
|
-
{({ hasPermission }) => {
|
|
50
|
-
if (installed) {
|
|
51
|
-
return children;
|
|
52
|
-
}
|
|
53
|
-
if (noPermissionMute && !hasPermission) {
|
|
54
|
-
return fallback || null;
|
|
55
|
-
}
|
|
56
|
-
if (typeof children === 'function') {
|
|
57
|
-
return (
|
|
58
|
-
<>
|
|
59
|
-
{fallback}
|
|
60
|
-
{children({
|
|
61
|
-
hasPermission,
|
|
62
|
-
optComponents,
|
|
63
|
-
installStatus,
|
|
64
|
-
})}
|
|
65
|
-
</>
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
// not installed, but has permission, can install directly
|
|
69
|
-
return (
|
|
70
|
-
<>
|
|
71
|
-
{fallback}
|
|
72
|
-
<ClickAwayListener
|
|
73
|
-
onClickAway={(e) => {
|
|
74
|
-
e.preventDefault();
|
|
75
|
-
e.stopPropagation();
|
|
76
|
-
if (closeByOutSize) {
|
|
77
|
-
handleClose();
|
|
78
|
-
}
|
|
79
|
-
}}>
|
|
80
|
-
<Fade in timeout={350}>
|
|
81
|
-
<Paper
|
|
82
|
-
variant="outlined"
|
|
83
|
-
sx={{
|
|
84
|
-
position: 'fixed',
|
|
85
|
-
top: 20,
|
|
86
|
-
right: 20,
|
|
87
|
-
zIndex: 3000,
|
|
88
|
-
borderRadius: 1.5,
|
|
89
|
-
width: 400,
|
|
90
|
-
maxWidth: '90vw',
|
|
91
|
-
borderColor: 'divider',
|
|
92
|
-
border: '0 !important',
|
|
93
|
-
fontSize: '14px',
|
|
94
|
-
textAlign: 'left',
|
|
95
|
-
boxShadow: ({ palette }) =>
|
|
96
|
-
`0px 8px 16px 0px ${palette.grey[100]}, 0px 0px 0px 1px ${palette.grey[100]}`,
|
|
97
|
-
}}>
|
|
98
|
-
{!definedInBlockletYML ? (
|
|
99
|
-
<Box sx={{ display: 'flex', flexDirection: 'column' }}>
|
|
100
|
-
<Box
|
|
101
|
-
sx={{
|
|
102
|
-
padding: '20px 24px',
|
|
103
|
-
marginLeft: 0,
|
|
104
|
-
display: 'flex',
|
|
105
|
-
alignItems: 'center',
|
|
106
|
-
flexDirection: 'row',
|
|
107
|
-
justifyContent: 'flex-start',
|
|
108
|
-
}}>
|
|
109
|
-
{warnIcon || <Icon icon="mdi:warning-box" style={{ color: 'yellowgreen', fontSize: 24 }} />}
|
|
110
|
-
<Box sx={{ marginLeft: 1, fontSize: '16px', fontWeight: 'bold' }}>
|
|
111
|
-
{t('componentInstallerTitle')}
|
|
112
|
-
</Box>
|
|
113
|
-
<Box sx={{ flex: 1 }} />
|
|
114
|
-
{onClose ? (
|
|
115
|
-
<IconButton variant="outlined" className="button" onClick={handleClose}>
|
|
116
|
-
<CloseIcon />
|
|
117
|
-
</IconButton>
|
|
118
|
-
) : null}
|
|
119
|
-
</Box>
|
|
120
|
-
<Box sx={{ width: '100%', height: '1px', backgroundColor: 'grey.100' }} />
|
|
121
|
-
<Box sx={{ padding: '20px 24px', marginTop: 0 }}>
|
|
122
|
-
{t('componentInstallerNoDefinedInBlockletYML')}: {did}
|
|
123
|
-
</Box>
|
|
124
|
-
</Box>
|
|
125
|
-
) : (
|
|
126
|
-
<Box sx={{ display: 'flex', flexDirection: 'column' }}>
|
|
127
|
-
<Box
|
|
128
|
-
sx={{
|
|
129
|
-
padding: '20px 24px',
|
|
130
|
-
marginLeft: 0,
|
|
131
|
-
display: 'flex',
|
|
132
|
-
flexDirection: 'row',
|
|
133
|
-
alignItems: 'center',
|
|
134
|
-
justifyContent: 'flex-start',
|
|
135
|
-
}}>
|
|
136
|
-
{warnIcon || <Icon icon="mdi:warning-box" style={{ color: 'yellowgreen', fontSize: 24 }} />}
|
|
137
|
-
<Box sx={{ marginLeft: 1, fontSize: '16px', fontWeight: 'bold' }}>
|
|
138
|
-
{t('componentInstallerTitle')}
|
|
139
|
-
</Box>
|
|
140
|
-
<Box sx={{ flex: 1 }} />
|
|
141
|
-
{onClose ? (
|
|
142
|
-
<IconButton variant="outlined" className="button" onClick={handleClose}>
|
|
143
|
-
<CloseIcon />
|
|
144
|
-
</IconButton>
|
|
145
|
-
) : null}
|
|
146
|
-
</Box>
|
|
147
|
-
<Box sx={{ width: '100%', height: '1px', backgroundColor: 'grey.100' }} />
|
|
148
|
-
<Box sx={{ maxHeight: '70vh', overflowY: 'auto' }}>
|
|
149
|
-
{optComponents.map((optionalComponent, index) => {
|
|
150
|
-
return (
|
|
151
|
-
<InstallerItem
|
|
152
|
-
t={t}
|
|
153
|
-
key={optionalComponent.meta?.did || index}
|
|
154
|
-
hasPermission={hasPermission}
|
|
155
|
-
index={index}
|
|
156
|
-
optionalComponent={optionalComponent}
|
|
157
|
-
installStatus={installStatus[optionalComponent.meta?.did]}
|
|
158
|
-
/>
|
|
159
|
-
);
|
|
160
|
-
})}
|
|
161
|
-
</Box>
|
|
162
|
-
{hasPermission ? null : (
|
|
163
|
-
<>
|
|
164
|
-
<Box sx={{ width: '100%', height: '1px', backgroundColor: 'grey.100' }} />
|
|
165
|
-
<Box sx={{ padding: '20px 24px' }}>
|
|
166
|
-
<Box sx={{ opacity: 1 }}>{t('componentInstallerSuggestions')}</Box>
|
|
167
|
-
</Box>
|
|
168
|
-
</>
|
|
169
|
-
)}
|
|
170
|
-
</Box>
|
|
171
|
-
)}
|
|
172
|
-
</Paper>
|
|
173
|
-
</Fade>
|
|
174
|
-
</ClickAwayListener>
|
|
175
|
-
</>
|
|
176
|
-
);
|
|
177
|
-
}}
|
|
178
|
-
</SessionPermission>
|
|
179
|
-
);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
ComponentInstaller.propTypes = {
|
|
183
|
-
disabled: PropTypes.bool,
|
|
184
|
-
warnIcon: PropTypes.node,
|
|
185
|
-
did: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]).isRequired,
|
|
186
|
-
noPermissionMute: PropTypes.bool,
|
|
187
|
-
onInstalled: PropTypes.func,
|
|
188
|
-
onError: PropTypes.func,
|
|
189
|
-
children: PropTypes.any.isRequired,
|
|
190
|
-
closeByOutSize: PropTypes.bool,
|
|
191
|
-
onClose: PropTypes.func,
|
|
192
|
-
fallback: PropTypes.node,
|
|
193
|
-
roles: PropTypes.array,
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
export default function WrapComponentInstaller(props) {
|
|
197
|
-
if (window.blocklet) {
|
|
198
|
-
return <ComponentInstaller {...props} />;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
return props.children;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
WrapComponentInstaller.propTypes = {
|
|
205
|
-
...ComponentInstaller.propTypes,
|
|
206
|
-
children: PropTypes.any.isRequired,
|
|
207
|
-
};
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import { Icon } from '@iconify/react';
|
|
2
|
-
import { Box, Button, useTheme } from '@mui/material';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
|
|
5
|
-
export default function InstallerItem({ optionalComponent, index, installStatus = '', hasPermission, t }) {
|
|
6
|
-
const { palette } = useTheme();
|
|
7
|
-
const handleInstall = () => {
|
|
8
|
-
// 这里是安全的
|
|
9
|
-
window.open(optionalComponent?.installUrl, '_blank');
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const handleOpenStore = () => {
|
|
13
|
-
// 这里是安全的
|
|
14
|
-
window.open(optionalComponent?.storeUrl, '_blank');
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const handleRefresh = () => {
|
|
18
|
-
window.location.reload();
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const installStatusDone = installStatus === 'stopped' || installStatus === 'running';
|
|
22
|
-
const size = 60;
|
|
23
|
-
|
|
24
|
-
return (
|
|
25
|
-
<Box>
|
|
26
|
-
{index === 0 ? null : <Box sx={{ width: '100%', height: '1px', backgroundColor: 'grey.100' }} />}
|
|
27
|
-
<Box
|
|
28
|
-
sx={{
|
|
29
|
-
padding: '20px 24px',
|
|
30
|
-
paddingTop: 0.5,
|
|
31
|
-
marginTop: 2,
|
|
32
|
-
display: 'flex',
|
|
33
|
-
flexDirection: 'row',
|
|
34
|
-
justifyContent: 'start',
|
|
35
|
-
alignItems: 'flex-start',
|
|
36
|
-
}}>
|
|
37
|
-
<img
|
|
38
|
-
style={{ width: size, height: size, minWidth: size, minHeight: size }}
|
|
39
|
-
src={optionalComponent.logoUrl}
|
|
40
|
-
alt={optionalComponent.meta.title}
|
|
41
|
-
/>
|
|
42
|
-
<Box
|
|
43
|
-
sx={{
|
|
44
|
-
display: 'flex',
|
|
45
|
-
flexDirection: 'column',
|
|
46
|
-
justifyContent: 'start',
|
|
47
|
-
alignItems: 'start',
|
|
48
|
-
marginLeft: 2,
|
|
49
|
-
}}>
|
|
50
|
-
<Box
|
|
51
|
-
sx={{
|
|
52
|
-
fontSize: '16px',
|
|
53
|
-
fontWeight: 'bold',
|
|
54
|
-
cursor: 'pointer',
|
|
55
|
-
'.link-icon': {
|
|
56
|
-
opacity: 0,
|
|
57
|
-
},
|
|
58
|
-
':hover .link-icon': {
|
|
59
|
-
opacity: 1,
|
|
60
|
-
},
|
|
61
|
-
}}
|
|
62
|
-
onClick={() => handleOpenStore(optionalComponent.meta?.did)}>
|
|
63
|
-
{optionalComponent.meta.title}
|
|
64
|
-
<Box
|
|
65
|
-
sx={{
|
|
66
|
-
paddingLeft: 1,
|
|
67
|
-
fontSize: '13px',
|
|
68
|
-
fontWeight: '400',
|
|
69
|
-
}}
|
|
70
|
-
component="span">
|
|
71
|
-
{optionalComponent.meta.version}
|
|
72
|
-
<Icon
|
|
73
|
-
className="link-icon"
|
|
74
|
-
icon="fluent:open-20-filled"
|
|
75
|
-
style={{
|
|
76
|
-
color: palette.primary.main,
|
|
77
|
-
fontSize: 16,
|
|
78
|
-
transform: 'translate(6px, 3px)',
|
|
79
|
-
transition: 'all 0.3s',
|
|
80
|
-
}}
|
|
81
|
-
/>
|
|
82
|
-
</Box>
|
|
83
|
-
</Box>
|
|
84
|
-
<Box sx={{ marginTop: 0, opacity: 0.7 }}>{optionalComponent.meta.description}</Box>
|
|
85
|
-
<Box sx={{ display: hasPermission ? 'flex' : 'none', flexDirection: 'row', gap: 1 }}>
|
|
86
|
-
{installStatus ? (
|
|
87
|
-
<Box sx={{ marginTop: 2, opacity: 0.7 }}>
|
|
88
|
-
{installStatusDone ? (
|
|
89
|
-
<Button key="refresh" variant="contained" onClick={handleRefresh}>
|
|
90
|
-
{t('componentInstallerRefresh')}
|
|
91
|
-
</Button>
|
|
92
|
-
) : (
|
|
93
|
-
<Button
|
|
94
|
-
key="status"
|
|
95
|
-
disabled
|
|
96
|
-
sx={{ color: 'text.primary' }}
|
|
97
|
-
startIcon={<Icon icon="line-md:loading-loop" style={{ color: 'text.primary', fontSize: 16 }} />}
|
|
98
|
-
variant="contained">
|
|
99
|
-
{installStatus}
|
|
100
|
-
</Button>
|
|
101
|
-
)}
|
|
102
|
-
</Box>
|
|
103
|
-
) : (
|
|
104
|
-
<Button
|
|
105
|
-
key="install"
|
|
106
|
-
sx={{ marginTop: 2 }}
|
|
107
|
-
variant="contained"
|
|
108
|
-
className="button"
|
|
109
|
-
onClick={() => handleInstall(optionalComponent.meta?.did)}>
|
|
110
|
-
{t('componentInstallerInstall')}
|
|
111
|
-
</Button>
|
|
112
|
-
)}
|
|
113
|
-
</Box>
|
|
114
|
-
{installStatusDone ? (
|
|
115
|
-
<Box sx={{ marginTop: 2, opacity: 0.7 }}>{t('componentInstallerSuccessInstalled')}</Box>
|
|
116
|
-
) : null}
|
|
117
|
-
</Box>
|
|
118
|
-
</Box>
|
|
119
|
-
</Box>
|
|
120
|
-
);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
InstallerItem.propTypes = {
|
|
124
|
-
t: PropTypes.func.isRequired,
|
|
125
|
-
optionalComponent: PropTypes.object.isRequired,
|
|
126
|
-
index: PropTypes.number.isRequired,
|
|
127
|
-
installStatus: PropTypes.string,
|
|
128
|
-
hasPermission: PropTypes.bool.isRequired,
|
|
129
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
const translations = {
|
|
2
|
-
zh: {
|
|
3
|
-
componentInstallerTitle: '缺少组件',
|
|
4
|
-
componentInstallerInstall: '安装',
|
|
5
|
-
componentInstallerClose: '关闭',
|
|
6
|
-
componentInstallerRefresh: '重载页面',
|
|
7
|
-
componentInstallerSuccessInstalled: '安装成功,请重载页面查看变化。',
|
|
8
|
-
componentInstallerSuggestions: '请联系系统管理员安装该组件。',
|
|
9
|
-
componentInstallerNoDefinedInBlockletYML: '组件未在 blocklet.yml 中定义',
|
|
10
|
-
},
|
|
11
|
-
en: {
|
|
12
|
-
componentInstallerTitle: 'Missing component',
|
|
13
|
-
componentInstallerInstall: 'Install',
|
|
14
|
-
componentInstallerClose: 'Close',
|
|
15
|
-
componentInstallerRefresh: 'Refresh',
|
|
16
|
-
componentInstallerSuccessInstalled: 'Successfully installed, please refresh the page to see the changes.',
|
|
17
|
-
componentInstallerSuggestions: 'Please contact the system administrator to install the component.',
|
|
18
|
-
componentInstallerNoDefinedInBlockletYML: 'The component is not defined in blocklet.yml',
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export default translations;
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { BLOCKLET_SERVICE_PATH_PREFIX } from '@arcblock/did-connect-react/lib/constant';
|
|
2
|
-
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
3
|
-
import { joinURL } from 'ufo';
|
|
4
|
-
|
|
5
|
-
const parseDidToSet = (did) => {
|
|
6
|
-
if (typeof did === 'string') {
|
|
7
|
-
return new Set(did.split(';;'));
|
|
8
|
-
}
|
|
9
|
-
return new Set(did);
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
function useComponentInstalled({ did, onInstalled, onError }) {
|
|
13
|
-
const didKeys = Array.isArray(did) ? did.join(';;') : did;
|
|
14
|
-
const [installStatus, setInstallStatus] = useState({});
|
|
15
|
-
const onInstalledRef = useRef({ onInstalled, onError });
|
|
16
|
-
onInstalledRef.current = { onInstalled, onError };
|
|
17
|
-
|
|
18
|
-
const { optionalComponents, componentMountPoints } = window.blocklet;
|
|
19
|
-
|
|
20
|
-
const optComponents = useMemo(() => {
|
|
21
|
-
if (!optionalComponents || !optionalComponents.length) {
|
|
22
|
-
return [];
|
|
23
|
-
}
|
|
24
|
-
const didSet = parseDidToSet(didKeys);
|
|
25
|
-
const components = optionalComponents.filter((c) => didSet.has(c.meta.did));
|
|
26
|
-
(components ? onInstalledRef.current.onError : onInstalledRef.current.onInstalled)?.(components);
|
|
27
|
-
return components;
|
|
28
|
-
}, [didKeys, optionalComponents]);
|
|
29
|
-
|
|
30
|
-
const definedInBlockletYML = useMemo(() => {
|
|
31
|
-
if (optComponents.length) {
|
|
32
|
-
return true;
|
|
33
|
-
}
|
|
34
|
-
const didSet = parseDidToSet(didKeys);
|
|
35
|
-
return (componentMountPoints || []).find((item) => didSet.has(item.did));
|
|
36
|
-
}, [optComponents, componentMountPoints, didKeys]);
|
|
37
|
-
|
|
38
|
-
optComponents.forEach((item) => {
|
|
39
|
-
item.storeUrl = joinURL(item.meta.homepage, 'blocklets', item.meta.did);
|
|
40
|
-
item.installUrl = joinURL(
|
|
41
|
-
window.blocklet.appUrl,
|
|
42
|
-
BLOCKLET_SERVICE_PATH_PREFIX,
|
|
43
|
-
`/admin/components?install-component=${item.meta.did}`
|
|
44
|
-
);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
useEffect(() => {
|
|
48
|
-
const handle = (event) => {
|
|
49
|
-
if (event.origin !== window.blocklet.appUrl) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (event.data?.kind === 'component-installer' && event.data?.blocklet?.children) {
|
|
54
|
-
let hasChild = false;
|
|
55
|
-
const didSet = parseDidToSet(didKeys);
|
|
56
|
-
event.data?.blocklet?.children.forEach((item) => {
|
|
57
|
-
if (didSet.has(item.meta?.did)) {
|
|
58
|
-
hasChild = true;
|
|
59
|
-
setInstallStatus((value) => {
|
|
60
|
-
return {
|
|
61
|
-
...value,
|
|
62
|
-
[item.meta?.did]: item.status || 'waiting',
|
|
63
|
-
};
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
if (!hasChild) {
|
|
68
|
-
setInstallStatus({});
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
window.addEventListener('message', handle);
|
|
74
|
-
return () => {
|
|
75
|
-
window.removeEventListener('message', handle);
|
|
76
|
-
};
|
|
77
|
-
}, [didKeys]);
|
|
78
|
-
|
|
79
|
-
return {
|
|
80
|
-
optComponents,
|
|
81
|
-
installed: !optComponents.length && definedInBlockletYML,
|
|
82
|
-
installStatus,
|
|
83
|
-
setInstallStatus,
|
|
84
|
-
definedInBlockletYML,
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export default useComponentInstalled;
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { useEffect, ReactElement, useRef, use } from 'react';
|
|
2
|
-
import Button from '@arcblock/ux/lib/Button';
|
|
3
|
-
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
4
|
-
import { BLOCKLET_SERVICE_PATH_PREFIX } from '@arcblock/ux/lib/Util/constant';
|
|
5
|
-
import { useMemoizedFn, useReactive } from 'ahooks';
|
|
6
|
-
import { translate } from '@arcblock/ux/lib/Locale/util';
|
|
7
|
-
import { joinURL, withQuery } from 'ufo';
|
|
8
|
-
import { SessionContext } from '@arcblock/did-connect-react/lib/Session';
|
|
9
|
-
import Toast from '@arcblock/ux/lib/Toast';
|
|
10
|
-
|
|
11
|
-
import ResourceDialog from './resource-dialog';
|
|
12
|
-
import { translations } from '../libs/locales';
|
|
13
|
-
import type { SessionContext as TSessionContext } from '../../@types';
|
|
14
|
-
|
|
15
|
-
export default function AddComponent({
|
|
16
|
-
componentDid,
|
|
17
|
-
resourceType = undefined,
|
|
18
|
-
resourceDid = undefined,
|
|
19
|
-
grantedRoles = ['admin', 'owner'],
|
|
20
|
-
autoClose = true,
|
|
21
|
-
selectedMeta = undefined,
|
|
22
|
-
storeUrl = undefined,
|
|
23
|
-
onComplete,
|
|
24
|
-
onClose,
|
|
25
|
-
render = undefined,
|
|
26
|
-
}: {
|
|
27
|
-
componentDid: string;
|
|
28
|
-
resourceType?: string;
|
|
29
|
-
resourceDid?: string;
|
|
30
|
-
autoClose?: boolean;
|
|
31
|
-
selectedMeta?: any;
|
|
32
|
-
storeUrl?: string;
|
|
33
|
-
grantedRoles?: string[];
|
|
34
|
-
onComplete: () => void;
|
|
35
|
-
onClose: () => void;
|
|
36
|
-
render?: ({ onClick, loading }: { onClick: () => void; loading: boolean }) => ReactElement<any>;
|
|
37
|
-
}) {
|
|
38
|
-
const { session } = use<TSessionContext>(SessionContext);
|
|
39
|
-
const { locale } = useLocaleContext();
|
|
40
|
-
const t = useMemoizedFn((key, data = {}) => {
|
|
41
|
-
return translate(translations, key, locale, 'en', data);
|
|
42
|
-
});
|
|
43
|
-
const refIframe = useRef<{ selectBlocklet: (meta: any) => void }>(null);
|
|
44
|
-
|
|
45
|
-
const currentState = useReactive({
|
|
46
|
-
loading: false,
|
|
47
|
-
showDialog: false,
|
|
48
|
-
});
|
|
49
|
-
const importUrl = withQuery(joinURL(BLOCKLET_SERVICE_PATH_PREFIX, 'embed/resources', componentDid, 'add'), {
|
|
50
|
-
resourceDid,
|
|
51
|
-
resourceType,
|
|
52
|
-
mode: 'dialog',
|
|
53
|
-
showFromUrl: 'false',
|
|
54
|
-
showResourcesSwitch: 'false',
|
|
55
|
-
enableRunBackground: 'false',
|
|
56
|
-
showCategory: 'false',
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
const handleClose = useMemoizedFn(() => {
|
|
60
|
-
currentState.showDialog = false;
|
|
61
|
-
onClose?.();
|
|
62
|
-
});
|
|
63
|
-
const handleComplete = useMemoizedFn(() => {
|
|
64
|
-
currentState.showDialog = false;
|
|
65
|
-
onComplete?.();
|
|
66
|
-
});
|
|
67
|
-
const handleOpen = useMemoizedFn(() => {
|
|
68
|
-
if (!session.user) {
|
|
69
|
-
Toast.warning(t('needLogin'));
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
if (!grantedRoles.includes(session.user?.role as string)) {
|
|
73
|
-
Toast.warning(t('noPermission'));
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
currentState.loading = true;
|
|
77
|
-
currentState.showDialog = true;
|
|
78
|
-
});
|
|
79
|
-
const handleLoad = useMemoizedFn(() => {
|
|
80
|
-
currentState.loading = false;
|
|
81
|
-
if (refIframe.current) {
|
|
82
|
-
refIframe.current?.selectBlocklet(selectedMeta);
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
const handleIframeMessage = useMemoizedFn((event: MessageEvent) => {
|
|
87
|
-
if (event?.data?.event === 'component.installed' && event.data.componentDid === componentDid) {
|
|
88
|
-
if (autoClose || event.data.manual) {
|
|
89
|
-
handleComplete();
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
useEffect(() => {
|
|
95
|
-
if (currentState.showDialog) {
|
|
96
|
-
window.addEventListener('message', handleIframeMessage);
|
|
97
|
-
} else {
|
|
98
|
-
window.removeEventListener('message', handleIframeMessage);
|
|
99
|
-
}
|
|
100
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
101
|
-
}, [currentState.showDialog]);
|
|
102
|
-
|
|
103
|
-
return (
|
|
104
|
-
<>
|
|
105
|
-
{render ? (
|
|
106
|
-
render({ onClick: handleOpen, loading: currentState.loading })
|
|
107
|
-
) : (
|
|
108
|
-
<Button
|
|
109
|
-
key="button"
|
|
110
|
-
variant="outlined"
|
|
111
|
-
color="secondary"
|
|
112
|
-
type="button"
|
|
113
|
-
className="submit"
|
|
114
|
-
onClick={handleOpen}
|
|
115
|
-
loading={currentState.loading}
|
|
116
|
-
sx={{ mr: 1, ml: 1 }}>
|
|
117
|
-
{t('importResource')}
|
|
118
|
-
</Button>
|
|
119
|
-
)}
|
|
120
|
-
|
|
121
|
-
{currentState.showDialog && (
|
|
122
|
-
<ResourceDialog
|
|
123
|
-
ref={refIframe}
|
|
124
|
-
src={importUrl}
|
|
125
|
-
storeUrl={storeUrl}
|
|
126
|
-
open
|
|
127
|
-
componentDid={componentDid}
|
|
128
|
-
loading={currentState.loading}
|
|
129
|
-
onClose={handleClose}
|
|
130
|
-
onComplete={handleComplete}
|
|
131
|
-
onLoad={handleLoad}
|
|
132
|
-
/>
|
|
133
|
-
)}
|
|
134
|
-
</>
|
|
135
|
-
);
|
|
136
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { ReactElement, use } from 'react';
|
|
2
|
-
import Button from '@arcblock/ux/lib/Button';
|
|
3
|
-
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
4
|
-
import { BLOCKLET_SERVICE_PATH_PREFIX } from '@arcblock/ux/lib/Util/constant';
|
|
5
|
-
import { useMemoizedFn, useReactive } from 'ahooks';
|
|
6
|
-
import { translate } from '@arcblock/ux/lib/Locale/util';
|
|
7
|
-
import { SessionContext } from '@arcblock/did-connect-react/lib/Session';
|
|
8
|
-
import Toast from '@arcblock/ux/lib/Toast';
|
|
9
|
-
|
|
10
|
-
import type { SessionContext as TSessionContext } from '../../@types';
|
|
11
|
-
import ResourceDialog from './resource-dialog';
|
|
12
|
-
import { translations } from '../libs/locales';
|
|
13
|
-
|
|
14
|
-
export default function PublishComponent({
|
|
15
|
-
componentDid,
|
|
16
|
-
grantedRoles = undefined,
|
|
17
|
-
onClose,
|
|
18
|
-
render = undefined,
|
|
19
|
-
}: {
|
|
20
|
-
componentDid: string;
|
|
21
|
-
grantedRoles?: string[];
|
|
22
|
-
onClose: () => void;
|
|
23
|
-
render?: ({ onClick, loading }: { onClick: () => void; loading: boolean }) => ReactElement<any>;
|
|
24
|
-
}) {
|
|
25
|
-
const { session } = use<TSessionContext>(SessionContext);
|
|
26
|
-
const { locale } = useLocaleContext();
|
|
27
|
-
const t = useMemoizedFn((key, data = {}) => {
|
|
28
|
-
return translate(translations, key, locale, 'en', data);
|
|
29
|
-
});
|
|
30
|
-
const currentState = useReactive({
|
|
31
|
-
showDialog: false,
|
|
32
|
-
loading: false,
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
const exportUrl = `${BLOCKLET_SERVICE_PATH_PREFIX}/embed/resources/${componentDid}/publish?mode=dialog`;
|
|
36
|
-
|
|
37
|
-
const handleClose = useMemoizedFn(() => {
|
|
38
|
-
currentState.showDialog = false;
|
|
39
|
-
onClose?.();
|
|
40
|
-
});
|
|
41
|
-
const handleLoad = useMemoizedFn(() => {
|
|
42
|
-
currentState.loading = false;
|
|
43
|
-
});
|
|
44
|
-
const handleOpen = useMemoizedFn(() => {
|
|
45
|
-
if (!session.user) {
|
|
46
|
-
Toast.warning(t('needLogin'));
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (grantedRoles && grantedRoles.length > 0) {
|
|
51
|
-
if (!grantedRoles?.includes(session.user?.role)) {
|
|
52
|
-
Toast.warning(t('noPermission'));
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
currentState.loading = true;
|
|
57
|
-
currentState.showDialog = true;
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
return (
|
|
61
|
-
<>
|
|
62
|
-
{render ? (
|
|
63
|
-
render({ onClick: handleOpen, loading: currentState.loading })
|
|
64
|
-
) : (
|
|
65
|
-
<Button
|
|
66
|
-
key="button"
|
|
67
|
-
variant="outlined"
|
|
68
|
-
color="secondary"
|
|
69
|
-
type="button"
|
|
70
|
-
className="submit"
|
|
71
|
-
loading={currentState.loading}
|
|
72
|
-
onClick={handleOpen}
|
|
73
|
-
sx={{ mr: 1, ml: 1 }}>
|
|
74
|
-
{t('exportResource')}
|
|
75
|
-
</Button>
|
|
76
|
-
)}
|
|
77
|
-
|
|
78
|
-
{currentState.showDialog && (
|
|
79
|
-
<ResourceDialog
|
|
80
|
-
src={exportUrl}
|
|
81
|
-
open
|
|
82
|
-
onClose={handleClose}
|
|
83
|
-
onLoad={handleLoad}
|
|
84
|
-
componentDid={componentDid}
|
|
85
|
-
loading={currentState.loading}
|
|
86
|
-
/>
|
|
87
|
-
)}
|
|
88
|
-
</>
|
|
89
|
-
);
|
|
90
|
-
}
|