From 8288655b30d878ce77d077f8183c5c9e4f2e6519 Mon Sep 17 00:00:00 2001 From: nixocio Date: Mon, 11 Apr 2022 13:33:01 -0400 Subject: [PATCH] Update when deleted is shown on job details Update when deleted is show on job details. Some job types should not display inventory or projects, update when showing those fields. Also, update when displaying information when those fields where deleted. See: https://github.com/ansible/awx/issues/12008 --- awx/ui/src/screens/Job/JobDetail/JobDetail.js | 85 +++++++++++++------ .../screens/Job/JobDetail/JobDetail.test.js | 23 ++++- 2 files changed, 81 insertions(+), 27 deletions(-) diff --git a/awx/ui/src/screens/Job/JobDetail/JobDetail.js b/awx/ui/src/screens/Job/JobDetail/JobDetail.js index 8513ca8dcf..89b14cd0d5 100644 --- a/awx/ui/src/screens/Job/JobDetail/JobDetail.js +++ b/awx/ui/src/screens/Job/JobDetail/JobDetail.js @@ -93,7 +93,11 @@ function JobDetail({ job, inventorySourceLabels }) { ); const renderInventoryDetail = () => { - if (job.type !== 'project_update') { + if ( + job.type !== 'project_update' && + job.type !== 'system_job' && + job.type !== 'workflow_job' + ) { return inventory ? ( ); } + if (job.type === 'workflow_job') { + return inventory ? ( + + {inventory.name} + + } + /> + ) : null; + } + return null; + }; + + const renderProjectDetail = () => { + if ( + job.type !== 'ad_hoc_command' && + job.type !== 'inventory_update' && + job.type !== 'system_job' && + job.type !== 'workflow_job' + ) { + return project ? ( + <> + {project.name}} + /> + + + + ) : ( + + ) + } + /> + + ) : ( + + ); + } return null; }; @@ -225,30 +283,7 @@ function JobDetail({ job, inventorySourceLabels }) { } /> )} - {project ? ( - <> - {project.name}} - /> - - - - ) : ( - - ) - } - /> - - ) : ( - - )} + {renderProjectDetail()} {scmBranch && ( ', () => { 'Instance Group', mockJobData.summary_fields.instance_group.name ); - assertDetail('Job Slice', '0/1'); assertDetail('Credentials', 'SSH: Demo Credential'); assertDetail('Machine Credential', 'SSH: Machine cred'); assertDetail('Source Control Branch', 'main'); @@ -104,6 +103,23 @@ describe('', () => { expect(projectStatusLabel.prop('status')).toEqual('successful'); }); + test('should display Deleted for Inventory and Project for job type run', () => { + const job = { + ...mockJobData, + summary_fields: { + ...mockJobData.summary_fields, + project: null, + inventory: null, + }, + project: null, + inventory: null, + }; + + wrapper = mountWithContexts(); + expect(wrapper.find(`DeletedDetail[label="Project"]`).length).toBe(1); + expect(wrapper.find(`DeletedDetail[label="Inventory"]`).length).toBe(1); + }); + test('should not display finished date', () => { wrapper = mountWithContexts( ', () => { assertDetail('Module Name', 'command'); assertDetail('Module Arguments', 'echo hello_world'); assertDetail('Job Type', 'Run Command'); + expect(wrapper.find(`Detail[label="Project"]`).length).toBe(0); }); test('should display source data', () => { @@ -182,6 +199,7 @@ describe('', () => { /> ); assertDetail('Source', 'Sourced from Project'); + expect(wrapper.find(`Detail[label="Project"]`).length).toBe(0); }); test('should show schedule that launched workflow job', async () => { @@ -215,7 +233,7 @@ describe('', () => { ).toHaveLength(1); }); - test('should hide "Launched By" detail for JT launched from a workflow launched by a schedule', async () => { + test('should hide "Launched By" detail for JT launched from a workflow launched by a schedule', () => { wrapper = mountWithContexts( ', () => { expect( wrapper.find('Button[aria-label="Cancel Demo Job Template"]') ).toHaveLength(0); + expect(wrapper.find(`Detail[label="Project"]`).length).toBe(0); }); test('should not show cancel job button, job completed', async () => {