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

View file

@ -36,6 +36,12 @@ limitations under the License.
color: $primary-fg-color; color: $primary-fg-color;
} }
.mx_Auth_editServerDetails {
padding-left: 1em;
font-size: 12px;
font-weight: normal;
}
.mx_AuthBody a:link, .mx_AuthBody a:link,
.mx_AuthBody a:hover, .mx_AuthBody a:hover,
.mx_AuthBody a:visited { .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) { _tryWellKnownDiscovery: async function(serverName) {
if (!serverName.trim()) { if (!serverName.trim()) {
// Nothing to discover // Nothing to discover
@ -605,10 +613,20 @@ module.exports = React.createClass({
_renderPasswordStep: function() { _renderPasswordStep: function() {
const PasswordLogin = sdk.getComponent('auth.PasswordLogin'); 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 ( return (
<PasswordLogin <PasswordLogin
onSubmit={this.onPasswordLogin} onSubmit={this.onPasswordLogin}
onError={this.onPasswordLoginError} onError={this.onPasswordLoginError}
onEditServerDetailsClick={onEditServerDetailsClick}
initialUsername={this.state.username} initialUsername={this.state.username}
initialPhoneCountry={this.state.phoneCountry} initialPhoneCountry={this.state.phoneCountry}
initialPhoneNumber={this.state.phoneNumber} initialPhoneNumber={this.state.phoneNumber}

View file

@ -29,6 +29,7 @@ import SdkConfig from '../../../SdkConfig';
class PasswordLogin extends React.Component { class PasswordLogin extends React.Component {
static defaultProps = { static defaultProps = {
onError: function() {}, onError: function() {},
onEditServerDetailsClick: null,
onUsernameChanged: function() {}, onUsernameChanged: function() {},
onUsernameBlur: function() {}, onUsernameBlur: function() {},
onPasswordChanged: 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({ const pwFieldClass = classNames({
mx_Login_field: true, mx_Login_field: true,
error: this.props.loginIncorrect && !this.isLoginEmpty(), // only error password if error isn't top field 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 ( return (
<div> <div>
<h3>{ yourMatrixAccountText }</h3> <h3>
{yourMatrixAccountText}
{editLink}
</h3>
<form onSubmit={this.onSubmitForm}> <form onSubmit={this.onSubmitForm}>
{ loginType } { loginType }
{ loginField } { loginField }