Split kcContext among pages

This commit is contained in:
Joseph Garrone
2021-03-04 21:14:54 +01:00
parent 546c74aa28
commit 624409434a
12 changed files with 428 additions and 455 deletions

View File

@ -3,8 +3,8 @@ import { useState, memo } from "react";
import { Template } from "./Template";
import type { KcPagesProperties } from "./KcProperties";
import { defaultKcPagesProperties } from "./KcProperties";
import { assert } from "evt/tools/typeSafety/assert";
import { kcContext } from "../kcContext";
import { assert } from "../tools/assert";
import { kcContext } from "../kcContext";
import { useKcTranslation } from "../i18n/useKcTranslation";
import { cx } from "tss-react";
import { useConstCallback } from "powerhooks";
@ -25,13 +25,16 @@ export const Login = memo((props: LoginProps) => {
social, realm, url,
usernameEditDisabled, login,
auth, registrationDisabled
}] = useState(() => (
}] = useState(() => {
assert(
kcContext !== undefined,
"App is currently being served by keycloak"
),
kcContext
));
kcContext !== undefined &&
kcContext.pageBasename === "login.ftl"
);
return kcContext;
});
const [isLoginButtonDisabled, setIsLoginButtonDisabled] = useState(false);