From e163a46bc3e5bed17b639a07af0e819d4ae9ae5f Mon Sep 17 00:00:00 2001 From: Joakim Hulthe Date: Tue, 19 Nov 2024 15:50:37 +0100 Subject: [PATCH] Add daemon restart button to split tunneling settings on MacOS --- CHANGELOG.md | 2 ++ .../packages/mullvad-vpn/locales/messages.pot | 12 +++++++++ .../packages/mullvad-vpn/src/main/index.ts | 4 +++ .../packages/mullvad-vpn/src/renderer/app.tsx | 3 +++ .../src/renderer/components/Layout.tsx | 4 +++ .../components/SplitTunnelingSettings.tsx | 26 ++++++++++++++----- .../SplitTunnelingSettingsStyles.tsx | 14 +++++++--- .../src/renderer/components/common-styles.ts | 7 +++++ .../mullvad-vpn/src/shared/ipc-schema.ts | 1 + 9 files changed, 64 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e4a0097d4a35..b38edcec3930 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,8 @@ Line wrap the file at 100 chars. Th #### macOS - Detect whether full disk access is enabled in the split tunneling view. +- Add button to restart system service in split tunneling view. This can help mitigate edge-case + issues when enabling full disk access. ### Changed - Replace the draft key encapsulation mechanism Kyber (round 3) with the standardized diff --git a/desktop/packages/mullvad-vpn/locales/messages.pot b/desktop/packages/mullvad-vpn/locales/messages.pot index bebb7d90b358..6bdcd42b514c 100644 --- a/desktop/packages/mullvad-vpn/locales/messages.pot +++ b/desktop/packages/mullvad-vpn/locales/messages.pot @@ -1571,6 +1571,10 @@ msgctxt "split-tunneling-view" msgid "Click on an app to launch it. Its traffic will bypass the VPN tunnel until you close it." msgstr "" +msgctxt "split-tunneling-view" +msgid "Enabled \"Full disk access\" and still having issues?" +msgstr "" + msgctxt "split-tunneling-view" msgid "Excluded apps" msgstr "" @@ -1587,6 +1591,10 @@ msgctxt "split-tunneling-view" msgid "Launch" msgstr "" +msgctxt "split-tunneling-view" +msgid "Open System Settings" +msgstr "" + #. This error message is shown if the user tries to launch a Linux desktop #. entry file that doesn't contain the required 'Exec' value. msgctxt "split-tunneling-view" @@ -1600,6 +1608,10 @@ msgctxt "split-tunneling-view" msgid "Please try again or send a problem report." msgstr "" +msgctxt "split-tunneling-view" +msgid "Restart Mullvad Service" +msgstr "" + msgctxt "split-tunneling-view" msgid "To use split tunneling please enable “Full disk access” for “Mullvad VPN” in the macOS system settings." msgstr "" diff --git a/desktop/packages/mullvad-vpn/src/main/index.ts b/desktop/packages/mullvad-vpn/src/main/index.ts index 8f5c8cbb64f2..ea2f12199c1c 100644 --- a/desktop/packages/mullvad-vpn/src/main/index.ts +++ b/desktop/packages/mullvad-vpn/src/main/index.ts @@ -877,6 +877,10 @@ class ApplicationMain return this.daemonRpc.updateCustomList(customList); }); + IpcMainEventChannel.daemon.handlePrepareRestart((shutdown) => { + return this.daemonRpc.prepareRestart(shutdown); + }); + problemReport.registerIpcListeners(); this.userInterface!.registerIpcListeners(); this.settings.registerIpcListeners(); diff --git a/desktop/packages/mullvad-vpn/src/renderer/app.tsx b/desktop/packages/mullvad-vpn/src/renderer/app.tsx index ddbb43aab7b1..7c7b0edbfaac 100644 --- a/desktop/packages/mullvad-vpn/src/renderer/app.tsx +++ b/desktop/packages/mullvad-vpn/src/renderer/app.tsx @@ -385,6 +385,9 @@ export default class AppRenderer { public getMapData = () => IpcRendererEventChannel.map.getData(); public setAnimateMap = (displayMap: boolean): void => IpcRendererEventChannel.guiSettings.setAnimateMap(displayMap); + public daemonPrepareRestart = (shutdown: boolean): void => { + IpcRendererEventChannel.daemon.prepareRestart(shutdown); + }; public login = async (accountNumber: AccountNumber) => { const actions = this.reduxActions; diff --git a/desktop/packages/mullvad-vpn/src/renderer/components/Layout.tsx b/desktop/packages/mullvad-vpn/src/renderer/components/Layout.tsx index b74cfd929f65..f104b9235f4c 100644 --- a/desktop/packages/mullvad-vpn/src/renderer/components/Layout.tsx +++ b/desktop/packages/mullvad-vpn/src/renderer/components/Layout.tsx @@ -36,3 +36,7 @@ export const Footer = styled.div({ paddingRight: measurements.viewMargin, paddingBottom: measurements.viewMargin, }); + +export const Spacing = styled.div<{ height: string }>((props) => ({ + height: props.height, +})); diff --git a/desktop/packages/mullvad-vpn/src/renderer/components/SplitTunnelingSettings.tsx b/desktop/packages/mullvad-vpn/src/renderer/components/SplitTunnelingSettings.tsx index 7e8830e6f89d..072f62728c59 100644 --- a/desktop/packages/mullvad-vpn/src/renderer/components/SplitTunnelingSettings.tsx +++ b/desktop/packages/mullvad-vpn/src/renderer/components/SplitTunnelingSettings.tsx @@ -20,7 +20,7 @@ import * as Cell from './cell'; import { CustomScrollbarsRef } from './CustomScrollbars'; import ImageView from './ImageView'; import { BackAction } from './KeyboardNavigation'; -import { Layout, SettingsContainer } from './Layout'; +import { Layout, SettingsContainer, Spacing } from './Layout'; import List from './List'; import { ModalAlert, ModalAlertType } from './Modal'; import { NavigationBar, NavigationContainer, NavigationItems, TitleBarItem } from './NavigationBar'; @@ -37,13 +37,14 @@ import { StyledIcon, StyledIconPlaceholder, StyledListContainer, + StyledMiniTitle, StyledNavigationScrollbars, StyledNoResult, StyledNoResultText, StyledPageCover, StyledSearchBar, StyledSpinnerRow, - StyledSystemSettingsButton, + WideSmallButton, } from './SplitTunnelingSettingsStyles'; import Switch from './Switch'; @@ -534,7 +535,8 @@ interface MacOsSplitTunnelingAvailabilityProps { function MacOsSplitTunnelingAvailability({ needFullDiskPermissions, }: MacOsSplitTunnelingAvailabilityProps) { - const { showFullDiskAccessSettings } = useAppContext(); + const { showFullDiskAccessSettings, daemonPrepareRestart } = useAppContext(); + const restartDaemon = useCallback(() => daemonPrepareRestart(true), [daemonPrepareRestart]); return ( <> @@ -546,9 +548,21 @@ function MacOsSplitTunnelingAvailability({ 'To use split tunneling please enable “Full disk access” for “Mullvad VPN” in the macOS system settings.', )} - - Open System Settings - + + + {messages.pgettext('split-tunneling-view', 'Open System Settings')} + + + + {messages.pgettext( + 'split-tunneling-view', + 'Enabled "Full disk access" and still having issues?', + )} + + + + {messages.pgettext('split-tunneling-view', 'Restart Mullvad Service')} + ) : null} diff --git a/desktop/packages/mullvad-vpn/src/renderer/components/SplitTunnelingSettingsStyles.tsx b/desktop/packages/mullvad-vpn/src/renderer/components/SplitTunnelingSettingsStyles.tsx index a2019fba8dcc..8bd7067440eb 100644 --- a/desktop/packages/mullvad-vpn/src/renderer/components/SplitTunnelingSettingsStyles.tsx +++ b/desktop/packages/mullvad-vpn/src/renderer/components/SplitTunnelingSettingsStyles.tsx @@ -3,7 +3,7 @@ import styled from 'styled-components'; import { colors } from '../../config.json'; import * as AppButton from './AppButton'; import * as Cell from './cell'; -import { measurements, normalText } from './common-styles'; +import { measurements, miniText, normalText } from './common-styles'; import ImageView from './ImageView'; import { NavigationScrollbars } from './NavigationBar'; import SearchBar from './SearchBar'; @@ -118,13 +118,21 @@ export const StyledHeaderTitle = styled(HeaderTitle)({ flex: 1, }); +export const StyledMiniTitle = styled.span({ + ...miniText, + color: colors.white60, +}); + export const StyledSearchBar = styled(SearchBar)({ marginLeft: measurements.viewMargin, marginRight: measurements.viewMargin, marginBottom: measurements.buttonVerticalMargin, }); -export const StyledSystemSettingsButton = styled(SmallButton)({ +export const WideSmallButton = styled(SmallButton)({ width: '100%', - marginTop: '24px', }); + +export const Spacing = styled.div<{ height: string }>((props) => ({ + height: props.height, +})); diff --git a/desktop/packages/mullvad-vpn/src/renderer/components/common-styles.ts b/desktop/packages/mullvad-vpn/src/renderer/components/common-styles.ts index dbfb720e44b5..98f4d803c7b0 100644 --- a/desktop/packages/mullvad-vpn/src/renderer/components/common-styles.ts +++ b/desktop/packages/mullvad-vpn/src/renderer/components/common-styles.ts @@ -10,6 +10,13 @@ export const sourceSansPro: React.CSSProperties = { fontFamily: '"Source Sans Pro", "Noto Sans Myanmar", "Noto Sans Thai", sans-serif', }; +export const miniText = { + ...openSans, + fontSize: '10px', + fontWeight: 600, + lineHeight: '15px', +}; + export const tinyText = { ...openSans, fontSize: '12px', diff --git a/desktop/packages/mullvad-vpn/src/shared/ipc-schema.ts b/desktop/packages/mullvad-vpn/src/shared/ipc-schema.ts index a2282e28498b..856239c0f556 100644 --- a/desktop/packages/mullvad-vpn/src/shared/ipc-schema.ts +++ b/desktop/packages/mullvad-vpn/src/shared/ipc-schema.ts @@ -140,6 +140,7 @@ export const ipcSchema = { daemonAllowed: notifyRenderer(), connected: notifyRenderer(), disconnected: notifyRenderer(), + prepareRestart: send(), }, relays: { '': notifyRenderer(),