Skip to content

Commit ab068cc

Browse files
committed
improve login, including checkbox fix for advanced options, rechecking when you change server, avoiding flickering when you change HS, better error/spinner layout, and trimming whitespace
1 parent 25a4f1f commit ab068cc

4 files changed

Lines changed: 43 additions & 30 deletions

File tree

‎skins/base/css/templates/Login.css‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,19 @@ limitations under the License.
8282
opacity: 0.8;
8383
}
8484

85+
.mx_Login_loader {
86+
position: absolute;
87+
left: 50%;
88+
margin-top: 12px;
89+
}
90+
8591
.mx_Login_error {
8692
color: #ff2020;
8793
font-weight: bold;
8894
text-align: center;
89-
margin-bottom: 24px;
95+
height: 24px;
96+
margin-top: 12px;
97+
margin-bottom: 12px;
9098
}
9199

92100
.mx_Login_create:link {

‎skins/base/views/templates/Login.js‎

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,14 @@ module.exports = React.createClass({
7474
*/
7575
getFormVals: function() {
7676
return {
77-
'username': this.refs.user.getDOMNode().value,
78-
'password': this.refs.pass.getDOMNode().value
77+
'username': this.refs.user.getDOMNode().value.trim(),
78+
'password': this.refs.pass.getDOMNode().value.trim()
7979
};
8080
},
8181

8282
onHsUrlChanged: function() {
83-
this.customHsUrl = this.refs.serverConfig.getHsUrl();
84-
this.customIsUrl = this.refs.serverConfig.getIsUrl();
83+
this.customHsUrl = this.refs.serverConfig.getHsUrl().trim();
84+
this.customIsUrl = this.refs.serverConfig.getIsUrl().trim();
8585
MatrixClientPeg.replaceUsingUrls(
8686
this.getHsUrl(),
8787
this.getIsUrl()
@@ -93,23 +93,24 @@ module.exports = React.createClass({
9393
// XXX: HSes do not have to offer password auth, so we
9494
// need to update and maybe show a different component
9595
// when a new HS is entered.
96-
/*if (this.updateHsTimeout) {
96+
if (this.updateHsTimeout) {
9797
clearTimeout(this.updateHsTimeout);
9898
}
9999
var self = this;
100100
this.updateHsTimeout = setTimeout(function() {
101101
self.onHSChosen();
102-
}, 500);*/
102+
}, 500);
103103
},
104104

105105
componentForStep: function(step) {
106106
switch (step) {
107107
case 'choose_hs':
108+
case 'fetch_stages':
108109
var serverConfigStyle = {};
109110
serverConfigStyle.display = this.state.serverConfigVisible ? 'block' : 'none';
110111
return (
111112
<div>
112-
<input className="mx_Login_checkbox" id="advanced" type="checkbox" value={this.state.serverConfigVisible} onChange={this.onServerConfigVisibleChange} />
113+
<input className="mx_Login_checkbox" id="advanced" type="checkbox" checked={this.state.serverConfigVisible} onChange={this.onServerConfigVisibleChange} />
113114
<label className="mx_Login_label" htmlFor="advanced">Use custom server options (advanced)</label>
114115
<div style={serverConfigStyle}>
115116
<ServerConfig ref="serverConfig"
@@ -126,7 +127,7 @@ module.exports = React.createClass({
126127
<form onSubmit={this.onUserPassEntered}>
127128
<input className="mx_Login_field" ref="user" type="text" value={this.state.username} onChange={this.onUsernameChanged} placeholder="Email or user name" /><br />
128129
<input className="mx_Login_field" ref="pass" type="password" value={this.state.password} onChange={this.onPasswordChanged} placeholder="Password" /><br />
129-
{this.componentForStep('choose_hs')}
130+
{ this.componentForStep('choose_hs') }
130131
<input className="mx_Login_submit" type="submit" value="Log in" />
131132
</form>
132133
</div>
@@ -143,20 +144,18 @@ module.exports = React.createClass({
143144
},
144145

145146
loginContent: function() {
146-
if (this.state.busy) {
147-
return (
148-
<Loader />
149-
);
150-
} else {
151-
return (
152-
<div>
153-
<h2>Sign in</h2>
154-
{this.componentForStep(this.state.step)}
155-
<div className="mx_Login_error">{this.state.errorText}</div>
156-
<a className="mx_Login_create" onClick={this.showRegister} href="#">Create a new account</a>
147+
var loader = this.state.busy ? <div className="mx_Login_loader"><Loader /></div> : null;
148+
return (
149+
<div>
150+
<h2>Sign in</h2>
151+
{this.componentForStep(this.state.step)}
152+
<div className="mx_Login_error">
153+
{ loader }
154+
{this.state.errorText}
157155
</div>
158-
);
159-
}
156+
<a className="mx_Login_create" onClick={this.showRegister} href="#">Create a new account</a>
157+
</div>
158+
);
160159
},
161160

162161
render: function() {

‎skins/base/views/templates/Register.js‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ module.exports = React.createClass({
4646

4747
getRegFormVals: function() {
4848
return {
49-
email: this.refs.email.getDOMNode().value,
50-
username: this.refs.username.getDOMNode().value,
51-
password: this.refs.password.getDOMNode().value,
52-
confirmPassword: this.refs.confirmPassword.getDOMNode().value
49+
email: this.refs.email.getDOMNode().value.trim(),
50+
username: this.refs.username.getDOMNode().value.trim(),
51+
password: this.refs.password.getDOMNode().value.trim(),
52+
confirmPassword: this.refs.confirmPassword.getDOMNode().value.trim()
5353
};
5454
},
5555

‎src/controllers/templates/Login.js‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ module.exports = {
3535
},
3636

3737
setStep: function(step) {
38-
this.setState({ step: step, errorText: '', busy: false });
38+
this.setState({ step: step, busy: false });
3939
},
4040

4141
onHSChosen: function() {
@@ -45,11 +45,14 @@ module.exports = {
4545
);
4646
this.setState({
4747
hs_url: this.getHsUrl(),
48-
is_url: this.getIsUrl()
48+
is_url: this.getIsUrl(),
4949
});
5050
this.setStep("fetch_stages");
5151
var cli = MatrixClientPeg.get();
52-
this.setState({busy: true});
52+
this.setState({
53+
busy: true,
54+
errorText: "",
55+
});
5356
var self = this;
5457
cli.loginFlows().done(function(result) {
5558
self.setState({
@@ -66,7 +69,10 @@ module.exports = {
6669

6770
onUserPassEntered: function(ev) {
6871
ev.preventDefault();
69-
this.setState({busy: true});
72+
this.setState({
73+
busy: true,
74+
errorText: "",
75+
});
7076
var self = this;
7177

7278
var formVals = this.getFormVals();

0 commit comments

Comments
 (0)