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 () => {