@@ -116,32 +116,43 @@ class PasswordLogin extends React.Component {
116
116
this . props . onPasswordChanged ( ev . target . value ) ;
117
117
}
118
118
119
- renderLoginField ( loginType ) {
119
+ renderLoginField ( loginType , disabled ) {
120
+ const classes = {
121
+ mx_Login_field : true ,
122
+ mx_Login_field_disabled : disabled ,
123
+ } ;
124
+
120
125
switch ( loginType ) {
121
126
case PasswordLogin . LOGIN_FIELD_EMAIL :
127
+ classes . mx_Login_email = true ;
122
128
return < input
123
- className = "mx_Login_field mx_Login_email"
129
+ className = { classNames ( classes ) }
124
130
key = "email_input"
125
131
type = "text"
126
132
name = "username" // make it a little easier for browser's remember-password
127
133
onChange = { this . onUsernameChanged }
128
134
129
135
value = { this . state . username }
130
136
autoFocus
137
+ disabled = { disabled }
131
138
/> ;
132
139
case PasswordLogin . LOGIN_FIELD_MXID :
140
+ classes . mx_Login_username = true ;
133
141
return < input
134
- className = "mx_Login_field mx_Login_username"
142
+ className = { classNames ( classes ) }
135
143
key = "username_input"
136
144
type = "text"
137
145
name = "username" // make it a little easier for browser's remember-password
138
146
onChange = { this . onUsernameChanged }
139
147
placeholder = { _t ( 'User name' ) }
140
148
value = { this . state . username }
141
149
autoFocus
150
+ disabled = { disabled }
142
151
/> ;
143
152
case PasswordLogin . LOGIN_FIELD_PHONE :
144
153
const CountryDropdown = sdk . getComponent ( 'views.login.CountryDropdown' ) ;
154
+ classes . mx_Login_phoneNumberField = true ;
155
+ classes . mx_Login_field_has_prefix = true ;
145
156
return < div className = "mx_Login_phoneSection" >
146
157
< CountryDropdown
147
158
className = "mx_Login_phoneCountry mx_Login_field_prefix"
@@ -150,9 +161,10 @@ class PasswordLogin extends React.Component {
150
161
value = { this . state . phoneCountry }
151
162
isSmall = { true }
152
163
showPrefix = { true }
164
+ disabled = { disabled }
153
165
/>
154
166
< input
155
- className = "mx_Login_phoneNumberField mx_Login_field mx_Login_field_has_prefix"
167
+ className = { classNames ( classes ) }
156
168
ref = "phoneNumber"
157
169
key = "phone_input"
158
170
type = "text"
@@ -161,6 +173,7 @@ class PasswordLogin extends React.Component {
161
173
placeholder = { _t ( "Mobile phone number" ) }
162
174
value = { this . state . phoneNumber }
163
175
autoFocus
176
+ disabled = { disabled }
164
177
/>
165
178
</ div > ;
166
179
}
@@ -177,15 +190,6 @@ class PasswordLogin extends React.Component {
177
190
) ;
178
191
}
179
192
180
- const pwFieldClass = classNames ( {
181
- mx_Login_field : true ,
182
- error : this . props . loginIncorrect ,
183
- } ) ;
184
-
185
- const Dropdown = sdk . getComponent ( 'elements.Dropdown' ) ;
186
-
187
- const loginField = this . renderLoginField ( this . state . loginType ) ;
188
-
189
193
let matrixIdText = '' ;
190
194
if ( this . props . hsUrl ) {
191
195
try {
@@ -196,6 +200,16 @@ class PasswordLogin extends React.Component {
196
200
}
197
201
}
198
202
203
+ const pwFieldClass = classNames ( {
204
+ mx_Login_field : true ,
205
+ mx_Login_field_disabled : matrixIdText === '' ,
206
+ error : this . props . loginIncorrect ,
207
+ } ) ;
208
+
209
+ const Dropdown = sdk . getComponent ( 'elements.Dropdown' ) ;
210
+
211
+ const loginField = this . renderLoginField ( this . state . loginType , matrixIdText === '' ) ;
212
+
199
213
return (
200
214
< div >
201
215
< form onSubmit = { this . onSubmitForm } >
@@ -215,10 +229,12 @@ class PasswordLogin extends React.Component {
215
229
< input className = { pwFieldClass } ref = { ( e ) => { this . _passwordField = e ; } } type = "password"
216
230
name = "password"
217
231
value = { this . state . password } onChange = { this . onPasswordChanged }
218
- placeholder = { _t ( 'Password' ) } />
232
+ placeholder = { _t ( 'Password' ) }
233
+ disabled = { matrixIdText === '' }
234
+ />
219
235
< br />
220
236
{ forgotPasswordJsx }
221
- < 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 === '' } />
222
238
</ form >
223
239
</ div >
224
240
) ;
0 commit comments