Skip to content

Commit

Permalink
feat(RHINENG-1850): Enable filter ungrouped hosts
Browse files Browse the repository at this point in the history
  • Loading branch information
gkarat committed Nov 24, 2023
1 parent 8ddf835 commit d320c84
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ const AddSystemsToGroupModal = ({
initialLoading={true}
showTags
showCentosVersions
showNoGroupOption
/>
);

Expand Down
4 changes: 3 additions & 1 deletion src/components/InventoryTable/EntityTableToolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -647,13 +647,15 @@ EntityTableToolbar.propTypes = {
showTagModal: PropTypes.bool,
disableDefaultColumns: PropTypes.any,
showCentosVersions: PropTypes.bool,
showNoGroupOption: PropTypes.bool,
};

EntityTableToolbar.defaultProps = {
showTags: false,
hasAccess: true,
activeFiltersConfig: {},
hideFilters: {},
showNoGroupOption: false,
};

export default EntityTableToolbar;
41 changes: 36 additions & 5 deletions src/components/InventoryTable/InventoryTable.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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=`);
});
});
1 change: 1 addition & 0 deletions src/components/InventoryTable/InventoryTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ InventoryTable.propTypes = {
hasCheckbox: PropTypes.bool,
abortOnUnmount: PropTypes.bool,
showCentosVersions: PropTypes.bool,
showNoGroupOption: PropTypes.bool, // group filter option
};

export default InventoryTable;
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ exports[`EntityTableToolbar DOM should render correctly - no data 1`] = `
size="lg"
/>
}
showNoGroupOption={false}
/>
`;

Expand Down Expand Up @@ -384,6 +385,7 @@ exports[`EntityTableToolbar DOM should render correctly - with children 1`] = `
"perPage": undefined,
}
}
showNoGroupOption={false}
/>
`;

Expand Down Expand Up @@ -667,6 +669,7 @@ exports[`EntityTableToolbar DOM should render correctly - with custom activeFilt
"perPage": undefined,
}
}
showNoGroupOption={false}
/>
`;

Expand Down Expand Up @@ -915,6 +918,7 @@ exports[`EntityTableToolbar DOM should render correctly - with custom filters 1`
"perPage": undefined,
}
}
showNoGroupOption={false}
/>
`;

Expand Down Expand Up @@ -1199,6 +1203,7 @@ exports[`EntityTableToolbar DOM should render correctly - with customFilters 1`]
"perPage": undefined,
}
}
showNoGroupOption={false}
/>
`;

Expand Down Expand Up @@ -1453,6 +1458,7 @@ exports[`EntityTableToolbar DOM should render correctly - with default filters 1
"perPage": undefined,
}
}
showNoGroupOption={false}
/>
`;

Expand Down Expand Up @@ -1694,6 +1700,7 @@ exports[`EntityTableToolbar DOM should render correctly - with default tag filte
"perPage": undefined,
}
}
showNoGroupOption={false}
/>
`;

Expand All @@ -1716,6 +1723,7 @@ exports[`EntityTableToolbar DOM should render correctly - with items 1`] = `
"perPage": undefined,
}
}
showNoGroupOption={false}
/>
`;

Expand Down Expand Up @@ -1951,6 +1959,7 @@ exports[`EntityTableToolbar DOM should render correctly - with no access 1`] = `
"perPage": undefined,
}
}
showNoGroupOption={false}
/>
`;

Expand Down Expand Up @@ -2230,6 +2239,7 @@ exports[`EntityTableToolbar DOM should render correctly - with tags 1`] = `
"perPage": undefined,
}
}
showNoGroupOption={false}
/>
`;

Expand Down Expand Up @@ -2479,5 +2489,6 @@ exports[`EntityTableToolbar DOM should render correctly 1`] = `
"perPage": 50,
}
}
showNoGroupOption={false}
/>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ exports[`InventoryTable should render correctly - no data 1`] = `
page={1}
perPage={50}
showCentosVersions={false}
showNoGroupOption={false}
showTags={false}
/>
<ForwardRef
Expand Down Expand Up @@ -57,6 +58,7 @@ exports[`InventoryTable should render correctly - with no access 1`] = `
page={1}
perPage={50}
showCentosVersions={false}
showNoGroupOption={false}
showTags={false}
sortBy={
Object {
Expand Down Expand Up @@ -137,6 +139,7 @@ exports[`InventoryTable should render correctly 1`] = `
page={1}
perPage={50}
showCentosVersions={false}
showNoGroupOption={false}
showTags={false}
sortBy={
Object {
Expand Down Expand Up @@ -255,6 +258,7 @@ exports[`InventoryTable should render correctly with items 1`] = `
page={5}
perPage={20}
showCentosVersions={false}
showNoGroupOption={false}
showTags={false}
sortBy={
Object {
Expand Down Expand Up @@ -366,6 +370,7 @@ exports[`InventoryTable should render correctly with items no totla 1`] = `
page={5}
perPage={20}
showCentosVersions={false}
showNoGroupOption={false}
showTags={false}
sortBy={
Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,8 @@ const ConventionalSystemsTab = ({
],
}}
bulkSelect={bulkSelectConfig}
showCentosVersions={true}
showCentosVersions
showNoGroupOption
/>

<DeleteModal
Expand Down

0 comments on commit d320c84

Please sign in to comment.