summaryrefslogtreecommitdiffhomepage
path: root/gui/src/renderer
diff options
context:
space:
mode:
authorOskar Nyberg <oskar@mullvad.net>2020-12-29 12:07:21 +0100
committerOskar Nyberg <oskar@mullvad.net>2021-01-26 09:06:54 +0100
commit2dcefcc1bfefacda59f647769b0dd751977d2c62 (patch)
tree1d9bfb3e4b2be69c147dabca194aae0616d4b477 /gui/src/renderer
parentf055d887eba76100033176512129ede48523a7d3 (diff)
downloadmullvadvpn-2dcefcc1bfefacda59f647769b0dd751977d2c62.tar.xz
mullvadvpn-2dcefcc1bfefacda59f647769b0dd751977d2c62.zip
Pass env and platform from process API over IPC to renderer
Diffstat (limited to 'gui/src/renderer')
-rw-r--r--gui/src/renderer/app.tsx5
-rw-r--r--gui/src/renderer/components/AdvancedSettings.tsx2
-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/context.tsx4
-rw-r--r--gui/src/renderer/redux/settings/reducers.ts2
-rw-r--r--gui/src/renderer/redux/store.ts2
10 files changed, 15 insertions, 12 deletions
diff --git a/gui/src/renderer/app.tsx b/gui/src/renderer/app.tsx
index 6d37e63279..9ff1459322 100644
--- a/gui/src/renderer/app.tsx
+++ b/gui/src/renderer/app.tsx
@@ -175,6 +175,9 @@ export default class AppRenderer {
// Request the initial state from the main process
const initialState = IpcRendererEventChannel.state.get();
+ window.platform = initialState.platform;
+ window.runningInDevelopment = initialState.runningInDevelopment;
+
this.setLocale(initialState.locale);
loadTranslations(
messages,
@@ -582,7 +585,7 @@ export default class AppRenderer {
}
private async autoConnect() {
- if (process.env.NODE_ENV === 'development') {
+ if (window.runningInDevelopment) {
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 6633e35746..7c97f0d844 100644
--- a/gui/src/renderer/components/AdvancedSettings.tsx
+++ b/gui/src/renderer/components/AdvancedSettings.tsx
@@ -429,7 +429,7 @@ export default class AdvancedSettings extends React.Component<IProps, IState> {
<Cell.Icon height={12} width={7} source="icon-chevron" />
</Cell.CellButton>
- {process.platform === 'linux' && (
+ {window.platform === 'linux' && (
<Cell.CellButton onClick={this.props.onViewLinuxSplitTunneling}>
<Cell.Label>
{messages.pgettext('advanced-settings-view', 'Split tunneling')}
diff --git a/gui/src/renderer/components/CustomScrollbars.tsx b/gui/src/renderer/components/CustomScrollbars.tsx
index bc56ffcf3c..87c5b82dce 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: process.platform === 'darwin',
+ autoHide: window.platform === 'darwin',
trackPadding: { x: 2, y: 2 },
};
diff --git a/gui/src/renderer/components/HeaderBar.tsx b/gui/src/renderer/components/HeaderBar.tsx
index 67b9622b21..bdf7d51924 100644
--- a/gui/src/renderer/components/HeaderBar.tsx
+++ b/gui/src/renderer/components/HeaderBar.tsx
@@ -28,7 +28,7 @@ interface IHeaderBarContainerProps {
const HeaderBarContainer = styled.header({}, (props: IHeaderBarContainerProps) => ({
padding: '12px 16px',
- paddingTop: process.platform === 'darwin' && !props.unpinnedWindow ? '24px' : '12px',
+ paddingTop: window.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 98c5184ea3..a82256b077 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: process.platform === 'darwin' && !props.unpinnedWindow ? '24px' : '12px',
+ paddingTop: window.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 633b7aee95..83aa7b3f7f 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 (process.platform === 'darwin' && !props.unpinnedWindow) {
+ if (window.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 ab2b423686..d47a7315c6 100644
--- a/gui/src/renderer/components/Preferences.tsx
+++ b/gui/src/renderer/components/Preferences.tsx
@@ -179,8 +179,8 @@ export default class Preferences extends React.Component<IProps> {
</Cell.Footer>
</AriaInputGroup>
- {(process.platform === 'win32' ||
- (process.platform === 'darwin' && process.env.NODE_ENV === 'development')) && (
+ {(window.platform === 'win32' ||
+ (window.platform === 'darwin' && window.runningInDevelopment)) && (
<AriaInputGroup>
<Cell.Container>
<AriaLabel>
diff --git a/gui/src/renderer/context.tsx b/gui/src/renderer/context.tsx
index 113a29fe71..d4b20daeb1 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 (process.env.NODE_ENV === 'development') {
+if (window.runningInDevelopment) {
AppContext.displayName = 'AppContext';
}
@@ -34,7 +34,7 @@ export default function withAppContext<Props>(BaseComponent: React.ComponentType
);
};
- if (process.env.NODE_ENV === 'development') {
+ if (window.runningInDevelopment) {
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 59b4c32b46..592caab687 100644
--- a/gui/src/renderer/redux/settings/reducers.ts
+++ b/gui/src/renderer/redux/settings/reducers.ts
@@ -148,7 +148,7 @@ const initialState: ISettingsReduxState = {
autoConnect: true,
monochromaticIcon: false,
startMinimized: false,
- unpinnedWindow: process.platform !== 'win32' && process.platform !== 'darwin',
+ unpinnedWindow: window.platform !== 'win32' && window.platform !== 'darwin',
},
relaySettings: {
normal: {
diff --git a/gui/src/renderer/redux/store.ts b/gui/src/renderer/redux/store.ts
index 49f864d18b..92d85e4dbe 100644
--- a/gui/src/renderer/redux/store.ts
+++ b/gui/src/renderer/redux/store.ts
@@ -54,7 +54,7 @@ export default function configureStore(initialState?: IReduxState) {
const composeEnhancers: typeof compose = (() => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const reduxCompose = window && (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;
- if (process.env.NODE_ENV === 'development' && reduxCompose) {
+ if (window.runningInDevelopment && reduxCompose) {
return reduxCompose({ actionCreators });
}
return compose;