@abtnode/ux 1.16.16 → 1.16.17-beta-7ec31a60
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/es/blocklet/publish/create-project.js +188 -0
- package/es/blocklet/publish/create-release.js +643 -0
- package/es/blocklet/publish/index.js +37 -0
- package/es/blocklet/publish/project-list.js +190 -0
- package/es/blocklet/publish/release-list.js +274 -0
- package/es/blocklet/publish/resource.js +72 -0
- package/es/empty-spinner.js +24 -0
- package/es/locales/en.js +35 -0
- package/es/locales/zh.js +35 -0
- package/lib/blocklet/publish/create-project.js +197 -0
- package/lib/blocklet/publish/create-release.js +582 -0
- package/lib/blocklet/publish/index.js +44 -0
- package/lib/blocklet/publish/project-list.js +196 -0
- package/lib/blocklet/publish/release-list.js +270 -0
- package/lib/blocklet/publish/resource.js +78 -0
- package/lib/empty-spinner.js +40 -0
- package/lib/locales/en.js +35 -0
- package/lib/locales/zh.js +35 -0
- package/package.json +24 -18
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/* eslint-disable react/no-unstable-nested-components */
|
|
2
|
+
import React, { useState, useEffect } from 'react';
|
|
3
|
+
import { Link } from 'react-router-dom';
|
|
4
|
+
import styled from '@emotion/styled';
|
|
5
|
+
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
6
|
+
import Box from '@mui/material/Box';
|
|
7
|
+
import IconButton from '@mui/material/IconButton';
|
|
8
|
+
import DeleteIcon from '@mui/icons-material/Delete';
|
|
9
|
+
import Datatable from '@arcblock/ux/lib/Datatable';
|
|
10
|
+
import Button from '@arcblock/ux/lib/Button';
|
|
11
|
+
import Toast from '@arcblock/ux/lib/Toast';
|
|
12
|
+
import { useBlockletContext } from '../../contexts/blocklet';
|
|
13
|
+
import { useNodeContext } from '../../contexts/node';
|
|
14
|
+
import EmptySpinner from '../../empty-spinner';
|
|
15
|
+
import DidAddress from '../../did-address';
|
|
16
|
+
import Confirm from '../../confirm';
|
|
17
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
|
+
export default function ProjectList() {
|
|
20
|
+
const {
|
|
21
|
+
t,
|
|
22
|
+
locale
|
|
23
|
+
} = useLocaleContext();
|
|
24
|
+
const {
|
|
25
|
+
api
|
|
26
|
+
} = useNodeContext();
|
|
27
|
+
const [loading, setLoading] = useState(true);
|
|
28
|
+
const {
|
|
29
|
+
blocklet
|
|
30
|
+
} = useBlockletContext();
|
|
31
|
+
const [deleteConfirm, setDeleteConfirm] = useState(null);
|
|
32
|
+
const [projects, setProjects] = useState(null);
|
|
33
|
+
const getProjects = () => {
|
|
34
|
+
api.getProjects({
|
|
35
|
+
input: {
|
|
36
|
+
did: blocklet.meta.did
|
|
37
|
+
}
|
|
38
|
+
}).then(res => {
|
|
39
|
+
const list = res?.projects || [];
|
|
40
|
+
setLoading(false);
|
|
41
|
+
setProjects(list);
|
|
42
|
+
}).catch(err => {
|
|
43
|
+
setLoading(false);
|
|
44
|
+
Toast.error(err.message);
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
const onDeleteProject = project => {
|
|
48
|
+
setDeleteConfirm(project);
|
|
49
|
+
};
|
|
50
|
+
const deleteProject = () => {
|
|
51
|
+
setLoading(false);
|
|
52
|
+
const projectId = deleteConfirm.id;
|
|
53
|
+
api.deleteProject({
|
|
54
|
+
input: {
|
|
55
|
+
did: blocklet.meta.did,
|
|
56
|
+
projectId
|
|
57
|
+
}
|
|
58
|
+
}).then(() => {
|
|
59
|
+
setLoading(false);
|
|
60
|
+
getProjects();
|
|
61
|
+
Toast.success(t('common.removeSuccess'));
|
|
62
|
+
}).catch(err => {
|
|
63
|
+
setLoading(false);
|
|
64
|
+
Toast.error(err.message);
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
getProjects();
|
|
69
|
+
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
|
70
|
+
|
|
71
|
+
if (!projects && loading) {
|
|
72
|
+
return /*#__PURE__*/_jsx(EmptySpinner, {});
|
|
73
|
+
}
|
|
74
|
+
if (!projects) {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
if (!projects.length) {
|
|
78
|
+
return /*#__PURE__*/_jsxs(Box, {
|
|
79
|
+
display: "flex",
|
|
80
|
+
flexDirection: "column",
|
|
81
|
+
alignItems: "center",
|
|
82
|
+
pt: 10,
|
|
83
|
+
children: [/*#__PURE__*/_jsx(Box, {
|
|
84
|
+
sx: {
|
|
85
|
+
fontSize: 20,
|
|
86
|
+
fontWeight: 'bold',
|
|
87
|
+
mb: 3
|
|
88
|
+
},
|
|
89
|
+
children: t('blocklet.publish.blockletEmptyTip')
|
|
90
|
+
}), /*#__PURE__*/_jsx(Box, {
|
|
91
|
+
sx: {
|
|
92
|
+
fontSize: 14,
|
|
93
|
+
color: 'text.secondary',
|
|
94
|
+
mb: 3
|
|
95
|
+
},
|
|
96
|
+
children: t('blocklet.publish.createBlockletTip')
|
|
97
|
+
}), /*#__PURE__*/_jsx(Link, {
|
|
98
|
+
to: "create",
|
|
99
|
+
children: /*#__PURE__*/_jsx(Button, {
|
|
100
|
+
variant: "contained",
|
|
101
|
+
children: t('blocklet.publish.createBlocklet')
|
|
102
|
+
})
|
|
103
|
+
})]
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
const columns = [{
|
|
107
|
+
label: t('common.name'),
|
|
108
|
+
name: 'blockletTitle',
|
|
109
|
+
options: {
|
|
110
|
+
customBodyRenderLite: rawIndex => {
|
|
111
|
+
const project = projects[rawIndex];
|
|
112
|
+
return /*#__PURE__*/_jsx(Link, {
|
|
113
|
+
to: `${project.id}`,
|
|
114
|
+
children: project.blockletTitle || '/'
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}, {
|
|
119
|
+
label: t('common.address'),
|
|
120
|
+
name: 'blockletDid',
|
|
121
|
+
options: {
|
|
122
|
+
customBodyRender: e => {
|
|
123
|
+
return /*#__PURE__*/_jsx(DidAddress, {
|
|
124
|
+
size: 14,
|
|
125
|
+
responsive: true,
|
|
126
|
+
did: e
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}, {
|
|
131
|
+
label: t('common.actions'),
|
|
132
|
+
name: 'actions',
|
|
133
|
+
options: {
|
|
134
|
+
customBodyRenderLite: rawIndex => {
|
|
135
|
+
const project = projects[rawIndex];
|
|
136
|
+
return /*#__PURE__*/_jsx(Box, {
|
|
137
|
+
display: "flex",
|
|
138
|
+
children: /*#__PURE__*/_jsx(IconButton, {
|
|
139
|
+
color: "error",
|
|
140
|
+
"aria-label": "delete",
|
|
141
|
+
onClick: () => onDeleteProject(project),
|
|
142
|
+
children: /*#__PURE__*/_jsx(DeleteIcon, {
|
|
143
|
+
sx: {
|
|
144
|
+
fontSize: 18
|
|
145
|
+
}
|
|
146
|
+
})
|
|
147
|
+
})
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}];
|
|
152
|
+
return /*#__PURE__*/_jsxs(Main, {
|
|
153
|
+
children: [/*#__PURE__*/_jsx(Box, {
|
|
154
|
+
sx: {
|
|
155
|
+
textAlign: 'right'
|
|
156
|
+
},
|
|
157
|
+
children: /*#__PURE__*/_jsx(Link, {
|
|
158
|
+
to: "create",
|
|
159
|
+
children: /*#__PURE__*/_jsx(Button, {
|
|
160
|
+
variant: "contained",
|
|
161
|
+
children: t('blocklet.publish.createBlocklet')
|
|
162
|
+
})
|
|
163
|
+
})
|
|
164
|
+
}), /*#__PURE__*/_jsx(Datatable, {
|
|
165
|
+
className: "main-table",
|
|
166
|
+
locale: locale,
|
|
167
|
+
data: projects,
|
|
168
|
+
columns: columns,
|
|
169
|
+
options: {
|
|
170
|
+
sort: false,
|
|
171
|
+
download: false,
|
|
172
|
+
filter: false,
|
|
173
|
+
print: false,
|
|
174
|
+
search: false
|
|
175
|
+
}
|
|
176
|
+
}), deleteConfirm && /*#__PURE__*/_jsx(Confirm, {
|
|
177
|
+
title: `${t('common.delete')} ${deleteConfirm.blockletTitle}`,
|
|
178
|
+
description: t('blocklet.publish.deleteBlockletTip'),
|
|
179
|
+
confirm: t('common.confirm'),
|
|
180
|
+
onConfirm: deleteProject,
|
|
181
|
+
onCancel: () => setDeleteConfirm(null)
|
|
182
|
+
})]
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
ProjectList.propTypes = {};
|
|
186
|
+
const Main = styled(Box)`
|
|
187
|
+
.main-table > div:first-child {
|
|
188
|
+
display: none;
|
|
189
|
+
}
|
|
190
|
+
`;
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
/* eslint-disable react/no-unstable-nested-components */
|
|
2
|
+
import React, { useState, useEffect } from 'react';
|
|
3
|
+
import { Link, useParams } from 'react-router-dom';
|
|
4
|
+
import styled from '@emotion/styled';
|
|
5
|
+
import joinUrl from 'url-join';
|
|
6
|
+
import upperFirst from 'lodash/upperFirst';
|
|
7
|
+
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
8
|
+
import Box from '@mui/material/Box';
|
|
9
|
+
import IconButton from '@mui/material/IconButton';
|
|
10
|
+
import Typography from '@mui/material/Typography';
|
|
11
|
+
import Breadcrumbs from '@mui/material/Breadcrumbs';
|
|
12
|
+
import DownloadIcon from '@mui/icons-material/Download';
|
|
13
|
+
import DeleteIcon from '@mui/icons-material/Delete';
|
|
14
|
+
import Datatable from '@arcblock/ux/lib/Datatable';
|
|
15
|
+
import { WELLKNOWN_SERVICE_PATH_PREFIX } from '@abtnode/constant';
|
|
16
|
+
import Button from '@arcblock/ux/lib/Button';
|
|
17
|
+
import Toast from '@arcblock/ux/lib/Toast';
|
|
18
|
+
import Tag from '@arcblock/ux/lib/Tag';
|
|
19
|
+
import { useBlockletContext } from '../../contexts/blocklet';
|
|
20
|
+
import { useNodeContext } from '../../contexts/node';
|
|
21
|
+
import EmptySpinner from '../../empty-spinner';
|
|
22
|
+
import Confirm from '../../confirm';
|
|
23
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
25
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
26
|
+
export default function ReleaseList() {
|
|
27
|
+
const {
|
|
28
|
+
t,
|
|
29
|
+
locale
|
|
30
|
+
} = useLocaleContext();
|
|
31
|
+
const {
|
|
32
|
+
projectId
|
|
33
|
+
} = useParams();
|
|
34
|
+
const {
|
|
35
|
+
api
|
|
36
|
+
} = useNodeContext();
|
|
37
|
+
const [loading, setLoading] = useState(true);
|
|
38
|
+
const {
|
|
39
|
+
blocklet
|
|
40
|
+
} = useBlockletContext();
|
|
41
|
+
const [releases, setReleases] = useState(null);
|
|
42
|
+
const [project, setProject] = useState(null);
|
|
43
|
+
const [deleteConfirm, setDeleteConfirm] = useState(null);
|
|
44
|
+
const getReleases = () => {
|
|
45
|
+
api.getReleases({
|
|
46
|
+
input: {
|
|
47
|
+
did: blocklet.meta.did,
|
|
48
|
+
projectId
|
|
49
|
+
}
|
|
50
|
+
}).then(res => {
|
|
51
|
+
const list = res?.releases || [];
|
|
52
|
+
setLoading(false);
|
|
53
|
+
setReleases(list);
|
|
54
|
+
}).catch(err => {
|
|
55
|
+
setLoading(false);
|
|
56
|
+
Toast.error(err.message);
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
const getData = () => {
|
|
60
|
+
api.doBatchQuery({
|
|
61
|
+
getProject: {
|
|
62
|
+
input: {
|
|
63
|
+
did: blocklet.meta.did,
|
|
64
|
+
projectId
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
getReleases: {
|
|
68
|
+
input: {
|
|
69
|
+
did: blocklet.meta.did,
|
|
70
|
+
projectId
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}).then(res => {
|
|
74
|
+
setProject(res.getProject.project || {});
|
|
75
|
+
setReleases(res.getReleases.releases || []);
|
|
76
|
+
setLoading(false);
|
|
77
|
+
}).catch(err => {
|
|
78
|
+
setLoading(false);
|
|
79
|
+
Toast.error(err.message);
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
getData();
|
|
84
|
+
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
|
85
|
+
|
|
86
|
+
const deleteRelease = () => {
|
|
87
|
+
setLoading(false);
|
|
88
|
+
const releaseId = deleteConfirm.id;
|
|
89
|
+
api.deleteRelease({
|
|
90
|
+
input: {
|
|
91
|
+
did: blocklet.meta.did,
|
|
92
|
+
projectId,
|
|
93
|
+
releaseId
|
|
94
|
+
}
|
|
95
|
+
}).then(() => {
|
|
96
|
+
setLoading(false);
|
|
97
|
+
getReleases();
|
|
98
|
+
Toast.success(t('common.removeSuccess'));
|
|
99
|
+
}).catch(err => {
|
|
100
|
+
setLoading(false);
|
|
101
|
+
Toast.error(err.message);
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
const onDeleteRelease = release => {
|
|
105
|
+
setDeleteConfirm(release);
|
|
106
|
+
};
|
|
107
|
+
if (!releases && loading) {
|
|
108
|
+
return /*#__PURE__*/_jsx(EmptySpinner, {});
|
|
109
|
+
}
|
|
110
|
+
if (!releases) {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
const breadcrumbs = /*#__PURE__*/_jsxs(Breadcrumbs, {
|
|
114
|
+
className: "breadcrumbs",
|
|
115
|
+
"aria-label": "breadcrumb",
|
|
116
|
+
children: [/*#__PURE__*/_jsx(Link, {
|
|
117
|
+
to: "..",
|
|
118
|
+
children: t('common.publish')
|
|
119
|
+
}), /*#__PURE__*/_jsx(Typography, {
|
|
120
|
+
color: "text.primary",
|
|
121
|
+
children: project.blockletTitle
|
|
122
|
+
})]
|
|
123
|
+
});
|
|
124
|
+
if (!releases.length) {
|
|
125
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
126
|
+
children: [breadcrumbs, /*#__PURE__*/_jsxs(Box, {
|
|
127
|
+
display: "flex",
|
|
128
|
+
flexDirection: "column",
|
|
129
|
+
alignItems: "center",
|
|
130
|
+
pt: 10,
|
|
131
|
+
children: [/*#__PURE__*/_jsx(Box, {
|
|
132
|
+
sx: {
|
|
133
|
+
fontSize: 20,
|
|
134
|
+
fontWeight: 'bold',
|
|
135
|
+
mb: 3
|
|
136
|
+
},
|
|
137
|
+
children: t('blocklet.publish.releaseEmptyTip')
|
|
138
|
+
}), /*#__PURE__*/_jsx(Box, {
|
|
139
|
+
sx: {
|
|
140
|
+
fontSize: 14,
|
|
141
|
+
color: 'text.secondary',
|
|
142
|
+
mb: 3
|
|
143
|
+
},
|
|
144
|
+
children: t('blocklet.publish.createReleaseTip')
|
|
145
|
+
}), /*#__PURE__*/_jsx(Link, {
|
|
146
|
+
to: "create",
|
|
147
|
+
children: /*#__PURE__*/_jsx(Button, {
|
|
148
|
+
variant: "contained",
|
|
149
|
+
children: t('blocklet.publish.createRelease')
|
|
150
|
+
})
|
|
151
|
+
})]
|
|
152
|
+
})]
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
const columns = [{
|
|
156
|
+
label: t('common.version'),
|
|
157
|
+
name: 'blockletVersion',
|
|
158
|
+
options: {
|
|
159
|
+
customBodyRenderLite: rawIndex => {
|
|
160
|
+
const release = releases[rawIndex];
|
|
161
|
+
return /*#__PURE__*/_jsx(Link, {
|
|
162
|
+
to: `${release.id}`,
|
|
163
|
+
children: release.blockletVersion || '/'
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}, {
|
|
168
|
+
label: t('blocklet.publish.releaseNote'),
|
|
169
|
+
name: 'note',
|
|
170
|
+
options: {
|
|
171
|
+
customBodyRenderLite: rawIndex => {
|
|
172
|
+
const release = releases[rawIndex];
|
|
173
|
+
return /*#__PURE__*/_jsx(Typography, {
|
|
174
|
+
className: "note",
|
|
175
|
+
children: release.note || ''
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}, {
|
|
180
|
+
label: t('common.status'),
|
|
181
|
+
name: 'status',
|
|
182
|
+
options: {
|
|
183
|
+
customBodyRender: value => {
|
|
184
|
+
return /*#__PURE__*/_jsx(Tag, {
|
|
185
|
+
type: value === 'published' ? 'success' : 'warning',
|
|
186
|
+
children: upperFirst(value)
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}, {
|
|
191
|
+
label: t('common.actions'),
|
|
192
|
+
name: 'actions',
|
|
193
|
+
options: {
|
|
194
|
+
customBodyRenderLite: rawIndex => {
|
|
195
|
+
const release = releases[rawIndex];
|
|
196
|
+
return /*#__PURE__*/_jsxs(Box, {
|
|
197
|
+
display: "flex",
|
|
198
|
+
children: [/*#__PURE__*/_jsx(IconButton, {
|
|
199
|
+
color: "primary",
|
|
200
|
+
"aria-label": "download",
|
|
201
|
+
disabled: release.status !== 'published',
|
|
202
|
+
children: release.status === 'published' ? /*#__PURE__*/_jsx("a", {
|
|
203
|
+
href: joinUrl(`${WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${blocklet.meta.did}/${project.id}/${release.id}/download/${(release.files || [])[0]}`),
|
|
204
|
+
children: /*#__PURE__*/_jsx(DownloadIcon, {
|
|
205
|
+
sx: {
|
|
206
|
+
fontSize: 18
|
|
207
|
+
}
|
|
208
|
+
})
|
|
209
|
+
}) : /*#__PURE__*/_jsx(DownloadIcon, {
|
|
210
|
+
sx: {
|
|
211
|
+
fontSize: 18
|
|
212
|
+
}
|
|
213
|
+
})
|
|
214
|
+
}), /*#__PURE__*/_jsx(IconButton, {
|
|
215
|
+
color: "error",
|
|
216
|
+
"aria-label": "delete",
|
|
217
|
+
onClick: () => onDeleteRelease(release),
|
|
218
|
+
children: /*#__PURE__*/_jsx(DeleteIcon, {
|
|
219
|
+
sx: {
|
|
220
|
+
fontSize: 18
|
|
221
|
+
}
|
|
222
|
+
})
|
|
223
|
+
})]
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}];
|
|
228
|
+
return /*#__PURE__*/_jsxs(Main, {
|
|
229
|
+
children: [/*#__PURE__*/_jsxs(Box, {
|
|
230
|
+
className: "header",
|
|
231
|
+
children: [breadcrumbs, /*#__PURE__*/_jsx(Link, {
|
|
232
|
+
to: "create",
|
|
233
|
+
children: /*#__PURE__*/_jsx(Button, {
|
|
234
|
+
variant: "contained",
|
|
235
|
+
children: t('blocklet.publish.createRelease')
|
|
236
|
+
})
|
|
237
|
+
})]
|
|
238
|
+
}), /*#__PURE__*/_jsx(Datatable, {
|
|
239
|
+
className: "main-table",
|
|
240
|
+
verticalKeyWidth: 100,
|
|
241
|
+
locale: locale,
|
|
242
|
+
data: releases,
|
|
243
|
+
columns: columns,
|
|
244
|
+
options: {
|
|
245
|
+
sort: false,
|
|
246
|
+
download: false,
|
|
247
|
+
filter: false,
|
|
248
|
+
print: false,
|
|
249
|
+
search: false
|
|
250
|
+
}
|
|
251
|
+
}), deleteConfirm && /*#__PURE__*/_jsx(Confirm, {
|
|
252
|
+
title: t(`${t('common.delete')} ${deleteConfirm.blockletVersion}`),
|
|
253
|
+
description: t('blocklet.publish.deleteReleaseTip'),
|
|
254
|
+
confirm: t('common.confirm'),
|
|
255
|
+
onConfirm: deleteRelease,
|
|
256
|
+
onCancel: () => setDeleteConfirm(null)
|
|
257
|
+
})]
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
ReleaseList.propTypes = {};
|
|
261
|
+
const Main = styled(Box)`
|
|
262
|
+
.header {
|
|
263
|
+
display: flex;
|
|
264
|
+
align-items: center;
|
|
265
|
+
justify-content: space-between;
|
|
266
|
+
}
|
|
267
|
+
.main-table > div:first-child {
|
|
268
|
+
display: none;
|
|
269
|
+
}
|
|
270
|
+
.note {
|
|
271
|
+
word-break: break-all;
|
|
272
|
+
white-space: pre-line;
|
|
273
|
+
}
|
|
274
|
+
`;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/* eslint-disable no-unused-vars */
|
|
2
|
+
/* eslint-disable react/no-unstable-nested-components */
|
|
3
|
+
import { useState, useRef, useEffect } from 'react';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import styled from '@emotion/styled';
|
|
6
|
+
import Box from '@mui/material/Box';
|
|
7
|
+
import joinUrl from 'url-join';
|
|
8
|
+
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
export default function Resource({
|
|
11
|
+
app,
|
|
12
|
+
component,
|
|
13
|
+
projectId,
|
|
14
|
+
release
|
|
15
|
+
}) {
|
|
16
|
+
const {
|
|
17
|
+
t,
|
|
18
|
+
locale
|
|
19
|
+
} = useLocaleContext();
|
|
20
|
+
const iframeRef = useRef(null);
|
|
21
|
+
const releaseId = release.id;
|
|
22
|
+
const readonly = release.status === 'published';
|
|
23
|
+
const {
|
|
24
|
+
resourceExportPage = '/'
|
|
25
|
+
} = component?.meta.capabilities || {};
|
|
26
|
+
const url = new URL(joinUrl('http://127.0.0.1', component.mountPoint, resourceExportPage).replace(/\/+/g, '/'));
|
|
27
|
+
url.searchParams.set('projectId', projectId);
|
|
28
|
+
url.searchParams.set('releaseId', releaseId);
|
|
29
|
+
url.searchParams.set('local', locale);
|
|
30
|
+
if (readonly) {
|
|
31
|
+
url.searchParams.set('readonly', '1');
|
|
32
|
+
}
|
|
33
|
+
const src = `${url.pathname}${url.search}`;
|
|
34
|
+
if (component.status !== 'running') {
|
|
35
|
+
return /*#__PURE__*/_jsx(Container, {
|
|
36
|
+
children: /*#__PURE__*/_jsx(Box, {
|
|
37
|
+
pt: 6,
|
|
38
|
+
children: t('blocklet.publish.componentNotRunning', {
|
|
39
|
+
name: component.meta.title
|
|
40
|
+
})
|
|
41
|
+
})
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
return /*#__PURE__*/_jsx(Container, {
|
|
45
|
+
children: /*#__PURE__*/_jsx("iframe", {
|
|
46
|
+
ref: iframeRef,
|
|
47
|
+
title: component.meta.title,
|
|
48
|
+
src: src,
|
|
49
|
+
width: "100%",
|
|
50
|
+
height: "600px"
|
|
51
|
+
})
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
Resource.propTypes = {
|
|
55
|
+
component: PropTypes.object.isRequired,
|
|
56
|
+
app: PropTypes.object.isRequired,
|
|
57
|
+
projectId: PropTypes.string.isRequired,
|
|
58
|
+
release: PropTypes.shape({
|
|
59
|
+
id: PropTypes.string.isRequired,
|
|
60
|
+
status: PropTypes.string
|
|
61
|
+
})
|
|
62
|
+
};
|
|
63
|
+
Resource.defaultProps = {
|
|
64
|
+
release: {
|
|
65
|
+
id: ''
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
const Container = styled(Box)`
|
|
69
|
+
iframe {
|
|
70
|
+
border: none;
|
|
71
|
+
}
|
|
72
|
+
`;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import Box from '@mui/material/Box';
|
|
4
|
+
import Spinner from '@mui/material/CircularProgress';
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
export default function EmptySpinner({
|
|
7
|
+
size,
|
|
8
|
+
...rest
|
|
9
|
+
}) {
|
|
10
|
+
return /*#__PURE__*/_jsx(Box, {
|
|
11
|
+
display: "flex",
|
|
12
|
+
mt: 4,
|
|
13
|
+
...rest,
|
|
14
|
+
children: /*#__PURE__*/_jsx(Spinner, {
|
|
15
|
+
size: size
|
|
16
|
+
})
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
EmptySpinner.propTypes = {
|
|
20
|
+
size: PropTypes.number
|
|
21
|
+
};
|
|
22
|
+
EmptySpinner.defaultProps = {
|
|
23
|
+
size: 24
|
|
24
|
+
};
|
package/es/locales/en.js
CHANGED
|
@@ -177,6 +177,7 @@ module.exports = {
|
|
|
177
177
|
installSuccess: 'Successfully installed',
|
|
178
178
|
installing: 'Installing',
|
|
179
179
|
internalIp: 'Internal IP',
|
|
180
|
+
introduction: 'Introduction',
|
|
180
181
|
invite: 'Invite',
|
|
181
182
|
inviting: 'Inviting',
|
|
182
183
|
ip: 'IP',
|
|
@@ -228,6 +229,7 @@ module.exports = {
|
|
|
228
229
|
preferences: 'Preferences',
|
|
229
230
|
protected: 'Protected',
|
|
230
231
|
protocol: 'Protocol',
|
|
232
|
+
publish: 'Publish',
|
|
231
233
|
published: 'published',
|
|
232
234
|
purchase: 'Purchase',
|
|
233
235
|
readMore: 'More',
|
|
@@ -237,11 +239,13 @@ module.exports = {
|
|
|
237
239
|
redirectTemporary: 'Temporary Redirect',
|
|
238
240
|
redirectUrl: 'Redirect URL',
|
|
239
241
|
rewrite: 'Rewrite',
|
|
242
|
+
release: 'Release',
|
|
240
243
|
rewriteUrl: 'Rewrite URL',
|
|
241
244
|
reject: 'Reject',
|
|
242
245
|
reload: 'Reload',
|
|
243
246
|
remark: 'Remark',
|
|
244
247
|
remove: 'Remove',
|
|
248
|
+
removeSuccess: 'Remove successfully',
|
|
245
249
|
renew: 'Renew',
|
|
246
250
|
reportIssue: 'Report an issue',
|
|
247
251
|
required: 'Required',
|
|
@@ -259,6 +263,7 @@ module.exports = {
|
|
|
259
263
|
saveSuccess: 'Saved successfully',
|
|
260
264
|
scheduleFailed: 'schedule failed',
|
|
261
265
|
scheduleSuccess: 'successfully scheduled',
|
|
266
|
+
screenshot: 'Screenshot',
|
|
262
267
|
search: 'Search',
|
|
263
268
|
security: 'Security',
|
|
264
269
|
serverDid: 'Server DID',
|
|
@@ -602,6 +607,36 @@ module.exports = {
|
|
|
602
607
|
error: {
|
|
603
608
|
isRunning: 'Blocklet is running, please stop it first',
|
|
604
609
|
isInProgress: 'Blocklet is in progress, please wait for it to finish'
|
|
610
|
+
},
|
|
611
|
+
publish: {
|
|
612
|
+
productTitle: 'Product',
|
|
613
|
+
versionTitle: 'Version',
|
|
614
|
+
imgTitle: 'Images',
|
|
615
|
+
resourceTitle: 'Resources',
|
|
616
|
+
blockletEmptyTip: 'There aren’t any blocklets here',
|
|
617
|
+
createBlockletTip: 'You can create new blocklet through existing resources, components, and configuration in this application',
|
|
618
|
+
createBlocklet: 'Create a new blocklet',
|
|
619
|
+
deleteBlockletTip: 'The blocklet cannot be recovered after deletion, please confirm',
|
|
620
|
+
componentNotRunning: 'Component {name} is not running, please start it first',
|
|
621
|
+
releaseEmptyTip: 'There aren’t any releases here',
|
|
622
|
+
createReleaseTip: 'You can create a release of the blocklet, along with release notes and resources, for other people to use',
|
|
623
|
+
createRelease: 'Create a new release',
|
|
624
|
+
deleteReleaseTip: 'The release cannot be recovered after deletion',
|
|
625
|
+
createBlockletDid: 'Create from DID Wallet',
|
|
626
|
+
connect: {
|
|
627
|
+
title: 'Create Blocklet DID',
|
|
628
|
+
scan: 'Scan the QR code below to generate Blocklet DID',
|
|
629
|
+
confirm: 'Confirm using DID Wallet',
|
|
630
|
+
success: 'Blocklet DID has been generated, please continue your operation'
|
|
631
|
+
},
|
|
632
|
+
saveDraft: 'Save Draft',
|
|
633
|
+
releaseNote: 'Release Note',
|
|
634
|
+
errorTip: {
|
|
635
|
+
noTitle: 'Blocklet Title is required',
|
|
636
|
+
noVersion: 'Blocklet Version is required',
|
|
637
|
+
noDescription: 'Blocklet Description is required',
|
|
638
|
+
noNote: 'Release Note is required'
|
|
639
|
+
}
|
|
605
640
|
}
|
|
606
641
|
},
|
|
607
642
|
dashboard: {
|
package/es/locales/zh.js
CHANGED
|
@@ -182,6 +182,7 @@ module.exports = {
|
|
|
182
182
|
installSuccess: '安装成功',
|
|
183
183
|
installing: '安装中',
|
|
184
184
|
internalIp: '内网 IP',
|
|
185
|
+
introduction: '介绍',
|
|
185
186
|
invite: '邀请',
|
|
186
187
|
inviting: '邀请中',
|
|
187
188
|
ip: 'IP',
|
|
@@ -233,6 +234,7 @@ module.exports = {
|
|
|
233
234
|
preferences: '偏好',
|
|
234
235
|
protected: '受保护',
|
|
235
236
|
protocol: '协议',
|
|
237
|
+
publish: '发布',
|
|
236
238
|
published: '发布于',
|
|
237
239
|
purchase: '购买',
|
|
238
240
|
readMore: '更多',
|
|
@@ -243,10 +245,12 @@ module.exports = {
|
|
|
243
245
|
redirectUrl: '重定向 URL',
|
|
244
246
|
rewriteUrl: '重写到 URL',
|
|
245
247
|
rewrite: '重写',
|
|
248
|
+
release: '发布',
|
|
246
249
|
reject: '拒绝',
|
|
247
250
|
reload: '优雅重启',
|
|
248
251
|
remark: '备注',
|
|
249
252
|
remove: '删除',
|
|
253
|
+
removeSuccess: '删除成功',
|
|
250
254
|
renew: '续期',
|
|
251
255
|
reportIssue: '问题反馈',
|
|
252
256
|
required: '必需的',
|
|
@@ -264,6 +268,7 @@ module.exports = {
|
|
|
264
268
|
saveSuccess: '保存成功',
|
|
265
269
|
scheduleFailed: '加入任务队列失败',
|
|
266
270
|
scheduleSuccess: '成功加入任务队列',
|
|
271
|
+
screenshot: '截图',
|
|
267
272
|
search: '搜索',
|
|
268
273
|
security: '安全',
|
|
269
274
|
serverDid: '服务器 DID',
|
|
@@ -609,6 +614,36 @@ module.exports = {
|
|
|
609
614
|
error: {
|
|
610
615
|
isRunning: '应用正在运行,请先停止运行',
|
|
611
616
|
isInProgress: '应用正在进行中,请等待完成'
|
|
617
|
+
},
|
|
618
|
+
publish: {
|
|
619
|
+
productTitle: 'Blocklet 详情',
|
|
620
|
+
versionTitle: '版本信息',
|
|
621
|
+
imgTitle: '图片资源',
|
|
622
|
+
resourceTitle: '组件资源',
|
|
623
|
+
blockletEmptyTip: '这里没有任何 blocklet',
|
|
624
|
+
createBlockletTip: '你可以使用此应用的资源,组件,配置制作新的 Blocklet',
|
|
625
|
+
createBlocklet: '创建 Blocklet',
|
|
626
|
+
deleteBlockletTip: '此 Blocklet 删除后不可恢复,是否继续?',
|
|
627
|
+
componentNotRunning: '组件 {name} 未运行',
|
|
628
|
+
releaseEmptyTip: '这里没有任何发布',
|
|
629
|
+
createReleaseTip: '您可以创建 Blocklet 发布,在发布中包含说明和资源,以供其他人使用',
|
|
630
|
+
createRelease: '创建新的发布',
|
|
631
|
+
deleteReleaseTip: '此发布删除后不可恢复,是否继续?',
|
|
632
|
+
createBlockletDid: '通过 DID 钱包创建',
|
|
633
|
+
connect: {
|
|
634
|
+
title: '创建 Blocklet DID',
|
|
635
|
+
scan: '扫描下面的二维码来生成 Blocklet DID',
|
|
636
|
+
confirm: '使用 DID Wallet 确认',
|
|
637
|
+
success: 'Blocklet DID 已经生成,请继续您的操作'
|
|
638
|
+
},
|
|
639
|
+
saveDraft: '保存草稿',
|
|
640
|
+
releaseNote: '发布说明',
|
|
641
|
+
errorTip: {
|
|
642
|
+
noTitle: '请填写 Blocklet 名称',
|
|
643
|
+
noVersion: '请填写 Blocklet 版本号',
|
|
644
|
+
noDescription: '请填写 Blocklet 描述',
|
|
645
|
+
noNote: '请填写 发布说明'
|
|
646
|
+
}
|
|
612
647
|
}
|
|
613
648
|
},
|
|
614
649
|
dashboard: {
|