mirror of https://github.com/vector-im/riot-web
Grey out login form when no valid HS
parent
fa24b4bd2d
commit
0f84216a9f
|
@ -302,6 +302,7 @@ export default class Dropdown extends React.Component {
|
||||||
|
|
||||||
const dropdownClasses = {
|
const dropdownClasses = {
|
||||||
mx_Dropdown: true,
|
mx_Dropdown: true,
|
||||||
|
mx_Dropdown_disabled: this.props.disabled,
|
||||||
};
|
};
|
||||||
if (this.props.className) {
|
if (this.props.className) {
|
||||||
dropdownClasses[this.props.className] = true;
|
dropdownClasses[this.props.className] = true;
|
||||||
|
|
|
@ -123,7 +123,7 @@ export default class CountryDropdown extends React.Component {
|
||||||
return <Dropdown className={this.props.className + " left_aligned"}
|
return <Dropdown className={this.props.className + " left_aligned"}
|
||||||
onOptionChange={this._onOptionChange} onSearchChange={this._onSearchChange}
|
onOptionChange={this._onOptionChange} onSearchChange={this._onSearchChange}
|
||||||
menuWidth={298} getShortOption={this._getShortOption}
|
menuWidth={298} getShortOption={this._getShortOption}
|
||||||
value={value} searchEnabled={true}
|
value={value} searchEnabled={true} disabled={this.props.disabled}
|
||||||
>
|
>
|
||||||
{options}
|
{options}
|
||||||
</Dropdown>;
|
</Dropdown>;
|
||||||
|
@ -137,4 +137,5 @@ CountryDropdown.propTypes = {
|
||||||
showPrefix: React.PropTypes.bool,
|
showPrefix: React.PropTypes.bool,
|
||||||
onOptionChange: React.PropTypes.func.isRequired,
|
onOptionChange: React.PropTypes.func.isRequired,
|
||||||
value: React.PropTypes.string,
|
value: React.PropTypes.string,
|
||||||
|
disabled: React.PropTypes.bool,
|
||||||
};
|
};
|
||||||
|
|
|
@ -116,11 +116,17 @@ class PasswordLogin extends React.Component {
|
||||||
this.props.onPasswordChanged(ev.target.value);
|
this.props.onPasswordChanged(ev.target.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderLoginField(loginType) {
|
renderLoginField(loginType, disabled) {
|
||||||
|
const classes = {
|
||||||
|
mx_Login_field: true,
|
||||||
|
mx_Login_field_disabled: disabled,
|
||||||
|
};
|
||||||
|
|
||||||
switch(loginType) {
|
switch(loginType) {
|
||||||
case PasswordLogin.LOGIN_FIELD_EMAIL:
|
case PasswordLogin.LOGIN_FIELD_EMAIL:
|
||||||
|
classes.mx_Login_email = true;
|
||||||
return <input
|
return <input
|
||||||
className="mx_Login_field mx_Login_email"
|
className={classNames(classes)}
|
||||||
key="email_input"
|
key="email_input"
|
||||||
type="text"
|
type="text"
|
||||||
name="username" // make it a little easier for browser's remember-password
|
name="username" // make it a little easier for browser's remember-password
|
||||||
|
@ -128,10 +134,12 @@ class PasswordLogin extends React.Component {
|
||||||
placeholder="joe@example.com"
|
placeholder="joe@example.com"
|
||||||
value={this.state.username}
|
value={this.state.username}
|
||||||
autoFocus
|
autoFocus
|
||||||
|
disabled={disabled}
|
||||||
/>;
|
/>;
|
||||||
case PasswordLogin.LOGIN_FIELD_MXID:
|
case PasswordLogin.LOGIN_FIELD_MXID:
|
||||||
|
classes.mx_Login_username = true;
|
||||||
return <input
|
return <input
|
||||||
className="mx_Login_field mx_Login_username"
|
className={classNames(classes)}
|
||||||
key="username_input"
|
key="username_input"
|
||||||
type="text"
|
type="text"
|
||||||
name="username" // make it a little easier for browser's remember-password
|
name="username" // make it a little easier for browser's remember-password
|
||||||
|
@ -139,9 +147,12 @@ class PasswordLogin extends React.Component {
|
||||||
placeholder={_t('User name')}
|
placeholder={_t('User name')}
|
||||||
value={this.state.username}
|
value={this.state.username}
|
||||||
autoFocus
|
autoFocus
|
||||||
|
disabled={disabled}
|
||||||
/>;
|
/>;
|
||||||
case PasswordLogin.LOGIN_FIELD_PHONE:
|
case PasswordLogin.LOGIN_FIELD_PHONE:
|
||||||
const CountryDropdown = sdk.getComponent('views.login.CountryDropdown');
|
const CountryDropdown = sdk.getComponent('views.login.CountryDropdown');
|
||||||
|
classes.mx_Login_phoneNumberField = true;
|
||||||
|
classes.mx_Login_field_has_prefix = true;
|
||||||
return <div className="mx_Login_phoneSection">
|
return <div className="mx_Login_phoneSection">
|
||||||
<CountryDropdown
|
<CountryDropdown
|
||||||
className="mx_Login_phoneCountry mx_Login_field_prefix"
|
className="mx_Login_phoneCountry mx_Login_field_prefix"
|
||||||
|
@ -150,9 +161,10 @@ class PasswordLogin extends React.Component {
|
||||||
value={this.state.phoneCountry}
|
value={this.state.phoneCountry}
|
||||||
isSmall={true}
|
isSmall={true}
|
||||||
showPrefix={true}
|
showPrefix={true}
|
||||||
|
disabled={disabled}
|
||||||
/>
|
/>
|
||||||
<input
|
<input
|
||||||
className="mx_Login_phoneNumberField mx_Login_field mx_Login_field_has_prefix"
|
className={classNames(classes)}
|
||||||
ref="phoneNumber"
|
ref="phoneNumber"
|
||||||
key="phone_input"
|
key="phone_input"
|
||||||
type="text"
|
type="text"
|
||||||
|
@ -161,6 +173,7 @@ class PasswordLogin extends React.Component {
|
||||||
placeholder={_t("Mobile phone number")}
|
placeholder={_t("Mobile phone number")}
|
||||||
value={this.state.phoneNumber}
|
value={this.state.phoneNumber}
|
||||||
autoFocus
|
autoFocus
|
||||||
|
disabled={disabled}
|
||||||
/>
|
/>
|
||||||
</div>;
|
</div>;
|
||||||
}
|
}
|
||||||
|
@ -177,15 +190,6 @@ class PasswordLogin extends React.Component {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const pwFieldClass = classNames({
|
|
||||||
mx_Login_field: true,
|
|
||||||
error: this.props.loginIncorrect,
|
|
||||||
});
|
|
||||||
|
|
||||||
const Dropdown = sdk.getComponent('elements.Dropdown');
|
|
||||||
|
|
||||||
const loginField = this.renderLoginField(this.state.loginType);
|
|
||||||
|
|
||||||
let matrixIdText = '';
|
let matrixIdText = '';
|
||||||
if (this.props.hsUrl) {
|
if (this.props.hsUrl) {
|
||||||
try {
|
try {
|
||||||
|
@ -196,6 +200,16 @@ class PasswordLogin extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const pwFieldClass = classNames({
|
||||||
|
mx_Login_field: true,
|
||||||
|
mx_Login_field_disabled: matrixIdText === '',
|
||||||
|
error: this.props.loginIncorrect,
|
||||||
|
});
|
||||||
|
|
||||||
|
const Dropdown = sdk.getComponent('elements.Dropdown');
|
||||||
|
|
||||||
|
const loginField = this.renderLoginField(this.state.loginType, matrixIdText === '');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<form onSubmit={this.onSubmitForm}>
|
<form onSubmit={this.onSubmitForm}>
|
||||||
|
@ -215,10 +229,12 @@ class PasswordLogin extends React.Component {
|
||||||
<input className={pwFieldClass} ref={(e) => {this._passwordField = e;}} type="password"
|
<input className={pwFieldClass} ref={(e) => {this._passwordField = e;}} type="password"
|
||||||
name="password"
|
name="password"
|
||||||
value={this.state.password} onChange={this.onPasswordChanged}
|
value={this.state.password} onChange={this.onPasswordChanged}
|
||||||
placeholder={ _t('Password') } />
|
placeholder={ _t('Password') }
|
||||||
|
disabled={matrixIdText === ''}
|
||||||
|
/>
|
||||||
<br />
|
<br />
|
||||||
{forgotPasswordJsx}
|
{forgotPasswordJsx}
|
||||||
<input className="mx_Login_submit" type="submit" value={ _t('Sign in') } />
|
<input className="mx_Login_submit" type="submit" value={ _t('Sign in') } disabled={matrixIdText === ''} />
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue