mirror of
https://github.com/Unleash/unleash.git
synced 2025-04-24 01:18:01 +02:00
feat: segments operators (#5562)
This commit is contained in:
parent
a228f54344
commit
38d02e1a85
@ -53,7 +53,7 @@ export const FilterItem: FC<IFilterItemProps> = ({
|
|||||||
const currentOperator = state ? state.operator : currentOperators[0];
|
const currentOperator = state ? state.operator : currentOperators[0];
|
||||||
|
|
||||||
const onDelete = () => {
|
const onDelete = () => {
|
||||||
onChange({ operator: 'IS', values: [] });
|
onChange({ operator: singularOperators[0], values: [] });
|
||||||
onClose();
|
onClose();
|
||||||
onChipClose();
|
onChipClose();
|
||||||
};
|
};
|
||||||
|
@ -31,6 +31,8 @@ export interface IFilterItem {
|
|||||||
}[];
|
}[];
|
||||||
filterKey: keyof FeatureTogglesListFilters;
|
filterKey: keyof FeatureTogglesListFilters;
|
||||||
enabled?: boolean;
|
enabled?: boolean;
|
||||||
|
singularOperators: [string, ...string[]];
|
||||||
|
pluralOperators: [string, ...string[]];
|
||||||
}
|
}
|
||||||
|
|
||||||
export const FeatureToggleFilters: VFC<IFeatureToggleFiltersProps> = ({
|
export const FeatureToggleFilters: VFC<IFeatureToggleFiltersProps> = ({
|
||||||
@ -79,19 +81,31 @@ export const FeatureToggleFilters: VFC<IFeatureToggleFiltersProps> = ({
|
|||||||
label: 'State',
|
label: 'State',
|
||||||
options: stateOptions,
|
options: stateOptions,
|
||||||
filterKey: 'state',
|
filterKey: 'state',
|
||||||
|
singularOperators: ['IS', 'IS_NOT'],
|
||||||
|
pluralOperators: ['IS_ANY_OF', 'IS_NONE_OF'],
|
||||||
enabled: Boolean(state.state),
|
enabled: Boolean(state.state),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Project',
|
label: 'Project',
|
||||||
options: projectsOptions,
|
options: projectsOptions,
|
||||||
filterKey: 'project',
|
filterKey: 'project',
|
||||||
|
singularOperators: ['IS', 'IS_NOT'],
|
||||||
|
pluralOperators: ['IS_ANY_OF', 'IS_NONE_OF'],
|
||||||
enabled: Boolean(state.project),
|
enabled: Boolean(state.project),
|
||||||
} as const,
|
},
|
||||||
{
|
{
|
||||||
label: 'Segment',
|
label: 'Segment',
|
||||||
options: segmentsOptions,
|
options: segmentsOptions,
|
||||||
filterKey: 'segment',
|
filterKey: 'segment',
|
||||||
} as const,
|
singularOperators: ['INCLUDE', 'DO_NOT_INCLUDE'],
|
||||||
|
pluralOperators: [
|
||||||
|
'INCLUDE_ALL_OF',
|
||||||
|
'INCLUDE_ANY_OF',
|
||||||
|
'EXCLUDE_IF_ANY_OF',
|
||||||
|
'EXCLUDE_ALL',
|
||||||
|
],
|
||||||
|
enabled: Boolean(state.segment),
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
setAvailableFilters(newFilterItems);
|
setAvailableFilters(newFilterItems);
|
||||||
@ -114,8 +128,8 @@ export const FeatureToggleFilters: VFC<IFeatureToggleFiltersProps> = ({
|
|||||||
onChange={(value) =>
|
onChange={(value) =>
|
||||||
onChange({ [filter.filterKey]: value })
|
onChange({ [filter.filterKey]: value })
|
||||||
}
|
}
|
||||||
singularOperators={['IS', 'IS_NOT']}
|
singularOperators={filter.singularOperators}
|
||||||
pluralOperators={['IS_ANY_OF', 'IS_NONE_OF']}
|
pluralOperators={filter.pluralOperators}
|
||||||
onChipClose={() => removeFilter(filter.label)}
|
onChipClose={() => removeFilter(filter.label)}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
|
Loading…
Reference in New Issue
Block a user