From c049374a2573e5d370cb35c74fe4de40fcc06fda Mon Sep 17 00:00:00 2001 From: Mateusz Kwasniewski Date: Tue, 27 Feb 2024 11:23:49 +0100 Subject: [PATCH] chore: remove new strategy configuration flag (#6335) --- .../Changes/Change/ChangeActions.tsx | 70 +++------- .../Changes/Change/EditChange.tsx | 68 +++------- .../Changes/Change/NewEditChange.tsx | 68 +++------- .../AutocompleteBox/AutocompleteBox.tsx | 38 ++---- ...FeatureStrategyConstraintAccordionList.tsx | 126 +++++------------- .../FeatureStrategyEnabledDisabled.tsx | 46 ++----- .../FeatureStrategySegment.tsx | 77 ++++------- .../FeatureOverview/FeatureOverview.tsx | 20 +-- .../FlexibleStrategy/FlexibleStrategy.tsx | 117 ++++------------ .../StickinessSelect/StickinessSelect.tsx | 7 +- .../__snapshots__/create-config.test.ts.snap | 1 - src/lib/types/experimental.ts | 5 - src/server-dev.ts | 1 - 13 files changed, 166 insertions(+), 478 deletions(-) diff --git a/frontend/src/component/changeRequest/ChangeRequest/Changes/Change/ChangeActions.tsx b/frontend/src/component/changeRequest/ChangeRequest/Changes/Change/ChangeActions.tsx index 6b8dae7783..51ea30be6e 100644 --- a/frontend/src/component/changeRequest/ChangeRequest/Changes/Change/ChangeActions.tsx +++ b/frontend/src/component/changeRequest/ChangeRequest/Changes/Change/ChangeActions.tsx @@ -1,9 +1,9 @@ import React, { FC, useState } from 'react'; import { ChangeRequestType, + IChange, IChangeRequestAddStrategy, IChangeRequestUpdateStrategy, - IChange, } from 'component/changeRequest/changeRequest.types'; import { useChangeRequestApi } from 'hooks/api/actions/useChangeRequestApi/useChangeRequestApi'; import useToast from 'hooks/useToast'; @@ -24,8 +24,6 @@ import { Typography, } from '@mui/material'; import { Delete, Edit, MoreVert } from '@mui/icons-material'; -import { EditChange } from './EditChange'; -import { useUiFlag } from 'hooks/useUiFlag'; import { NewEditChange } from './NewEditChange'; const useShowActions = (changeRequest: ChangeRequestType, change: IChange) => { @@ -68,7 +66,6 @@ export const ChangeActions: FC<{ const { showDiscard, showEdit } = useShowActions(changeRequest, change); const { discardChange } = useChangeRequestApi(); const { setToastData, setToastApiError } = useToast(); - const newStrategyConfiguration = useUiFlag('newStrategyConfiguration'); const [editOpen, setEditOpen] = useState(false); @@ -152,56 +149,25 @@ export const ChangeActions: FC<{ Edit change - { - setEditOpen(false); - onRefetch?.(); - }} - onClose={() => { - setEditOpen(false); - }} - /> + { - setEditOpen(false); - onRefetch?.(); - }} - onClose={() => { - setEditOpen(false); - }} - /> + environment={ + changeRequest.environment } + open={editOpen} + onSubmit={() => { + setEditOpen(false); + onRefetch?.(); + }} + onClose={() => { + setEditOpen(false); + }} /> } diff --git a/frontend/src/component/changeRequest/ChangeRequest/Changes/Change/EditChange.tsx b/frontend/src/component/changeRequest/ChangeRequest/Changes/Change/EditChange.tsx index ebdbe83e42..219ee62aa2 100644 --- a/frontend/src/component/changeRequest/ChangeRequest/Changes/Change/EditChange.tsx +++ b/frontend/src/component/changeRequest/ChangeRequest/Changes/Change/EditChange.tsx @@ -1,5 +1,4 @@ import { useEffect, useRef, useState } from 'react'; -import { FeatureStrategyForm } from 'component/feature/FeatureStrategy/FeatureStrategyForm/FeatureStrategyForm'; import FormTemplate from 'component/common/FormTemplate/FormTemplate'; import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig'; import { useRequiredPathParam } from 'hooks/useRequiredPathParam'; @@ -22,8 +21,6 @@ import { } from 'component/changeRequest/changeRequest.types'; import { SidebarModal } from 'component/common/SidebarModal/SidebarModal'; import { useSegments } from 'hooks/api/getters/useSegments/useSegments'; -import { useUiFlag } from 'hooks/useUiFlag'; -import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; import { NewFeatureStrategyForm } from 'component/feature/FeatureStrategy/FeatureStrategyForm/NewFeatureStrategyForm'; import { StrategyVariants } from 'component/feature/StrategyTypes/StrategyVariants'; @@ -49,7 +46,6 @@ export const EditChange = ({ const projectId = useRequiredPathParam('projectId'); const { editChange } = useChangeRequestApi(); const [tab, setTab] = useState(0); - const newStrategyConfiguration = useUiFlag('newStrategyConfiguration'); const [strategy, setStrategy] = useState>( change.payload, @@ -152,54 +148,28 @@ export const EditChange = ({ ) } > - - } - /> - } - elseShow={ - } /> diff --git a/frontend/src/component/changeRequest/ChangeRequest/Changes/Change/NewEditChange.tsx b/frontend/src/component/changeRequest/ChangeRequest/Changes/Change/NewEditChange.tsx index 86e89f6c9b..dfeff48487 100644 --- a/frontend/src/component/changeRequest/ChangeRequest/Changes/Change/NewEditChange.tsx +++ b/frontend/src/component/changeRequest/ChangeRequest/Changes/Change/NewEditChange.tsx @@ -1,5 +1,4 @@ import { useEffect, useRef, useState } from 'react'; -import { FeatureStrategyForm } from 'component/feature/FeatureStrategy/FeatureStrategyForm/FeatureStrategyForm'; import FormTemplate from 'component/common/FormTemplate/FormTemplate'; import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig'; import { useRequiredPathParam } from 'hooks/useRequiredPathParam'; @@ -23,8 +22,6 @@ import { } from 'component/changeRequest/changeRequest.types'; import { SidebarModal } from 'component/common/SidebarModal/SidebarModal'; import { useSegments } from 'hooks/api/getters/useSegments/useSegments'; -import { useUiFlag } from 'hooks/useUiFlag'; -import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; import { NewFeatureStrategyForm } from 'component/feature/FeatureStrategy/FeatureStrategyForm/NewFeatureStrategyForm'; import { NewStrategyVariants } from 'component/feature/StrategyTypes/NewStrategyVariants'; import { constraintId } from 'component/common/ConstraintAccordion/ConstraintAccordionList/createEmptyConstraint'; @@ -62,7 +59,6 @@ export const NewEditChange = ({ const projectId = useRequiredPathParam('projectId'); const { editChange } = useChangeRequestApi(); const [tab, setTab] = useState(0); - const newStrategyConfiguration = useUiFlag('newStrategyConfiguration'); const constraintsWithId = addIdSymbolToConstraints(change.payload); @@ -168,54 +164,28 @@ export const NewEditChange = ({ ) } > - - } - /> - } - elseShow={ - } /> diff --git a/frontend/src/component/common/AutocompleteBox/AutocompleteBox.tsx b/frontend/src/component/common/AutocompleteBox/AutocompleteBox.tsx index 913993a3b8..fd8fdea637 100644 --- a/frontend/src/component/common/AutocompleteBox/AutocompleteBox.tsx +++ b/frontend/src/component/common/AutocompleteBox/AutocompleteBox.tsx @@ -1,9 +1,13 @@ import { useStyles } from 'component/common/AutocompleteBox/AutocompleteBox.styles'; -import { Search, ArrowDropDown, Add } from '@mui/icons-material'; -import { Autocomplete, styled, InputAdornment, useTheme } from '@mui/material'; +import { Add } from '@mui/icons-material'; +import { + Autocomplete, + InputAdornment, + styled, + TextField, + useTheme, +} from '@mui/material'; import { AutocompleteRenderInputParams } from '@mui/material/Autocomplete'; -import { TextField } from '@mui/material'; -import { useUiFlag } from 'hooks/useUiFlag'; import { useState } from 'react'; interface IAutocompleteBoxProps { @@ -60,8 +64,6 @@ export const AutocompleteBox = ({ const { classes: styles } = useStyles(); const theme = useTheme(); - const newStrategyConfiguration = useUiFlag('newStrategyConfiguration'); - const renderInput = (params: AutocompleteRenderInputParams) => { return ; }; @@ -113,35 +115,13 @@ export const AutocompleteBox = ({ /> ); }; - if (newStrategyConfiguration) { - return ( - - onChange(value || [])} - renderInput={renderCustomInput} - getOptionLabel={(value) => value.label} - disabled={disabled} - size='small' - multiple - /> - - ); - } - return ( - - - } onChange={(event, value) => onChange(value || [])} - renderInput={renderInput} + renderInput={renderCustomInput} getOptionLabel={(value) => value.label} disabled={disabled} size='small' diff --git a/frontend/src/component/feature/FeatureStrategy/FeatureStrategyConstraints/FeatureStrategyConstraintAccordionList/FeatureStrategyConstraintAccordionList.tsx b/frontend/src/component/feature/FeatureStrategy/FeatureStrategyConstraints/FeatureStrategyConstraintAccordionList/FeatureStrategyConstraintAccordionList.tsx index 66db4d148e..2328aa40b8 100644 --- a/frontend/src/component/feature/FeatureStrategy/FeatureStrategyConstraints/FeatureStrategyConstraintAccordionList/FeatureStrategyConstraintAccordionList.tsx +++ b/frontend/src/component/feature/FeatureStrategy/FeatureStrategyConstraints/FeatureStrategyConstraintAccordionList/FeatureStrategyConstraintAccordionList.tsx @@ -4,11 +4,8 @@ import { Add, HelpOutline } from '@mui/icons-material'; import { IConstraint } from 'interfaces/strategy'; import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; - -import { useUiFlag } from 'hooks/useUiFlag'; import { HelpIcon } from 'component/common/HelpIcon/HelpIcon'; import { - ConstraintList, IConstraintAccordionListRef, useConstraintAccordionList, } from 'component/common/ConstraintAccordion/ConstraintAccordionList/ConstraintAccordionList'; @@ -21,6 +18,7 @@ interface IConstraintAccordionListProps { /* Add "constraints" title on the top - default `true` */ showLabel?: boolean; } + export const constraintAccordionListId = 'constraintAccordionListId'; const StyledContainer = styled('div')({ @@ -72,110 +70,52 @@ export const FeatureStrategyConstraintAccordionList = forwardRef< setConstraints, ref as RefObject, ); - const newStrategyConfiguration = useUiFlag('newStrategyConfiguration'); if (context.length === 0) { return null; } - if (newStrategyConfiguration) { - return ( - - - - Constraints - - - Constraints are advanced - targeting rules that you can - use to enable a feature - toggle for a subset of your - users. Read more about - constraints{' '} - - here - - - - } - /> - - - - - } - /> - - ); - } - return ( - 0 && showLabel - } - show={ - - Constraints - - } - /> - - -

Add any number of constraints

- - - - - -
+ + Constraints + + + Constraints are advanced + targeting rules that you can use + to enable a feature toggle for a + subset of your users. Read more + about constraints{' '} + + here + + + + } + /> + +