diff --git a/awx/ui_next/src/components/TemplateList/TemplateListItem.jsx b/awx/ui_next/src/components/TemplateList/TemplateListItem.jsx index 70c0076fd2..ca935c6f7a 100644 --- a/awx/ui_next/src/components/TemplateList/TemplateListItem.jsx +++ b/awx/ui_next/src/components/TemplateList/TemplateListItem.jsx @@ -17,6 +17,7 @@ import { ActionsTd, ActionItem } from '../PaginatedTable'; import { DetailList, Detail, DeletedDetail } from '../DetailList'; import ChipGroup from '../ChipGroup'; import CredentialChip from '../CredentialChip'; +import ExecutionEnvironmentDetail from '../ExecutionEnvironmentDetail'; import { timeOfDay, formatDateString } from '../../util/dates'; import { JobTemplatesAPI, WorkflowJobTemplatesAPI } from '../../api'; @@ -226,12 +227,68 @@ function TemplateListItem({ } - dataCy={`template-${template.id}-activity`} + label={i18n._(t`Description`)} + value={template.description} + dataCy={`template-${template.id}-description`} /> - {summaryFields.credentials && summaryFields.credentials.length && ( + {summaryFields.recent_jobs && summaryFields.recent_jobs.length ? ( } + dataCy={`template-${template.id}-activity`} + /> + ) : null} + {summaryFields.organization && ( + + {summaryFields.organization.name} + + } + dataCy={`template-${template.id}-organization`} + /> + )} + {summaryFields.inventory ? ( + + ) : ( + !askInventoryOnLaunch && + template.type === 'job_template' && ( + + ) + )} + {summaryFields.project && ( + + {summaryFields.project.name} + + } + dataCy={`template-${template.id}-project`} + /> + )} + + + {summaryFields.credentials && summaryFields.credentials.length ? ( + - )} - {summaryFields.inventory ? ( - - ) : ( - !askInventoryOnLaunch && ( - - ) - )} + ) : null} {summaryFields.labels && summaryFields.labels.results.length > 0 && ( )} - {summaryFields.project && ( - - {summaryFields.project.name} - - } - dataCy={`template-${template.id}-project`} - /> - )} - diff --git a/awx/ui_next/src/components/TemplateList/TemplateListItem.test.jsx b/awx/ui_next/src/components/TemplateList/TemplateListItem.test.jsx index a86512af09..c4bbf11e60 100644 --- a/awx/ui_next/src/components/TemplateList/TemplateListItem.test.jsx +++ b/awx/ui_next/src/components/TemplateList/TemplateListItem.test.jsx @@ -377,4 +377,67 @@ describe('', () => { 'Custom virtual environment /var/lib/awx/env must be replaced by an execution environment.' ); }); + + test('should render expected details in expanded section', async () => { + const wrapper = mountWithContexts( + + + + +
+ ); + expect( + wrapper + .find('Tr') + .last() + .prop('isExpanded') + ).toBe(false); + await act(async () => + wrapper.find('button[aria-label="Details"]').simulate('click') + ); + wrapper.update(); + expect( + wrapper + .find('Tr') + .last() + .prop('isExpanded') + ).toBe(true); + + function assertDetail(label, value) { + expect(wrapper.find(`Detail[label="${label}"] dt`).text()).toBe(label); + expect(wrapper.find(`Detail[label="${label}"] dd`).text()).toBe(value); + } + + assertDetail('Description', 'mock description'); + assertDetail('Organization', "Mike's Org"); + assertDetail('Inventory', "Mike's Inventory"); + assertDetail('Project', "Mike's Project"); + assertDetail('Execution Environment', 'Mock EE 1.2.3'); + expect( + wrapper.find('Detail[label="Credentials"]').containsAllMatchingElements([ + + SSH:Credential 1 + , + + Awx:Credential 2 + , + ]) + ).toEqual(true); + expect( + wrapper + .find('Detail[label="Labels"]') + .containsAllMatchingElements([L_91o2]) + ).toEqual(true); + expect(wrapper.find('Detail[label="Organization"] dd a').prop('href')).toBe( + '/organizations/1/details' + ); + expect(wrapper.find(`Detail[label="Activity"] Sparkline`)).toHaveLength(1); + }); }); diff --git a/awx/ui_next/src/components/TemplateList/data.job_template.json b/awx/ui_next/src/components/TemplateList/data.job_template.json index 804c3b72a2..8e1a41b473 100644 --- a/awx/ui_next/src/components/TemplateList/data.job_template.json +++ b/awx/ui_next/src/components/TemplateList/data.job_template.json @@ -28,6 +28,11 @@ "webhook_key": "/api/v2/job_templates/7/webhook_key/" }, "summary_fields": { + "organization": { + "id": 1, + "name": "Mike's Org", + "description": "" + }, "inventory": { "id": 1, "name": "Mike's Inventory", @@ -133,6 +138,12 @@ "id": "1", "name": "Webhook Credential" + }, + "execution_environment": { + "description": "", + "id": 1, + "image": "foo.io/mock/test-ee:1.2.3", + "name": "Mock EE 1.2.3" } }, "created": "2019-09-30T16:18:34.564820Z", @@ -174,6 +185,7 @@ "diff_mode": false, "allow_simultaneous": false, "custom_virtualenv": null, + "execution_environment": 1, "job_slice_count": 1, "webhook_credential": 1, "webhook_key": "asertdyuhjkhgfd234567kjgfds",