From b31bf8fab18fd8b4aff138f76e62c6ce64ae9384 Mon Sep 17 00:00:00 2001 From: nixocio Date: Mon, 13 Jun 2022 16:37:32 -0400 Subject: [PATCH] Add column org to template list Add column org to template list See: https://github.com/ansible/awx/issues/11795 --- .../components/TemplateList/TemplateList.js | 1 + .../TemplateList/TemplateListItem.js | 22 ++++----- .../TemplateList/TemplateListItem.test.js | 48 +++++++++++++++++-- 3 files changed, 54 insertions(+), 17 deletions(-) diff --git a/awx/ui/src/components/TemplateList/TemplateList.js b/awx/ui/src/components/TemplateList/TemplateList.js index 9e9997dd63..65a198abdf 100644 --- a/awx/ui/src/components/TemplateList/TemplateList.js +++ b/awx/ui/src/components/TemplateList/TemplateList.js @@ -241,6 +241,7 @@ function TemplateList({ defaultParams }) { {t`Name`} {t`Type`} + {t`Organization`} {t`Last Ran`} {t`Actions`} diff --git a/awx/ui/src/components/TemplateList/TemplateListItem.js b/awx/ui/src/components/TemplateList/TemplateListItem.js index 06feeee4b0..27dad710bb 100644 --- a/awx/ui/src/components/TemplateList/TemplateListItem.js +++ b/awx/ui/src/components/TemplateList/TemplateListItem.js @@ -182,6 +182,15 @@ function TemplateListItem({ )} {toTitleCase(template.type)} + + {summaryFields.organization ? ( + + {summaryFields.organization.name} + + ) : null} + {lastRun} ) : null} - {summaryFields.organization && ( - - {summaryFields.organization.name} - - } - dataCy={`template-${template.id}-organization`} - /> - )} {summaryFields.inventory ? ( ', () => { + test('should display expected data', () => { + const wrapper = mountWithContexts( + + + + +
+ ); + expect(wrapper.find('Td[dataLabel="Name"]').text()).toBe('Template 1'); + expect(wrapper.find('Td[dataLabel="Type"]').text()).toBe('Job Template'); + expect(wrapper.find('Td[dataLabel="Organization"]').text()).toBe('Foo'); + expect( + wrapper.find('Td[dataLabel="Organization"]').find('Link').prop('to') + ).toBe('/organizations/1/details'); + expect(wrapper.find('Td[dataLabel="Last Ran"]').text()).toBe( + '2/26/2020, 10:38:41 PM' + ); + }); + test('launch button shown to users with start capabilities', () => { const wrapper = mountWithContexts( @@ -401,7 +445,6 @@ describe('', () => { } 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'); @@ -420,9 +463,6 @@ describe('', () => { .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); }); });