From c1314a8ee83530d5a0a0c80259fc21446d86fb7d Mon Sep 17 00:00:00 2001 From: Jaanus Sellin Date: Thu, 10 Aug 2023 15:56:15 +0300 Subject: [PATCH] feat: delete segment from CR (#4469) --- .../ChangeRequest/ChangeRequest.tsx | 18 +++++++++++++----- .../Changes/Change/ChangeActions.tsx | 13 +++++-------- .../EnvironmentStrategyExecutionOrder.tsx | 6 +++--- .../Changes/Change/FeatureChange.tsx | 12 ++++++------ .../Changes/Change/SegmentChange.tsx | 6 ++++-- .../Changes/Change/SegmentChangeDetails.tsx | 8 ++++---- .../Changes/Change/StrategyChange.tsx | 10 +++++----- .../Changes/Change/ToggleStatusChange.tsx | 6 +++--- .../Change/VariantPatch/VariantPatch.tsx | 6 +++--- .../changeRequest/changeRequest.types.ts | 2 ++ 10 files changed, 48 insertions(+), 39 deletions(-) diff --git a/frontend/src/component/changeRequest/ChangeRequest/ChangeRequest.tsx b/frontend/src/component/changeRequest/ChangeRequest/ChangeRequest.tsx index fec8f21e1e..82e1f3dd11 100644 --- a/frontend/src/component/changeRequest/ChangeRequest/ChangeRequest.tsx +++ b/frontend/src/component/changeRequest/ChangeRequest/ChangeRequest.tsx @@ -29,11 +29,19 @@ export const ChangeRequest: VFC = ({ } /> - {changeRequest.segments?.map(segment => ( + {changeRequest.segments?.map(segmentChange => ( + } /> ))} = ({ {feature.changes.map((change, index) => ( = ({ ))} {feature.defaultChange ? ( { +const useShowActions = (changeRequest: IChangeRequest, change: IChange) => { const { isChangeRequestConfigured } = useChangeRequestsEnabled( changeRequest.project ); @@ -60,7 +57,7 @@ const StyledPopover = styled(Popover)(({ theme }) => ({ export const ChangeActions: FC<{ changeRequest: IChangeRequest; feature: string; - change: IFeatureChange; + change: IChange; onRefetch?: () => void; }> = ({ changeRequest, feature, change, onRefetch }) => { const { showDiscard, showEdit } = useShowActions(changeRequest, change); diff --git a/frontend/src/component/changeRequest/ChangeRequest/Changes/Change/EnvironmentStrategyExecutionOrder/EnvironmentStrategyExecutionOrder.tsx b/frontend/src/component/changeRequest/ChangeRequest/Changes/Change/EnvironmentStrategyExecutionOrder/EnvironmentStrategyExecutionOrder.tsx index eb23d6d6c5..1cebccd3b6 100644 --- a/frontend/src/component/changeRequest/ChangeRequest/Changes/Change/EnvironmentStrategyExecutionOrder/EnvironmentStrategyExecutionOrder.tsx +++ b/frontend/src/component/changeRequest/ChangeRequest/Changes/Change/EnvironmentStrategyExecutionOrder/EnvironmentStrategyExecutionOrder.tsx @@ -40,7 +40,7 @@ interface IEnvironmentStrategyExecutionOrderProps { project: string; environment: string; change: IChangeRequestReorderStrategy; - discard?: ReactNode; + actions?: ReactNode; } export const EnvironmentStrategyExecutionOrder = ({ @@ -48,7 +48,7 @@ export const EnvironmentStrategyExecutionOrder = ({ environment, change, project, - discard, + actions, }: IEnvironmentStrategyExecutionOrderProps) => { const { feature: featureData } = useFeature(project, feature); const featureEnvironment = featureData.environments.find( @@ -96,7 +96,7 @@ export const EnvironmentStrategyExecutionOrder = ({ > Updating strategy execution order to: - {discard} + {actions} {updatedStrategies.map((strategy, index) => ( diff --git a/frontend/src/component/changeRequest/ChangeRequest/Changes/Change/FeatureChange.tsx b/frontend/src/component/changeRequest/ChangeRequest/Changes/Change/FeatureChange.tsx index 4d0a90b433..0c27530548 100644 --- a/frontend/src/component/changeRequest/ChangeRequest/Changes/Change/FeatureChange.tsx +++ b/frontend/src/component/changeRequest/ChangeRequest/Changes/Change/FeatureChange.tsx @@ -55,12 +55,12 @@ const StyledAlert = styled(Alert)(({ theme }) => ({ })); export const FeatureChange: FC<{ - discard: ReactNode; + actions: ReactNode; index: number; changeRequest: IChangeRequest; change: IFeatureChange; feature: IChangeRequestFeature; -}> = ({ index, change, feature, changeRequest, discard }) => { +}> = ({ index, change, feature, changeRequest, actions }) => { const lastIndex = feature.defaultChange ? feature.changes.length + 1 : feature.changes.length; @@ -87,7 +87,7 @@ export const FeatureChange: FC<{ {change.action === 'updateEnabled' && ( )} @@ -95,7 +95,7 @@ export const FeatureChange: FC<{ change.action === 'deleteStrategy' || change.action === 'updateStrategy' ? ( )} {change.action === 'reorderStrategy' && ( @@ -117,7 +117,7 @@ export const FeatureChange: FC<{ project={changeRequest.project} environment={changeRequest.environment} change={change} - discard={discard} + actions={actions} /> )} diff --git a/frontend/src/component/changeRequest/ChangeRequest/Changes/Change/SegmentChange.tsx b/frontend/src/component/changeRequest/ChangeRequest/Changes/Change/SegmentChange.tsx index 0fcfd0a209..94c35602ea 100644 --- a/frontend/src/component/changeRequest/ChangeRequest/Changes/Change/SegmentChange.tsx +++ b/frontend/src/component/changeRequest/ChangeRequest/Changes/Change/SegmentChange.tsx @@ -1,4 +1,4 @@ -import { FC } from 'react'; +import { FC, ReactNode } from 'react'; import { Link as RouterLink } from 'react-router-dom'; import { Box, Card, Typography, Link } from '@mui/material'; import { ISegmentChange } from '../../../changeRequest.types'; @@ -8,11 +8,13 @@ import { ConflictWarning } from './ConflictWarning'; interface ISegmentChangeProps { segmentChange: ISegmentChange; onNavigate?: () => void; + actions: ReactNode; } export const SegmentChange: FC = ({ segmentChange, onNavigate, + actions, }) => ( = ({ - + ); diff --git a/frontend/src/component/changeRequest/ChangeRequest/Changes/Change/SegmentChangeDetails.tsx b/frontend/src/component/changeRequest/ChangeRequest/Changes/Change/SegmentChangeDetails.tsx index 4d9047b1b0..22eca0e554 100644 --- a/frontend/src/component/changeRequest/ChangeRequest/Changes/Change/SegmentChangeDetails.tsx +++ b/frontend/src/component/changeRequest/ChangeRequest/Changes/Change/SegmentChangeDetails.tsx @@ -46,9 +46,9 @@ const SegmentContainer = styled(Box, { })); export const SegmentChangeDetails: VFC<{ - discard?: ReactNode; + actions?: ReactNode; change: IChangeRequestUpdateSegment | IChangeRequestDeleteSegment; -}> = ({ discard, change }) => { +}> = ({ actions, change }) => { const { segment: currentSegment } = useSegment(change.payload.id); return ( @@ -70,7 +70,7 @@ export const SegmentChangeDetails: VFC<{ /> -
{discard}
+
{actions}
)} {change.action === 'updateSegment' && ( @@ -85,7 +85,7 @@ export const SegmentChangeDetails: VFC<{ /> -
{discard}
+
{actions}
)} diff --git a/frontend/src/component/changeRequest/ChangeRequest/Changes/Change/StrategyChange.tsx b/frontend/src/component/changeRequest/ChangeRequest/Changes/Change/StrategyChange.tsx index f238429158..7afc902c4d 100644 --- a/frontend/src/component/changeRequest/ChangeRequest/Changes/Change/StrategyChange.tsx +++ b/frontend/src/component/changeRequest/ChangeRequest/Changes/Change/StrategyChange.tsx @@ -101,7 +101,7 @@ const EditHeader: VFC<{ }; export const StrategyChange: VFC<{ - discard?: ReactNode; + actions?: ReactNode; change: | IChangeRequestAddStrategy | IChangeRequestDeleteStrategy @@ -109,7 +109,7 @@ export const StrategyChange: VFC<{ environmentName: string; featureName: string; projectId: string; -}> = ({ discard, change, featureName, environmentName, projectId }) => { +}> = ({ actions, change, featureName, environmentName, projectId }) => { const currentStrategy = useCurrentStrategy( change, projectId, @@ -145,7 +145,7 @@ export const StrategyChange: VFC<{ /> -
{discard}
+
{actions}
@@ -169,7 +169,7 @@ export const StrategyChange: VFC<{ )} -
{discard}
+
{actions}
)} {change.action === 'updateStrategy' && ( @@ -190,7 +190,7 @@ export const StrategyChange: VFC<{ /> -
{discard}
+
{actions}
= ({ enabled, - discard, + actions, }) => { return ( @@ -23,7 +23,7 @@ export const ToggleStatusChange: VFC = ({ {enabled ? ' Enabled' : 'Disabled'} - {discard} + {actions} ); }; diff --git a/frontend/src/component/changeRequest/ChangeRequest/Changes/Change/VariantPatch/VariantPatch.tsx b/frontend/src/component/changeRequest/ChangeRequest/Changes/Change/VariantPatch/VariantPatch.tsx index 90d27755c6..656a881f32 100644 --- a/frontend/src/component/changeRequest/ChangeRequest/Changes/Change/VariantPatch/VariantPatch.tsx +++ b/frontend/src/component/changeRequest/ChangeRequest/Changes/Change/VariantPatch/VariantPatch.tsx @@ -35,7 +35,7 @@ interface IVariantPatchProps { project: string; environment: string; change: IChangeRequestPatchVariant; - discard?: ReactNode; + actions?: ReactNode; } export const VariantPatch = ({ @@ -43,7 +43,7 @@ export const VariantPatch = ({ project, environment, change, - discard, + actions, }: IVariantPatchProps) => { const { feature: featureData } = useFeature(project, feature); @@ -68,7 +68,7 @@ export const VariantPatch = ({ > Updating variants to: - {discard} + {actions}