From 23aaf5b3ade990950e27d2b5e7cad57325d95336 Mon Sep 17 00:00:00 2001 From: Kersom <9053044+nixocio@users.noreply.github.com> Date: Thu, 9 Jun 2022 20:16:07 -0400 Subject: [PATCH] Add cancel button to workflow job output (#12338) Add cancel button to workflow job output See: https://github.com/ansible/awx/issues/10514 --- .../components/JobCancelButton/JobCancelButton.js | 5 ++++- .../Job/WorkflowOutput/WorkflowOutputToolbar.js | 14 +++++++++++++- .../WorkflowOutput/WorkflowOutputToolbar.test.js | 8 +++++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/awx/ui/src/components/JobCancelButton/JobCancelButton.js b/awx/ui/src/components/JobCancelButton/JobCancelButton.js index 2423da5888..b766a3b434 100644 --- a/awx/ui/src/components/JobCancelButton/JobCancelButton.js +++ b/awx/ui/src/components/JobCancelButton/JobCancelButton.js @@ -8,12 +8,13 @@ import AlertModal from '../AlertModal'; import ErrorDetail from '../ErrorDetail'; function JobCancelButton({ - job = {}, errorTitle, title, showIconButton, errorMessage, buttonText, + style = {}, + job = {}, }) { const [isOpen, setIsOpen] = useState(false); const { error: cancelError, request: cancelJob } = useRequest( @@ -38,6 +39,7 @@ function JobCancelButton({ ouiaId="cancel-job-button" onClick={() => setIsOpen(true)} variant="plain" + style={style} > @@ -48,6 +50,7 @@ function JobCancelButton({ variant="secondary" ouiaId="cancel-job-button" onClick={() => setIsOpen(true)} + style={style} > {buttonText || t`Cancel Job`} diff --git a/awx/ui/src/screens/Job/WorkflowOutput/WorkflowOutputToolbar.js b/awx/ui/src/screens/Job/WorkflowOutput/WorkflowOutputToolbar.js index 992e1a8cba..55b8262921 100644 --- a/awx/ui/src/screens/Job/WorkflowOutput/WorkflowOutputToolbar.js +++ b/awx/ui/src/screens/Job/WorkflowOutput/WorkflowOutputToolbar.js @@ -11,6 +11,7 @@ import { } from '@patternfly/react-icons'; import styled from 'styled-components'; import StatusLabel from 'components/StatusLabel'; +import JobCancelButton from 'components/JobCancelButton'; import { WorkflowDispatchContext, WorkflowStateContext, @@ -61,7 +62,6 @@ const ActionButton = styled(Button)` color: white; } `; - function WorkflowOutputToolbar({ job }) { const dispatch = useContext(WorkflowDispatchContext); const history = useHistory(); @@ -80,6 +80,18 @@ function WorkflowOutputToolbar({ job }) { + {['new', 'pending', 'waiting', 'running'].includes(job?.status) && + job?.summary_fields?.user_capabilities?.start ? ( + + ) : null} + { shouldFind('Button#workflow-output-toggle-legend'); shouldFind('Badge'); shouldFind('Button#workflow-output-toggle-tools'); + shouldFind('JobCancelButton'); }); test('Shows correct number of nodes', () => {