mirror of
https://github.com/ansible/awx.git
synced 2026-05-06 17:07:36 -02:30
Merge pull request #10920 from nixocio/ui_issue_10827
Update Workflow Node Convergence
This commit is contained in:
@@ -187,12 +187,27 @@ function NodeViewModal({ readOnly }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let nodeUpdatedConvergence = {};
|
||||||
|
|
||||||
|
if (
|
||||||
|
nodeToView.all_parents_must_converge !== undefined &&
|
||||||
|
nodeToView.all_parents_must_converge !==
|
||||||
|
nodeToView.originalNodeObject.all_parents_must_converge
|
||||||
|
) {
|
||||||
|
nodeUpdatedConvergence = {
|
||||||
|
...nodeToView.originalNodeObject,
|
||||||
|
all_parents_must_converge: nodeToView.all_parents_must_converge,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
nodeUpdatedConvergence = nodeToView.originalNodeObject;
|
||||||
|
}
|
||||||
|
|
||||||
Content = (
|
Content = (
|
||||||
<PromptDetail
|
<PromptDetail
|
||||||
launchConfig={launchConfig}
|
launchConfig={launchConfig}
|
||||||
resource={fullUnifiedJobTemplate}
|
resource={fullUnifiedJobTemplate}
|
||||||
overrides={overrides}
|
overrides={overrides}
|
||||||
workflowNode={nodeToView.originalNodeObject}
|
workflowNode={nodeUpdatedConvergence}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ function VisualizerNode({
|
|||||||
if (addingLink) {
|
if (addingLink) {
|
||||||
updateHelpText(
|
updateHelpText(
|
||||||
node.isInvalidLinkTarget
|
node.isInvalidLinkTarget
|
||||||
? t`Invalid link target. Unable to link to children or ancestor nodes. Graph cycles are not supported.`
|
? t`Invalid link target. Unable to link to children or ancestor nodes. Graph cycles are not supported.`
|
||||||
: t`Click to create a new link to this node.`
|
: t`Click to create a new link to this node.`
|
||||||
);
|
);
|
||||||
onMouseOver(node);
|
onMouseOver(node);
|
||||||
@@ -264,8 +264,12 @@ function VisualizerNode({
|
|||||||
nodePositions[node.id].y - nodePositions[1].y
|
nodePositions[node.id].y - nodePositions[1].y
|
||||||
})`}
|
})`}
|
||||||
>
|
>
|
||||||
{(node.all_parents_must_converge ||
|
{(Object.prototype.hasOwnProperty.call(
|
||||||
node?.originalNodeObject?.all_parents_must_converge) && (
|
node,
|
||||||
|
'all_parents_must_converge'
|
||||||
|
)
|
||||||
|
? node.all_parents_must_converge
|
||||||
|
: node?.originalNodeObject?.all_parents_must_converge) && (
|
||||||
<>
|
<>
|
||||||
<rect
|
<rect
|
||||||
fill={
|
fill={
|
||||||
@@ -292,7 +296,7 @@ function VisualizerNode({
|
|||||||
x={wfConstants.nodeW / 2 - wfConstants.nodeW / 10 + 7}
|
x={wfConstants.nodeW / 2 - wfConstants.nodeW / 10 + 7}
|
||||||
y={-wfConstants.nodeH / 4 - 1}
|
y={-wfConstants.nodeH / 4 - 1}
|
||||||
>
|
>
|
||||||
<ConvergenceLabel>{t`ALL`}</ConvergenceLabel>
|
<ConvergenceLabel data-cy="convergence-label">{t`ALL`}</ConvergenceLabel>
|
||||||
</foreignObject>
|
</foreignObject>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -270,6 +270,68 @@ describe('VisualizerNode', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('Node should display convergence label', () => {
|
||||||
|
test('Should display ALL convergence label', async () => {
|
||||||
|
const wrapper = mountWithContexts(
|
||||||
|
<WorkflowDispatchContext.Provider value={dispatch}>
|
||||||
|
<WorkflowStateContext.Provider value={mockedContext}>
|
||||||
|
<svg>
|
||||||
|
<VisualizerNode
|
||||||
|
node={{
|
||||||
|
id: 2,
|
||||||
|
originalNodeObject: {
|
||||||
|
all_parents_must_converge: true,
|
||||||
|
always_nodes: [],
|
||||||
|
created: '2020-11-19T21:47:55.278081Z',
|
||||||
|
diff_mode: null,
|
||||||
|
extra_data: {},
|
||||||
|
failure_nodes: [],
|
||||||
|
id: 49,
|
||||||
|
identifier: 'f03b62c5-40f8-49e4-97c3-5bb20c91ec91',
|
||||||
|
inventory: null,
|
||||||
|
job_tags: null,
|
||||||
|
job_type: null,
|
||||||
|
limit: null,
|
||||||
|
modified: '2020-11-19T21:47:55.278156Z',
|
||||||
|
related: {
|
||||||
|
credentials:
|
||||||
|
'/api/v2/workflow_job_template_nodes/49/credentials/',
|
||||||
|
},
|
||||||
|
scm_branch: null,
|
||||||
|
skip_tags: null,
|
||||||
|
success_nodes: [],
|
||||||
|
summary_fields: {
|
||||||
|
workflow_job_template: { id: 15 },
|
||||||
|
unified_job_template: {
|
||||||
|
id: 7,
|
||||||
|
description: '',
|
||||||
|
name: 'Example',
|
||||||
|
unified_job_type: 'job',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
type: 'workflow_job_template_node',
|
||||||
|
unified_job_template: 7,
|
||||||
|
url: '/api/v2/workflow_job_template_nodes/49/',
|
||||||
|
verbosity: null,
|
||||||
|
workflowMakerNodeId: 2,
|
||||||
|
workflow_job_template: 15,
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
readOnly={false}
|
||||||
|
updateHelpText={updateHelpText}
|
||||||
|
updateNodeHelp={updateNodeHelp}
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</WorkflowStateContext.Provider>
|
||||||
|
</WorkflowDispatchContext.Provider>
|
||||||
|
);
|
||||||
|
expect(wrapper.find('p[data-cy="convergence-label"]').length).toBe(1);
|
||||||
|
expect(
|
||||||
|
wrapper.find('p[data-cy="convergence-label"]').prop('children')
|
||||||
|
).toEqual('ALL');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('Node without full unified job template', () => {
|
describe('Node without full unified job template', () => {
|
||||||
let wrapper;
|
let wrapper;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@@ -336,6 +398,7 @@ describe('VisualizerNode', () => {
|
|||||||
.simulate('click');
|
.simulate('click');
|
||||||
});
|
});
|
||||||
expect(JobTemplatesAPI.readDetail).toHaveBeenCalledWith(7);
|
expect(JobTemplatesAPI.readDetail).toHaveBeenCalledWith(7);
|
||||||
|
expect(wrapper.find('p[data-cy="convergence-label"]').length).toBe(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Displays error fetching full unified job template', async () => {
|
test('Displays error fetching full unified job template', async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user