summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@codeispoetry.ru>2017-03-01 17:23:31 +0000
committerAndrej Mihajlov <and@codeispoetry.ru>2017-03-01 17:23:31 +0000
commit7ae7608cc0ac1a0790cff646ac47b6fb0f1f25e7 (patch)
tree7ced265f0510285864c438b49d2acaf9c1cc4371
parentd860dd85fa3da3999bf376d88cfc0926bffc2424 (diff)
downloadmullvadvpn-7ae7608cc0ac1a0790cff646ac47b6fb0f1f25e7.tar.xz
mullvadvpn-7ae7608cc0ac1a0790cff646ac47b6fb0f1f25e7.zip
Move routing logic to container
-rw-r--r--app/components/SelectLocation.js30
-rw-r--r--app/containers/SelectLocationPage.js4
2 files changed, 11 insertions, 23 deletions
diff --git a/app/components/SelectLocation.js b/app/components/SelectLocation.js
index 9b7bbae625..fdba1e7fc2 100644
--- a/app/components/SelectLocation.js
+++ b/app/components/SelectLocation.js
@@ -7,26 +7,12 @@ import CustomScrollbars from './CustomScrollbars';
export default class SelectLocation extends Component {
static propTypes = {
- onChangeLocation: PropTypes.func.isRequired
+ onClose: PropTypes.func.isRequired,
+ onSelect: PropTypes.func.isRequired
}
- onClose() {
- this.props.router.push('/connect');
- }
-
- handleSelection(name) {
- this.props.onChangeLocation(name);
- this.props.router.push('/connect');
- }
-
- handleFastest() {
- this.props.onChangeLocation('fastest');
- this.props.router.push('/connect');
- }
-
- handleNearest() {
- this.props.onChangeLocation('nearest');
- this.props.router.push('/connect');
+ onSelect(name) {
+ this.props.onSelect(name);
}
isSelected(key) {
@@ -84,7 +70,7 @@ export default class SelectLocation extends Component {
<Header hidden={ true } style={ Header.Style.defaultDark } />
<Container>
<div className="select-location">
- <button className="select-location__close" onClick={ ::this.onClose } />
+ <button className="select-location__close" onClick={ this.props.onClose } />
<div className="select-location__container">
<div className="select-location__header">
<h2 className="select-location__title">Select location</h2>
@@ -95,12 +81,12 @@ export default class SelectLocation extends Component {
<CustomScrollbars autoHide={ true }>
<div>
- { this.drawCell('fastest', 'Fastest', './assets/images/icon-fastest.svg', ::this.handleFastest) }
- { this.drawCell('nearest', 'Nearest', './assets/images/icon-nearest.svg', ::this.handleNearest) }
+ { this.drawCell('fastest', 'Fastest', './assets/images/icon-fastest.svg', this.onSelect.bind(this, 'fastest')) }
+ { this.drawCell('nearest', 'Nearest', './assets/images/icon-nearest.svg', this.onSelect.bind(this, 'nearest')) }
<div className="select-location__separator"></div>
- { Object.keys(servers).map((key) => this.drawCell(key, servers[key].name, null, this.handleSelection.bind(this, key))) }
+ { Object.keys(servers).map((key) => this.drawCell(key, servers[key].name, null, this.onSelect.bind(this, key))) }
</div>
</CustomScrollbars>
diff --git a/app/containers/SelectLocationPage.js b/app/containers/SelectLocationPage.js
index 37892d508e..a817d0d9cb 100644
--- a/app/containers/SelectLocationPage.js
+++ b/app/containers/SelectLocationPage.js
@@ -8,10 +8,12 @@ const mapDispatchToProps = (dispatch, props) => {
const { backend } = props;
const settings = bindActionCreators(settingsActions, dispatch);
return {
- onChangeLocation: (preferredServer) => {
+ onClose: () => props.router.push('/connect'),
+ onSelect: (preferredServer) => {
const server = backend.serverInfo(preferredServer);
settings.updateSettings({ preferredServer });
backend.connect(server.address);
+ props.router.push('/connect');
}
};
};