Merge pull request #11998 from mabashian/344-host-count

Adds total host count to inv and smart inv details views
This commit is contained in:
Sarah Akus
2022-04-29 10:37:26 -04:00
committed by GitHub
5 changed files with 70 additions and 65 deletions

View File

@@ -78,6 +78,7 @@ function InventoryDetail({ inventory }) {
</Link> </Link>
} }
/> />
<Detail label={t`Total hosts`} value={inventory.total_hosts} />
{instanceGroups && instanceGroups.length > 0 && ( {instanceGroups && instanceGroups.length > 0 && (
<Detail <Detail
fullWidth fullWidth

View File

@@ -85,6 +85,7 @@ describe('<InventoryDetail />', () => {
expectDetailToMatch(wrapper, 'Name', mockInventory.name); expectDetailToMatch(wrapper, 'Name', mockInventory.name);
expectDetailToMatch(wrapper, 'Description', mockInventory.description); expectDetailToMatch(wrapper, 'Description', mockInventory.description);
expectDetailToMatch(wrapper, 'Type', 'Inventory'); expectDetailToMatch(wrapper, 'Type', 'Inventory');
expectDetailToMatch(wrapper, 'Total hosts', mockInventory.total_hosts);
const link = wrapper.find('Detail[label="Organization"]').find('Link'); const link = wrapper.find('Detail[label="Organization"]').find('Link');
const org = wrapper.find('Detail[label="Organization"]'); const org = wrapper.find('Detail[label="Organization"]');

View File

@@ -28,6 +28,7 @@ function SmartInventoryDetail({ inventory }) {
id, id,
modified, modified,
name, name,
total_hosts,
variables, variables,
summary_fields: { summary_fields: {
created_by, created_by,
@@ -116,6 +117,7 @@ function SmartInventoryDetail({ inventory }) {
label={t`Smart host filter`} label={t`Smart host filter`}
value={<Label variant="outline">{host_filter}</Label>} value={<Label variant="outline">{host_filter}</Label>}
/> />
<Detail label={t`Total hosts`} value={total_hosts} />
{instanceGroups.length > 0 && ( {instanceGroups.length > 0 && (
<Detail <Detail
fullWidth fullWidth

View File

@@ -57,6 +57,7 @@ describe('<SmartInventoryDetail />', () => {
assertDetail('Organization', 'Default'); assertDetail('Organization', 'Default');
assertDetail('Smart host filter', 'name__icontains=local'); assertDetail('Smart host filter', 'name__icontains=local');
assertDetail('Instance groups', 'mock instance group'); assertDetail('Instance groups', 'mock instance group');
assertDetail('Total hosts', '2');
expect(wrapper.find(`Detail[label="Activity"] Sparkline`)).toHaveLength( expect(wrapper.find(`Detail[label="Activity"] Sparkline`)).toHaveLength(
1 1
); );

View File

@@ -3,76 +3,76 @@
"type": "inventory", "type": "inventory",
"url": "/api/v2/inventories/2/", "url": "/api/v2/inventories/2/",
"related": { "related": {
"created_by": "/api/v2/users/1/", "created_by": "/api/v2/users/1/",
"modified_by": "/api/v2/users/1/", "modified_by": "/api/v2/users/1/",
"hosts": "/api/v2/inventories/2/hosts/", "hosts": "/api/v2/inventories/2/hosts/",
"groups": "/api/v2/inventories/2/groups/", "groups": "/api/v2/inventories/2/groups/",
"root_groups": "/api/v2/inventories/2/root_groups/", "root_groups": "/api/v2/inventories/2/root_groups/",
"variable_data": "/api/v2/inventories/2/variable_data/", "variable_data": "/api/v2/inventories/2/variable_data/",
"script": "/api/v2/inventories/2/script/", "script": "/api/v2/inventories/2/script/",
"tree": "/api/v2/inventories/2/tree/", "tree": "/api/v2/inventories/2/tree/",
"inventory_sources": "/api/v2/inventories/2/inventory_sources/", "inventory_sources": "/api/v2/inventories/2/inventory_sources/",
"update_inventory_sources": "/api/v2/inventories/2/update_inventory_sources/", "update_inventory_sources": "/api/v2/inventories/2/update_inventory_sources/",
"activity_stream": "/api/v2/inventories/2/activity_stream/", "activity_stream": "/api/v2/inventories/2/activity_stream/",
"job_templates": "/api/v2/inventories/2/job_templates/", "job_templates": "/api/v2/inventories/2/job_templates/",
"ad_hoc_commands": "/api/v2/inventories/2/ad_hoc_commands/", "ad_hoc_commands": "/api/v2/inventories/2/ad_hoc_commands/",
"access_list": "/api/v2/inventories/2/access_list/", "access_list": "/api/v2/inventories/2/access_list/",
"object_roles": "/api/v2/inventories/2/object_roles/", "object_roles": "/api/v2/inventories/2/object_roles/",
"instance_groups": "/api/v2/inventories/2/instance_groups/", "instance_groups": "/api/v2/inventories/2/instance_groups/",
"copy": "/api/v2/inventories/2/copy/", "copy": "/api/v2/inventories/2/copy/",
"organization": "/api/v2/organizations/1/" "organization": "/api/v2/organizations/1/"
}, },
"summary_fields": { "summary_fields": {
"organization": { "organization": {
"id": 1, "id": 1,
"name": "Default", "name": "Default",
"description": "" "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": { "update_role": {
"id": 1, "description": "May update the inventory",
"username": "admin", "name": "Update",
"first_name": "", "id": 28
"last_name": ""
}, },
"modified_by": { "adhoc_role": {
"id": 1, "description": "May run ad hoc commands on the inventory",
"username": "admin", "name": "Ad Hoc",
"first_name": "", "id": 29
"last_name": ""
}, },
"object_roles": { "use_role": {
"admin_role": { "description": "Can use the inventory in a job template",
"description": "Can manage all aspects of the inventory", "name": "Use",
"name": "Admin", "id": 30
"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
}
}, },
"user_capabilities": { "read_role": {
"edit": true, "description": "May view settings for the inventory",
"delete": true, "name": "Read",
"copy": true, "id": 31
"adhoc": true
} }
},
"user_capabilities": {
"edit": true,
"delete": true,
"copy": true,
"adhoc": true
}
}, },
"created": "2019-10-04T15:29:11.542911Z", "created": "2019-10-04T15:29:11.542911Z",
"modified": "2019-10-04T15:29:11.542924Z", "modified": "2019-10-04T15:29:11.542924Z",
@@ -83,7 +83,7 @@
"host_filter": "name__icontains=local", "host_filter": "name__icontains=local",
"variables": "", "variables": "",
"has_active_failures": false, "has_active_failures": false,
"total_hosts": 1, "total_hosts": 2,
"hosts_with_active_failures": 0, "hosts_with_active_failures": 0,
"total_groups": 0, "total_groups": 0,
"groups_with_active_failures": 0, "groups_with_active_failures": 0,
@@ -91,4 +91,4 @@
"total_inventory_sources": 0, "total_inventory_sources": 0,
"inventory_sources_with_failures": 0, "inventory_sources_with_failures": 0,
"pending_deletion": false "pending_deletion": false
} }