From cfbef0177ee706a226d4eda9b7d4bc5a095100cb Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 16 Jul 2015 17:51:21 +0100 Subject: [PATCH] Fix custom server or registration & do some of new login UI --- skins/base/views/templates/Login.js | 63 +++++++++++++++++++++++--- skins/base/views/templates/Register.js | 13 ++++-- src/controllers/templates/Login.js | 3 +- 3 files changed, 67 insertions(+), 12 deletions(-) diff --git a/skins/base/views/templates/Login.js b/skins/base/views/templates/Login.js index f71e307068..ba75e5d1c0 100644 --- a/skins/base/views/templates/Login.js +++ b/skins/base/views/templates/Login.js @@ -28,15 +28,44 @@ var LoginController = require("../../../../src/controllers/templates/Login"); var ServerConfig = ComponentBroker.get("molecules/ServerConfig"); module.exports = React.createClass({ + DEFAULT_HS_URL: 'https://matrix.org', + DEFAULT_IS_URL: 'https://matrix.org', + displayName: 'Login', mixins: [LoginController], + getInitialState: function() { + return { + serverConfigVisible: false + }; + }, + + componentWillMount: function() { + this.onHSChosen(); + this.customHsUrl = this.DEFAULT_HS_URL; + this.customIsUrl = this.DEFAULT_IS_URL; + }, + getHsUrl: function() { - return this.refs.serverConfig.getHsUrl(); + if (this.state.serverConfigVisible) { + return this.refs.serverConfig.getHsUrl(); + } else { + return this.DEFAULT_HS_URL; + } }, getIsUrl: function() { - return this.refs.serverConfig.getIsUrl(); + if (this.state.serverConfigVisible) { + return this.refs.serverConfig.getIsUrl(); + } else { + return this.DEFAULT_IS_URL; + } + }, + + onServerConfigVisibleChange: function(ev) { + this.setState({ + serverConfigVisible: ev.target.checked + }); }, /** @@ -49,15 +78,35 @@ module.exports = React.createClass({ }; }, + onHsUrlChanged: function() { + this.customHsUrl = this.getHsUrl(); + this.customIsUrl = this.getIsUrl(); + if (this.updateHsTimeout) { + clearTimeout(this.updateHsTimeout); + } + /*var self = this; + this.updateHsTimeout = setTimeout(function() { + self.onHSChosen(); + }, 500);*/ + }, + componentForStep: function(step) { switch (step) { case 'choose_hs': + var serverConfigStyle = {}; + if (!this.state.serverConfigVisible) { + serverConfigStyle.display = 'none'; + } return (
-
- - - + + Use custom server options (advanced) +
+ +
); // XXX: clearly these should be separate organisms @@ -67,6 +116,7 @@ module.exports = React.createClass({


+ {this.componentForStep('choose_hs')}
@@ -94,7 +144,6 @@ module.exports = React.createClass({ render: function() { return (
- {this.loginContent()}
); diff --git a/skins/base/views/templates/Register.js b/skins/base/views/templates/Register.js index 930228b8b8..2336737864 100644 --- a/skins/base/views/templates/Register.js +++ b/skins/base/views/templates/Register.js @@ -39,6 +39,11 @@ module.exports = React.createClass({ }; }, + componentWillMount: function() { + this.customHsUrl = this.DEFAULT_HS_URL; + this.customIsUrl = this.DEFAULT_IS_URL; + }, + getRegFormVals: function() { return { email: this.refs.email.getDOMNode().value, @@ -50,7 +55,7 @@ module.exports = React.createClass({ getHsUrl: function() { if (this.state.serverConfigVisible) { - return this.refs.serverConfig.getHsUrl(); + return this.customHsUrl; } else { return this.DEFAULT_HS_URL; } @@ -58,7 +63,7 @@ module.exports = React.createClass({ getIsUrl: function() { if (this.state.serverConfigVisible) { - return this.refs.serverConfig.getIsUrl(); + return this.customIsUrl; } else { return this.DEFAULT_IS_URL; } @@ -82,6 +87,8 @@ module.exports = React.createClass({ }, onServerUrlChanged: function(newUrl) { + this.customHsUrl = this.refs.serverConfig.getHsUrl(); + this.customIsUrl = this.refs.serverConfig.getIsUrl(); this.forceUpdate(); }, @@ -104,7 +111,7 @@ module.exports = React.createClass({ Use custom server options (advanced)

diff --git a/src/controllers/templates/Login.js b/src/controllers/templates/Login.js index 07ace740d5..3d25a91062 100644 --- a/src/controllers/templates/Login.js +++ b/src/controllers/templates/Login.js @@ -38,8 +38,7 @@ module.exports = { this.setState({ step: step, errorText: '', busy: false }); }, - onHSChosen: function(ev) { - ev.preventDefault(); + onHSChosen: function() { MatrixClientPeg.replaceUsingUrls( this.getHsUrl(), this.getIsUrl()