From bd17c631e09d0388eab607bc18ad1e65c17311cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nuno=20G=C3=B3is?= Date: Thu, 16 Mar 2023 12:17:33 +0000 Subject: [PATCH] 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. --- .../FeatureStrategyForm/FeatureStrategyForm.tsx | 1 + .../FeatureStrategySegment/FeatureStrategySegment.tsx | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/frontend/src/component/feature/FeatureStrategy/FeatureStrategyForm/FeatureStrategyForm.tsx b/frontend/src/component/feature/FeatureStrategy/FeatureStrategyForm/FeatureStrategyForm.tsx index 08ca64d4c8..f69de73b6b 100644 --- a/frontend/src/component/feature/FeatureStrategy/FeatureStrategyForm/FeatureStrategyForm.tsx +++ b/frontend/src/component/feature/FeatureStrategy/FeatureStrategyForm/FeatureStrategyForm.tsx @@ -213,6 +213,7 @@ export const FeatureStrategyForm = ({ } /> diff --git a/frontend/src/component/feature/FeatureStrategy/FeatureStrategySegment/FeatureStrategySegment.tsx b/frontend/src/component/feature/FeatureStrategy/FeatureStrategySegment/FeatureStrategySegment.tsx index 62d1463497..d9e6be585a 100644 --- a/frontend/src/component/feature/FeatureStrategy/FeatureStrategySegment/FeatureStrategySegment.tsx +++ b/frontend/src/component/feature/FeatureStrategy/FeatureStrategySegment/FeatureStrategySegment.tsx @@ -13,6 +13,7 @@ import { Divider, styled, Typography } from '@mui/material'; interface IFeatureStrategySegmentProps { segments: ISegment[]; setSegments: React.Dispatch>; + 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); });