From cd35787a8682af2a8c829a765b3d935c6690f655 Mon Sep 17 00:00:00 2001 From: mabashian Date: Fri, 1 Apr 2022 16:31:48 -0400 Subject: [PATCH] Adds total host count to inv and smart inv details views --- .../InventoryDetail/InventoryDetail.js | 1 + .../InventoryDetail/InventoryDetail.test.js | 1 + .../SmartInventoryDetail.js | 2 + .../SmartInventoryDetail.test.js | 1 + .../shared/data.smart_inventory.json | 130 +++++++++--------- 5 files changed, 70 insertions(+), 65 deletions(-) diff --git a/awx/ui/src/screens/Inventory/InventoryDetail/InventoryDetail.js b/awx/ui/src/screens/Inventory/InventoryDetail/InventoryDetail.js index 03691e690f..b2ddbb3ab7 100644 --- a/awx/ui/src/screens/Inventory/InventoryDetail/InventoryDetail.js +++ b/awx/ui/src/screens/Inventory/InventoryDetail/InventoryDetail.js @@ -78,6 +78,7 @@ function InventoryDetail({ inventory }) { } /> + {instanceGroups && instanceGroups.length > 0 && ( ', () => { expectDetailToMatch(wrapper, 'Name', mockInventory.name); expectDetailToMatch(wrapper, 'Description', mockInventory.description); expectDetailToMatch(wrapper, 'Type', 'Inventory'); + expectDetailToMatch(wrapper, 'Total hosts', mockInventory.total_hosts); const link = wrapper.find('Detail[label="Organization"]').find('Link'); const org = wrapper.find('Detail[label="Organization"]'); diff --git a/awx/ui/src/screens/Inventory/SmartInventoryDetail/SmartInventoryDetail.js b/awx/ui/src/screens/Inventory/SmartInventoryDetail/SmartInventoryDetail.js index 465c753d3a..6518f97411 100644 --- a/awx/ui/src/screens/Inventory/SmartInventoryDetail/SmartInventoryDetail.js +++ b/awx/ui/src/screens/Inventory/SmartInventoryDetail/SmartInventoryDetail.js @@ -28,6 +28,7 @@ function SmartInventoryDetail({ inventory }) { id, modified, name, + total_hosts, variables, summary_fields: { created_by, @@ -116,6 +117,7 @@ function SmartInventoryDetail({ inventory }) { label={t`Smart host filter`} value={} /> + {instanceGroups.length > 0 && ( ', () => { assertDetail('Organization', 'Default'); assertDetail('Smart host filter', 'name__icontains=local'); assertDetail('Instance groups', 'mock instance group'); + assertDetail('Total hosts', '2'); expect(wrapper.find(`Detail[label="Activity"] Sparkline`)).toHaveLength( 1 ); diff --git a/awx/ui/src/screens/Inventory/shared/data.smart_inventory.json b/awx/ui/src/screens/Inventory/shared/data.smart_inventory.json index e34e569a52..aa6c370269 100644 --- a/awx/ui/src/screens/Inventory/shared/data.smart_inventory.json +++ b/awx/ui/src/screens/Inventory/shared/data.smart_inventory.json @@ -3,76 +3,76 @@ "type": "inventory", "url": "/api/v2/inventories/2/", "related": { - "created_by": "/api/v2/users/1/", - "modified_by": "/api/v2/users/1/", - "hosts": "/api/v2/inventories/2/hosts/", - "groups": "/api/v2/inventories/2/groups/", - "root_groups": "/api/v2/inventories/2/root_groups/", - "variable_data": "/api/v2/inventories/2/variable_data/", - "script": "/api/v2/inventories/2/script/", - "tree": "/api/v2/inventories/2/tree/", - "inventory_sources": "/api/v2/inventories/2/inventory_sources/", - "update_inventory_sources": "/api/v2/inventories/2/update_inventory_sources/", - "activity_stream": "/api/v2/inventories/2/activity_stream/", - "job_templates": "/api/v2/inventories/2/job_templates/", - "ad_hoc_commands": "/api/v2/inventories/2/ad_hoc_commands/", - "access_list": "/api/v2/inventories/2/access_list/", - "object_roles": "/api/v2/inventories/2/object_roles/", - "instance_groups": "/api/v2/inventories/2/instance_groups/", - "copy": "/api/v2/inventories/2/copy/", - "organization": "/api/v2/organizations/1/" + "created_by": "/api/v2/users/1/", + "modified_by": "/api/v2/users/1/", + "hosts": "/api/v2/inventories/2/hosts/", + "groups": "/api/v2/inventories/2/groups/", + "root_groups": "/api/v2/inventories/2/root_groups/", + "variable_data": "/api/v2/inventories/2/variable_data/", + "script": "/api/v2/inventories/2/script/", + "tree": "/api/v2/inventories/2/tree/", + "inventory_sources": "/api/v2/inventories/2/inventory_sources/", + "update_inventory_sources": "/api/v2/inventories/2/update_inventory_sources/", + "activity_stream": "/api/v2/inventories/2/activity_stream/", + "job_templates": "/api/v2/inventories/2/job_templates/", + "ad_hoc_commands": "/api/v2/inventories/2/ad_hoc_commands/", + "access_list": "/api/v2/inventories/2/access_list/", + "object_roles": "/api/v2/inventories/2/object_roles/", + "instance_groups": "/api/v2/inventories/2/instance_groups/", + "copy": "/api/v2/inventories/2/copy/", + "organization": "/api/v2/organizations/1/" }, "summary_fields": { - "organization": { - "id": 1, - "name": "Default", - "description": "" + "organization": { + "id": 1, + "name": "Default", + "description": "" + }, + "created_by": { + "id": 1, + "username": "admin", + "first_name": "", + "last_name": "" + }, + "modified_by": { + "id": 1, + "username": "admin", + "first_name": "", + "last_name": "" + }, + "object_roles": { + "admin_role": { + "description": "Can manage all aspects of the inventory", + "name": "Admin", + "id": 27 }, - "created_by": { - "id": 1, - "username": "admin", - "first_name": "", - "last_name": "" + "update_role": { + "description": "May update the inventory", + "name": "Update", + "id": 28 }, - "modified_by": { - "id": 1, - "username": "admin", - "first_name": "", - "last_name": "" + "adhoc_role": { + "description": "May run ad hoc commands on the inventory", + "name": "Ad Hoc", + "id": 29 }, - "object_roles": { - "admin_role": { - "description": "Can manage all aspects of the inventory", - "name": "Admin", - "id": 27 - }, - "update_role": { - "description": "May update the inventory", - "name": "Update", - "id": 28 - }, - "adhoc_role": { - "description": "May run ad hoc commands on the inventory", - "name": "Ad Hoc", - "id": 29 - }, - "use_role": { - "description": "Can use the inventory in a job template", - "name": "Use", - "id": 30 - }, - "read_role": { - "description": "May view settings for the inventory", - "name": "Read", - "id": 31 - } + "use_role": { + "description": "Can use the inventory in a job template", + "name": "Use", + "id": 30 }, - "user_capabilities": { - "edit": true, - "delete": true, - "copy": true, - "adhoc": true + "read_role": { + "description": "May view settings for the inventory", + "name": "Read", + "id": 31 } + }, + "user_capabilities": { + "edit": true, + "delete": true, + "copy": true, + "adhoc": true + } }, "created": "2019-10-04T15:29:11.542911Z", "modified": "2019-10-04T15:29:11.542924Z", @@ -83,7 +83,7 @@ "host_filter": "name__icontains=local", "variables": "", "has_active_failures": false, - "total_hosts": 1, + "total_hosts": 2, "hosts_with_active_failures": 0, "total_groups": 0, "groups_with_active_failures": 0, @@ -91,4 +91,4 @@ "total_inventory_sources": 0, "inventory_sources_with_failures": 0, "pending_deletion": false -} \ No newline at end of file +}