Add link to edit server details

This commit is contained in:
J. Ryan Stinnett 2019-01-28 16:13:19 -06:00
parent 8e9fc8a8e7
commit d96e814a92
3 changed files with 38 additions and 1 deletions
res/css/views/auth
src/components
structures/auth
views/auth

View file

@ -36,6 +36,12 @@ limitations under the License.
color: $primary-fg-color;
}
.mx_Auth_editServerDetails {
padding-left: 1em;
font-size: 12px;
font-weight: normal;
}
.mx_AuthBody a:link,
.mx_AuthBody a:hover,
.mx_AuthBody a:visited {

View file

@ -360,6 +360,14 @@ module.exports = React.createClass({
});
},
onEditServerDetailsClick(ev) {
ev.preventDefault();
ev.stopPropagation();
this.setState({
phase: PHASE_SERVER_DETAILS,
});
},
_tryWellKnownDiscovery: async function(serverName) {
if (!serverName.trim()) {
// Nothing to discover
@ -605,10 +613,20 @@ module.exports = React.createClass({
_renderPasswordStep: function() {
const PasswordLogin = sdk.getComponent('auth.PasswordLogin');
let onEditServerDetailsClick = null;
// If custom URLs are allowed and we haven't selected the Free server type, wire
// up the server details edit link.
if (
!SdkConfig.get()['disable_custom_urls'] &&
this.state.serverType !== ServerType.FREE
) {
onEditServerDetailsClick = this.onEditServerDetailsClick;
}
return (
<PasswordLogin
onSubmit={this.onPasswordLogin}
onError={this.onPasswordLoginError}
onEditServerDetailsClick={onEditServerDetailsClick}
initialUsername={this.state.username}
initialPhoneCountry={this.state.phoneCountry}
initialPhoneNumber={this.state.phoneNumber}

View file

@ -29,6 +29,7 @@ import SdkConfig from '../../../SdkConfig';
class PasswordLogin extends React.Component {
static defaultProps = {
onError: function() {},
onEditServerDetailsClick: null,
onUsernameChanged: function() {},
onUsernameBlur: function() {},
onPasswordChanged: function() {},
@ -261,6 +262,15 @@ class PasswordLogin extends React.Component {
}
}
let editLink = null;
if (this.props.onEditServerDetailsClick) {
editLink = <a className="mx_Auth_editServerDetails"
href="#" onClick={this.props.onEditServerDetailsClick}
>
{_t('Edit')}
</a>;
}
const pwFieldClass = classNames({
mx_Login_field: true,
error: this.props.loginIncorrect && !this.isLoginEmpty(), // only error password if error isn't top field
@ -289,7 +299,10 @@ class PasswordLogin extends React.Component {
return (
<div>
<h3>{ yourMatrixAccountText }</h3>
<h3>
{yourMatrixAccountText}
{editLink}
</h3>
<form onSubmit={this.onSubmitForm}>
{ loginType }
{ loginField }