Fix GitLab login option (#1374)

This commit is contained in:
enahum 2018-01-23 15:04:31 -03:00 committed by Stephen Kiers
parent 3c45fe94c6
commit aa1330a1ee
2 changed files with 20 additions and 28 deletions

View file

@ -8,11 +8,10 @@ import {getTheme} from 'mattermost-redux/selectors/entities/preferences';
import LoginOptions from './login_options';
function mapStateToProps(state) {
const {config, license, serverVersion} = state.entities.general;
const {config, license} = state.entities.general;
return {
config,
license,
serverVersion,
theme: getTheme(state)
};
}

View file

@ -12,7 +12,6 @@ import {
} from 'react-native';
import Button from 'react-native-button';
import Orientation from 'react-native-orientation';
import semver from 'semver';
import {ViewTypes} from 'app/constants';
import FormattedText from 'app/components/formatted_text';
@ -30,7 +29,6 @@ class LoginOptions extends PureComponent {
navigator: PropTypes.object,
config: PropTypes.object.isRequired,
license: PropTypes.object.isRequired,
serverVersion: PropTypes.string.isRequired,
theme: PropTypes.object
};
@ -163,35 +161,30 @@ class LoginOptions extends PureComponent {
};
renderGitlabOption = () => {
const {config, serverVersion} = this.props;
const {config} = this.props;
const forceHideFromLocal = LocalConfig.HideGitLabLoginExperimental;
const match = serverVersion.match(/^[0-9]*.[0-9]*.[0-9]*(-[a-zA-Z0-9.-]*)?/g);
if (match) {
const version = match[0];
if (!forceHideFromLocal && config.EnableSignUpWithGitLab === 'true' && semver.valid(version) && semver.gte(version, 'v3.10.0')) {
return (
<Button
key='gitlab'
onPress={() => preventDoubleTap(this.goToSSO, this, ViewTypes.GITLAB)}
containerStyle={[GlobalStyles.signupButton, {backgroundColor: '#548'}]}
if (!forceHideFromLocal && config.EnableSignUpWithGitLab === 'true') {
return (
<Button
key='gitlab'
onPress={() => preventDoubleTap(this.goToSSO, this, ViewTypes.GITLAB)}
containerStyle={[GlobalStyles.signupButton, {backgroundColor: '#548'}]}
>
<Image
source={gitlab}
style={{height: 18, marginRight: 5, width: 18}}
/>
<Text
style={[GlobalStyles.signupButtonText, {color: 'white'}]}
>
<Image
source={gitlab}
style={{height: 18, marginRight: 5, width: 18}}
/>
<Text
style={[GlobalStyles.signupButtonText, {color: 'white'}]}
>
{'GitLab'}
</Text>
</Button>
);
}
return null;
{'GitLab'}
</Text>
</Button>
);
}
return null;
};