mirror of
https://github.com/Unleash/unleash.git
synced 2025-07-26 13:48:33 +02:00
fix: get all strategies and check if env to be disabled (#9357)
This commit is contained in:
parent
a6cfcea029
commit
836c920154
@ -790,12 +790,35 @@ class FeatureToggleService {
|
||||
auditUser: IAuditUser,
|
||||
user?: IUser,
|
||||
): Promise<void> {
|
||||
if (this.flagResolver.isEnabled('simplifyDisableFeature')) {
|
||||
const strategies =
|
||||
await this.featureStrategiesStore.getStrategiesForFeatureEnv(
|
||||
projectId,
|
||||
featureName,
|
||||
environment,
|
||||
);
|
||||
const hasOnlyDisabledStrategies = strategies.every(
|
||||
(strategy) => strategy.disabled,
|
||||
);
|
||||
if (hasOnlyDisabledStrategies) {
|
||||
await this.unprotectedUpdateEnabled(
|
||||
projectId,
|
||||
featureName,
|
||||
environment,
|
||||
false,
|
||||
auditUser,
|
||||
user,
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
const feature = await this.getFeature({ featureName });
|
||||
|
||||
const env = feature.environments.find((e) => e.name === environment);
|
||||
const hasOnlyDisabledStrategies = env?.strategies.every(
|
||||
(strategy) => strategy.disabled,
|
||||
);
|
||||
|
||||
if (hasOnlyDisabledStrategies) {
|
||||
await this.unprotectedUpdateEnabled(
|
||||
projectId,
|
||||
@ -1090,6 +1113,7 @@ class FeatureToggleService {
|
||||
userId,
|
||||
archived,
|
||||
);
|
||||
|
||||
return {
|
||||
...result,
|
||||
dependencies,
|
||||
|
@ -143,7 +143,11 @@ describe('Strategy limits', () => {
|
||||
{
|
||||
constraints: newConstraints,
|
||||
},
|
||||
{ projectId: 'default', featureName: 'feature' } as any,
|
||||
{
|
||||
projectId: 'default',
|
||||
featureName: 'feature',
|
||||
environment: 'default',
|
||||
},
|
||||
{} as IAuditUser,
|
||||
);
|
||||
|
||||
@ -246,7 +250,11 @@ describe('Strategy limits', () => {
|
||||
{
|
||||
constraints: constraints(valueCount),
|
||||
},
|
||||
{ projectId: 'default', featureName: 'feature' } as any,
|
||||
{
|
||||
projectId: 'default',
|
||||
featureName: 'feature',
|
||||
environment: 'default',
|
||||
},
|
||||
{} as IAuditUser,
|
||||
);
|
||||
|
||||
|
@ -66,7 +66,8 @@ export type IFlagKey =
|
||||
| 'dataUsageMultiMonthView'
|
||||
| 'consumptionModel'
|
||||
| 'teamsIntegrationChangeRequests'
|
||||
| 'edgeObservability';
|
||||
| 'edgeObservability'
|
||||
| 'simplifyDisableFeature';
|
||||
|
||||
export type IFlags = Partial<{ [key in IFlagKey]: boolean | Variant }>;
|
||||
|
||||
@ -319,6 +320,10 @@ const flags: IFlags = {
|
||||
process.env.EXPERIMENTAL_EDGE_OBSERVABILITY,
|
||||
false,
|
||||
),
|
||||
simplifyDisableFeature: parseEnvVarBoolean(
|
||||
process.env.EXPERIMENTAL_SIMPLIFY_DISABLE_FEATURE,
|
||||
false,
|
||||
),
|
||||
};
|
||||
|
||||
export const defaultExperimentalOptions: IExperimentalOptions = {
|
||||
|
@ -60,6 +60,7 @@ process.nextTick(async () => {
|
||||
dataUsageMultiMonthView: true,
|
||||
filterExistingFlagNames: true,
|
||||
teamsIntegrationChangeRequests: true,
|
||||
simplifyDisableFeature: true,
|
||||
},
|
||||
},
|
||||
authentication: {
|
||||
|
Loading…
Reference in New Issue
Block a user