Skip to content

Commit 372d1ca

Browse files
authored
Remove unreachable job statuses from workflow output status bar (#2737)
1 parent 3899df2 commit 372d1ca

File tree

2 files changed

+13
-34
lines changed

2 files changed

+13
-34
lines changed

frontend/awx/views/jobs/JobOutput/StatusBar.cy.tsx

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -46,32 +46,13 @@ describe('HostStatusBar and WorkflowNodesStatusBar (StatusBar)', () => {
4646
cy.mount(
4747
<WorkflowNodesStatusBar nodes={jobWorkflowNodes.results as unknown as WorkflowNode[]} />
4848
);
49-
cy.contains('Success 13%');
50-
cy.contains('Canceled 13%');
51-
cy.contains('Error 25%');
52-
cy.contains('Unreachable 50%');
49+
cy.contains('Success 25%');
50+
cy.contains('Canceled 25%');
51+
cy.contains('Error 50%');
5352

5453
cy.mount(<WorkflowNodesStatusBar nodes={workflowNodes.results as unknown as WorkflowNode[]} />);
5554

56-
cy.contains('Failed 17%');
57-
cy.contains('Unreachable 17%');
58-
cy.contains('Success 67%');
59-
});
60-
it('WorkflowNodesStatusBar should NOT fail on unexpected value', () => {
61-
const wfNode = workflowNodes.results[0];
62-
const updatedWFNode = {
63-
...wfNode,
64-
summary_fields: {
65-
...wfNode.summary_fields,
66-
job: {
67-
...wfNode.summary_fields.job,
68-
status: 'unexpected_status',
69-
},
70-
},
71-
};
72-
73-
cy.mount(<WorkflowNodesStatusBar nodes={[updatedWFNode] as unknown as WorkflowNode[]} />);
74-
75-
cy.contains('Unreachable 100%');
55+
cy.contains('Failed 20%');
56+
cy.contains('Success 80%');
7657
});
7758
});

frontend/awx/views/jobs/JobOutput/StatusBar.tsx

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,12 @@ interface StatusProps {
5555
label: string;
5656
}
5757

58-
type HostStatusCountType = 'ok' | 'skipped' | 'changed' | 'failures' | 'dark';
59-
type WorkflowStatusCountType = JobStatus | 'dark';
60-
6158
type CommonStatusType = Record<'dark', StatusProps>;
59+
type HostStatusCountType = 'ok' | 'skipped' | 'changed' | 'failures' | 'dark';
6260
type HostStatusType = Record<HostStatusCountType, StatusProps>;
63-
type WorkflowStatusType = Record<WorkflowStatusCountType, StatusProps>;
6461

65-
type WFNodesStatusProps = Partial<Record<WorkflowStatusCountType, number>>;
62+
type WorkflowStatusType = Record<JobStatus, StatusProps>;
63+
type WFNodesStatusProps = Partial<Record<JobStatus, number>>;
6664

6765
export function WorkflowNodesStatusBar(props: { nodes: WorkflowNode[] }) {
6866
const { t } = useTranslation();
@@ -100,16 +98,16 @@ export function WorkflowNodesStatusBar(props: { nodes: WorkflowNode[] }) {
10098
color: pfDanger,
10199
label: t`Failed`,
102100
},
103-
dark: {
104-
color: pfUnreachable,
105-
label: t`Unreachable`,
106-
},
107101
};
108102

109103
const segments: WFNodesStatusProps = {};
110104

111105
props.nodes.map((node) => {
112-
const nodeStatus = (node?.summary_fields?.job?.status ?? 'dark') as WorkflowStatusCountType;
106+
if (!node?.summary_fields?.job?.status) {
107+
return;
108+
}
109+
110+
const nodeStatus = node.summary_fields.job.status as JobStatus;
113111

114112
const nodeVal = segments[nodeStatus];
115113
segments[nodeStatus] = nodeStatus in segments && nodeVal ? nodeVal + 1 : 1;

0 commit comments

Comments
 (0)