-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
index.js
57 lines (46 loc) · 2.14 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import {getConfig} from '@mm-redux/selectors/entities/general';
import {getTheme} from '@mm-redux/selectors/entities/preferences';
import {isMinimumServerVersion} from '@mm-redux/utils/helpers';
import {isLandscape} from 'app/selectors/device';
import {setProfileImageUri, removeProfileImage, updateUser} from 'app/actions/views/edit_profile';
import EditProfile from './edit_profile';
function mapStateToProps(state, ownProps) {
const config = getConfig(state);
const {serverVersion} = state.entities.general;
const {auth_service: 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 {
firstNameDisabled,
lastNameDisabled,
nicknameDisabled,
positionDisabled,
theme: getTheme(state),
isLandscape: isLandscape(state),
};
}
function mapDispatchToProps(dispatch) {
return {
actions: bindActionCreators({
setProfileImageUri,
removeProfileImage,
updateUser,
}, dispatch),
};
}
export default connect(mapStateToProps, mapDispatchToProps)(EditProfile);