diff --git a/app/screens/edit_profile/edit_profile.js b/app/screens/edit_profile/edit_profile.js index 0f6927ef5..104ece5e2 100644 --- a/app/screens/edit_profile/edit_profile.js +++ b/app/screens/edit_profile/edit_profile.js @@ -88,9 +88,12 @@ export default class EditProfile extends PureComponent { removeProfileImage: PropTypes.func.isRequired, updateUser: PropTypes.func.isRequired, }).isRequired, - config: PropTypes.object.isRequired, currentUser: PropTypes.object.isRequired, + firstNameDisabled: PropTypes.bool.isRequired, + lastNameDisabled: PropTypes.bool.isRequired, navigator: PropTypes.object.isRequired, + nicknameDisabled: PropTypes.bool.isRequired, + positionDisabled: PropTypes.bool.isRequired, theme: PropTypes.object.isRequired, commandType: PropTypes.string.isRequired, }; @@ -316,16 +319,12 @@ export default class EditProfile extends PureComponent { renderFirstNameSettings = () => { const {formatMessage} = this.context.intl; - const {config, currentUser, theme} = this.props; + const {firstNameDisabled, theme} = this.props; const {firstName} = this.state; - const {auth_service: service} = currentUser; - const disabled = (service === 'ldap' && config.LdapFristNameAttributeSet === 'true') || - (service === 'saml' && config.SamlFirstNameAttributeSet === 'true'); - return ( { const {formatMessage} = this.context.intl; - const {config, currentUser, theme} = this.props; + const {lastNameDisabled, theme} = this.props; const {lastName} = this.state; - const {auth_service: service} = currentUser; - const disabled = (service === 'ldap' && config.LdapLastNameAttributeSet === 'true') || - (service === 'saml' && config.SamlLastNameAttributeSet === 'true'); - return ( { const {formatMessage} = this.context.intl; - const {config, currentUser, theme} = this.props; + const {nicknameDisabled, theme} = this.props; const {nickname} = this.state; - const {auth_service: service} = currentUser; - const disabled = (service === 'ldap' && config.LdapNicknameAttributeSet === 'true') || - (service === 'saml' && config.SamlNicknameAttributeSet === 'true'); - return ( { const {formatMessage} = this.context.intl; - const {config, currentUser, theme} = this.props; + const {positionDisabled, theme} = this.props; const {position} = this.state; - const {auth_service: service} = currentUser; - const disabled = (service === 'ldap' || service === 'saml') && config.PositionAttribute === 'true'; - return ( { const baseProps = { actions, - config: { - ShowEmailAddress: true, - }, + firstNameDisabled: true, + lastNameDisabled: true, + nicknameDisabled: true, + positionDisabled: true, theme: Preferences.THEMES.default, navigator, currentUser: { diff --git a/app/screens/edit_profile/index.js b/app/screens/edit_profile/index.js index 50f3eff2c..44ee8b27f 100644 --- a/app/screens/edit_profile/index.js +++ b/app/screens/edit_profile/index.js @@ -6,14 +6,39 @@ import {bindActionCreators} from 'redux'; import {getConfig} from 'mattermost-redux/selectors/entities/general'; import {getTheme} from 'mattermost-redux/selectors/entities/preferences'; +import {isMinimumServerVersion} from 'mattermost-redux/utils/helpers'; import {setProfileImageUri, removeProfileImage, updateUser} from 'app/actions/views/edit_profile'; import EditProfile from './edit_profile'; -function mapStateToProps(state) { +function mapStateToProps(state, ownProps) { + const config = getConfig(state); + const {serverVersion} = state.entities.general; + const {service} = ownProps.currentUser; + + const firstNameDisabled = (service === 'ldap' && config.LdapFirstNameAttributeSet === 'true') || + (service === 'saml' && config.SamlFirstNameAttributeSet === 'true'); + + const lastNameDisabled = (service === 'ldap' && config.LdapLastNameAttributeSet === 'true') || + (service === 'saml' && config.SamlLastNameAttributeSet === 'true'); + + const nicknameDisabled = (service === 'ldap' && config.LdapNicknameAttributeSet === 'true') || + (service === 'saml' && config.SamlNicknameAttributeSet === 'true'); + + let positionDisabled = false; + if (isMinimumServerVersion(serverVersion, 5, 12)) { + positionDisabled = (service === 'ldap' && config.LdapPositionAttributeSet === 'true') || + (service === 'saml' && config.SamlPositionAttributeSet === 'true'); + } else { + positionDisabled = (service === 'ldap' || service === 'saml') && config.PositionAttribute === 'true'; + } + return { - config: getConfig(state), + firstNameDisabled, + lastNameDisabled, + nicknameDisabled, + positionDisabled, theme: getTheme(state), }; }