1
0
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:
David Leek 2025-02-28 11:03:28 +01:00 committed by GitHub
parent a6cfcea029
commit 836c920154
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 41 additions and 3 deletions

View File

@ -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,

View File

@ -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,
);

View File

@ -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 = {

View File

@ -60,6 +60,7 @@ process.nextTick(async () => {
dataUsageMultiMonthView: true,
filterExistingFlagNames: true,
teamsIntegrationChangeRequests: true,
simplifyDisableFeature: true,
},
},
authentication: {