Merge pull request #666 from matrix-org/luke/rts-welcome-pages

RTS Welcome Pages
This commit is contained in:
David Baker 2017-02-07 13:42:47 +00:00 committed by GitHub
commit 96539a4054
4 changed files with 38 additions and 2 deletions

BIN
.DS_Store vendored

Binary file not shown.

View file

@ -16,6 +16,7 @@ limitations under the License.
/** The types of page which can be shown by the LoggedInView */ /** The types of page which can be shown by the LoggedInView */
export default { export default {
HomePage: "home_page",
RoomView: "room_view", RoomView: "room_view",
UserSettings: "user_settings", UserSettings: "user_settings",
CreateRoom: "create_room", CreateRoom: "create_room",

View file

@ -42,6 +42,8 @@ export default React.createClass({
onRoomCreated: React.PropTypes.func, onRoomCreated: React.PropTypes.func,
onUserSettingsClose: React.PropTypes.func, onUserSettingsClose: React.PropTypes.func,
teamToken: React.PropTypes.string,
// and lots and lots of other stuff. // and lots and lots of other stuff.
}, },
@ -137,6 +139,7 @@ export default React.createClass({
var UserSettings = sdk.getComponent('structures.UserSettings'); var UserSettings = sdk.getComponent('structures.UserSettings');
var CreateRoom = sdk.getComponent('structures.CreateRoom'); var CreateRoom = sdk.getComponent('structures.CreateRoom');
var RoomDirectory = sdk.getComponent('structures.RoomDirectory'); var RoomDirectory = sdk.getComponent('structures.RoomDirectory');
var HomePage = sdk.getComponent('structures.HomePage');
var MatrixToolbar = sdk.getComponent('globals.MatrixToolbar'); var MatrixToolbar = sdk.getComponent('globals.MatrixToolbar');
var GuestWarningBar = sdk.getComponent('globals.GuestWarningBar'); var GuestWarningBar = sdk.getComponent('globals.GuestWarningBar');
var NewVersionBar = sdk.getComponent('globals.NewVersionBar'); var NewVersionBar = sdk.getComponent('globals.NewVersionBar');
@ -191,6 +194,16 @@ export default React.createClass({
/>; />;
if (!this.props.collapse_rhs) right_panel = <RightPanel opacity={this.props.sideOpacity}/>; if (!this.props.collapse_rhs) right_panel = <RightPanel opacity={this.props.sideOpacity}/>;
break; break;
case PageTypes.HomePage:
page_element = <HomePage
collapsedRhs={this.props.collapse_rhs}
teamServerUrl={this.props.config.teamServerConfig.teamServerURL}
teamToken={this.props.teamToken}
/>
if (!this.props.collapse_rhs) right_panel = <RightPanel opacity={this.props.sideOpacity}/>
break;
case PageTypes.UserView: case PageTypes.UserView:
page_element = null; // deliberately null for now page_element = null; // deliberately null for now
right_panel = <RightPanel userId={this.props.viewUserId} opacity={this.props.sideOpacity} />; right_panel = <RightPanel userId={this.props.viewUserId} opacity={this.props.sideOpacity} />;

View file

@ -190,6 +190,11 @@ module.exports = React.createClass({
if (this.props.config.sync_timeline_limit) { if (this.props.config.sync_timeline_limit) {
MatrixClientPeg.opts.initialSyncLimit = this.props.config.sync_timeline_limit; MatrixClientPeg.opts.initialSyncLimit = this.props.config.sync_timeline_limit;
} }
// Use the locally-stored team token first, then as a fall-back, check to see if
// a referral link was used, which will contain a query parameter `team_token`.
this._teamToken = window.localStorage.getItem('mx_team_token') ||
this.props.startingFragmentQueryParams.team_token;
}, },
componentDidMount: function() { componentDidMount: function() {
@ -421,6 +426,10 @@ module.exports = React.createClass({
this._setPage(PageTypes.RoomDirectory); this._setPage(PageTypes.RoomDirectory);
this.notifyNewScreen('directory'); this.notifyNewScreen('directory');
break; break;
case 'view_home_page':
this._setPage(PageTypes.HomePage);
this.notifyNewScreen('home');
break;
case 'view_create_chat': case 'view_create_chat':
this._createChat(); this._createChat();
break; break;
@ -690,7 +699,11 @@ module.exports = React.createClass({
)[0].roomId; )[0].roomId;
self.setState({ready: true, currentRoomId: firstRoom, page_type: PageTypes.RoomView}); self.setState({ready: true, currentRoomId: firstRoom, page_type: PageTypes.RoomView});
} else { } else {
self.setState({ready: true, page_type: PageTypes.RoomDirectory}); if (self._teamToken) {
self.setState({ready: true, page_type: PageTypes.HomePage});
} else {
self.setState({ready: true, page_type: PageTypes.RoomDirectory});
}
} }
} else { } else {
self.setState({ready: true, page_type: PageTypes.RoomView}); self.setState({ready: true, page_type: PageTypes.RoomView});
@ -710,7 +723,11 @@ module.exports = React.createClass({
} else { } else {
// There is no information on presentedId // There is no information on presentedId
// so point user to fallback like /directory // so point user to fallback like /directory
self.notifyNewScreen('directory'); if (self._teamToken) {
self.notifyNewScreen('home');
} else {
self.notifyNewScreen('directory');
}
} }
dis.dispatch({action: 'focus_composer'}); dis.dispatch({action: 'focus_composer'});
@ -774,6 +791,10 @@ module.exports = React.createClass({
dis.dispatch({ dis.dispatch({
action: 'view_user_settings', action: 'view_user_settings',
}); });
} else if (screen == 'home') {
dis.dispatch({
action: 'view_home_page',
});
} else if (screen == 'directory') { } else if (screen == 'directory') {
dis.dispatch({ dis.dispatch({
action: 'view_room_directory', action: 'view_room_directory',
@ -1033,6 +1054,7 @@ module.exports = React.createClass({
onRoomIdResolved={this.onRoomIdResolved} onRoomIdResolved={this.onRoomIdResolved}
onRoomCreated={this.onRoomCreated} onRoomCreated={this.onRoomCreated}
onUserSettingsClose={this.onUserSettingsClose} onUserSettingsClose={this.onUserSettingsClose}
teamToken={this._teamToken}
{...this.props} {...this.props}
{...this.state} {...this.state}
/> />