@orange-soft/strapi-deployment-trigger 1.0.1 → 1.1.2
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/admin/src/pages/HomePage.jsx +117 -62
- package/admin/src/pages/SettingsPage.jsx +274 -101
- package/dist/_chunks/App-CCbQMMHR.js +669 -0
- package/dist/_chunks/App-DRqMK_8x.mjs +669 -0
- package/dist/_chunks/{index-CqpMwL_C.js → index-SuWmJtOE.js} +1 -1
- package/dist/_chunks/{index-C18aSW5z.mjs → index-vQ0KWcpU.mjs} +1 -1
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/server/index.js +164 -24
- package/dist/server/index.mjs +164 -24
- package/package.json +1 -1
- package/server/src/controllers/controller.js +58 -3
- package/server/src/routes/admin/index.js +25 -0
- package/server/src/services/service.js +122 -24
- package/dist/_chunks/App-3JntxPYv.js +0 -520
- package/dist/_chunks/App-C0Byi5W1.mjs +0 -520
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {useState, useEffect} from 'react';
|
|
2
2
|
import {useIntl} from 'react-intl';
|
|
3
3
|
import {Layouts, useFetchClient} from '@strapi/strapi/admin';
|
|
4
|
-
import {Link} from 'react-router-dom';
|
|
4
|
+
import {Link, useLocation} from 'react-router-dom';
|
|
5
5
|
import {
|
|
6
6
|
Box,
|
|
7
7
|
Button,
|
|
@@ -9,6 +9,12 @@ import {
|
|
|
9
9
|
Typography,
|
|
10
10
|
Alert,
|
|
11
11
|
Loader,
|
|
12
|
+
Table,
|
|
13
|
+
Thead,
|
|
14
|
+
Tbody,
|
|
15
|
+
Tr,
|
|
16
|
+
Th,
|
|
17
|
+
Td,
|
|
12
18
|
} from '@strapi/design-system';
|
|
13
19
|
import {Rocket, Cog} from '@strapi/icons';
|
|
14
20
|
|
|
@@ -18,13 +24,20 @@ import {getTranslation} from '../utils/getTranslation';
|
|
|
18
24
|
const HomePage = () => {
|
|
19
25
|
const {formatMessage} = useIntl();
|
|
20
26
|
const {get, post} = useFetchClient();
|
|
27
|
+
const location = useLocation();
|
|
21
28
|
const [status, setStatus] = useState(null);
|
|
22
29
|
const [loading, setLoading] = useState(true);
|
|
23
|
-
const [
|
|
30
|
+
const [deployingTargetId, setDeployingTargetId] = useState(null);
|
|
24
31
|
const [notification, setNotification] = useState(null);
|
|
25
32
|
|
|
26
33
|
useEffect(() => {
|
|
27
34
|
fetchStatus();
|
|
35
|
+
// Check for notification from navigation state (e.g., after saving settings)
|
|
36
|
+
if (location.state?.notification) {
|
|
37
|
+
setNotification(location.state.notification);
|
|
38
|
+
// Clear the state so notification doesn't reappear on refresh
|
|
39
|
+
window.history.replaceState({}, document.title);
|
|
40
|
+
}
|
|
28
41
|
}, []);
|
|
29
42
|
|
|
30
43
|
const fetchStatus = async () => {
|
|
@@ -38,23 +51,23 @@ const HomePage = () => {
|
|
|
38
51
|
}
|
|
39
52
|
};
|
|
40
53
|
|
|
41
|
-
const handleDeploy = async () => {
|
|
42
|
-
|
|
54
|
+
const handleDeploy = async (targetId, targetName) => {
|
|
55
|
+
setDeployingTargetId(targetId);
|
|
43
56
|
setNotification(null);
|
|
44
57
|
try {
|
|
45
|
-
const {data} = await post(`/${PLUGIN_ID}/trigger`, {});
|
|
58
|
+
const {data} = await post(`/${PLUGIN_ID}/trigger`, { targetId });
|
|
46
59
|
setNotification({
|
|
47
60
|
type: 'success',
|
|
48
|
-
message: data.data?.message || 'Deployment triggered successfully!'
|
|
61
|
+
message: `${targetName}: ${data.data?.message || 'Deployment triggered successfully!'}`,
|
|
49
62
|
actionsUrl: data.data?.actionsUrl,
|
|
50
63
|
});
|
|
51
64
|
} catch (error) {
|
|
52
65
|
setNotification({
|
|
53
66
|
type: 'danger',
|
|
54
|
-
message: error?.response?.data?.error?.message || error.message || 'Deployment failed'
|
|
67
|
+
message: `${targetName}: ${error?.response?.data?.error?.message || error.message || 'Deployment failed'}`,
|
|
55
68
|
});
|
|
56
69
|
} finally {
|
|
57
|
-
|
|
70
|
+
setDeployingTargetId(null);
|
|
58
71
|
}
|
|
59
72
|
};
|
|
60
73
|
|
|
@@ -78,12 +91,13 @@ const HomePage = () => {
|
|
|
78
91
|
const parsed = status?.parsed || {};
|
|
79
92
|
const isConfigured = status?.configured;
|
|
80
93
|
const hasToken = status?.hasToken;
|
|
94
|
+
const targets = settings.targets || [];
|
|
81
95
|
|
|
82
96
|
return (
|
|
83
97
|
<Layouts.Root>
|
|
84
98
|
<Layouts.Header
|
|
85
99
|
title={formatMessage({id: getTranslation('plugin.name')})}
|
|
86
|
-
subtitle="Trigger GitHub Actions deployment
|
|
100
|
+
subtitle="Trigger GitHub Actions deployment"
|
|
87
101
|
secondaryAction={
|
|
88
102
|
<Link to={`/plugins/${PLUGIN_ID}/settings`}>
|
|
89
103
|
<Button variant="tertiary" startIcon={<Cog />}>
|
|
@@ -137,7 +151,7 @@ const HomePage = () => {
|
|
|
137
151
|
)}
|
|
138
152
|
|
|
139
153
|
<Flex direction="column" alignItems="stretch" gap={4}>
|
|
140
|
-
{/* Repository
|
|
154
|
+
{/* Repository Info Card */}
|
|
141
155
|
<Box
|
|
142
156
|
background="neutral0"
|
|
143
157
|
hasRadius
|
|
@@ -149,78 +163,119 @@ const HomePage = () => {
|
|
|
149
163
|
>
|
|
150
164
|
<Flex direction="column" alignItems="stretch" gap={4}>
|
|
151
165
|
<Typography variant="delta" tag="h2">
|
|
152
|
-
|
|
166
|
+
Repository
|
|
153
167
|
</Typography>
|
|
154
168
|
|
|
155
|
-
<
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
<Typography
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
>
|
|
169
|
-
{parsed.owner}/{parsed.repo}
|
|
170
|
-
</Typography>
|
|
171
|
-
) : (
|
|
172
|
-
<Typography variant="pi" textColor="neutral500">Not configured</Typography>
|
|
173
|
-
)}
|
|
174
|
-
|
|
175
|
-
<Typography variant="sigma" textColor="neutral600">Workflow</Typography>
|
|
176
|
-
<Typography variant="pi">
|
|
177
|
-
{settings.workflow || 'deploy.yml (default)'}
|
|
169
|
+
<Box style={{ display: 'grid', gridTemplateColumns: '120px 1fr', gap: '12px 16px', alignItems: 'center' }}>
|
|
170
|
+
<Typography variant="sigma" textColor="neutral600">Repository</Typography>
|
|
171
|
+
{parsed.owner && parsed.repo ? (
|
|
172
|
+
<Typography
|
|
173
|
+
variant="pi"
|
|
174
|
+
tag="a"
|
|
175
|
+
href={settings.repoUrl}
|
|
176
|
+
target="_blank"
|
|
177
|
+
rel="noopener noreferrer"
|
|
178
|
+
textColor="primary600"
|
|
179
|
+
style={{ textDecoration: 'none' }}
|
|
180
|
+
>
|
|
181
|
+
{parsed.owner}/{parsed.repo}
|
|
178
182
|
</Typography>
|
|
183
|
+
) : (
|
|
184
|
+
<Typography variant="pi" textColor="neutral500">Not configured</Typography>
|
|
185
|
+
)}
|
|
179
186
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
187
|
+
<Typography variant="sigma" textColor="neutral600">GitHub Token</Typography>
|
|
188
|
+
<Typography variant="pi" textColor={hasToken ? 'success600' : 'danger600'}>
|
|
189
|
+
{hasToken ? 'Configured' : 'Missing'}
|
|
190
|
+
</Typography>
|
|
191
|
+
</Box>
|
|
192
|
+
</Flex>
|
|
193
|
+
</Box>
|
|
184
194
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
195
|
+
{/* Deployment Targets Card */}
|
|
196
|
+
<Box
|
|
197
|
+
background="neutral0"
|
|
198
|
+
hasRadius
|
|
199
|
+
shadow="filterShadow"
|
|
200
|
+
paddingTop={6}
|
|
201
|
+
paddingBottom={6}
|
|
202
|
+
paddingLeft={7}
|
|
203
|
+
paddingRight={7}
|
|
204
|
+
>
|
|
205
|
+
<Flex direction="column" alignItems="stretch" gap={4}>
|
|
206
|
+
<Typography variant="delta" tag="h2">
|
|
207
|
+
Deployment Targets
|
|
208
|
+
</Typography>
|
|
190
209
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
<
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
210
|
+
{targets.length > 0 ? (
|
|
211
|
+
<Table>
|
|
212
|
+
<Thead>
|
|
213
|
+
<Tr>
|
|
214
|
+
<Th><Typography variant="sigma">Name</Typography></Th>
|
|
215
|
+
<Th><Typography variant="sigma">Workflow</Typography></Th>
|
|
216
|
+
<Th><Typography variant="sigma">Branch</Typography></Th>
|
|
217
|
+
<Th><Typography variant="sigma">Action</Typography></Th>
|
|
218
|
+
</Tr>
|
|
219
|
+
</Thead>
|
|
220
|
+
<Tbody>
|
|
221
|
+
{targets.map((target) => (
|
|
222
|
+
<Tr key={target.id}>
|
|
223
|
+
<Td>
|
|
224
|
+
<Typography variant="omega" fontWeight="bold">{target.name}</Typography>
|
|
225
|
+
</Td>
|
|
226
|
+
<Td>
|
|
227
|
+
<Typography variant="omega">{target.workflow}</Typography>
|
|
228
|
+
</Td>
|
|
229
|
+
<Td>
|
|
230
|
+
<Typography variant="omega">{target.branch}</Typography>
|
|
231
|
+
</Td>
|
|
232
|
+
<Td>
|
|
233
|
+
<Button
|
|
234
|
+
onClick={() => handleDeploy(target.id, target.name)}
|
|
235
|
+
loading={deployingTargetId === target.id}
|
|
236
|
+
disabled={!isConfigured || deployingTargetId !== null}
|
|
237
|
+
startIcon={<Rocket />}
|
|
238
|
+
size="S"
|
|
239
|
+
>
|
|
240
|
+
{deployingTargetId === target.id ? 'Triggering...' : 'Trigger'}
|
|
241
|
+
</Button>
|
|
242
|
+
</Td>
|
|
243
|
+
</Tr>
|
|
244
|
+
))}
|
|
245
|
+
</Tbody>
|
|
246
|
+
</Table>
|
|
247
|
+
) : (
|
|
248
|
+
<Flex direction="column" alignItems="center" justifyContent="center" gap={3} padding={6}>
|
|
249
|
+
<Typography variant="epsilon" textColor="neutral600" textAlign="center">
|
|
250
|
+
No deployment targets configured
|
|
251
|
+
</Typography>
|
|
252
|
+
<Link to={`/plugins/${PLUGIN_ID}/settings`}>
|
|
253
|
+
<Button variant="default" startIcon={<Cog />}>
|
|
254
|
+
Add Targets in Settings
|
|
255
|
+
</Button>
|
|
256
|
+
</Link>
|
|
257
|
+
</Flex>
|
|
258
|
+
)}
|
|
204
259
|
</Flex>
|
|
205
260
|
</Box>
|
|
206
261
|
|
|
207
|
-
{/* Instructions Card */}
|
|
208
|
-
{!isConfigured && (
|
|
262
|
+
{/* Instructions Card - Show only when not configured */}
|
|
263
|
+
{!isConfigured && targets.length > 0 && (
|
|
209
264
|
<Box
|
|
210
265
|
background="neutral0"
|
|
211
266
|
hasRadius
|
|
212
267
|
shadow="filterShadow"
|
|
213
|
-
paddingTop={
|
|
214
|
-
paddingBottom={
|
|
268
|
+
paddingTop={6}
|
|
269
|
+
paddingBottom={6}
|
|
215
270
|
paddingLeft={7}
|
|
216
271
|
paddingRight={7}
|
|
217
272
|
>
|
|
218
273
|
<Flex direction="column" alignItems="center" justifyContent="center" gap={3}>
|
|
219
274
|
<Typography variant="beta" textColor="neutral600" textAlign="center">
|
|
220
|
-
Setup
|
|
275
|
+
Setup Incomplete
|
|
221
276
|
</Typography>
|
|
222
277
|
<Typography variant="epsilon" textColor="neutral600" textAlign="center">
|
|
223
|
-
|
|
278
|
+
Please ensure repository URL and GitHub token are configured in Settings.
|
|
224
279
|
</Typography>
|
|
225
280
|
<Box paddingTop={2}>
|
|
226
281
|
<Link to={`/plugins/${PLUGIN_ID}/settings`}>
|