summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorErik Larkö <erik@mullvad.net>2018-01-31 15:53:31 +0100
committerErik Larkö <erik@mullvad.net>2018-02-01 13:10:04 +0100
commit1706407194d4fc52cb167c0dac17b46604ba2163 (patch)
treef9f76faa7da03369ab732d96f14d66377fdfad58
parent3f5593b174474cae47d110a1899400648e2a855e (diff)
downloadmullvadvpn-1706407194d4fc52cb167c0dac17b46604ba2163.tar.xz
mullvadvpn-1706407194d4fc52cb167c0dac17b46604ba2163.zip
Show the app version in the settings view
-rw-r--r--app/components/Settings.js27
-rw-r--r--app/components/SettingsStyles.js2
-rw-r--r--app/containers/SettingsPage.js8
-rw-r--r--test/components/Settings.spec.js1
4 files changed, 33 insertions, 5 deletions
diff --git a/app/components/Settings.js b/app/components/Settings.js
index a25cb39f19..edd9d37f7a 100644
--- a/app/components/Settings.js
+++ b/app/components/Settings.js
@@ -14,13 +14,14 @@ import type { SettingsReduxState } from '../redux/settings/reducers';
export type SettingsProps = {
account: AccountReduxState,
settings: SettingsReduxState,
+ version: string,
onQuit: () => void,
onClose: () => void,
onViewAccount: () => void,
onViewSupport: () => void,
onViewPreferences: () => void,
onViewAdvancedSettings: () => void,
- onExternalLink: (type: string) => void
+ onExternalLink: (type: string) => void,
};
export default class Settings extends Component {
@@ -47,6 +48,9 @@ export default class Settings extends Component {
<View style={styles.settings__content}>
<View>
{ this._renderTopButtons() }
+ <View style={styles.settings__cell_spacer}/>
+ { this._renderMiddleButtons() }
+ <View style={styles.settings__cell_spacer}/>
{ this._renderBottomButtons() }
</View>
{ this._renderQuitButton() }
@@ -83,7 +87,7 @@ export default class Settings extends Component {
{isOutOfTime ? (
<Text style={styles.settings__account_paid_until_label__error} testName='settings__account_paid_until_label'>OUT OF TIME</Text>
) : (
- <Text style={styles.settings__account_paid_until_label} testName='settings__account_paid_until_label'>{formattedExpiry}</Text>
+ <Text style={styles.settings__cell_subtext} testName='settings__account_paid_until_label'>{formattedExpiry}</Text>
)}
<Img style={styles.settings__cell_disclosure} source='icon-chevron' tintColor='currentColor'/>
</View>
@@ -100,10 +104,27 @@ export default class Settings extends Component {
<Img style={styles.settings__cell_disclosure} source='icon-chevron' tintColor='currentColor'/>
</ButtonCell>
- <View style={styles.settings__cell_spacer}></View>
</View>;
}
+ _renderMiddleButtons() {
+ return <View>
+ <ButtonCell testName='settings__version'>
+ <Text style={styles.settings__cell_label}>App version</Text>
+ <Text style={styles.settings__cell_subtext}>{this._formattedVersion()}</Text>
+ </ButtonCell>
+ </View>;
+ }
+
+ _formattedVersion() {
+ // the version in package.json has to be semver, but we use a YEAR.release-channel
+ // version scheme. in package.json we thus have to write YEAR.release.X-channel and
+ // this function is responsible for removing .X part.
+ return this.props.version
+ .replace('.0-', '-') // remove the .0 in 2018.1.0-beta9
+ .replace(/\.0$/, ''); // remove the .0 in 2018.1.0
+ }
+
_renderBottomButtons() {
return <View>
<ButtonCell onPress={ this.props.onExternalLink.bind(this, 'faq') } testName='settings__external_link'>
diff --git a/app/components/SettingsStyles.js b/app/components/SettingsStyles.js
index 15b55d5009..fb4570feec 100644
--- a/app/components/SettingsStyles.js
+++ b/app/components/SettingsStyles.js
@@ -119,7 +119,7 @@ export default Object.assign(createViewStyles({
lineHeight: 26,
color: 'rgba(255,255,255,0.8)'
},
- settings__account_paid_until_label:{
+ settings__cell_subtext:{
fontFamily: 'Open Sans',
fontSize: 13,
fontWeight: '800',
diff --git a/app/containers/SettingsPage.js b/app/containers/SettingsPage.js
index 3612b099b5..84977bab65 100644
--- a/app/containers/SettingsPage.js
+++ b/app/containers/SettingsPage.js
@@ -3,6 +3,7 @@
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { push } from 'react-router-redux';
+import { remote } from 'electron';
import Settings from '../components/Settings';
import { links } from '../config';
import { openLink, exit } from '../lib/platform';
@@ -10,7 +11,12 @@ import { openLink, exit } from '../lib/platform';
import type { ReduxState, ReduxDispatch } from '../redux/store';
import type { SharedRouteProps } from '../routes';
-const mapStateToProps = (state: ReduxState) => state;
+const mapStateToProps = (state: ReduxState) => {
+ return {
+ ...state,
+ version: remote.app.getVersion(),
+ };
+};
const mapDispatchToProps = (dispatch: ReduxDispatch, _props: SharedRouteProps) => {
const { push: pushHistory } = bindActionCreators({ push }, dispatch);
return {
diff --git a/test/components/Settings.spec.js b/test/components/Settings.spec.js
index 415be57fd2..fc6b73f17c 100644
--- a/test/components/Settings.spec.js
+++ b/test/components/Settings.spec.js
@@ -52,6 +52,7 @@ describe('components/Settings', () => {
const defaultProps: SettingsProps = {
account: anAccountState,
settings: aSettingsState,
+ version: '',
onQuit: () => {},
onClose: () => {},
onViewAccount: () => {},