Skip to content

Commit cb15273

Browse files
Sasa JovicicSasa993
Sasa Jovicic
authored andcommitted
Add a dropdown to job header to choose job type on relaunch
Signed-off-by: Sasa Jovicic <[email protected]>
1 parent 96dcf0b commit cb15273

File tree

3 files changed

+38
-3
lines changed

3 files changed

+38
-3
lines changed

frontend/awx/interfaces/RelaunchConfiguration.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export interface JobRelaunch {
1717
hosts?: 'all' | 'failed' | null;
1818
/** Credential passwords */
1919
credential_passwords?: string;
20+
job_type?: 'run' | 'check' | null;
2021
}
2122

2223
export interface InventorySourceUpdate {

frontend/awx/views/jobs/JobHeader.cy.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ describe('Job Page', () => {
1414
});
1515
it('Relaunch and cancel buttons are visible on a running job', () => {
1616
cy.mount(<JobHeader />, { path: ':job_type/:id', initialEntries: ['/workflow/1'] });
17-
cy.get('[data-cy="relaunch-job"]').should('contain', 'Relaunch job');
17+
cy.get('[data-cy="relaunch-job-with"]').should('exist');
18+
cy.get('[data-cy="relaunch-job-with"]').click();
19+
cy.get('[data-cy="job-type-run"]').should('exist');
20+
cy.get('[data-cy="job-type-check"]').should('exist');
1821
cy.get('[data-cy="cancel-job"]').should('contain', 'Cancel job');
1922
});
2023
it('Delete button is disabled on a running job', () => {

frontend/awx/views/jobs/hooks/useRelaunchOptions.tsx

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ export function useRelaunchOptions(): IPageAction<UnifiedJob>[] {
1111
const relaunchJob = useRelaunchJob();
1212
const relaunchAllHosts = useRelaunchJob({ hosts: 'all' });
1313
const relaunchFailedHosts = useRelaunchJob({ hosts: 'failed' });
14+
const relaunchRunJobType = useRelaunchJob({ job_type: 'run' });
15+
const relaunchCheckJobType = useRelaunchJob({ job_type: 'check' });
1416
return useMemo(
1517
() => [
1618
{
@@ -22,9 +24,31 @@ export function useRelaunchOptions(): IPageAction<UnifiedJob>[] {
2224
label: t(`Relaunch job`),
2325
isHidden: (job: UnifiedJob) =>
2426
!(job.type !== 'system_job' && job.summary_fields?.user_capabilities?.start) ||
25-
(job.status === 'failed' && job.type === 'job'),
27+
job.type === 'job',
2628
onClick: (job: UnifiedJob) => void relaunchJob(job),
2729
},
30+
{
31+
type: PageActionType.Dropdown,
32+
selection: PageActionSelection.Single,
33+
isPinned: true,
34+
icon: RocketIcon,
35+
label: t(`Relaunch job with`),
36+
isHidden: (job: UnifiedJob) => job.type !== 'job' || job.status === 'failed',
37+
actions: [
38+
{
39+
type: PageActionType.Button,
40+
selection: PageActionSelection.Single,
41+
label: t(`Job type run`),
42+
onClick: (job: UnifiedJob) => void relaunchRunJobType(job),
43+
},
44+
{
45+
type: PageActionType.Button,
46+
selection: PageActionSelection.Single,
47+
label: t(`Job type check`),
48+
onClick: (job: UnifiedJob) => void relaunchCheckJobType(job),
49+
},
50+
],
51+
},
2852
{
2953
type: PageActionType.Dropdown,
3054
selection: PageActionSelection.Single,
@@ -50,6 +74,13 @@ export function useRelaunchOptions(): IPageAction<UnifiedJob>[] {
5074
],
5175
},
5276
],
53-
[t, relaunchAllHosts, relaunchFailedHosts, relaunchJob]
77+
[
78+
t,
79+
relaunchRunJobType,
80+
relaunchCheckJobType,
81+
relaunchAllHosts,
82+
relaunchFailedHosts,
83+
relaunchJob,
84+
]
5485
);
5586
}

0 commit comments

Comments
 (0)