Fix UIFeature.Registration not applying to all paths (#10371)
This commit is contained in:
parent
587da5b7dc
commit
e0e83bd81d
3 changed files with 39 additions and 31 deletions
|
@ -27,6 +27,8 @@ import Modal from "./Modal";
|
||||||
import { _t } from "./languageHandler";
|
import { _t } from "./languageHandler";
|
||||||
import QuestionDialog from "./components/views/dialogs/QuestionDialog";
|
import QuestionDialog from "./components/views/dialogs/QuestionDialog";
|
||||||
import { Action } from "./dispatcher/actions";
|
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.
|
// 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
|
// 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(
|
export async function startAnyRegistrationFlow(
|
||||||
// eslint-disable-next-line camelcase
|
// 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> {
|
): Promise<void> {
|
||||||
if (options === undefined) options = {};
|
|
||||||
const modal = Modal.createDialog(QuestionDialog, {
|
const modal = Modal.createDialog(QuestionDialog, {
|
||||||
hasCancelButton: true,
|
hasCancelButton: true,
|
||||||
quitOnly: true,
|
quitOnly: true,
|
||||||
title: _t("Sign In or Create Account"),
|
title: SettingsStore.getValue(UIFeature.Registration) ? _t("Sign In or Create Account") : _t("Sign In"),
|
||||||
description: _t("Use your account or create a new one to continue."),
|
description: SettingsStore.getValue(UIFeature.Registration)
|
||||||
button: _t("Create Account"),
|
? _t("Use your account or create a new one to continue.")
|
||||||
extraButtons: [
|
: _t("Use your account to continue."),
|
||||||
<button
|
button: _t("Sign In"),
|
||||||
key="start_login"
|
extraButtons: SettingsStore.getValue(UIFeature.Registration)
|
||||||
onClick={() => {
|
? [
|
||||||
modal.close();
|
<button
|
||||||
dis.dispatch({ action: "start_login", screenAfterLogin: options.screen_after });
|
key="register"
|
||||||
}}
|
onClick={() => {
|
||||||
>
|
modal.close();
|
||||||
{_t("Sign In")}
|
dis.dispatch({ action: "start_registration", screenAfterLogin: options.screen_after });
|
||||||
</button>,
|
}}
|
||||||
],
|
>
|
||||||
|
{_t("Create Account")}
|
||||||
|
</button>,
|
||||||
|
]
|
||||||
|
: [],
|
||||||
onFinished: (proceed) => {
|
onFinished: (proceed) => {
|
||||||
if (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) {
|
} else if (options.go_home_on_cancel) {
|
||||||
dis.dispatch({ action: Action.ViewHomePage });
|
dis.dispatch({ action: Action.ViewHomePage });
|
||||||
} else if (options.go_welcome_on_cancel) {
|
} else if (options.go_welcome_on_cancel) {
|
||||||
|
|
|
@ -289,7 +289,7 @@ export default class UserMenu extends React.Component<IProps, IState> {
|
||||||
private renderContextMenu = (): React.ReactNode => {
|
private renderContextMenu = (): React.ReactNode => {
|
||||||
if (!this.state.contextMenuPosition) return null;
|
if (!this.state.contextMenuPosition) return null;
|
||||||
|
|
||||||
let topSection;
|
let topSection: JSX.Element | undefined;
|
||||||
if (MatrixClientPeg.get().isGuest()) {
|
if (MatrixClientPeg.get().isGuest()) {
|
||||||
topSection = (
|
topSection = (
|
||||||
<div className="mx_UserMenu_contextMenu_header mx_UserMenu_contextMenu_guestPrompts">
|
<div className="mx_UserMenu_contextMenu_header mx_UserMenu_contextMenu_guestPrompts">
|
||||||
|
@ -304,17 +304,19 @@ export default class UserMenu extends React.Component<IProps, IState> {
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
)}
|
)}
|
||||||
{_t(
|
{SettingsStore.getValue(UIFeature.Registration)
|
||||||
"New here? <a>Create an account</a>",
|
? _t(
|
||||||
{},
|
"New here? <a>Create an account</a>",
|
||||||
{
|
{},
|
||||||
a: (sub) => (
|
{
|
||||||
<AccessibleButton kind="link_inline" onClick={this.onRegisterClick}>
|
a: (sub) => (
|
||||||
{sub}
|
<AccessibleButton kind="link_inline" onClick={this.onRegisterClick}>
|
||||||
</AccessibleButton>
|
{sub}
|
||||||
),
|
</AccessibleButton>
|
||||||
},
|
),
|
||||||
)}
|
},
|
||||||
|
)
|
||||||
|
: null}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -368,9 +368,10 @@
|
||||||
"Zambia": "Zambia",
|
"Zambia": "Zambia",
|
||||||
"Zimbabwe": "Zimbabwe",
|
"Zimbabwe": "Zimbabwe",
|
||||||
"Sign In or Create Account": "Sign In or Create Account",
|
"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",
|
"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",
|
"Default": "Default",
|
||||||
"Restricted": "Restricted",
|
"Restricted": "Restricted",
|
||||||
"Moderator": "Moderator",
|
"Moderator": "Moderator",
|
||||||
|
|
Loading…
Reference in a new issue