summaryrefslogtreecommitdiffhomepage
path: root/gui/src/renderer/containers
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2019-09-10 14:35:00 +0200
committerAndrej Mihajlov <and@mullvad.net>2019-09-12 12:50:51 +0200
commit57f5d8f246fa688a36e3138cbbcd51dd95fdf7ea (patch)
treefc85b595edbdda91e5f7e894d7ed536d0ac69ba8 /gui/src/renderer/containers
parentef20b724201e5c374e6080298974bc8e97818cf2 (diff)
downloadmullvadvpn-57f5d8f246fa688a36e3138cbbcd51dd95fdf7ea.tar.xz
mullvadvpn-57f5d8f246fa688a36e3138cbbcd51dd95fdf7ea.zip
Add bridge selector
Diffstat (limited to 'gui/src/renderer/containers')
-rw-r--r--gui/src/renderer/containers/SelectLocationPage.tsx57
1 files changed, 51 insertions, 6 deletions
diff --git a/gui/src/renderer/containers/SelectLocationPage.tsx b/gui/src/renderer/containers/SelectLocationPage.tsx
index a517c34b3f..24bae9f24d 100644
--- a/gui/src/renderer/containers/SelectLocationPage.tsx
+++ b/gui/src/renderer/containers/SelectLocationPage.tsx
@@ -5,19 +5,54 @@ import { bindActionCreators } from 'redux';
import { RelayLocation } from '../../shared/daemon-rpc-types';
import SelectLocation from '../components/SelectLocation';
import RelaySettingsBuilder from '../lib/relay-settings-builder';
+import userInterfaceActions from '../redux/userinterface/actions';
+import { LocationScope } from '../redux/userinterface/reducers';
import { IReduxState, ReduxDispatch } from '../redux/store';
import { ISharedRouteProps } from '../routes';
-const mapStateToProps = (state: IReduxState) => ({
- relaySettings: state.settings.relaySettings,
- relayLocations: state.settings.relayLocations,
-});
+const mapStateToProps = (state: IReduxState) => {
+ let selectedExitLocation: RelayLocation | undefined;
+ let selectedBridgeLocation: RelayLocation | undefined;
+
+ if ('normal' in state.settings.relaySettings) {
+ const exitLocation = state.settings.relaySettings.normal.location;
+ if (exitLocation !== 'any') {
+ selectedExitLocation = exitLocation;
+ }
+ }
+
+ if ('normal' in state.settings.bridgeSettings) {
+ const bridgeLocation = state.settings.bridgeSettings.normal.location;
+ if (bridgeLocation !== 'any') {
+ selectedBridgeLocation = bridgeLocation;
+ }
+ }
+
+ const allowBridgeSelection = state.settings.bridgeState === 'on';
+ const locationScope = allowBridgeSelection
+ ? state.userInterface.locationScope
+ : LocationScope.relay;
+
+ return {
+ selectedExitLocation,
+ selectedBridgeLocation,
+ relayLocations: state.settings.relayLocations,
+ bridgeLocations: state.settings.bridgeLocations,
+ locationScope,
+ allowBridgeSelection,
+ };
+};
const mapDispatchToProps = (dispatch: ReduxDispatch, props: ISharedRouteProps) => {
const history = bindActionCreators({ goBack }, dispatch);
+ const userInterface = bindActionCreators(userInterfaceActions, dispatch);
+
return {
onClose: () => history.goBack(),
- onSelect: async (relayLocation: RelayLocation) => {
+ onChangeLocationScope: (scope: LocationScope) => {
+ userInterface.setLocationScope(scope);
+ },
+ onSelectExitLocation: async (relayLocation: RelayLocation) => {
// dismiss the view first
history.goBack();
@@ -29,7 +64,17 @@ const mapDispatchToProps = (dispatch: ReduxDispatch, props: ISharedRouteProps) =
await props.app.updateRelaySettings(relayUpdate);
await props.app.connectTunnel();
} catch (e) {
- log.error(`Failed to select server: ${e.message}`);
+ log.error(`Failed to select the exit location: ${e.message}`);
+ }
+ },
+ onSelectBridgeLocation: async (bridgeLocation: RelayLocation) => {
+ // dismiss the view first
+ history.goBack();
+
+ try {
+ await props.app.updateBridgeLocation(bridgeLocation);
+ } catch (e) {
+ log.error(`Failed to select the bridge location: ${e.message}`);
}
},
};