11/*
22Copyright 2015, 2016 OpenMarket Ltd
33Copyright 2017 Vector Creations Ltd
4+ Copyright 2018 New Vector Ltd
45
56Licensed under the Apache License, Version 2.0 (the "License");
67you may not use this file except in compliance with the License.
@@ -49,7 +50,7 @@ module.exports = React.createClass({
4950 teamsConfig : PropTypes . shape ( {
5051 // Email address to request new teams
5152 supportEmail : PropTypes . string ,
52- teams : PropTypes . arrayOf ( React . PropTypes . shape ( {
53+ teams : PropTypes . arrayOf ( PropTypes . shape ( {
5354 // The displayed name of the team
5455 "name" : PropTypes . string ,
5556 // The domain of team email addresses
@@ -60,6 +61,7 @@ module.exports = React.createClass({
6061 minPasswordLength : PropTypes . number ,
6162 onError : PropTypes . func ,
6263 onRegisterClick : PropTypes . func . isRequired , // onRegisterClick(Object) => ?Promise
64+ flows : PropTypes . arrayOf ( PropTypes . object ) . isRequired ,
6365 } ,
6466
6567 getDefaultProps : function ( ) {
@@ -273,12 +275,18 @@ module.exports = React.createClass({
273275 } ) ;
274276 } ,
275277
278+ _authStepIsRequired ( step ) {
279+ // A step is required if no flow exists which does not include that step
280+ // (Notwithstanding setups like either email or msisdn being required)
281+ return ! this . props . flows . some ( ( flow ) => {
282+ return ! flow . stages . includes ( step ) ;
283+ } ) ;
284+ } ,
285+
276286 render : function ( ) {
277287 const self = this ;
278288
279- const theme = SettingsStore . getValue ( "theme" ) ;
280- // FIXME: remove hardcoded Status team tweaks at some point
281- const emailPlaceholder = theme === 'status' ? _t ( "Email address" ) : _t ( "Email address (optional)" ) ;
289+ const emailPlaceholder = this . _authStepIsRequired ( 'm.login.email.identity' ) ? _t ( "Email address" ) : _t ( "Email address (optional)" ) ;
282290
283291 const emailSection = (
284292 < div >
@@ -315,6 +323,7 @@ module.exports = React.createClass({
315323 const CountryDropdown = sdk . getComponent ( 'views.login.CountryDropdown' ) ;
316324 let phoneSection ;
317325 if ( ! SdkConfig . get ( ) . disable_3pid_login ) {
326+ const phonePlaceholder = this . _authStepIsRequired ( 'm.login.msisdn' ) ? _t ( "Mobile phone number" ) : _t ( "Mobile phone number (optional)" ) ;
318327 phoneSection = (
319328 < div className = "mx_Login_phoneSection" >
320329 < CountryDropdown ref = "phone_country" onOptionChange = { this . _onPhoneCountryChange }
@@ -324,7 +333,7 @@ module.exports = React.createClass({
324333 showPrefix = { true }
325334 />
326335 < input type = "text" ref = "phoneNumber"
327- placeholder = { _t ( "Mobile phone number (optional)" ) }
336+ placeholder = { phonePlaceholder }
328337 defaultValue = { this . props . defaultPhoneNumber }
329338 className = { this . _classForField (
330339 FIELD_PHONE_NUMBER ,
0 commit comments