mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-11-08 12:24:45 +00:00
fix(ui): stop the add-provider modal from shifting while it loads (#13179)
This commit is contained in:
1 parent
75c9a6bf51
commit
dcd3d5a0fb
22 files changed
+799
-151
No files matched your search
@@ -2,7 +2,7 @@ import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { RUNTIME_CONFIG_SCRIPT_ID } from "@/lib/runtime-config.shared";
|
||||
|
||||
import { isCloud, isSelfRegistrationEnabled } from "./env";
|
||||
import { isCloud, isRegistryEnabled, isSelfRegistrationEnabled } from "./env";
|
||||
|
||||
const writeIsland = (content: Record<string, unknown> | string) => {
|
||||
const el = document.createElement("script");
|
||||
@@ -95,3 +95,38 @@ describe("isSelfRegistrationEnabled", () => {
|
||||
expect(isSelfRegistrationEnabled()).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("isRegistryEnabled", () => {
|
||||
afterEach(() => {
|
||||
vi.unstubAllEnvs();
|
||||
document.head.innerHTML = "";
|
||||
});
|
||||
|
||||
it('returns true in Prowler Cloud when UI_REGISTRY_ENABLED is "true"', () => {
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "true");
|
||||
vi.stubEnv("UI_REGISTRY_ENABLED", "true");
|
||||
expect(isRegistryEnabled()).toBe(true);
|
||||
});
|
||||
|
||||
it("returns false in Prowler Cloud when UI_REGISTRY_ENABLED is unset", () => {
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "true");
|
||||
expect(isRegistryEnabled()).toBe(false);
|
||||
});
|
||||
|
||||
it('returns false outside Prowler Cloud even when UI_REGISTRY_ENABLED is "true"', () => {
|
||||
vi.stubEnv("UI_REGISTRY_ENABLED", "true");
|
||||
expect(isRegistryEnabled()).toBe(false);
|
||||
});
|
||||
|
||||
it("uses the island flags over the env vars", () => {
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "true");
|
||||
vi.stubEnv("UI_REGISTRY_ENABLED", "true");
|
||||
writeIsland({ cloudEnabled: true, registryEnabled: false });
|
||||
expect(isRegistryEnabled()).toBe(false);
|
||||
|
||||
document.head.innerHTML = "";
|
||||
vi.stubEnv("UI_REGISTRY_ENABLED", "false");
|
||||
writeIsland({ cloudEnabled: true, registryEnabled: true });
|
||||
expect(isRegistryEnabled()).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -21,6 +21,21 @@ export function isCloud(): boolean {
|
||||
return readBoolEnv("UI_CLOUD_ENABLED");
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this Cloud deployment offers Registry providers (`UI_REGISTRY_ENABLED`).
|
||||
*
|
||||
* Read from the island in the browser, then the env, like `isCloud()`. It only
|
||||
* gates the deployment: per-user Registry access is still decided server-side.
|
||||
*/
|
||||
export function isRegistryEnabled(): boolean {
|
||||
if (!isCloud()) return false;
|
||||
|
||||
const islandConfig = readRuntimeConfigIsland();
|
||||
if (islandConfig) return islandConfig.registryEnabled;
|
||||
|
||||
return readBoolEnv("UI_REGISTRY_ENABLED");
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether visitors can create an account without an invitation.
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user