Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a dropdown to job header to choose job type on relaunch #2760

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions frontend/awx/interfaces/RelaunchConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface JobRelaunch {
hosts?: 'all' | 'failed' | null;
/** Credential passwords */
credential_passwords?: string;
job_type?: 'run' | 'check' | null;
}

export interface InventorySourceUpdate {
Expand Down
5 changes: 4 additions & 1 deletion frontend/awx/views/jobs/JobHeader.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ describe('Job Page', () => {
});
it('Relaunch and cancel buttons are visible on a running job', () => {
cy.mount(<JobHeader />, { path: ':job_type/:id', initialEntries: ['/workflow/1'] });
cy.get('[data-cy="relaunch-job"]').should('contain', 'Relaunch job');
cy.get('[data-cy="relaunch-job-with"]').should('exist');
cy.get('[data-cy="relaunch-job-with"]').click();
cy.get('[data-cy="job-type-run"]').should('exist');
cy.get('[data-cy="job-type-check"]').should('exist');
cy.get('[data-cy="cancel-job"]').should('contain', 'Cancel job');
});
it('Delete button is disabled on a running job', () => {
Expand Down
35 changes: 33 additions & 2 deletions frontend/awx/views/jobs/hooks/useRelaunchOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export function useRelaunchOptions(): IPageAction<UnifiedJob>[] {
const relaunchJob = useRelaunchJob();
const relaunchAllHosts = useRelaunchJob({ hosts: 'all' });
const relaunchFailedHosts = useRelaunchJob({ hosts: 'failed' });
const relaunchRunJobType = useRelaunchJob({ job_type: 'run' });
const relaunchCheckJobType = useRelaunchJob({ job_type: 'check' });
return useMemo(
() => [
{
Expand All @@ -22,9 +24,31 @@ export function useRelaunchOptions(): IPageAction<UnifiedJob>[] {
label: t(`Relaunch job`),
isHidden: (job: UnifiedJob) =>
!(job.type !== 'system_job' && job.summary_fields?.user_capabilities?.start) ||
(job.status === 'failed' && job.type === 'job'),
job.type === 'job',
onClick: (job: UnifiedJob) => void relaunchJob(job),
},
{
type: PageActionType.Dropdown,
selection: PageActionSelection.Single,
isPinned: true,
icon: RocketIcon,
label: t(`Relaunch job with`),
isHidden: (job: UnifiedJob) => job.type !== 'job' || job.status === 'failed',
actions: [
{
type: PageActionType.Button,
selection: PageActionSelection.Single,
label: t(`Job type run`),
onClick: (job: UnifiedJob) => void relaunchRunJobType(job),
},
{
type: PageActionType.Button,
selection: PageActionSelection.Single,
label: t(`Job type check`),
onClick: (job: UnifiedJob) => void relaunchCheckJobType(job),
},
],
},
{
type: PageActionType.Dropdown,
selection: PageActionSelection.Single,
Expand All @@ -50,6 +74,13 @@ export function useRelaunchOptions(): IPageAction<UnifiedJob>[] {
],
},
],
[t, relaunchAllHosts, relaunchFailedHosts, relaunchJob]
[
t,
relaunchRunJobType,
relaunchCheckJobType,
relaunchAllHosts,
relaunchFailedHosts,
relaunchJob,
]
);
}
Loading