mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-22 19:07:54 +01:00
fix: state now persist to filters (#5559)
When navigating to features list, now it will respect the query params.
This commit is contained in:
parent
d9648de08d
commit
eda4186a6c
@ -88,12 +88,12 @@ describe('FilterItem Component', () => {
|
||||
const operatorsElement = await screen.findByText('is any of');
|
||||
|
||||
operatorsElement.click();
|
||||
const newOperator = await screen.findByText('is not any of');
|
||||
const newOperator = await screen.findByText('is none of');
|
||||
|
||||
newOperator.click();
|
||||
|
||||
expect(recordedChanges).toEqual([
|
||||
{ operator: 'IS_NOT_ANY_OF', values: ['1', '3'] },
|
||||
{ operator: 'IS_NONE_OF', values: ['1', '3'] },
|
||||
]);
|
||||
});
|
||||
|
||||
|
@ -47,15 +47,8 @@ export const FeatureToggleFilters: VFC<IFeatureToggleFiltersProps> = ({
|
||||
value: 'stale',
|
||||
},
|
||||
];
|
||||
const defaultFilterItems: IFilterItem[] = [
|
||||
{
|
||||
label: 'State',
|
||||
options: stateOptions,
|
||||
filterKey: 'state',
|
||||
},
|
||||
];
|
||||
const [availableFilters, setAvailableFilters] =
|
||||
useState<IFilterItem[]>(defaultFilterItems);
|
||||
|
||||
const [availableFilters, setAvailableFilters] = useState<IFilterItem[]>([]);
|
||||
const removeFilter = (label: string) => {
|
||||
const filters = availableFilters.map((filter) =>
|
||||
filter.label === label
|
||||
@ -74,17 +67,24 @@ export const FeatureToggleFilters: VFC<IFeatureToggleFiltersProps> = ({
|
||||
value: project.id,
|
||||
}));
|
||||
|
||||
const newFilterItems = [
|
||||
...defaultFilterItems,
|
||||
const newFilterItems: IFilterItem[] = [
|
||||
{
|
||||
label: 'State',
|
||||
options: stateOptions,
|
||||
filterKey: 'state',
|
||||
enabled: Boolean(state.state),
|
||||
},
|
||||
{
|
||||
label: 'Project',
|
||||
options: projectsOptions,
|
||||
filterKey: 'project',
|
||||
enabled: Boolean(state.project),
|
||||
} as const,
|
||||
];
|
||||
|
||||
setAvailableFilters(newFilterItems);
|
||||
}, [JSON.stringify(projects)]);
|
||||
}, [JSON.stringify(projects), JSON.stringify(state)]);
|
||||
|
||||
return (
|
||||
<StyledBox>
|
||||
{availableFilters.map(
|
||||
|
Loading…
Reference in New Issue
Block a user