From ca55b28135894d0f6d509aecec782ed74e3b1d56 Mon Sep 17 00:00:00 2001 From: Christian Fehmer Date: Mon, 4 Mar 2024 14:13:39 +0100 Subject: [PATCH] impr: hide login/signUp button if user signup is disabled (fehmer) (#5172) * impr: hide signIn button if user signup is disabled * move UI modifying code to ready.ts --------- Co-authored-by: Miodec --- frontend/src/html/header.html | 2 +- frontend/src/html/pages/login.html | 7 +++++-- frontend/src/ts/pages/login.ts | 11 +++++++++-- frontend/src/ts/ready.ts | 6 +++++- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/frontend/src/html/header.html b/frontend/src/html/header.html index 5ebfe0bd89da..21716d4baa8e 100644 --- a/frontend/src/html/header.html +++ b/frontend/src/html/header.html @@ -128,7 +128,7 @@

-
diff --git a/frontend/src/ts/pages/login.ts b/frontend/src/ts/pages/login.ts index aa3c55f0d5a6..c0b776391b22 100644 --- a/frontend/src/ts/pages/login.ts +++ b/frontend/src/ts/pages/login.ts @@ -6,6 +6,7 @@ import { InputIndicator } from "../elements/input-indicator"; import * as Skeleton from "../utils/skeleton"; import * as Misc from "../utils/misc"; import TypoList from "../utils/typo-list"; +import * as ServerConfiguration from "../ape/server-configuration"; export function enableSignUpButton(): void { $(".page.pageLogin .register.side button").prop("disabled", false); @@ -353,8 +354,14 @@ export const page = new Page( }, async () => { Skeleton.append("pageLogin", "main"); - enableInputs(); - enableSignUpButton(); + if (ServerConfiguration.get()?.users.signUp) { + enableInputs(); + enableSignUpButton(); + + $(".register").removeClass("hidden"); + $(".login").removeClass("hidden"); + $(".disabledNotification").addClass("hidden"); + } }, async () => { // diff --git a/frontend/src/ts/ready.ts b/frontend/src/ts/ready.ts index 0cdc10f48f08..a2358f83ee41 100644 --- a/frontend/src/ts/ready.ts +++ b/frontend/src/ts/ready.ts @@ -89,7 +89,11 @@ $(document).ready(() => { .animate({ opacity: 1 }, 250); if (ConnectionState.get()) { void PSA.show(); - void ServerConfiguration.sync(); + void ServerConfiguration.sync().then(() => { + if (ServerConfiguration.get()?.users.signUp) { + $(".signInOut").removeClass("hidden"); + } + }); } MonkeyPower.init();