Skip to content

Commit

Permalink
fix(RecsListTable): Reset filters button behavior update (#183)
Browse files Browse the repository at this point in the history
The recommendations list page Reset filters button change: the button is always available; if the button is clicked with the default filters, then the data are re-fetched; if the button is clicked with extra filters applied, it sets them to the default set.
  • Loading branch information
Fewwy authored Mar 21, 2022
1 parent 688857b commit 2287020
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Components/RecsListTable/RecsListTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
PaginationVariant,
} from '@patternfly/react-core/dist/js/components/Pagination';
import { Stack } from '@patternfly/react-core/dist/js/layouts/Stack';
import isEqual from 'lodash/isEqual';
import {
Tooltip,
TooltipPosition,
Expand Down Expand Up @@ -419,11 +420,16 @@ const RecsListTable = ({ query }) => {
};

const activeFiltersConfig = {
showDeleteButton: true,
deleteTitle: intl.formatMessage(messages.resetFilters),
filters: buildFilterChips(),
onDelete: (_event, itemsToRemove, isAll) => {
if (isAll) {
updateFilters(RECS_LIST_INITIAL_STATE);
if (isEqual(filters, RECS_LIST_INITIAL_STATE)) {
refetch();
} else {
updateFilters(RECS_LIST_INITIAL_STATE);
}
} else {
itemsToRemove.map((item) => {
const newFilter = {
Expand Down
1 change: 1 addition & 0 deletions src/Components/RecsListTable/RecsListTable.spec.ct.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ describe('successful non-empty recommendations list table', () => {
isUninitialized: false,
isSuccess: true,
data: data,
refetch: cy.stub(),
}}
/>
</Provider>
Expand Down

0 comments on commit 2287020

Please sign in to comment.