summaryrefslogtreecommitdiffhomepage
path: root/app
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@codeispoetry.ru>2017-06-30 19:19:54 +0300
committerAndrej Mihajlov <and@codeispoetry.ru>2017-06-30 23:58:44 +0300
commitdabb402082623d892a685e39ffe49fc52fa6d226 (patch)
tree29891144f8ed37f3294bcb50a4e0e3f4c72a8df5 /app
parent79d46a4bcd8257d5473bae2ef2ed894829638c86 (diff)
downloadmullvadvpn-dabb402082623d892a685e39ffe49fc52fa6d226.tar.xz
mullvadvpn-dabb402082623d892a685e39ffe49fc52fa6d226.zip
Annotate Settings component
Diffstat (limited to 'app')
-rw-r--r--app/components/Settings.js45
-rw-r--r--app/containers/SettingsPage.js2
2 files changed, 21 insertions, 26 deletions
diff --git a/app/components/Settings.js b/app/components/Settings.js
index eaec0355f2..9b8eff5321 100644
--- a/app/components/Settings.js
+++ b/app/components/Settings.js
@@ -1,39 +1,36 @@
+// @flow
import moment from 'moment';
import React, { Component } from 'react';
-import PropTypes from 'prop-types';
import { If, Then, Else } from 'react-if';
import { Layout, Container, Header } from './Layout';
import Switch from './Switch';
import CustomScrollbars from './CustomScrollbars';
-export default class Settings extends Component {
+import type { UserReduxState } from '../reducers/user';
+import type { SettingsReduxState } from '../reducers/settings';
- static propTypes = {
- onQuit: PropTypes.func.isRequired,
- onLogout: PropTypes.func.isRequired,
- onClose: PropTypes.func.isRequired,
- onViewAccount: PropTypes.func.isRequired,
- onExternalLink: PropTypes.func.isRequired,
- onUpdateSettings: PropTypes.func.isRequired
- }
+export type SettingsProps = {
+ user: UserReduxState,
+ settings: SettingsReduxState,
+ onQuit: () => void,
+ onClose: () => void,
+ onViewAccount: () => void,
+ onExternalLink: (type: string) => void,
+ onUpdateSettings: (update: $Shape<SettingsReduxState>) => void
+};
- onClose() {
- this.props.onClose();
- }
+export default class Settings extends Component {
- onAutoSecure(isOn) {
- this.props.onUpdateSettings({ autoSecure: isOn });
- }
+ props: SettingsProps;
- onExternalLink(type) {
- this.props.onExternalLink(type);
- }
+ onClose = () => this.props.onClose();
+ onAutoSecure = (autoSecure: boolean) => this.props.onUpdateSettings({ autoSecure });
- onLogout() {
- this.props.onLogout();
+ onExternalLink(type: string) {
+ this.props.onExternalLink(type);
}
- render() {
+ render(): React.Element<*> {
const isLoggedIn = this.props.user.status === 'ok';
let isOutOfTime = false, formattedPaidUntil = '';
let paidUntilIso = this.props.user.paidUntil;
@@ -49,7 +46,7 @@ export default class Settings extends Component {
<Header hidden={ true } style={ 'defaultDark' } />
<Container>
<div className="settings">
- <button className="settings__close" onClick={ ::this.onClose } />
+ <button className="settings__close" onClick={ this.onClose } />
<div className="settings__container">
<div className="settings__header">
<h2 className="settings__title">Settings</h2>
@@ -82,7 +79,7 @@ export default class Settings extends Component {
<div className="settings__cell">
<div className="settings__cell-label">Auto-connect</div>
<div className="settings__cell-value">
- <Switch onChange={ ::this.onAutoSecure } isOn={ this.props.settings.autoSecure } />
+ <Switch onChange={ this.onAutoSecure } isOn={ this.props.settings.autoSecure } />
</div>
</div>
<div className="settings__cell-footer">
diff --git a/app/containers/SettingsPage.js b/app/containers/SettingsPage.js
index b0bc7868b0..e9cc3814d9 100644
--- a/app/containers/SettingsPage.js
+++ b/app/containers/SettingsPage.js
@@ -12,11 +12,9 @@ const mapStateToProps = (state) => {
};
const mapDispatchToProps = (dispatch, props) => {
- const { logout } = bindActionCreators(userActions, dispatch);
const { updateSettings } = bindActionCreators(settingsActions, dispatch);
return {
onQuit: () => remote.app.quit(),
- onLogout: () => logout(props.backend),
onClose: () => dispatch(push('/connect')),
onViewAccount: () => dispatch(push('/settings/account')),
onExternalLink: (type) => shell.openExternal(links[type]),