Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit f6eca14

Browse files
authored
Merge pull request #1456 from matrix-org/dbkr/say_which_homeserver
Make it clearer which HS you're logging into
2 parents 99aabd9 + 0f84216 commit f6eca14

26 files changed

+61
-32
lines changed

src/components/structures/login/Login.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ module.exports = React.createClass({
290290
onPhoneNumberChanged={this.onPhoneNumberChanged}
291291
onForgotPasswordClick={this.props.onForgotPasswordClick}
292292
loginIncorrect={this.state.loginIncorrect}
293+
hsUrl={this.state.enteredHomeserverUrl}
293294
/>
294295
);
295296
case 'm.login.cas':

src/components/views/elements/Dropdown.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ class MenuOption extends React.Component {
2626
this._onClick = this._onClick.bind(this);
2727
}
2828

29+
getDefaultProps() {
30+
return {
31+
disabled: false,
32+
}
33+
}
34+
2935
_onMouseEnter() {
3036
this.props.onMouseEnter(this.props.dropdownKey);
3137
}
@@ -153,6 +159,8 @@ export default class Dropdown extends React.Component {
153159
}
154160

155161
_onInputClick(ev) {
162+
if (this.props.disabled) return;
163+
156164
if (!this.state.expanded) {
157165
this.setState({
158166
expanded: true,
@@ -294,6 +302,7 @@ export default class Dropdown extends React.Component {
294302

295303
const dropdownClasses = {
296304
mx_Dropdown: true,
305+
mx_Dropdown_disabled: this.props.disabled,
297306
};
298307
if (this.props.className) {
299308
dropdownClasses[this.props.className] = true;
@@ -329,4 +338,6 @@ Dropdown.propTypes = {
329338
// in the dropped-down menu.
330339
getShortOption: React.PropTypes.func,
331340
value: React.PropTypes.string,
341+
// negative for consistency with HTML
342+
disabled: React.PropTypes.bool,
332343
}

src/components/views/login/CountryDropdown.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export default class CountryDropdown extends React.Component {
123123
return <Dropdown className={this.props.className + " left_aligned"}
124124
onOptionChange={this._onOptionChange} onSearchChange={this._onSearchChange}
125125
menuWidth={298} getShortOption={this._getShortOption}
126-
value={value} searchEnabled={true}
126+
value={value} searchEnabled={true} disabled={this.props.disabled}
127127
>
128128
{options}
129129
</Dropdown>;
@@ -137,4 +137,5 @@ CountryDropdown.propTypes = {
137137
showPrefix: React.PropTypes.bool,
138138
onOptionChange: React.PropTypes.func.isRequired,
139139
value: React.PropTypes.string,
140+
disabled: React.PropTypes.bool,
140141
};

src/components/views/login/PasswordLogin.js

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,32 +116,43 @@ class PasswordLogin extends React.Component {
116116
this.props.onPasswordChanged(ev.target.value);
117117
}
118118

119-
renderLoginField(loginType) {
119+
renderLoginField(loginType, disabled) {
120+
const classes = {
121+
mx_Login_field: true,
122+
mx_Login_field_disabled: disabled,
123+
};
124+
120125
switch(loginType) {
121126
case PasswordLogin.LOGIN_FIELD_EMAIL:
127+
classes.mx_Login_email = true;
122128
return <input
123-
className="mx_Login_field mx_Login_email"
129+
className={classNames(classes)}
124130
key="email_input"
125131
type="text"
126132
name="username" // make it a little easier for browser's remember-password
127133
onChange={this.onUsernameChanged}
128134
placeholder="[email protected]"
129135
value={this.state.username}
130136
autoFocus
137+
disabled={disabled}
131138
/>;
132139
case PasswordLogin.LOGIN_FIELD_MXID:
140+
classes.mx_Login_username = true;
133141
return <input
134-
className="mx_Login_field mx_Login_username"
142+
className={classNames(classes)}
135143
key="username_input"
136144
type="text"
137145
name="username" // make it a little easier for browser's remember-password
138146
onChange={this.onUsernameChanged}
139147
placeholder={_t('User name')}
140148
value={this.state.username}
141149
autoFocus
150+
disabled={disabled}
142151
/>;
143152
case PasswordLogin.LOGIN_FIELD_PHONE:
144153
const CountryDropdown = sdk.getComponent('views.login.CountryDropdown');
154+
classes.mx_Login_phoneNumberField = true;
155+
classes.mx_Login_field_has_prefix = true;
145156
return <div className="mx_Login_phoneSection">
146157
<CountryDropdown
147158
className="mx_Login_phoneCountry mx_Login_field_prefix"
@@ -150,9 +161,10 @@ class PasswordLogin extends React.Component {
150161
value={this.state.phoneCountry}
151162
isSmall={true}
152163
showPrefix={true}
164+
disabled={disabled}
153165
/>
154166
<input
155-
className="mx_Login_phoneNumberField mx_Login_field mx_Login_field_has_prefix"
167+
className={classNames(classes)}
156168
ref="phoneNumber"
157169
key="phone_input"
158170
type="text"
@@ -161,6 +173,7 @@ class PasswordLogin extends React.Component {
161173
placeholder={_t("Mobile phone number")}
162174
value={this.state.phoneNumber}
163175
autoFocus
176+
disabled={disabled}
164177
/>
165178
</div>;
166179
}
@@ -177,14 +190,25 @@ class PasswordLogin extends React.Component {
177190
);
178191
}
179192

193+
let matrixIdText = '';
194+
if (this.props.hsUrl) {
195+
try {
196+
const parsedHsUrl = new URL(this.props.hsUrl);
197+
matrixIdText = _t('%(serverName)s Matrix ID', {serverName: parsedHsUrl.hostname});
198+
} catch (e) {
199+
// pass
200+
}
201+
}
202+
180203
const pwFieldClass = classNames({
181204
mx_Login_field: true,
205+
mx_Login_field_disabled: matrixIdText === '',
182206
error: this.props.loginIncorrect,
183207
});
184208

185209
const Dropdown = sdk.getComponent('elements.Dropdown');
186210

187-
const loginField = this.renderLoginField(this.state.loginType);
211+
const loginField = this.renderLoginField(this.state.loginType, matrixIdText === '');
188212

189213
return (
190214
<div>
@@ -194,8 +218,9 @@ class PasswordLogin extends React.Component {
194218
<Dropdown
195219
className="mx_Login_type_dropdown"
196220
value={this.state.loginType}
221+
disabled={matrixIdText === ''}
197222
onOptionChange={this.onLoginTypeChange}>
198-
<span key={PasswordLogin.LOGIN_FIELD_MXID}>{ _t('my Matrix ID') }</span>
223+
<span key={PasswordLogin.LOGIN_FIELD_MXID}>{matrixIdText}</span>
199224
<span key={PasswordLogin.LOGIN_FIELD_EMAIL}>{ _t('Email address') }</span>
200225
<span key={PasswordLogin.LOGIN_FIELD_PHONE}>{ _t('Phone') }</span>
201226
</Dropdown>
@@ -204,10 +229,12 @@ class PasswordLogin extends React.Component {
204229
<input className={pwFieldClass} ref={(e) => {this._passwordField = e;}} type="password"
205230
name="password"
206231
value={this.state.password} onChange={this.onPasswordChanged}
207-
placeholder={ _t('Password') } />
232+
placeholder={ _t('Password') }
233+
disabled={matrixIdText === ''}
234+
/>
208235
<br />
209236
{forgotPasswordJsx}
210-
<input className="mx_Login_submit" type="submit" value={ _t('Sign in') } />
237+
<input className="mx_Login_submit" type="submit" value={ _t('Sign in') } disabled={matrixIdText === ''} />
211238
</form>
212239
</div>
213240
);

src/i18n/strings/de_DE.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@
146146
"Members only": "Nur Mitglieder",
147147
"Mobile phone number": "Mobiltelefonnummer",
148148
"Moderator": "Moderator",
149-
"my Matrix ID": "meiner Matrix-ID",
149+
"%(serverName)s Matrix ID": "%(serverName)s Matrix-ID",
150150
"Never send encrypted messages to unverified devices from this device": "Niemals verschlüsselte Nachrichten an unverifizierte Geräte von diesem Gerät aus versenden",
151151
"Never send encrypted messages to unverified devices in this room from this device": "Niemals verschlüsselte Nachrichten an unverifizierte Geräte in diesem Raum von diesem Gerät aus senden",
152152
"New password": "Neues Passwort",

src/i18n/strings/el.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@
188188
"Failure to create room": "Δεν ήταν δυνατή η δημιουργία δωματίου",
189189
"Join Room": "Είσοδος σε δωμάτιο",
190190
"Moderator": "Συντονιστής",
191-
"my Matrix ID": "το Matrix ID μου",
192191
"Name": "Όνομα",
193192
"New address (e.g. #foo:%(localDomain)s)": "Νέα διεύθυνση (e.g. #όνομα:%(localDomain)s)",
194193
"New password": "Νέος κωδικός πρόσβασης",

src/i18n/strings/en_EN.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,6 @@
295295
"Moderator": "Moderator",
296296
"Must be viewing a room": "Must be viewing a room",
297297
"Mute": "Mute",
298-
"my Matrix ID": "my Matrix ID",
299298
"Name": "Name",
300299
"Never send encrypted messages to unverified devices from this device": "Never send encrypted messages to unverified devices from this device",
301300
"Never send encrypted messages to unverified devices in this room": "Never send encrypted messages to unverified devices in this room",
@@ -906,5 +905,6 @@
906905
"Related Groups": "Related Groups",
907906
"Related groups for this room:": "Related groups for this room:",
908907
"This room has no related groups": "This room has no related groups",
909-
"New group ID (e.g. +foo:%(localDomain)s)": "New group ID (e.g. +foo:%(localDomain)s)"
908+
"New group ID (e.g. +foo:%(localDomain)s)": "New group ID (e.g. +foo:%(localDomain)s)",
909+
"%(serverName)s Matrix ID": "%(serverName)s Matrix ID"
910910
}

src/i18n/strings/en_US.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,6 @@
262262
"Moderator": "Moderator",
263263
"Must be viewing a room": "Must be viewing a room",
264264
"Mute": "Mute",
265-
"my Matrix ID": "my Matrix ID",
266265
"Name": "Name",
267266
"Never send encrypted messages to unverified devices from this device": "Never send encrypted messages to unverified devices from this device",
268267
"Never send encrypted messages to unverified devices in this room": "Never send encrypted messages to unverified devices in this room",

src/i18n/strings/es.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@
379379
"Moderator": "Moderador",
380380
"Must be viewing a room": "Debe estar viendo una sala",
381381
"Mute": "Silenciar",
382-
"my Matrix ID": "Mi ID de Matrix",
382+
"%(serverName)s Matrix ID": "%(serverName)s ID de Matrix",
383383
"Name": "Nombre",
384384
"Never send encrypted messages to unverified devices from this device": "No enviar nunca mensajes cifrados, desde este dispositivo, a dispositivos sin verificar",
385385
"Never send encrypted messages to unverified devices in this room": "No enviar nunca mensajes cifrados a dispositivos no verificados, en esta sala",

src/i18n/strings/eu.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,6 @@
346346
"Missing room_id in request": "Gelaren ID-a falta da eskaeran",
347347
"Missing user_id in request": "Erabiltzailearen ID-a falta da eskaeran",
348348
"Mobile phone number": "Mugikorraren telefono zenbakia",
349-
"my Matrix ID": "Nire Matrix ID-a",
350349
"Never send encrypted messages to unverified devices in this room": "Ez bidali inoiz zifratutako mezuak egiaztatu gabeko gailuetara gela honetan",
351350
"Never send encrypted messages to unverified devices in this room from this device": "Ez bidali inoiz zifratutako mezuak egiaztatu gabeko gailuetara gela honetan gailu honetatik",
352351
"New address (e.g. #foo:%(localDomain)s)": "Helbide berria (adib. #foo:%(localDomain)s)",

0 commit comments

Comments
 (0)