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

Fix UIFeature.Registration not applying to all paths #10371

Merged
merged 1 commit into from
Mar 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 22 additions & 17 deletions src/Registration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<void> {
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: [
<button
key="start_login"
onClick={() => {
modal.close();
dis.dispatch({ action: "start_login", screenAfterLogin: options.screen_after });
}}
>
{_t("Sign In")}
</button>,
],
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)
? [
<button
key="register"
onClick={() => {
modal.close();
dis.dispatch({ action: "start_registration", screenAfterLogin: options.screen_after });
}}
>
{_t("Create Account")}
</button>,
]
: [],
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) {
Expand Down
26 changes: 14 additions & 12 deletions src/components/structures/UserMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ export default class UserMenu extends React.Component<IProps, IState> {
private renderContextMenu = (): React.ReactNode => {
if (!this.state.contextMenuPosition) return null;

let topSection;
let topSection: JSX.Element | undefined;
if (MatrixClientPeg.get().isGuest()) {
topSection = (
<div className="mx_UserMenu_contextMenu_header mx_UserMenu_contextMenu_guestPrompts">
Expand All @@ -304,17 +304,19 @@ export default class UserMenu extends React.Component<IProps, IState> {
),
},
)}
{_t(
"New here? <a>Create an account</a>",
{},
{
a: (sub) => (
<AccessibleButton kind="link_inline" onClick={this.onRegisterClick}>
{sub}
</AccessibleButton>
),
},
)}
{SettingsStore.getValue(UIFeature.Registration)
? _t(
"New here? <a>Create an account</a>",
{},
{
a: (sub) => (
<AccessibleButton kind="link_inline" onClick={this.onRegisterClick}>
{sub}
</AccessibleButton>
),
},
)
: null}
</div>
);
}
Expand Down
3 changes: 2 additions & 1 deletion src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,10 @@
"Zambia": "Zambia",
"Zimbabwe": "Zimbabwe",
"Sign In or Create Account": "Sign In or 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",
"Sign In": "Sign In",
"Default": "Default",
"Restricted": "Restricted",
"Moderator": "Moderator",
Expand Down