mirror of
https://github.com/element-hq/element-web
synced 2024-11-24 02:05:45 +03:00
Merge pull request #5658 from matrix-org/travis/welcome-login
Add an optional config option to make the welcome page the login page
This commit is contained in:
commit
3caf07be87
2 changed files with 28 additions and 21 deletions
|
@ -1,8 +1,5 @@
|
|||
/*
|
||||
Copyright 2015, 2016 OpenMarket Ltd
|
||||
Copyright 2017 Vector Creations Ltd
|
||||
Copyright 2017-2019 New Vector Ltd
|
||||
Copyright 2019, 2020 The Matrix.org Foundation C.I.C.
|
||||
Copyright 2015-2021 The Matrix.org Foundation C.I.C.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
@ -81,6 +78,7 @@ import {UIFeature} from "../../settings/UIFeature";
|
|||
import { CommunityPrototypeStore } from "../../stores/CommunityPrototypeStore";
|
||||
import DialPadModal from "../views/voip/DialPadModal";
|
||||
import { showToast as showMobileGuideToast } from '../../toasts/MobileGuideToast';
|
||||
import { shouldUseLoginForWelcome } from "../../utils/pages";
|
||||
import SpaceStore from "../../stores/SpaceStore";
|
||||
import SpaceRoomDirectory from "./SpaceRoomDirectory";
|
||||
import {replaceableComponent} from "../../utils/replaceableComponent";
|
||||
|
@ -608,12 +606,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
|||
if (payload.screenAfterLogin) {
|
||||
this.screenAfterLogin = payload.screenAfterLogin;
|
||||
}
|
||||
this.setStateForNewView({
|
||||
view: Views.LOGIN,
|
||||
});
|
||||
this.notifyNewScreen('login');
|
||||
ThemeController.isLogin = true;
|
||||
this.themeWatcher.recheck();
|
||||
this.viewLogin();
|
||||
break;
|
||||
case 'start_password_recovery':
|
||||
this.setStateForNewView({
|
||||
|
@ -977,6 +970,9 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
|||
}
|
||||
|
||||
private viewWelcome() {
|
||||
if (shouldUseLoginForWelcome(SdkConfig.get())) {
|
||||
return this.viewLogin();
|
||||
}
|
||||
this.setStateForNewView({
|
||||
view: Views.WELCOME,
|
||||
});
|
||||
|
@ -985,6 +981,16 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
|||
this.themeWatcher.recheck();
|
||||
}
|
||||
|
||||
private viewLogin(otherState?: any) {
|
||||
this.setStateForNewView({
|
||||
view: Views.LOGIN,
|
||||
...otherState,
|
||||
});
|
||||
this.notifyNewScreen('login');
|
||||
ThemeController.isLogin = true;
|
||||
this.themeWatcher.recheck();
|
||||
}
|
||||
|
||||
private viewHome(justRegistered = false) {
|
||||
// The home page requires the "logged in" view, so we'll set that.
|
||||
this.setStateForNewView({
|
||||
|
@ -1306,17 +1312,13 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
|||
* Called when the session is logged out
|
||||
*/
|
||||
private onLoggedOut() {
|
||||
this.notifyNewScreen('login');
|
||||
this.setStateForNewView({
|
||||
view: Views.LOGIN,
|
||||
this.viewLogin({
|
||||
ready: false,
|
||||
collapseLhs: false,
|
||||
currentRoomId: null,
|
||||
});
|
||||
this.subTitleStatus = '';
|
||||
this.setPageSubtitle();
|
||||
ThemeController.isLogin = true;
|
||||
this.themeWatcher.recheck();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright 2019 New Vector Ltd
|
||||
Copyright 2019, 2021 The Matrix.org Foundation C.I.C.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
@ -14,12 +14,12 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
export function getHomePageUrl(appConfig) {
|
||||
import { ConfigOptions } from "../SdkConfig";
|
||||
|
||||
export function getHomePageUrl(appConfig: ConfigOptions): string | null {
|
||||
const pagesConfig = appConfig.embeddedPages;
|
||||
let pageUrl = null;
|
||||
if (pagesConfig) {
|
||||
pageUrl = pagesConfig.homeUrl;
|
||||
}
|
||||
let pageUrl = pagesConfig?.homeUrl;
|
||||
|
||||
if (!pageUrl) {
|
||||
// This is a deprecated config option for the home page
|
||||
// (despite the name, given we also now have a welcome
|
||||
|
@ -29,3 +29,8 @@ export function getHomePageUrl(appConfig) {
|
|||
|
||||
return pageUrl;
|
||||
}
|
||||
|
||||
export function shouldUseLoginForWelcome(appConfig: ConfigOptions): boolean {
|
||||
const pagesConfig = appConfig.embeddedPages;
|
||||
return pagesConfig?.loginForWelcome === true;
|
||||
}
|
Loading…
Reference in a new issue