1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

feat: filter segments by project on the strategy (#3325)

https://linear.app/unleash/issue/2-737/when-listing-segments-project-specific-segments-should-also-be-present

Simple filter on the UI for segments that are either global or for the
specific project.
This commit is contained in:
Nuno Góis 2023-03-16 12:17:33 +00:00 committed by GitHub
parent 49d3e8e300
commit bd17c631e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -213,6 +213,7 @@ export const FeatureStrategyForm = ({
<FeatureStrategySegment
segments={segments}
setSegments={setSegments}
projectId={projectId}
/>
}
/>

View File

@ -13,6 +13,7 @@ import { Divider, styled, Typography } from '@mui/material';
interface IFeatureStrategySegmentProps {
segments: ISegment[];
setSegments: React.Dispatch<React.SetStateAction<ISegment[]>>;
projectId: string;
}
const StyledDivider = styled(Divider)(({ theme }) => ({
@ -22,6 +23,7 @@ const StyledDivider = styled(Divider)(({ theme }) => ({
export const FeatureStrategySegment = ({
segments: selectedSegments,
setSegments: setSelectedSegments,
projectId,
}: IFeatureStrategySegmentProps) => {
const { segments: allSegments } = useSegments();
const { strategySegmentsLimit } = useSegmentLimits();
@ -35,7 +37,11 @@ export const FeatureStrategySegment = ({
return null;
}
const unusedSegments = allSegments.filter(segment => {
const allSelectableSegments = allSegments.filter(
({ project }) => !project || project === projectId
);
const unusedSegments = allSelectableSegments.filter(segment => {
return !selectedSegments.find(selected => selected.id === segment.id);
});