fix(ui): enable grouped Jira dispatch for Cloud users (#12100)

This commit is contained in:
Daniel Barranquero
2026-07-23 15:30:27 +02:00
committed by GitHub
parent 641c418816
commit 885555e080
2 changed files with 10 additions and 58 deletions
+7 -23
View File
@@ -10,21 +10,20 @@ describe("enterprise feature flags", () => {
vi.unstubAllEnvs();
});
it("should keep grouped Jira dispatch disabled by default", async () => {
// Given / When
it("should keep grouped Jira dispatch disabled outside cloud", async () => {
// Given
vi.stubEnv("UI_CLOUD_ENABLED", "false");
// When
const { isGroupedJiraDispatchEnabled } = await importFresh();
// Then
expect(isGroupedJiraDispatchEnabled()).toBe(false);
});
it("should enable grouped Jira dispatch from the enterprise env flag in cloud", async () => {
it("should enable grouped Jira dispatch in cloud without an enterprise flag", async () => {
// Given
vi.stubEnv("NEXT_PUBLIC_PROWLER_DEPLOYMENT_MODE", "cloud");
vi.stubEnv(
"NEXT_PUBLIC_PROWLER_ENTERPRISE_GROUPED_JIRA_DISPATCH_ENABLED",
"true",
);
vi.stubEnv("UI_CLOUD_ENABLED", "true");
// When
const { isGroupedJiraDispatchEnabled } = await importFresh();
@@ -32,19 +31,4 @@ describe("enterprise feature flags", () => {
// Then
expect(isGroupedJiraDispatchEnabled()).toBe(true);
});
it("should keep grouped Jira dispatch disabled outside cloud", async () => {
// Given
vi.stubEnv("NEXT_PUBLIC_PROWLER_DEPLOYMENT_MODE", "onpremise");
vi.stubEnv(
"NEXT_PUBLIC_PROWLER_ENTERPRISE_GROUPED_JIRA_DISPATCH_ENABLED",
"true",
);
// When
const { isGroupedJiraDispatchEnabled } = await importFresh();
// Then
expect(isGroupedJiraDispatchEnabled()).toBe(false);
});
});
+3 -35
View File
@@ -1,45 +1,15 @@
import { isCloud } from "./shared/env";
export const DEPLOYMENT_MODE = {
CLOUD: "cloud",
ON_PREMISE: "onpremise",
} as const;
export const ENTERPRISE_FEATURE_ENV = {
GROUPED_JIRA_DISPATCH_ENABLED:
"NEXT_PUBLIC_PROWLER_ENTERPRISE_GROUPED_JIRA_DISPATCH_ENABLED",
} as const;
export const PROWLER_CLOUD_ONLY_TOOLTIP = "Available only in Prowler Cloud";
export type DeploymentMode =
(typeof DEPLOYMENT_MODE)[keyof typeof DEPLOYMENT_MODE];
type EnterpriseFeatureEnv =
(typeof ENTERPRISE_FEATURE_ENV)[keyof typeof ENTERPRISE_FEATURE_ENV];
const getEnterpriseFeatureValue = (
envName: EnterpriseFeatureEnv,
): string | undefined => {
if (envName === ENTERPRISE_FEATURE_ENV.GROUPED_JIRA_DISPATCH_ENABLED) {
return process.env
.NEXT_PUBLIC_PROWLER_ENTERPRISE_GROUPED_JIRA_DISPATCH_ENABLED;
}
return undefined;
};
const getBooleanEnv = (
envName: EnterpriseFeatureEnv,
defaultValue: boolean,
): boolean => {
const value = getEnterpriseFeatureValue(envName);
if (value === undefined || value === "") {
return defaultValue;
}
return value === "true";
};
export const getDeploymentMode = (): DeploymentMode | undefined => {
const mode = process.env.NEXT_PUBLIC_PROWLER_DEPLOYMENT_MODE;
@@ -50,6 +20,4 @@ export const getDeploymentMode = (): DeploymentMode | undefined => {
return undefined;
};
export const isGroupedJiraDispatchEnabled = (): boolean =>
getDeploymentMode() === DEPLOYMENT_MODE.CLOUD &&
getBooleanEnv(ENTERPRISE_FEATURE_ENV.GROUPED_JIRA_DISPATCH_ENABLED, false);
export const isGroupedJiraDispatchEnabled = (): boolean => isCloud();