mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +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');
|
const operatorsElement = await screen.findByText('is any of');
|
||||||
|
|
||||||
operatorsElement.click();
|
operatorsElement.click();
|
||||||
const newOperator = await screen.findByText('is not any of');
|
const newOperator = await screen.findByText('is none of');
|
||||||
|
|
||||||
newOperator.click();
|
newOperator.click();
|
||||||
|
|
||||||
expect(recordedChanges).toEqual([
|
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',
|
value: 'stale',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
const defaultFilterItems: IFilterItem[] = [
|
|
||||||
{
|
const [availableFilters, setAvailableFilters] = useState<IFilterItem[]>([]);
|
||||||
label: 'State',
|
|
||||||
options: stateOptions,
|
|
||||||
filterKey: 'state',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
const [availableFilters, setAvailableFilters] =
|
|
||||||
useState<IFilterItem[]>(defaultFilterItems);
|
|
||||||
const removeFilter = (label: string) => {
|
const removeFilter = (label: string) => {
|
||||||
const filters = availableFilters.map((filter) =>
|
const filters = availableFilters.map((filter) =>
|
||||||
filter.label === label
|
filter.label === label
|
||||||
@ -74,17 +67,24 @@ export const FeatureToggleFilters: VFC<IFeatureToggleFiltersProps> = ({
|
|||||||
value: project.id,
|
value: project.id,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const newFilterItems = [
|
const newFilterItems: IFilterItem[] = [
|
||||||
...defaultFilterItems,
|
{
|
||||||
|
label: 'State',
|
||||||
|
options: stateOptions,
|
||||||
|
filterKey: 'state',
|
||||||
|
enabled: Boolean(state.state),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: 'Project',
|
label: 'Project',
|
||||||
options: projectsOptions,
|
options: projectsOptions,
|
||||||
filterKey: 'project',
|
filterKey: 'project',
|
||||||
|
enabled: Boolean(state.project),
|
||||||
} as const,
|
} as const,
|
||||||
];
|
];
|
||||||
|
|
||||||
setAvailableFilters(newFilterItems);
|
setAvailableFilters(newFilterItems);
|
||||||
}, [JSON.stringify(projects)]);
|
}, [JSON.stringify(projects), JSON.stringify(state)]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledBox>
|
<StyledBox>
|
||||||
{availableFilters.map(
|
{availableFilters.map(
|
||||||
|
Loading…
Reference in New Issue
Block a user