From e0e83bd81de3dc61aa99a496d0796753cf0e22b6 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 14 Mar 2023 15:20:38 +0000 Subject: [PATCH] Fix UIFeature.Registration not applying to all paths (#10371) --- src/Registration.tsx | 39 +++++++++++++++----------- src/components/structures/UserMenu.tsx | 26 +++++++++-------- src/i18n/strings/en_EN.json | 5 ++-- 3 files changed, 39 insertions(+), 31 deletions(-) diff --git a/src/Registration.tsx b/src/Registration.tsx index 0b3cdd19d7..f96aef2251 100644 --- a/src/Registration.tsx +++ b/src/Registration.tsx @@ -27,6 +27,8 @@ import Modal from "./Modal"; import { _t } from "./languageHandler"; import QuestionDialog from "./components/views/dialogs/QuestionDialog"; import { Action } from "./dispatcher/actions"; +import SettingsStore from "./settings/SettingsStore"; +import { UIFeature } from "./settings/UIFeature"; // Regex for what a "safe" or "Matrix-looking" localpart would be. // TODO: Update as needed for https://github.com/matrix-org/matrix-doc/issues/1514 @@ -46,29 +48,32 @@ export const SAFE_LOCALPART_REGEX = /^[a-z0-9=_\-./]+$/; */ export async function startAnyRegistrationFlow( // eslint-disable-next-line camelcase - options: { go_home_on_cancel?: boolean; go_welcome_on_cancel?: boolean; screen_after?: boolean }, + options: { go_home_on_cancel?: boolean; go_welcome_on_cancel?: boolean; screen_after?: boolean } = {}, ): Promise { - if (options === undefined) options = {}; const modal = Modal.createDialog(QuestionDialog, { hasCancelButton: true, quitOnly: true, - title: _t("Sign In or Create Account"), - description: _t("Use your account or create a new one to continue."), - button: _t("Create Account"), - extraButtons: [ - , - ], + title: SettingsStore.getValue(UIFeature.Registration) ? _t("Sign In or Create Account") : _t("Sign In"), + description: SettingsStore.getValue(UIFeature.Registration) + ? _t("Use your account or create a new one to continue.") + : _t("Use your account to continue."), + button: _t("Sign In"), + extraButtons: SettingsStore.getValue(UIFeature.Registration) + ? [ + , + ] + : [], onFinished: (proceed) => { if (proceed) { - dis.dispatch({ action: "start_registration", screenAfterLogin: options.screen_after }); + dis.dispatch({ action: "start_login", screenAfterLogin: options.screen_after }); } else if (options.go_home_on_cancel) { dis.dispatch({ action: Action.ViewHomePage }); } else if (options.go_welcome_on_cancel) { diff --git a/src/components/structures/UserMenu.tsx b/src/components/structures/UserMenu.tsx index 0780fc408d..0f9569d6bf 100644 --- a/src/components/structures/UserMenu.tsx +++ b/src/components/structures/UserMenu.tsx @@ -289,7 +289,7 @@ export default class UserMenu extends React.Component { private renderContextMenu = (): React.ReactNode => { if (!this.state.contextMenuPosition) return null; - let topSection; + let topSection: JSX.Element | undefined; if (MatrixClientPeg.get().isGuest()) { topSection = (
@@ -304,17 +304,19 @@ export default class UserMenu extends React.Component { ), }, )} - {_t( - "New here? Create an account", - {}, - { - a: (sub) => ( - - {sub} - - ), - }, - )} + {SettingsStore.getValue(UIFeature.Registration) + ? _t( + "New here? Create an account", + {}, + { + a: (sub) => ( + + {sub} + + ), + }, + ) + : null}
); } diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index ab1c3131f0..ad8d4e2abe 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -368,9 +368,10 @@ "Zambia": "Zambia", "Zimbabwe": "Zimbabwe", "Sign In or Create Account": "Sign In or Create Account", - "Use your account or create a new one to continue.": "Use your account or create a new one to continue.", - "Create Account": "Create Account", "Sign In": "Sign In", + "Use your account or create a new one to continue.": "Use your account or create a new one to continue.", + "Use your account to continue.": "Use your account to continue.", + "Create Account": "Create Account", "Default": "Default", "Restricted": "Restricted", "Moderator": "Moderator",