@orange-soft/strapi-deployment-trigger 1.0.1 → 1.1.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.
@@ -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
 
@@ -20,7 +26,7 @@ const HomePage = () => {
20
26
  const {get, post} = useFetchClient();
21
27
  const [status, setStatus] = useState(null);
22
28
  const [loading, setLoading] = useState(true);
23
- const [deploying, setDeploying] = useState(false);
29
+ const [deployingTargetId, setDeployingTargetId] = useState(null);
24
30
  const [notification, setNotification] = useState(null);
25
31
 
26
32
  useEffect(() => {
@@ -38,23 +44,23 @@ const HomePage = () => {
38
44
  }
39
45
  };
40
46
 
41
- const handleDeploy = async () => {
42
- setDeploying(true);
47
+ const handleDeploy = async (targetId, targetName) => {
48
+ setDeployingTargetId(targetId);
43
49
  setNotification(null);
44
50
  try {
45
- const {data} = await post(`/${PLUGIN_ID}/trigger`, {});
51
+ const {data} = await post(`/${PLUGIN_ID}/trigger`, { targetId });
46
52
  setNotification({
47
53
  type: 'success',
48
- message: data.data?.message || 'Deployment triggered successfully!',
54
+ message: `${targetName}: ${data.data?.message || 'Deployment triggered successfully!'}`,
49
55
  actionsUrl: data.data?.actionsUrl,
50
56
  });
51
57
  } catch (error) {
52
58
  setNotification({
53
59
  type: 'danger',
54
- message: error?.response?.data?.error?.message || error.message || 'Deployment failed',
60
+ message: `${targetName}: ${error?.response?.data?.error?.message || error.message || 'Deployment failed'}`,
55
61
  });
56
62
  } finally {
57
- setDeploying(false);
63
+ setDeployingTargetId(null);
58
64
  }
59
65
  };
60
66
 
@@ -78,12 +84,13 @@ const HomePage = () => {
78
84
  const parsed = status?.parsed || {};
79
85
  const isConfigured = status?.configured;
80
86
  const hasToken = status?.hasToken;
87
+ const targets = settings.targets || [];
81
88
 
82
89
  return (
83
90
  <Layouts.Root>
84
91
  <Layouts.Header
85
92
  title={formatMessage({id: getTranslation('plugin.name')})}
86
- subtitle="Trigger GitHub Actions deployment to production"
93
+ subtitle="Trigger GitHub Actions deployment"
87
94
  secondaryAction={
88
95
  <Link to={`/plugins/${PLUGIN_ID}/settings`}>
89
96
  <Button variant="tertiary" startIcon={<Cog />}>
@@ -137,7 +144,7 @@ const HomePage = () => {
137
144
  )}
138
145
 
139
146
  <Flex direction="column" alignItems="stretch" gap={4}>
140
- {/* Repository Configuration Card */}
147
+ {/* Repository Info Card */}
141
148
  <Box
142
149
  background="neutral0"
143
150
  hasRadius
@@ -149,78 +156,119 @@ const HomePage = () => {
149
156
  >
150
157
  <Flex direction="column" alignItems="stretch" gap={4}>
151
158
  <Typography variant="delta" tag="h2">
152
- Configuration
159
+ Repository
153
160
  </Typography>
154
161
 
155
- <Flex justifyContent="space-between" alignItems="center" gap={6}>
156
- {/* Labels and Values */}
157
- <Box style={{ display: 'grid', gridTemplateColumns: '120px 1fr', gap: '12px 16px', alignItems: 'center' }}>
158
- <Typography variant="sigma" textColor="neutral600">Repository</Typography>
159
- {parsed.owner && parsed.repo ? (
160
- <Typography
161
- variant="pi"
162
- tag="a"
163
- href={settings.repoUrl}
164
- target="_blank"
165
- rel="noopener noreferrer"
166
- textColor="primary600"
167
- style={{ textDecoration: 'none' }}
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)'}
162
+ <Box style={{ display: 'grid', gridTemplateColumns: '120px 1fr', gap: '12px 16px', alignItems: 'center' }}>
163
+ <Typography variant="sigma" textColor="neutral600">Repository</Typography>
164
+ {parsed.owner && parsed.repo ? (
165
+ <Typography
166
+ variant="pi"
167
+ tag="a"
168
+ href={settings.repoUrl}
169
+ target="_blank"
170
+ rel="noopener noreferrer"
171
+ textColor="primary600"
172
+ style={{ textDecoration: 'none' }}
173
+ >
174
+ {parsed.owner}/{parsed.repo}
178
175
  </Typography>
176
+ ) : (
177
+ <Typography variant="pi" textColor="neutral500">Not configured</Typography>
178
+ )}
179
179
 
180
- <Typography variant="sigma" textColor="neutral600">Branch</Typography>
181
- <Typography variant="pi">
182
- {settings.branch || 'master (default)'}
183
- </Typography>
180
+ <Typography variant="sigma" textColor="neutral600">GitHub Token</Typography>
181
+ <Typography variant="pi" textColor={hasToken ? 'success600' : 'danger600'}>
182
+ {hasToken ? 'Configured' : 'Missing'}
183
+ </Typography>
184
+ </Box>
185
+ </Flex>
186
+ </Box>
184
187
 
185
- <Typography variant="sigma" textColor="neutral600">GitHub Token</Typography>
186
- <Typography variant="pi" textColor={hasToken ? 'success600' : 'danger600'}>
187
- {hasToken ? 'Configured' : 'Missing'}
188
- </Typography>
189
- </Box>
188
+ {/* Deployment Targets Card */}
189
+ <Box
190
+ background="neutral0"
191
+ hasRadius
192
+ shadow="filterShadow"
193
+ paddingTop={6}
194
+ paddingBottom={6}
195
+ paddingLeft={7}
196
+ paddingRight={7}
197
+ >
198
+ <Flex direction="column" alignItems="stretch" gap={4}>
199
+ <Typography variant="delta" tag="h2">
200
+ Deployment Targets
201
+ </Typography>
190
202
 
191
- {/* Action Button */}
192
- {isConfigured && (
193
- <Button
194
- onClick={handleDeploy}
195
- loading={deploying}
196
- disabled={deploying}
197
- startIcon={<Rocket />}
198
- size="L"
199
- >
200
- {deploying ? 'Triggering...' : 'Trigger Deployment'}
201
- </Button>
202
- )}
203
- </Flex>
203
+ {targets.length > 0 ? (
204
+ <Table>
205
+ <Thead>
206
+ <Tr>
207
+ <Th><Typography variant="sigma">Name</Typography></Th>
208
+ <Th><Typography variant="sigma">Workflow</Typography></Th>
209
+ <Th><Typography variant="sigma">Branch</Typography></Th>
210
+ <Th><Typography variant="sigma">Action</Typography></Th>
211
+ </Tr>
212
+ </Thead>
213
+ <Tbody>
214
+ {targets.map((target) => (
215
+ <Tr key={target.id}>
216
+ <Td>
217
+ <Typography variant="omega" fontWeight="bold">{target.name}</Typography>
218
+ </Td>
219
+ <Td>
220
+ <Typography variant="omega">{target.workflow}</Typography>
221
+ </Td>
222
+ <Td>
223
+ <Typography variant="omega">{target.branch}</Typography>
224
+ </Td>
225
+ <Td>
226
+ <Button
227
+ onClick={() => handleDeploy(target.id, target.name)}
228
+ loading={deployingTargetId === target.id}
229
+ disabled={!isConfigured || deployingTargetId !== null}
230
+ startIcon={<Rocket />}
231
+ size="S"
232
+ >
233
+ {deployingTargetId === target.id ? 'Triggering...' : 'Trigger'}
234
+ </Button>
235
+ </Td>
236
+ </Tr>
237
+ ))}
238
+ </Tbody>
239
+ </Table>
240
+ ) : (
241
+ <Flex direction="column" alignItems="center" justifyContent="center" gap={3} padding={6}>
242
+ <Typography variant="epsilon" textColor="neutral600" textAlign="center">
243
+ No deployment targets configured
244
+ </Typography>
245
+ <Link to={`/plugins/${PLUGIN_ID}/settings`}>
246
+ <Button variant="default" startIcon={<Cog />}>
247
+ Add Targets in Settings
248
+ </Button>
249
+ </Link>
250
+ </Flex>
251
+ )}
204
252
  </Flex>
205
253
  </Box>
206
254
 
207
- {/* Instructions Card */}
208
- {!isConfigured && (
255
+ {/* Instructions Card - Show only when not configured */}
256
+ {!isConfigured && targets.length > 0 && (
209
257
  <Box
210
258
  background="neutral0"
211
259
  hasRadius
212
260
  shadow="filterShadow"
213
- paddingTop={8}
214
- paddingBottom={8}
261
+ paddingTop={6}
262
+ paddingBottom={6}
215
263
  paddingLeft={7}
216
264
  paddingRight={7}
217
265
  >
218
266
  <Flex direction="column" alignItems="center" justifyContent="center" gap={3}>
219
267
  <Typography variant="beta" textColor="neutral600" textAlign="center">
220
- Setup Required
268
+ Setup Incomplete
221
269
  </Typography>
222
270
  <Typography variant="epsilon" textColor="neutral600" textAlign="center">
223
- Configure your GitHub repository settings to enable deployment triggering.
271
+ Please ensure repository URL and GitHub token are configured in Settings.
224
272
  </Typography>
225
273
  <Box paddingTop={2}>
226
274
  <Link to={`/plugins/${PLUGIN_ID}/settings`}>