Skip to content

Commit

Permalink
Remove unreachable job statuses from workflow output status bar (#2737)
Browse files Browse the repository at this point in the history
  • Loading branch information
marshmalien authored Jul 16, 2024
1 parent 3899df2 commit 372d1ca
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 34 deletions.
29 changes: 5 additions & 24 deletions frontend/awx/views/jobs/JobOutput/StatusBar.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,32 +46,13 @@ describe('HostStatusBar and WorkflowNodesStatusBar (StatusBar)', () => {
cy.mount(
<WorkflowNodesStatusBar nodes={jobWorkflowNodes.results as unknown as WorkflowNode[]} />
);
cy.contains('Success 13%');
cy.contains('Canceled 13%');
cy.contains('Error 25%');
cy.contains('Unreachable 50%');
cy.contains('Success 25%');
cy.contains('Canceled 25%');
cy.contains('Error 50%');

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

cy.contains('Failed 17%');
cy.contains('Unreachable 17%');
cy.contains('Success 67%');
});
it('WorkflowNodesStatusBar should NOT fail on unexpected value', () => {
const wfNode = workflowNodes.results[0];
const updatedWFNode = {
...wfNode,
summary_fields: {
...wfNode.summary_fields,
job: {
...wfNode.summary_fields.job,
status: 'unexpected_status',
},
},
};

cy.mount(<WorkflowNodesStatusBar nodes={[updatedWFNode] as unknown as WorkflowNode[]} />);

cy.contains('Unreachable 100%');
cy.contains('Failed 20%');
cy.contains('Success 80%');
});
});
18 changes: 8 additions & 10 deletions frontend/awx/views/jobs/JobOutput/StatusBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,12 @@ interface StatusProps {
label: string;
}

type HostStatusCountType = 'ok' | 'skipped' | 'changed' | 'failures' | 'dark';
type WorkflowStatusCountType = JobStatus | 'dark';

type CommonStatusType = Record<'dark', StatusProps>;
type HostStatusCountType = 'ok' | 'skipped' | 'changed' | 'failures' | 'dark';
type HostStatusType = Record<HostStatusCountType, StatusProps>;
type WorkflowStatusType = Record<WorkflowStatusCountType, StatusProps>;

type WFNodesStatusProps = Partial<Record<WorkflowStatusCountType, number>>;
type WorkflowStatusType = Record<JobStatus, StatusProps>;
type WFNodesStatusProps = Partial<Record<JobStatus, number>>;

export function WorkflowNodesStatusBar(props: { nodes: WorkflowNode[] }) {
const { t } = useTranslation();
Expand Down Expand Up @@ -100,16 +98,16 @@ export function WorkflowNodesStatusBar(props: { nodes: WorkflowNode[] }) {
color: pfDanger,
label: t`Failed`,
},
dark: {
color: pfUnreachable,
label: t`Unreachable`,
},
};

const segments: WFNodesStatusProps = {};

props.nodes.map((node) => {
const nodeStatus = (node?.summary_fields?.job?.status ?? 'dark') as WorkflowStatusCountType;
if (!node?.summary_fields?.job?.status) {
return;
}

const nodeStatus = node.summary_fields.job.status as JobStatus;

const nodeVal = segments[nodeStatus];
segments[nodeStatus] = nodeStatus in segments && nodeVal ? nodeVal + 1 : 1;
Expand Down

0 comments on commit 372d1ca

Please sign in to comment.