PLT-5501 Confirm server version is compatible with the app version (#385)
This commit is contained in:
parent
30d8f31bf8
commit
9fec29aa92
7 changed files with 53 additions and 54 deletions
|
|
@ -1,6 +0,0 @@
|
|||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import LogoutContainer from './logout_container';
|
||||
|
||||
export default LogoutContainer;
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import {TouchableHighlight} from 'react-native';
|
||||
import FormattedText from 'app/components/formatted_text';
|
||||
|
||||
export default class Logout extends React.Component {
|
||||
static propTypes = {
|
||||
actions: React.PropTypes.object.isRequired
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<TouchableHighlight onPress={this.props.actions.logout}>
|
||||
<FormattedText
|
||||
id='sidebar_right_menu.logout'
|
||||
defaultMessage='Logout'
|
||||
/>
|
||||
</TouchableHighlight>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import {bindActionCreators} from 'redux';
|
||||
import {connect} from 'react-redux';
|
||||
|
||||
import {logout} from 'mattermost-redux/actions/users';
|
||||
|
||||
import Logout from './logout.js';
|
||||
|
||||
function mapDispatchToProps(dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators({logout}, dispatch)
|
||||
};
|
||||
}
|
||||
|
||||
export default connect(null, mapDispatchToProps)(Logout);
|
||||
|
|
@ -2,15 +2,18 @@
|
|||
// See License.txt for license information.
|
||||
|
||||
import React, {Component, PropTypes} from 'react';
|
||||
import {AppState, StatusBar, View} from 'react-native';
|
||||
import {Alert, AppState, AsyncStorage, InteractionManager, StatusBar, View} from 'react-native';
|
||||
import {IntlProvider} from 'react-intl';
|
||||
import DeviceInfo from 'react-native-device-info';
|
||||
import semver from 'semver';
|
||||
|
||||
import Config from 'assets/config';
|
||||
|
||||
import PushNotification from 'app/components/push_notification';
|
||||
import {getTranslations} from 'app/i18n';
|
||||
|
||||
import Client from 'mattermost-redux/client';
|
||||
import {Constants} from 'mattermost-redux/constants';
|
||||
import {getTranslations} from 'app/i18n';
|
||||
import EventEmitter from 'mattermost-redux/utils/event_emitter';
|
||||
|
||||
export default class Root extends Component {
|
||||
|
|
@ -20,9 +23,12 @@ export default class Root extends Component {
|
|||
currentChannelId: PropTypes.string,
|
||||
locale: PropTypes.string.isRequired,
|
||||
actions: PropTypes.shape({
|
||||
closeDrawers: PropTypes.func.isRequired,
|
||||
loadConfigAndLicense: PropTypes.func.isRequired,
|
||||
logout: PropTypes.func.isRequired,
|
||||
setAppState: PropTypes.func.isRequired,
|
||||
flushToStorage: PropTypes.func.isRequired
|
||||
flushToStorage: PropTypes.func.isRequired,
|
||||
unrenderDrawer: PropTypes.func.isRequired
|
||||
}).isRequired
|
||||
};
|
||||
|
||||
|
|
@ -53,8 +59,41 @@ export default class Root extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
handleVersionUpgrade = async () => {
|
||||
const {closeDrawers, logout, unrenderDrawer} = this.props.actions;
|
||||
|
||||
Client.serverVersion = '';
|
||||
|
||||
const storage = await AsyncStorage.getItem('storage');
|
||||
if (storage) {
|
||||
setTimeout(async () => {
|
||||
const {token} = JSON.parse(await AsyncStorage.getItem('storage'));
|
||||
if (token) {
|
||||
closeDrawers();
|
||||
unrenderDrawer();
|
||||
InteractionManager.runAfterInteractions(logout);
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
};
|
||||
|
||||
handleConfigChanged = (serverVersion) => {
|
||||
this.props.actions.loadConfigAndLicense(serverVersion);
|
||||
const {loadConfigAndLicense} = this.props.actions;
|
||||
const version = serverVersion.match(/^[0-9]*.[0-9]*.[0-9]*(-[a-zA-Z0-9.-]*)?/g)[0];
|
||||
if (serverVersion) {
|
||||
if (semver.valid(version) && semver.lt(version, Config.MinServerVersion)) {
|
||||
Alert.alert(
|
||||
'Server upgrade required',
|
||||
'A server upgrade is required to use the Mattermost app. Please ask your System Administrator for details.',
|
||||
[{
|
||||
text: 'OK',
|
||||
onPress: this.handleVersionUpgrade
|
||||
}]
|
||||
);
|
||||
} else {
|
||||
loadConfigAndLicense(serverVersion);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
|
|
|
|||
|
|
@ -6,9 +6,11 @@ import {connect} from 'react-redux';
|
|||
|
||||
import Config from 'assets/config.json';
|
||||
|
||||
import {closeDrawers, unrenderDrawer} from 'app/actions/navigation';
|
||||
import {flushToStorage} from 'app/actions/storage';
|
||||
import {goToNotification, loadConfigAndLicense, queueNotification} from 'app/actions/views/root';
|
||||
import {setAppState, setDeviceToken} from 'mattermost-redux/actions/general';
|
||||
import {logout} from 'mattermost-redux/actions/users';
|
||||
|
||||
import Root from './root';
|
||||
|
||||
|
|
@ -34,12 +36,15 @@ function mapStateToProps(state, ownProps) {
|
|||
function mapDispatchToProps(dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators({
|
||||
closeDrawers,
|
||||
loadConfigAndLicense,
|
||||
logout,
|
||||
goToNotification,
|
||||
queueNotification,
|
||||
setAppState,
|
||||
setDeviceToken,
|
||||
flushToStorage
|
||||
flushToStorage,
|
||||
unrenderDrawer
|
||||
}, dispatch)
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,5 +4,6 @@
|
|||
"DefaultLocale": "en",
|
||||
"DefaultTheme": "default",
|
||||
"ShowErrorsList": false,
|
||||
"GooglePlaySenderId": "184930218130"
|
||||
"GooglePlaySenderId": "184930218130",
|
||||
"MinServerVersion": "3.7.0"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,8 @@
|
|||
"redux": "3.6.0",
|
||||
"redux-batched-actions": "0.1.5",
|
||||
"redux-thunk": "2.1.0",
|
||||
"reselect": "2.5.4"
|
||||
"reselect": "2.5.4",
|
||||
"semver": "5.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-cli": "6.23.0",
|
||||
|
|
|
|||
Loading…
Reference in a new issue