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:
parent
49d3e8e300
commit
bd17c631e0
@ -213,6 +213,7 @@ export const FeatureStrategyForm = ({
|
|||||||
<FeatureStrategySegment
|
<FeatureStrategySegment
|
||||||
segments={segments}
|
segments={segments}
|
||||||
setSegments={setSegments}
|
setSegments={setSegments}
|
||||||
|
projectId={projectId}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
@ -13,6 +13,7 @@ import { Divider, styled, Typography } from '@mui/material';
|
|||||||
interface IFeatureStrategySegmentProps {
|
interface IFeatureStrategySegmentProps {
|
||||||
segments: ISegment[];
|
segments: ISegment[];
|
||||||
setSegments: React.Dispatch<React.SetStateAction<ISegment[]>>;
|
setSegments: React.Dispatch<React.SetStateAction<ISegment[]>>;
|
||||||
|
projectId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const StyledDivider = styled(Divider)(({ theme }) => ({
|
const StyledDivider = styled(Divider)(({ theme }) => ({
|
||||||
@ -22,6 +23,7 @@ const StyledDivider = styled(Divider)(({ theme }) => ({
|
|||||||
export const FeatureStrategySegment = ({
|
export const FeatureStrategySegment = ({
|
||||||
segments: selectedSegments,
|
segments: selectedSegments,
|
||||||
setSegments: setSelectedSegments,
|
setSegments: setSelectedSegments,
|
||||||
|
projectId,
|
||||||
}: IFeatureStrategySegmentProps) => {
|
}: IFeatureStrategySegmentProps) => {
|
||||||
const { segments: allSegments } = useSegments();
|
const { segments: allSegments } = useSegments();
|
||||||
const { strategySegmentsLimit } = useSegmentLimits();
|
const { strategySegmentsLimit } = useSegmentLimits();
|
||||||
@ -35,7 +37,11 @@ export const FeatureStrategySegment = ({
|
|||||||
return null;
|
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);
|
return !selectedSegments.find(selected => selected.id === segment.id);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user