From 843f86fc1c9b534f9b46445fd94ceb7f98733b71 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Thu, 7 Feb 2019 16:25:09 +0000 Subject: [PATCH] Add separate welcome view --- src/components/structures/EmbeddedPage.js | 27 +++++++++++----- src/components/structures/LoggedInView.js | 1 + src/components/structures/MatrixChat.js | 34 ++++++++++++++++---- src/components/views/auth/Welcome.js | 39 +++++++++++++++++++++++ 4 files changed, 87 insertions(+), 14 deletions(-) create mode 100644 src/components/views/auth/Welcome.js diff --git a/src/components/structures/EmbeddedPage.js b/src/components/structures/EmbeddedPage.js index 8e5be965e7..bb671094db 100644 --- a/src/components/structures/EmbeddedPage.js +++ b/src/components/structures/EmbeddedPage.js @@ -33,6 +33,8 @@ export default class EmbeddedPage extends React.PureComponent { url: PropTypes.string, // Class name prefix to apply for a given instance className: PropTypes.string, + // Whether to wrap the page in a scrollbar + scrollbar: PropTypes.bool, }; static contextTypes = { @@ -83,19 +85,28 @@ export default class EmbeddedPage extends React.PureComponent { } render() { - const isGuest = this.context.matrixClient.isGuest(); + const client = this.context.matrixClient; + const isGuest = client ? client.isGuest() : true; const className = this.props.className; const classes = classnames({ [className]: true, [`${className}_guest`]: isGuest, }); - const GeminiScrollbarWrapper = sdk.getComponent("elements.GeminiScrollbarWrapper"); - return -
-
-
; + const content =
+
; + + if (this.props.scrollbar) { + const GeminiScrollbarWrapper = sdk.getComponent("elements.GeminiScrollbarWrapper"); + return + {content} + ; + } else { + return
+ {content} +
; + } } } diff --git a/src/components/structures/LoggedInView.js b/src/components/structures/LoggedInView.js index 22a6110674..b285bdc782 100644 --- a/src/components/structures/LoggedInView.js +++ b/src/components/structures/LoggedInView.js @@ -461,6 +461,7 @@ const LoggedInView = React.createClass({ { pageElement = ; } break; diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index bb90b2aeb5..a9918ff155 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -60,27 +60,30 @@ const VIEWS = { // trying to re-animate a matrix client or register as a guest. LOADING: 0, + // we are showing the welcome view + WELCOME: 1, + // we are showing the login view - LOGIN: 1, + LOGIN: 2, // we are showing the registration view - REGISTER: 2, + REGISTER: 3, // completeing the registration flow - POST_REGISTRATION: 3, + POST_REGISTRATION: 4, // showing the 'forgot password' view - FORGOT_PASSWORD: 4, + FORGOT_PASSWORD: 5, // we have valid matrix credentials (either via an explicit login, via the // initial re-animation/guest registration, or via a registration), and are // now setting up a matrixclient to talk to it. This isn't an instant // process because we need to clear out indexeddb. While it is going on we // show a big spinner. - LOGGING_IN: 5, + LOGGING_IN: 6, // we are logged in with an active matrix client. - LOGGED_IN: 6, + LOGGED_IN: 7, }; // Actions that are redirected through the onboarding process prior to being @@ -606,6 +609,9 @@ export default React.createClass({ case 'view_group': this._viewGroup(payload); break; + case 'view_welcome_page': + this._viewWelcome(); + break; case 'view_home_page': this._viewHome(); break; @@ -881,6 +887,13 @@ export default React.createClass({ this.notifyNewScreen('group/' + groupId); }, + _viewWelcome() { + this.setStateForNewView({ + view: VIEWS.WELCOME, + }); + this.notifyNewScreen('welcome'); + }, + _viewHome: function() { // The home page requires the "logged in" view, so we'll set that. this.setStateForNewView({ @@ -1466,6 +1479,10 @@ export default React.createClass({ dis.dispatch({ action: 'view_user_settings', }); + } else if (screen == 'welcome') { + dis.dispatch({ + action: 'view_welcome_page', + }); } else if (screen == 'home') { dis.dispatch({ action: 'view_home_page', @@ -1849,6 +1866,11 @@ export default React.createClass({ } } + if (this.state.view === VIEWS.WELCOME) { + const Welcome = sdk.getComponent('auth.Welcome'); + return ; + } + if (this.state.view === VIEWS.REGISTER) { const Registration = sdk.getComponent('structures.auth.Registration'); return ( diff --git a/src/components/views/auth/Welcome.js b/src/components/views/auth/Welcome.js new file mode 100644 index 0000000000..162e549724 --- /dev/null +++ b/src/components/views/auth/Welcome.js @@ -0,0 +1,39 @@ +/* +Copyright 2019 New Vector Ltd + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import React from 'react'; +import sdk from '../../../index'; +import SdkConfig from '../../../SdkConfig'; + +export default class Welcome extends React.PureComponent { + render() { + const AuthPage = sdk.getComponent("auth.AuthPage"); + const AuthHeader = sdk.getComponent("auth.AuthHeader"); + const AuthBody = sdk.getComponent("auth.AuthBody"); + const EmbeddedPage = sdk.getComponent('structures.EmbeddedPage'); + + return ( + + + + + + + ); + } +}