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,
|
auditUser: IAuditUser,
|
||||||
user?: IUser,
|
user?: IUser,
|
||||||
): Promise<void> {
|
): 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 feature = await this.getFeature({ featureName });
|
||||||
|
|
||||||
const env = feature.environments.find((e) => e.name === environment);
|
const env = feature.environments.find((e) => e.name === environment);
|
||||||
const hasOnlyDisabledStrategies = env?.strategies.every(
|
const hasOnlyDisabledStrategies = env?.strategies.every(
|
||||||
(strategy) => strategy.disabled,
|
(strategy) => strategy.disabled,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (hasOnlyDisabledStrategies) {
|
if (hasOnlyDisabledStrategies) {
|
||||||
await this.unprotectedUpdateEnabled(
|
await this.unprotectedUpdateEnabled(
|
||||||
projectId,
|
projectId,
|
||||||
@ -1090,6 +1113,7 @@ class FeatureToggleService {
|
|||||||
userId,
|
userId,
|
||||||
archived,
|
archived,
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...result,
|
...result,
|
||||||
dependencies,
|
dependencies,
|
||||||
|
@ -143,7 +143,11 @@ describe('Strategy limits', () => {
|
|||||||
{
|
{
|
||||||
constraints: newConstraints,
|
constraints: newConstraints,
|
||||||
},
|
},
|
||||||
{ projectId: 'default', featureName: 'feature' } as any,
|
{
|
||||||
|
projectId: 'default',
|
||||||
|
featureName: 'feature',
|
||||||
|
environment: 'default',
|
||||||
|
},
|
||||||
{} as IAuditUser,
|
{} as IAuditUser,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -246,7 +250,11 @@ describe('Strategy limits', () => {
|
|||||||
{
|
{
|
||||||
constraints: constraints(valueCount),
|
constraints: constraints(valueCount),
|
||||||
},
|
},
|
||||||
{ projectId: 'default', featureName: 'feature' } as any,
|
{
|
||||||
|
projectId: 'default',
|
||||||
|
featureName: 'feature',
|
||||||
|
environment: 'default',
|
||||||
|
},
|
||||||
{} as IAuditUser,
|
{} as IAuditUser,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -66,7 +66,8 @@ export type IFlagKey =
|
|||||||
| 'dataUsageMultiMonthView'
|
| 'dataUsageMultiMonthView'
|
||||||
| 'consumptionModel'
|
| 'consumptionModel'
|
||||||
| 'teamsIntegrationChangeRequests'
|
| 'teamsIntegrationChangeRequests'
|
||||||
| 'edgeObservability';
|
| 'edgeObservability'
|
||||||
|
| 'simplifyDisableFeature';
|
||||||
|
|
||||||
export type IFlags = Partial<{ [key in IFlagKey]: boolean | Variant }>;
|
export type IFlags = Partial<{ [key in IFlagKey]: boolean | Variant }>;
|
||||||
|
|
||||||
@ -319,6 +320,10 @@ const flags: IFlags = {
|
|||||||
process.env.EXPERIMENTAL_EDGE_OBSERVABILITY,
|
process.env.EXPERIMENTAL_EDGE_OBSERVABILITY,
|
||||||
false,
|
false,
|
||||||
),
|
),
|
||||||
|
simplifyDisableFeature: parseEnvVarBoolean(
|
||||||
|
process.env.EXPERIMENTAL_SIMPLIFY_DISABLE_FEATURE,
|
||||||
|
false,
|
||||||
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
export const defaultExperimentalOptions: IExperimentalOptions = {
|
export const defaultExperimentalOptions: IExperimentalOptions = {
|
||||||
|
@ -60,6 +60,7 @@ process.nextTick(async () => {
|
|||||||
dataUsageMultiMonthView: true,
|
dataUsageMultiMonthView: true,
|
||||||
filterExistingFlagNames: true,
|
filterExistingFlagNames: true,
|
||||||
teamsIntegrationChangeRequests: true,
|
teamsIntegrationChangeRequests: true,
|
||||||
|
simplifyDisableFeature: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
authentication: {
|
authentication: {
|
||||||
|
Loading…
Reference in New Issue
Block a user