summaryrefslogtreecommitdiffhomepage
path: root/gui/src
diff options
context:
space:
mode:
authorOskar Nyberg <oskar@mullvad.net>2021-07-06 13:17:46 +0200
committerOskar Nyberg <oskar@mullvad.net>2021-07-12 10:09:19 +0200
commit17d77726bffdebd4977ff9d39d5ef60acaf861f1 (patch)
tree662dd298b064e994282dd33c5d0f229685e81663 /gui/src
parentf3191b3d5d50b6aec641d0d0167f86085eba31c1 (diff)
downloadmullvadvpn-17d77726bffdebd4977ff9d39d5ef60acaf861f1.tar.xz
mullvadvpn-17d77726bffdebd4977ff9d39d5ef60acaf861f1.zip
Update usages of platform and node env in renderer
Diffstat (limited to 'gui/src')
-rw-r--r--gui/src/renderer/app.tsx4
-rw-r--r--gui/src/renderer/components/AdvancedSettings.tsx4
-rw-r--r--gui/src/renderer/components/CustomScrollbars.tsx2
-rw-r--r--gui/src/renderer/components/HeaderBar.tsx2
-rw-r--r--gui/src/renderer/components/NavigationBarStyles.tsx2
-rw-r--r--gui/src/renderer/components/PlatformWindow.tsx2
-rw-r--r--gui/src/renderer/components/Preferences.tsx4
-rw-r--r--gui/src/renderer/components/SplitTunnelingSettings.tsx4
-rw-r--r--gui/src/renderer/context.tsx4
-rw-r--r--gui/src/renderer/redux/settings/reducers.ts2
-rw-r--r--gui/src/shared/notifications/error.ts4
-rw-r--r--gui/src/shared/notifications/no-valid-key.ts3
12 files changed, 19 insertions, 18 deletions
diff --git a/gui/src/renderer/app.tsx b/gui/src/renderer/app.tsx
index 681086ee0a..5b4f4be972 100644
--- a/gui/src/renderer/app.tsx
+++ b/gui/src/renderer/app.tsx
@@ -560,7 +560,7 @@ export default class AppRenderer {
let expectedContentHeight = 568;
// The app content is 12px taller on macOS to fit the top arrow.
- if (window.platform === 'darwin' && !this.guiSettings.unpinnedWindow) {
+ if (window.env.platform === 'darwin' && !this.guiSettings.unpinnedWindow) {
expectedContentHeight += 12;
}
@@ -673,7 +673,7 @@ export default class AppRenderer {
}
private async autoConnect() {
- if (window.runningInDevelopment) {
+ if (window.env.development) {
log.info('Skip autoconnect in development');
} else if (this.autoConnected) {
log.info('Skip autoconnect because it was done before');
diff --git a/gui/src/renderer/components/AdvancedSettings.tsx b/gui/src/renderer/components/AdvancedSettings.tsx
index 77c815fe61..62232b6b8c 100644
--- a/gui/src/renderer/components/AdvancedSettings.tsx
+++ b/gui/src/renderer/components/AdvancedSettings.tsx
@@ -441,11 +441,11 @@ export default class AdvancedSettings extends React.Component<IProps, IState> {
</Cell.CellButton>
</StyledButtonCellGroup>
- {(window.platform === 'linux' || window.platform === 'win32') && (
+ {(window.env.platform === 'linux' || window.env.platform === 'win32') && (
<StyledButtonCellGroup>
<Cell.CellButton onClick={this.props.onViewSplitTunneling}>
<Cell.Label>
- {window.platform === 'win32' && <StyledBetaLabel />}
+ {window.env.platform === 'win32' && <StyledBetaLabel />}
{messages.pgettext('advanced-settings-view', 'Split tunneling')}
</Cell.Label>
<Cell.Icon height={12} width={7} source="icon-chevron" />
diff --git a/gui/src/renderer/components/CustomScrollbars.tsx b/gui/src/renderer/components/CustomScrollbars.tsx
index 2b5119839c..3dacd26626 100644
--- a/gui/src/renderer/components/CustomScrollbars.tsx
+++ b/gui/src/renderer/components/CustomScrollbars.tsx
@@ -47,7 +47,7 @@ interface IScrollbarUpdateContext {
export default class CustomScrollbars extends React.Component<IProps, IState> {
public static defaultProps: IProps = {
// auto-hide on macOS by default
- autoHide: window.platform === 'darwin',
+ autoHide: window.env.platform === 'darwin',
trackPadding: { x: 2, y: 2 },
};
diff --git a/gui/src/renderer/components/HeaderBar.tsx b/gui/src/renderer/components/HeaderBar.tsx
index f3a69f5af2..0dcd2e7ea9 100644
--- a/gui/src/renderer/components/HeaderBar.tsx
+++ b/gui/src/renderer/components/HeaderBar.tsx
@@ -31,7 +31,7 @@ interface IHeaderBarContainerProps {
const HeaderBarContainer = styled.header({}, (props: IHeaderBarContainerProps) => ({
padding: '12px 16px',
- paddingTop: window.platform === 'darwin' && !props.unpinnedWindow ? '24px' : '12px',
+ paddingTop: window.env.platform === 'darwin' && !props.unpinnedWindow ? '24px' : '12px',
backgroundColor: headerBarStyleColorMap[props.barStyle ?? HeaderBarStyle.default],
}));
diff --git a/gui/src/renderer/components/NavigationBarStyles.tsx b/gui/src/renderer/components/NavigationBarStyles.tsx
index f8ac87f3e2..52aefe323d 100644
--- a/gui/src/renderer/components/NavigationBarStyles.tsx
+++ b/gui/src/renderer/components/NavigationBarStyles.tsx
@@ -20,7 +20,7 @@ export const StyledNavigationItems = styled.div({
export const StyledNavigationBar = styled.nav((props: { unpinnedWindow: boolean }) => ({
flex: 0,
padding: '12px',
- paddingTop: window.platform === 'darwin' && !props.unpinnedWindow ? '24px' : '12px',
+ paddingTop: window.env.platform === 'darwin' && !props.unpinnedWindow ? '24px' : '12px',
}));
export const StyledNavigationBarWrapper = styled.div({
diff --git a/gui/src/renderer/components/PlatformWindow.tsx b/gui/src/renderer/components/PlatformWindow.tsx
index 83aa7b3f7f..9b18f5f726 100644
--- a/gui/src/renderer/components/PlatformWindow.tsx
+++ b/gui/src/renderer/components/PlatformWindow.tsx
@@ -10,7 +10,7 @@ interface IPlatformWindowProps {
export default styled.div({}, (props: IPlatformWindowProps) => {
let mask: string | undefined;
- if (window.platform === 'darwin' && !props.unpinnedWindow) {
+ if (window.env.platform === 'darwin' && !props.unpinnedWindow) {
const arrowPositionCss =
props.arrowPosition !== undefined ? `${props.arrowPosition - ARROW_WIDTH * 0.5}px` : '50%';
diff --git a/gui/src/renderer/components/Preferences.tsx b/gui/src/renderer/components/Preferences.tsx
index c91330aee0..ebaa2da359 100644
--- a/gui/src/renderer/components/Preferences.tsx
+++ b/gui/src/renderer/components/Preferences.tsx
@@ -225,8 +225,8 @@ export default class Preferences extends React.Component<IProps> {
</Cell.Footer>
</AriaInputGroup>
- {(window.platform === 'win32' ||
- (window.platform === 'darwin' && window.runningInDevelopment)) && (
+ {(window.env.platform === 'win32' ||
+ (window.env.platform === 'darwin' && window.env.development)) && (
<AriaInputGroup>
<Cell.Container>
<AriaLabel>
diff --git a/gui/src/renderer/components/SplitTunnelingSettings.tsx b/gui/src/renderer/components/SplitTunnelingSettings.tsx
index d6f2bbbdcf..30948dae35 100644
--- a/gui/src/renderer/components/SplitTunnelingSettings.tsx
+++ b/gui/src/renderer/components/SplitTunnelingSettings.tsx
@@ -102,13 +102,13 @@ interface IPlatformSplitTunnelingSettingsProps {
}
function PlatformSpecificSplitTunnelingSettings(props: IPlatformSplitTunnelingSettingsProps) {
- switch (window.platform) {
+ switch (window.env.platform) {
case 'linux':
return <LinuxSplitTunnelingSettings {...props} />;
case 'win32':
return <WindowsSplitTunnelingSettings {...props} />;
default:
- throw new Error(`Split tunneling not implemented on ${window.platform}`);
+ throw new Error(`Split tunneling not implemented on ${window.env.platform}`);
}
}
diff --git a/gui/src/renderer/context.tsx b/gui/src/renderer/context.tsx
index d4b20daeb1..341ddda893 100644
--- a/gui/src/renderer/context.tsx
+++ b/gui/src/renderer/context.tsx
@@ -6,7 +6,7 @@ export interface IAppContext {
}
export const AppContext = React.createContext<IAppContext | undefined>(undefined);
-if (window.runningInDevelopment) {
+if (window.env.development) {
AppContext.displayName = 'AppContext';
}
@@ -34,7 +34,7 @@ export default function withAppContext<Props>(BaseComponent: React.ComponentType
);
};
- if (window.runningInDevelopment) {
+ if (window.env.development) {
wrappedComponent.displayName =
'withAppContext(' + (BaseComponent.displayName || BaseComponent.name) + ')';
}
diff --git a/gui/src/renderer/redux/settings/reducers.ts b/gui/src/renderer/redux/settings/reducers.ts
index 1b07e805fa..8f61721a6e 100644
--- a/gui/src/renderer/redux/settings/reducers.ts
+++ b/gui/src/renderer/redux/settings/reducers.ts
@@ -149,7 +149,7 @@ const initialState: ISettingsReduxState = {
autoConnect: true,
monochromaticIcon: false,
startMinimized: false,
- unpinnedWindow: window.platform !== 'win32' && window.platform !== 'darwin',
+ unpinnedWindow: window.env.platform !== 'win32' && window.env.platform !== 'darwin',
browsedForSplitTunnelingApplications: [],
},
relaySettings: {
diff --git a/gui/src/shared/notifications/error.ts b/gui/src/shared/notifications/error.ts
index 97e5e2ce93..066c9c333e 100644
--- a/gui/src/shared/notifications/error.ts
+++ b/gui/src/shared/notifications/error.ts
@@ -66,7 +66,7 @@ export class ErrorNotificationProvider
function getMessage(errorDetails: IErrorState, accountExpiry?: string): string {
if (errorDetails.blockFailure) {
if (errorDetails.cause.reason === 'set_firewall_policy_error') {
- switch (process.platform ?? window.platform) {
+ switch (process.platform ?? window.env.platform) {
case 'win32':
return messages.pgettext(
'notifications',
@@ -107,7 +107,7 @@ function getMessage(errorDetails: IErrorState, accountExpiry?: string): string {
'Could not configure IPv6. Disable it in the app or enable it on your device.',
);
case 'set_firewall_policy_error':
- switch (process.platform ?? window.platform) {
+ switch (process.platform ?? window.env.platform) {
case 'win32':
return messages.pgettext(
'notifications',
diff --git a/gui/src/shared/notifications/no-valid-key.ts b/gui/src/shared/notifications/no-valid-key.ts
index 8da145a1f0..6de28ab8df 100644
--- a/gui/src/shared/notifications/no-valid-key.ts
+++ b/gui/src/shared/notifications/no-valid-key.ts
@@ -14,7 +14,8 @@ export class NoValidKeyNotificationProvider implements InAppNotificationProvider
public mayDisplay() {
const usingWireGuard =
this.context.tunnelProtocol === 'wireguard' ||
- (this.context.tunnelProtocol === 'any' && (process.platform ?? window.platform) !== 'win32');
+ (this.context.tunnelProtocol === 'any' &&
+ (process.platform ?? window.env.platform) !== 'win32');
const keyInvalid =
this.context.wireGuardKey.type === 'key-not-set' ||
this.context.wireGuardKey.type === 'too-many-keys' ||