Hide registration fields that aren't used by any flow
This commit is contained in:
parent
ba50ef8445
commit
4ed13e897a
1 changed files with 30 additions and 14 deletions
|
@ -282,6 +282,18 @@ module.exports = React.createClass({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A step is used if any flows include that step.
|
||||||
|
*
|
||||||
|
* @param {string} step A stage name to check
|
||||||
|
* @returns {boolean} Whether it is used
|
||||||
|
*/
|
||||||
|
_authStepIsUsed(step) {
|
||||||
|
return this.props.flows.some((flow) => {
|
||||||
|
return flow.stages.includes(step);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
let yourMatrixAccountText = _t('Create your account');
|
let yourMatrixAccountText = _t('Create your account');
|
||||||
try {
|
try {
|
||||||
|
@ -302,24 +314,28 @@ module.exports = React.createClass({
|
||||||
</a>;
|
</a>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const emailPlaceholder = this._authStepIsRequired('m.login.email.identity') ?
|
let emailSection;
|
||||||
_t("Email") :
|
if (this._authStepIsUsed('m.login.email.identity')) {
|
||||||
_t("Email (optional)");
|
const emailPlaceholder = this._authStepIsRequired('m.login.email.identity') ?
|
||||||
|
_t("Email") :
|
||||||
|
_t("Email (optional)");
|
||||||
|
|
||||||
const emailSection = (
|
emailSection = (
|
||||||
<div>
|
<div>
|
||||||
<input type="text" ref="email"
|
<input type="text" ref="email"
|
||||||
placeholder={emailPlaceholder}
|
placeholder={emailPlaceholder}
|
||||||
defaultValue={this.props.defaultEmail}
|
defaultValue={this.props.defaultEmail}
|
||||||
className={this._classForField(FIELD_EMAIL, 'mx_Login_field')}
|
className={this._classForField(FIELD_EMAIL, 'mx_Login_field')}
|
||||||
onBlur={this.onEmailBlur}
|
onBlur={this.onEmailBlur}
|
||||||
value={this.state.email} />
|
value={this.state.email} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const threePidLogin = !SdkConfig.get().disable_3pid_login;
|
||||||
const CountryDropdown = sdk.getComponent('views.auth.CountryDropdown');
|
const CountryDropdown = sdk.getComponent('views.auth.CountryDropdown');
|
||||||
let phoneSection;
|
let phoneSection;
|
||||||
if (!SdkConfig.get().disable_3pid_login) {
|
if (threePidLogin && this._authStepIsUsed('m.login.msisdn')) {
|
||||||
const phonePlaceholder = this._authStepIsRequired('m.login.msisdn') ?
|
const phonePlaceholder = this._authStepIsRequired('m.login.msisdn') ?
|
||||||
_t("Phone") :
|
_t("Phone") :
|
||||||
_t("Phone (optional)");
|
_t("Phone (optional)");
|
||||||
|
|
Loading…
Reference in a new issue