diff --git a/frontend/src/component/feature/FeatureStrategy/FeatureStrategyForm/FeatureStrategyForm.tsx b/frontend/src/component/feature/FeatureStrategy/FeatureStrategyForm/FeatureStrategyForm.tsx index a8583bb127..213f02d9d1 100644 --- a/frontend/src/component/feature/FeatureStrategy/FeatureStrategyForm/FeatureStrategyForm.tsx +++ b/frontend/src/component/feature/FeatureStrategy/FeatureStrategyForm/FeatureStrategyForm.tsx @@ -345,8 +345,9 @@ export const FeatureStrategyForm = ({ return constraintCount + segmentCount; }; - const showVariants = - strategy.parameters && 'stickiness' in strategy.parameters; + const showVariants = Boolean( + strategy.parameters && 'stickiness' in strategy.parameters, + ); return ( <> @@ -527,10 +528,7 @@ export const FeatureStrategyForm = ({ condition={tab === 2} show={ } diff --git a/frontend/src/component/feature/FeatureStrategy/FeatureStrategyType/FeatureStrategyType.tsx b/frontend/src/component/feature/FeatureStrategy/FeatureStrategyType/FeatureStrategyType.tsx index fcaadc6a8b..89c18dfc18 100644 --- a/frontend/src/component/feature/FeatureStrategy/FeatureStrategyType/FeatureStrategyType.tsx +++ b/frontend/src/component/feature/FeatureStrategy/FeatureStrategyType/FeatureStrategyType.tsx @@ -49,6 +49,7 @@ export const FeatureStrategyType = ({ parameters={strategy.parameters ?? {}} updateParameter={updateParameter} editable={hasAccess} + errors={errors} /> ); case 'userWithId': diff --git a/frontend/src/component/feature/StrategyTypes/FlexibleStrategy/FlexibleStrategy.test.tsx b/frontend/src/component/feature/StrategyTypes/FlexibleStrategy/FlexibleStrategy.test.tsx index 80b0a8a2af..89a4694fcc 100644 --- a/frontend/src/component/feature/StrategyTypes/FlexibleStrategy/FlexibleStrategy.test.tsx +++ b/frontend/src/component/feature/StrategyTypes/FlexibleStrategy/FlexibleStrategy.test.tsx @@ -29,7 +29,7 @@ test('manipulates the rollout slider', async () => { return ( void; context: any; editable: boolean; + errors?: IFormErrors; } const StyledBox = styled(Box)(({ theme }) => ({ @@ -53,8 +55,10 @@ const FlexibleStrategy = ({ updateParameter, parameters, editable = true, + errors, }: IFlexibleStrategyProps) => { const projectId = useRequiredPathParam('projectId'); + const featureId = useRequiredPathParam('featureId'); const { defaultStickiness, loading } = useDefaultProjectSettings(projectId); const { pathname } = useLocation(); @@ -77,7 +81,7 @@ const FlexibleStrategy = ({ return defaultStickiness; } - return parseParameterString(parameters.stickiness); + return parseParameterString(parameters.stickiness || defaultStickiness); }, [loading, parameters.stickiness]); if (parameters.stickiness === '') { @@ -85,10 +89,10 @@ const FlexibleStrategy = ({ } useEffect(() => { - if (isDefaultStrategyEdit && !parameters.groupId) { - onUpdate('groupId')(''); + if (!parameters.groupId) { + onUpdate('groupId')(isDefaultStrategyEdit ? '' : featureId); } - }, [isDefaultStrategyEdit]); + }, [isDefaultStrategyEdit, featureId]); if (loading) { return ; @@ -121,6 +125,8 @@ const FlexibleStrategy = ({ disabled={!editable} onChange={(e) => onUpdate('groupId')(e.target.value)} data-testid={FLEXIBLE_STRATEGY_GROUP_ID} + error={Boolean(errors?.getFormError('groupId'))} + helperText={errors?.getFormError('groupId')} />