Merge pull request #11353 from nixocio/ui_node_delete

Identify node to be deleted on workflow
This commit is contained in:
Sarah Akus
2021-11-19 12:32:27 -05:00
committed by GitHub
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
@@ -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={[
@@ -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',