diff --git a/src/components/InventoryGroups/Modals/AddSystemsToGroupModal.js b/src/components/InventoryGroups/Modals/AddSystemsToGroupModal.js
index bff1003f0..e45612ac1 100644
--- a/src/components/InventoryGroups/Modals/AddSystemsToGroupModal.js
+++ b/src/components/InventoryGroups/Modals/AddSystemsToGroupModal.js
@@ -160,6 +160,7 @@ const AddSystemsToGroupModal = ({
initialLoading={true}
showTags
showCentosVersions
+ showNoGroupOption
/>
);
diff --git a/src/components/InventoryTable/EntityTableToolbar.js b/src/components/InventoryTable/EntityTableToolbar.js
index 8368c73f0..5c1b943cf 100644
--- a/src/components/InventoryTable/EntityTableToolbar.js
+++ b/src/components/InventoryTable/EntityTableToolbar.js
@@ -167,7 +167,7 @@ const EntityTableToolbar = ({
setUpdateMethodValue,
] = useUpdateMethodFilter(reducer);
const [hostGroupConfig, hostGroupChips, hostGroupValue, setHostGroupValue] =
- useGroupFilter();
+ useGroupFilter(props.showNoGroupOption);
const isUpdateMethodEnabled = useFeatureFlag('hbi.ui.system-update-method');
const groupsEnabled = useFeatureFlag('hbi.ui.inventory-groups');
@@ -647,6 +647,7 @@ EntityTableToolbar.propTypes = {
showTagModal: PropTypes.bool,
disableDefaultColumns: PropTypes.any,
showCentosVersions: PropTypes.bool,
+ showNoGroupOption: PropTypes.bool,
};
EntityTableToolbar.defaultProps = {
@@ -654,6 +655,7 @@ EntityTableToolbar.defaultProps = {
hasAccess: true,
activeFiltersConfig: {},
hideFilters: {},
+ showNoGroupOption: false,
};
export default EntityTableToolbar;
diff --git a/src/components/InventoryTable/InventoryTable.cy.js b/src/components/InventoryTable/InventoryTable.cy.js
index 8c1334158..0aef1cf6e 100644
--- a/src/components/InventoryTable/InventoryTable.cy.js
+++ b/src/components/InventoryTable/InventoryTable.cy.js
@@ -46,11 +46,7 @@ const waitForTable = (waitNetwork = false) => {
}
// indicating the table is loaded
- cy.get('table[aria-label="Host inventory"]').should(
- 'have.attr',
- 'data-ouia-safe',
- 'true'
- );
+ cy.contains(hostsFixtures.results[0].id);
};
const shorterGroupsFixtures = {
@@ -300,3 +296,38 @@ describe('hiding filters', () => {
cy.get(DROPDOWN_ITEM).should('not.contain', 'Last seen');
});
});
+
+describe('with no group filter option', () => {
+ before(() => {
+ cy.mockWindowChrome();
+ });
+
+ beforeEach(() => {
+ setTableInterceptors();
+ mountTable({ showNoGroupOption: true });
+ waitForTable(true);
+ });
+
+ it('no group is the first option', () => {
+ cy.get('button[data-ouia-component-id="ConditionalFilter"]').click();
+ cy.get(DROPDOWN_ITEM).contains('Group').click();
+ cy.ouiaId('FilterByGroup').click();
+ cy.ouiaId('FilterByGroupOption').first().should('have.text', 'No group');
+ });
+
+ it('creates no group chip', () => {
+ cy.get('button[data-ouia-component-id="ConditionalFilter"]').click();
+ cy.get(DROPDOWN_ITEM).contains('Group').click();
+ cy.ouiaId('FilterByGroup').click();
+ cy.ouiaId('FilterByGroupOption').eq(0).click();
+ hasChip('Group', 'No group');
+ });
+
+ it('triggers new request with empty parameter', () => {
+ cy.get('button[data-ouia-component-id="ConditionalFilter"]').click();
+ cy.get(DROPDOWN_ITEM).contains('Group').click();
+ cy.ouiaId('FilterByGroup').click();
+ cy.ouiaId('FilterByGroupOption').eq(0).click();
+ cy.wait('@getHosts').its('request.url').should('include', `group_name=`);
+ });
+});
diff --git a/src/components/InventoryTable/InventoryTable.js b/src/components/InventoryTable/InventoryTable.js
index 3635b7039..891c61863 100644
--- a/src/components/InventoryTable/InventoryTable.js
+++ b/src/components/InventoryTable/InventoryTable.js
@@ -343,6 +343,7 @@ InventoryTable.propTypes = {
hasCheckbox: PropTypes.bool,
abortOnUnmount: PropTypes.bool,
showCentosVersions: PropTypes.bool,
+ showNoGroupOption: PropTypes.bool, // group filter option
};
export default InventoryTable;
diff --git a/src/components/InventoryTable/__snapshots__/EntityTableToolbar.test.js.snap b/src/components/InventoryTable/__snapshots__/EntityTableToolbar.test.js.snap
index 66abe63da..6b5cae1bf 100644
--- a/src/components/InventoryTable/__snapshots__/EntityTableToolbar.test.js.snap
+++ b/src/components/InventoryTable/__snapshots__/EntityTableToolbar.test.js.snap
@@ -143,6 +143,7 @@ exports[`EntityTableToolbar DOM should render correctly - no data 1`] = `
size="lg"
/>
}
+ showNoGroupOption={false}
/>
`;
@@ -384,6 +385,7 @@ exports[`EntityTableToolbar DOM should render correctly - with children 1`] = `
"perPage": undefined,
}
}
+ showNoGroupOption={false}
/>
`;
@@ -667,6 +669,7 @@ exports[`EntityTableToolbar DOM should render correctly - with custom activeFilt
"perPage": undefined,
}
}
+ showNoGroupOption={false}
/>
`;
@@ -915,6 +918,7 @@ exports[`EntityTableToolbar DOM should render correctly - with custom filters 1`
"perPage": undefined,
}
}
+ showNoGroupOption={false}
/>
`;
@@ -1199,6 +1203,7 @@ exports[`EntityTableToolbar DOM should render correctly - with customFilters 1`]
"perPage": undefined,
}
}
+ showNoGroupOption={false}
/>
`;
@@ -1453,6 +1458,7 @@ exports[`EntityTableToolbar DOM should render correctly - with default filters 1
"perPage": undefined,
}
}
+ showNoGroupOption={false}
/>
`;
@@ -1694,6 +1700,7 @@ exports[`EntityTableToolbar DOM should render correctly - with default tag filte
"perPage": undefined,
}
}
+ showNoGroupOption={false}
/>
`;
@@ -1716,6 +1723,7 @@ exports[`EntityTableToolbar DOM should render correctly - with items 1`] = `
"perPage": undefined,
}
}
+ showNoGroupOption={false}
/>
`;
@@ -1951,6 +1959,7 @@ exports[`EntityTableToolbar DOM should render correctly - with no access 1`] = `
"perPage": undefined,
}
}
+ showNoGroupOption={false}
/>
`;
@@ -2230,6 +2239,7 @@ exports[`EntityTableToolbar DOM should render correctly - with tags 1`] = `
"perPage": undefined,
}
}
+ showNoGroupOption={false}
/>
`;
@@ -2479,5 +2489,6 @@ exports[`EntityTableToolbar DOM should render correctly 1`] = `
"perPage": 50,
}
}
+ showNoGroupOption={false}
/>
`;
diff --git a/src/components/InventoryTable/__snapshots__/InventoryTable.test.js.snap b/src/components/InventoryTable/__snapshots__/InventoryTable.test.js.snap
index 76c04b007..d2045af19 100644
--- a/src/components/InventoryTable/__snapshots__/InventoryTable.test.js.snap
+++ b/src/components/InventoryTable/__snapshots__/InventoryTable.test.js.snap
@@ -15,6 +15,7 @@ exports[`InventoryTable should render correctly - no data 1`] = `
page={1}
perPage={50}
showCentosVersions={false}
+ showNoGroupOption={false}
showTags={false}
/>