web: only show debug locale if debug mode is enabled (#5111)

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens L 2023-03-28 20:49:40 +02:00 committed by GitHub
parent 1d2725825c
commit 2084156f1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 3 deletions

View File

@ -1,4 +1,5 @@
import { LOCALES } from "@goauthentik/common/ui/locale"; import { LOCALES } from "@goauthentik/common/ui/locale";
import { rootInterface } from "@goauthentik/elements/Base";
import "@goauthentik/elements/Divider"; import "@goauthentik/elements/Divider";
import "@goauthentik/elements/EmptyState"; import "@goauthentik/elements/EmptyState";
import "@goauthentik/elements/forms/FormElement"; import "@goauthentik/elements/forms/FormElement";
@ -19,6 +20,7 @@ import PFTitle from "@patternfly/patternfly/components/Title/title.css";
import PFBase from "@patternfly/patternfly/patternfly-base.css"; import PFBase from "@patternfly/patternfly/patternfly-base.css";
import { import {
CapabilitiesEnum,
PromptChallenge, PromptChallenge,
PromptChallengeResponseRequest, PromptChallengeResponseRequest,
PromptTypeEnum, PromptTypeEnum,
@ -181,14 +183,24 @@ export class PromptStage extends BaseStage<PromptChallenge, PromptChallengeRespo
<option value="" ${prompt.placeholder === "" ? "selected" : ""}> <option value="" ${prompt.placeholder === "" ? "selected" : ""}>
${t`Auto-detect (based on your browser)`} ${t`Auto-detect (based on your browser)`}
</option> </option>
${LOCALES.map((locale) => { ${LOCALES.filter((locale) => {
// Only show debug locale if debug mode is enabled
if (locale.code === "debug") {
return rootInterface()?.config?.capabilities.includes(
CapabilitiesEnum.Debug,
);
}
return true;
})
.map((locale) => {
return `<option return `<option
value=${locale.code} value=${locale.code}
${prompt.placeholder === locale.code ? "selected" : ""} ${prompt.placeholder === locale.code ? "selected" : ""}
> >
${locale.code.toUpperCase()} - ${locale.label} ${locale.code.toUpperCase()} - ${locale.label}
</option>`; </option>`;
}).join("")} })
.join("")}
</select>`; </select>`;
default: default:
return `<p>invalid type '${prompt.type}'</p>`; return `<p>invalid type '${prompt.type}'</p>`;