Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit e0e83bd

Browse files
authored
Fix UIFeature.Registration not applying to all paths (#10371)
1 parent 587da5b commit e0e83bd

File tree

3 files changed

+38
-30
lines changed

3 files changed

+38
-30
lines changed

src/Registration.tsx

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ import Modal from "./Modal";
2727
import { _t } from "./languageHandler";
2828
import QuestionDialog from "./components/views/dialogs/QuestionDialog";
2929
import { Action } from "./dispatcher/actions";
30+
import SettingsStore from "./settings/SettingsStore";
31+
import { UIFeature } from "./settings/UIFeature";
3032

3133
// Regex for what a "safe" or "Matrix-looking" localpart would be.
3234
// 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=_\-./]+$/;
4648
*/
4749
export async function startAnyRegistrationFlow(
4850
// eslint-disable-next-line camelcase
49-
options: { go_home_on_cancel?: boolean; go_welcome_on_cancel?: boolean; screen_after?: boolean },
51+
options: { go_home_on_cancel?: boolean; go_welcome_on_cancel?: boolean; screen_after?: boolean } = {},
5052
): Promise<void> {
51-
if (options === undefined) options = {};
5253
const modal = Modal.createDialog(QuestionDialog, {
5354
hasCancelButton: true,
5455
quitOnly: true,
55-
title: _t("Sign In or Create Account"),
56-
description: _t("Use your account or create a new one to continue."),
57-
button: _t("Create Account"),
58-
extraButtons: [
59-
<button
60-
key="start_login"
61-
onClick={() => {
62-
modal.close();
63-
dis.dispatch({ action: "start_login", screenAfterLogin: options.screen_after });
64-
}}
65-
>
66-
{_t("Sign In")}
67-
</button>,
68-
],
56+
title: SettingsStore.getValue(UIFeature.Registration) ? _t("Sign In or Create Account") : _t("Sign In"),
57+
description: SettingsStore.getValue(UIFeature.Registration)
58+
? _t("Use your account or create a new one to continue.")
59+
: _t("Use your account to continue."),
60+
button: _t("Sign In"),
61+
extraButtons: SettingsStore.getValue(UIFeature.Registration)
62+
? [
63+
<button
64+
key="register"
65+
onClick={() => {
66+
modal.close();
67+
dis.dispatch({ action: "start_registration", screenAfterLogin: options.screen_after });
68+
}}
69+
>
70+
{_t("Create Account")}
71+
</button>,
72+
]
73+
: [],
6974
onFinished: (proceed) => {
7075
if (proceed) {
71-
dis.dispatch({ action: "start_registration", screenAfterLogin: options.screen_after });
76+
dis.dispatch({ action: "start_login", screenAfterLogin: options.screen_after });
7277
} else if (options.go_home_on_cancel) {
7378
dis.dispatch({ action: Action.ViewHomePage });
7479
} else if (options.go_welcome_on_cancel) {

src/components/structures/UserMenu.tsx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ export default class UserMenu extends React.Component<IProps, IState> {
289289
private renderContextMenu = (): React.ReactNode => {
290290
if (!this.state.contextMenuPosition) return null;
291291

292-
let topSection;
292+
let topSection: JSX.Element | undefined;
293293
if (MatrixClientPeg.get().isGuest()) {
294294
topSection = (
295295
<div className="mx_UserMenu_contextMenu_header mx_UserMenu_contextMenu_guestPrompts">
@@ -304,17 +304,19 @@ export default class UserMenu extends React.Component<IProps, IState> {
304304
),
305305
},
306306
)}
307-
{_t(
308-
"New here? <a>Create an account</a>",
309-
{},
310-
{
311-
a: (sub) => (
312-
<AccessibleButton kind="link_inline" onClick={this.onRegisterClick}>
313-
{sub}
314-
</AccessibleButton>
315-
),
316-
},
317-
)}
307+
{SettingsStore.getValue(UIFeature.Registration)
308+
? _t(
309+
"New here? <a>Create an account</a>",
310+
{},
311+
{
312+
a: (sub) => (
313+
<AccessibleButton kind="link_inline" onClick={this.onRegisterClick}>
314+
{sub}
315+
</AccessibleButton>
316+
),
317+
},
318+
)
319+
: null}
318320
</div>
319321
);
320322
}

src/i18n/strings/en_EN.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,9 +368,10 @@
368368
"Zambia": "Zambia",
369369
"Zimbabwe": "Zimbabwe",
370370
"Sign In or Create Account": "Sign In or Create Account",
371+
"Sign In": "Sign In",
371372
"Use your account or create a new one to continue.": "Use your account or create a new one to continue.",
373+
"Use your account to continue.": "Use your account to continue.",
372374
"Create Account": "Create Account",
373-
"Sign In": "Sign In",
374375
"Default": "Default",
375376
"Restricted": "Restricted",
376377
"Moderator": "Moderator",

0 commit comments

Comments
 (0)