mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-11 00:08:30 +01:00
fix: default segments should only be selected when using default stra… (#4040)
This commit is contained in:
parent
197df96ff4
commit
3763e1b24d
@ -40,7 +40,7 @@ export const FeatureStrategyCreate = () => {
|
||||
const featureId = useRequiredPathParam('featureId');
|
||||
const environmentId = useRequiredQueryParam('environmentId');
|
||||
const strategyName = useRequiredQueryParam('strategyName');
|
||||
const useDefaultStrategy: boolean = JSON.parse(
|
||||
const shouldUseDefaultStrategy: boolean = JSON.parse(
|
||||
useQueryParams().get('defaultStrategy') || 'false'
|
||||
);
|
||||
const { project } = useProject(projectId);
|
||||
@ -56,7 +56,9 @@ export const FeatureStrategyCreate = () => {
|
||||
|
||||
const [strategy, setStrategy] = useState<Partial<IFeatureStrategy>>({});
|
||||
|
||||
const [segments, setSegments] = useState<ISegment[]>(strategySegments);
|
||||
const [segments, setSegments] = useState<ISegment[]>(
|
||||
shouldUseDefaultStrategy ? strategySegments : []
|
||||
);
|
||||
const { strategyDefinition } = useStrategy(strategyName);
|
||||
const errors = useFormErrors();
|
||||
|
||||
@ -98,12 +100,12 @@ export const FeatureStrategyCreate = () => {
|
||||
}, [feature.name]);
|
||||
|
||||
useEffect(() => {
|
||||
if (useDefaultStrategy) {
|
||||
if (shouldUseDefaultStrategy) {
|
||||
setStrategy((defaultStrategy as any) || DEFAULT_STRATEGY);
|
||||
} else if (strategyDefinition) {
|
||||
setStrategy(createFeatureStrategy(featureId, strategyDefinition));
|
||||
}
|
||||
}, [featureId, strategyDefinition, useDefaultStrategy]);
|
||||
}, [featureId, strategyDefinition, shouldUseDefaultStrategy]);
|
||||
|
||||
const onAddStrategy = async (payload: IFeatureStrategyPayload) => {
|
||||
await addStrategyToFeature(
|
||||
|
Loading…
Reference in New Issue
Block a user