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

@@ -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,