Add server details edit link to registration

This commit is contained in:
J. Ryan Stinnett 2019-01-29 15:05:15 -06:00
parent 160cc4e156
commit 379b940bfa
2 changed files with 33 additions and 1 deletions

View file

@ -323,6 +323,14 @@ module.exports = React.createClass({
}); });
}, },
onEditServerDetailsClick(ev) {
ev.preventDefault();
ev.stopPropagation();
this.setState({
phase: PHASE_SERVER_DETAILS,
});
},
_makeRegisterRequest: function(auth) { _makeRegisterRequest: function(auth) {
// Only send the bind params if we're sending username / pw params // Only send the bind params if we're sending username / pw params
// (Since we need to send no params at all to use the ones saved in the // (Since we need to send no params at all to use the ones saved in the
@ -440,6 +448,16 @@ module.exports = React.createClass({
} else if (this.state.busy || !this.state.flows) { } else if (this.state.busy || !this.state.flows) {
return <Spinner />; return <Spinner />;
} else { } else {
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 (
PHASES_ENABLED &&
!SdkConfig.get()['disable_custom_urls'] &&
this.state.serverType !== ServerType.FREE
) {
onEditServerDetailsClick = this.onEditServerDetailsClick;
}
return <RegistrationForm return <RegistrationForm
defaultUsername={this.state.formVals.username} defaultUsername={this.state.formVals.username}
defaultEmail={this.state.formVals.email} defaultEmail={this.state.formVals.email}
@ -449,6 +467,7 @@ module.exports = React.createClass({
minPasswordLength={MIN_PASSWORD_LENGTH} minPasswordLength={MIN_PASSWORD_LENGTH}
onError={this.onFormValidationFailed} onError={this.onFormValidationFailed}
onRegisterClick={this.onFormSubmit} onRegisterClick={this.onFormSubmit}
onEditServerDetailsClick={onEditServerDetailsClick}
flows={this.state.flows} flows={this.state.flows}
hsUrl={this.state.hsUrl} hsUrl={this.state.hsUrl}
hsName={this.props.defaultServerName} hsName={this.props.defaultServerName}

View file

@ -49,6 +49,7 @@ module.exports = React.createClass({
minPasswordLength: PropTypes.number, minPasswordLength: PropTypes.number,
onError: PropTypes.func, onError: PropTypes.func,
onRegisterClick: PropTypes.func.isRequired, // onRegisterClick(Object) => ?Promise onRegisterClick: PropTypes.func.isRequired, // onRegisterClick(Object) => ?Promise
onEditServerDetailsClick: PropTypes.func,
flows: PropTypes.arrayOf(PropTypes.object).isRequired, flows: PropTypes.arrayOf(PropTypes.object).isRequired,
}, },
@ -272,6 +273,15 @@ module.exports = React.createClass({
} }
} }
let editLink = null;
if (this.props.onEditServerDetailsClick) {
editLink = <a className="mx_Auth_editServerDetails"
href="#" onClick={this.props.onEditServerDetailsClick}
>
{_t('Edit')}
</a>;
}
const emailPlaceholder = this._authStepIsRequired('m.login.email.identity') ? const emailPlaceholder = this._authStepIsRequired('m.login.email.identity') ?
_t("Email address") : _t("Email address") :
_t("Email address (optional)"); _t("Email address (optional)");
@ -325,7 +335,10 @@ module.exports = React.createClass({
return ( return (
<div> <div>
<h3>{yourMatrixAccountText}</h3> <h3>
{yourMatrixAccountText}
{editLink}
</h3>
<form onSubmit={this.onSubmit}> <form onSubmit={this.onSubmit}>
{ emailSection } { emailSection }
{ phoneSection } { phoneSection }