From c31d74100da94602a53b5b1e0ab1745cf570362e Mon Sep 17 00:00:00 2001 From: Kersom <9053044+nixocio@users.noreply.github.com> Date: Thu, 2 Jun 2022 15:40:41 -0400 Subject: [PATCH] Add host description in a couple of screens (#12292) Add host description in a couple of screens See:https://github.com/ansible/awx/issues/3348 Also: https://github.com/ansible/awx/issues/9363 --- .../src/components/Lookup/HostFilterLookup.js | 1 + awx/ui/src/components/Lookup/HostListItem.js | 1 + .../src/components/Lookup/HostListItem.test.js | 4 +++- awx/ui/src/screens/Host/HostList/HostList.js | 1 + .../src/screens/Host/HostList/HostListItem.js | 6 ++++++ .../screens/Host/HostList/HostListItem.test.js | 9 +++++++++ .../InventoryGroupHostList.js | 1 + .../InventoryGroupHostListItem.js | 5 +++-- .../InventoryGroupHostListItem.test.js | 10 ++++++++++ .../InventoryHosts/InventoryHostItem.js | 6 ++++++ .../InventoryHosts/InventoryHostItem.test.js | 9 +++++++++ .../InventoryHosts/InventoryHostList.js | 1 + .../screens/Inventory/shared/data.hosts.json | 6 +++--- .../screens/Job/JobOutput/HostEventModal.js | 6 ++++++ .../Job/JobOutput/HostEventModal.test.js | 18 +++++++++++++----- 15 files changed, 73 insertions(+), 11 deletions(-) diff --git a/awx/ui/src/components/Lookup/HostFilterLookup.js b/awx/ui/src/components/Lookup/HostFilterLookup.js index e580446813..65e1294b9e 100644 --- a/awx/ui/src/components/Lookup/HostFilterLookup.js +++ b/awx/ui/src/components/Lookup/HostFilterLookup.js @@ -419,6 +419,7 @@ function HostFilterLookup({ headerRow={ {t`Name`} + {t`Description`} {t`Inventory`} } diff --git a/awx/ui/src/components/Lookup/HostListItem.js b/awx/ui/src/components/Lookup/HostListItem.js index 1e32c788cc..11d9fe641f 100644 --- a/awx/ui/src/components/Lookup/HostListItem.js +++ b/awx/ui/src/components/Lookup/HostListItem.js @@ -6,6 +6,7 @@ function HostListItem({ item }) { return ( {item.name} + {item.description} {item.summary_fields.inventory.name} ); diff --git a/awx/ui/src/components/Lookup/HostListItem.test.js b/awx/ui/src/components/Lookup/HostListItem.test.js index af2c716efe..56768f33e5 100644 --- a/awx/ui/src/components/Lookup/HostListItem.test.js +++ b/awx/ui/src/components/Lookup/HostListItem.test.js @@ -8,6 +8,7 @@ describe('HostListItem', () => { id: 1, type: 'inventory', name: 'Foo', + description: 'Buzz', summary_fields: { inventory: { name: 'Bar', @@ -24,6 +25,7 @@ describe('HostListItem', () => { ); expect(wrapper.find('HostListItem').length).toBe(1); expect(wrapper.find('Td').at(0).text()).toBe('Foo'); - expect(wrapper.find('Td').at(1).text()).toBe('Bar'); + expect(wrapper.find('Td').at(1).text()).toBe('Buzz'); + expect(wrapper.find('Td').at(2).text()).toBe('Bar'); }); }); diff --git a/awx/ui/src/screens/Host/HostList/HostList.js b/awx/ui/src/screens/Host/HostList/HostList.js index 9a4611581b..0d4b0bdafd 100644 --- a/awx/ui/src/screens/Host/HostList/HostList.js +++ b/awx/ui/src/screens/Host/HostList/HostList.js @@ -167,6 +167,7 @@ function HostList() { headerRow={ {t`Name`} + {t`Description`} {t`Inventory`} {t`Actions`} diff --git a/awx/ui/src/screens/Host/HostList/HostListItem.js b/awx/ui/src/screens/Host/HostList/HostListItem.js index 09b27ccf9f..991ab47442 100644 --- a/awx/ui/src/screens/Host/HostList/HostListItem.js +++ b/awx/ui/src/screens/Host/HostList/HostListItem.js @@ -52,6 +52,12 @@ function HostListItem({ {host.name} + + {host.description} + {host.summary_fields.inventory && ( ', () => { ); }); + test('should display expected details', () => { + expect(wrapper.find('HostListItem').length).toBe(1); + expect(wrapper.find('Td[dataLabel="Name"]').find('Link').prop('to')).toBe( + '/host/1' + ); + expect(wrapper.find('Td[dataLabel="Description"]').text()).toBe('Buzz'); + }); + test('edit button shown to users with edit capabilities', () => { expect(wrapper.find('PencilAltIcon').exists()).toBeTruthy(); }); diff --git a/awx/ui/src/screens/Inventory/InventoryGroupHosts/InventoryGroupHostList.js b/awx/ui/src/screens/Inventory/InventoryGroupHosts/InventoryGroupHostList.js index 00d3439c5f..2825715ede 100644 --- a/awx/ui/src/screens/Inventory/InventoryGroupHosts/InventoryGroupHostList.js +++ b/awx/ui/src/screens/Inventory/InventoryGroupHosts/InventoryGroupHostList.js @@ -213,6 +213,7 @@ function InventoryGroupHostList() { headerRow={ {t`Name`} + {t`Description`} {t`Activity`} {t`Actions`} diff --git a/awx/ui/src/screens/Inventory/InventoryGroupHosts/InventoryGroupHostListItem.js b/awx/ui/src/screens/Inventory/InventoryGroupHosts/InventoryGroupHostListItem.js index a0121e4b9d..b5d56925b4 100644 --- a/awx/ui/src/screens/Inventory/InventoryGroupHosts/InventoryGroupHostListItem.js +++ b/awx/ui/src/screens/Inventory/InventoryGroupHosts/InventoryGroupHostListItem.js @@ -31,7 +31,7 @@ function InventoryGroupHostListItem({ - + {host.name} + {host.description} diff --git a/awx/ui/src/screens/Inventory/InventoryGroupHosts/InventoryGroupHostListItem.test.js b/awx/ui/src/screens/Inventory/InventoryGroupHosts/InventoryGroupHostListItem.test.js index c0fd0f230b..c26ac566f8 100644 --- a/awx/ui/src/screens/Inventory/InventoryGroupHosts/InventoryGroupHostListItem.test.js +++ b/awx/ui/src/screens/Inventory/InventoryGroupHosts/InventoryGroupHostListItem.test.js @@ -26,6 +26,16 @@ describe('', () => { ); }); + test('should display expected details', () => { + expect(wrapper.find('InventoryGroupHostListItem').length).toBe(1); + expect( + wrapper.find('Td[dataLabel="host-name-2"]').find('Link').prop('to') + ).toBe('/host/1'); + expect(wrapper.find('Td[dataLabel="host-description-2"]').text()).toBe( + 'Bar' + ); + }); + test('should display expected row item content', () => { expect(wrapper.find('b').text()).toContain( '.host-000001.group-00000.dummy' diff --git a/awx/ui/src/screens/Inventory/InventoryHosts/InventoryHostItem.js b/awx/ui/src/screens/Inventory/InventoryHosts/InventoryHostItem.js index ab2f67afca..9998dc12a4 100644 --- a/awx/ui/src/screens/Inventory/InventoryHosts/InventoryHostItem.js +++ b/awx/ui/src/screens/Inventory/InventoryHosts/InventoryHostItem.js @@ -35,6 +35,12 @@ function InventoryHostItem({ {host.name} + + {host.description} + ', () => { ); }); + test('should display expected details', () => { + expect(wrapper.find('InventoryHostItem').length).toBe(1); + expect(wrapper.find('Td[dataLabel="Name"]').find('Link').prop('to')).toBe( + '/host/1' + ); + expect(wrapper.find('Td[dataLabel="Description"]').text()).toBe('Bar'); + }); + test('edit button shown to users with edit capabilities', () => { expect(wrapper.find('PencilAltIcon').exists()).toBeTruthy(); }); diff --git a/awx/ui/src/screens/Inventory/InventoryHosts/InventoryHostList.js b/awx/ui/src/screens/Inventory/InventoryHosts/InventoryHostList.js index 41d2a69c25..3b8bbe5fe0 100644 --- a/awx/ui/src/screens/Inventory/InventoryHosts/InventoryHostList.js +++ b/awx/ui/src/screens/Inventory/InventoryHosts/InventoryHostList.js @@ -136,6 +136,7 @@ function InventoryHostList() { headerRow={ {t`Name`} + {t`Description`} {t`Actions`} } diff --git a/awx/ui/src/screens/Inventory/shared/data.hosts.json b/awx/ui/src/screens/Inventory/shared/data.hosts.json index 07c6ef7d9f..25caa6b6f1 100644 --- a/awx/ui/src/screens/Inventory/shared/data.hosts.json +++ b/awx/ui/src/screens/Inventory/shared/data.hosts.json @@ -119,7 +119,7 @@ "created": "2020-02-24T15:10:58.922179Z", "modified": "2020-02-26T21:52:43.428530Z", "name": ".host-000001.group-00000.dummy", - "description": "", + "description": "Bar", "inventory": 2, "enabled": false, "instance_id": "", @@ -248,7 +248,7 @@ "created": "2020-02-24T15:10:58.945113Z", "modified": "2020-02-27T03:43:43.635871Z", "name": ".host-000002.group-00000.dummy", - "description": "", + "description": "Buzz", "inventory": 2, "enabled": false, "instance_id": "", @@ -377,7 +377,7 @@ "created": "2020-02-24T15:10:58.962312Z", "modified": "2020-02-27T03:43:45.528882Z", "name": ".host-000003.group-00000.dummy", - "description": "", + "description": "BarFoo", "inventory": 2, "enabled": false, "instance_id": "", diff --git a/awx/ui/src/screens/Job/JobOutput/HostEventModal.js b/awx/ui/src/screens/Job/JobOutput/HostEventModal.js index 9aa7012358..19faa9d5e0 100644 --- a/awx/ui/src/screens/Job/JobOutput/HostEventModal.js +++ b/awx/ui/src/screens/Job/JobOutput/HostEventModal.js @@ -107,6 +107,12 @@ function HostEventModal({ onClose, hostEvent = {}, isOpen = false }) { gutter="sm" > + {hostEvent.summary_fields.host?.description ? ( + + ) : null} {hostStatus ? ( { {}} isOpen /> ); expect(wrapper.find('Tabs').prop('activeKey')).toEqual(0); - expect(wrapper.find('Detail')).toHaveLength(5); + expect(wrapper.find('Detail')).toHaveLength(6); function assertDetail(index, label, value) { const detail = wrapper.find('Detail').at(index); @@ -96,10 +103,11 @@ describe('HostEventModal', () => { const detail = wrapper.find('Detail').first(); expect(detail.prop('value')).toEqual('foo'); - assertDetail(1, 'Play', 'all'); - assertDetail(2, 'Task', 'command'); - assertDetail(3, 'Module', 'command'); - assertDetail(4, 'Command', hostEvent.event_data.res.cmd); + assertDetail(1, 'Description', 'Bar'); + assertDetail(2, 'Play', 'all'); + assertDetail(3, 'Task', 'command'); + assertDetail(4, 'Module', 'command'); + assertDetail(5, 'Command', hostEvent.event_data.res.cmd); }); test('should display successful host status label', () => {