Identify node to be deleted on workflow

Identify node to be deleted on workflow. If there is an alias show the
alias if no alias is available show the node name.

See: https://github.com/ansible/awx/issues/11351
This commit is contained in:
nixocio 2021-11-16 14:09:14 -05:00
parent 03ed6e9755
commit 47ae6e7a5a
9 changed files with 2478 additions and 2127 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -8,14 +8,24 @@ import {
WorkflowStateContext,
} from 'contexts/Workflow';
import AlertModal from 'components/AlertModal';
import { stringIsUUID } from 'util/strings';
function NodeDeleteModal() {
const dispatch = useContext(WorkflowDispatchContext);
const { nodeToDelete } = useContext(WorkflowStateContext);
const identifier = nodeToDelete?.originalNodeObject?.identifier;
const nodeIdentifier =
identifier && !stringIsUUID(identifier)
? identifier
: nodeToDelete?.identifier;
const unifiedJobTemplate =
nodeToDelete?.fullUnifiedJobTemplate ||
nodeToDelete?.originalNodeObject?.summary_fields?.unified_job_template;
const nodeName = nodeIdentifier || unifiedJobTemplate?.name;
return (
<AlertModal
variant="danger"
title={t`Remove Node`}
title={t`Remove Node ${nodeName}`}
isOpen={nodeToDelete}
onClose={() => dispatch({ type: 'SET_NODE_TO_DELETE', value: null })}
actions={[

View File

@ -23,6 +23,13 @@ describe('NodeDeleteModal', () => {
name: 'Test JT',
type: 'job_template',
},
fullUnifiedJobTemplate: {
name: 'Bar',
},
originalNodeObject: {
identifier: '654160ef-4013-4b90-8e4b-87dee0cb6783',
summary_fields: { unified_job_template: { name: 'Bar' } },
},
},
}}
>
@ -37,6 +44,7 @@ describe('NodeDeleteModal', () => {
});
test('Confirm button dispatches as expected', () => {
expect(wrapper.find('Title').text('Remove Node Bar'));
wrapper.find('button#confirm-node-removal').simulate('click');
expect(dispatch).toHaveBeenCalledWith({
type: 'DELETE_NODE',