Skip to content

Commit f34d216

Browse files
committed
Merge branch 'implement-move-information-in-popups-to-info-dialogs-des-1167'
2 parents 9b3a32b + eba34fc commit f34d216

File tree

3 files changed

+19
-105
lines changed

3 files changed

+19
-105
lines changed

desktop/packages/mullvad-vpn/locales/messages.pot

-13
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,6 @@ msgstr ""
260260
msgid "Test"
261261
msgstr ""
262262

263-
#. Warning shown in dialog to users when they enable setting that increases
264-
#. network latency (decreases performance).
265263
msgid "This setting increases latency. Use only if needed."
266264
msgstr ""
267265

@@ -1279,10 +1277,6 @@ msgctxt "openvpn-settings-view"
12791277
msgid "Bridge mode"
12801278
msgstr ""
12811279

1282-
msgctxt "openvpn-settings-view"
1283-
msgid "Enable bridge mode?"
1284-
msgstr ""
1285-
12861280
#. This is used as a description for the bridge mode
12871281
#. setting.
12881282
#. Available placeholders:
@@ -2041,13 +2035,6 @@ msgctxt "vpn-settings-view"
20412035
msgid "The DNS server you want to add is a private IP. You must ensure that your network interfaces are configured to use it."
20422036
msgstr ""
20432037

2044-
#. Available placeholders:
2045-
#. %(tunnelProtocol)s - the name of the tunnel protocol setting
2046-
#. %(wireguard)s - will be replaced with "WireGuard"
2047-
msgctxt "vpn-settings-view"
2048-
msgid "The DNS server you want to add is public and will only work with %(wireguard)s. To ensure that it always works, set the \"%(tunnelProtocol)s\" (in Advanced settings) to %(wireguard)s."
2049-
msgstr ""
2050-
20512038
msgctxt "vpn-settings-view"
20522039
msgid "This built-in feature prevents your traffic from leaking outside of the VPN tunnel if your network suddenly stops working or if the tunnel fails, it does this by blocking your traffic until your connection is reestablished."
20532040
msgstr ""

desktop/packages/mullvad-vpn/src/renderer/components/CustomDnsSettings.tsx

+16-57
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
2-
import { sprintf } from 'sprintf-js';
32

4-
import { colors, strings } from '../../config.json';
3+
import { colors } from '../../config.json';
54
import { messages } from '../../shared/gettext';
65
import { useAppContext } from '../context';
76
import { formatHtml } from '../lib/html-formatter';
@@ -44,7 +43,6 @@ export default function CustomDnsSettings() {
4443
const [savingAdd, setSavingAdd] = useState(false);
4544
const [savingEdit, setSavingEdit] = useState(false);
4645
const willShowConfirmationDialog = useRef(false);
47-
const addingLocalIp = useRef(false);
4846

4947
const featureAvailable = useMemo(
5048
() =>
@@ -63,11 +61,13 @@ export default function CustomDnsSettings() {
6361
const inputContainerRef = useStyledRef<HTMLDivElement>();
6462

6563
const confirm = useCallback(() => {
64+
willShowConfirmationDialog.current = false;
6665
void confirmAction?.();
6766
setConfirmAction(undefined);
6867
}, [confirmAction]);
6968
const abortConfirmation = useCallback(() => {
7069
setConfirmAction(undefined);
70+
willShowConfirmationDialog.current = false;
7171
}, []);
7272

7373
const setCustomDnsEnabled = useCallback(
@@ -124,23 +124,11 @@ export default function CustomDnsSettings() {
124124

125125
try {
126126
const ipAddress = IpAddress.fromString(address);
127-
addingLocalIp.current = ipAddress.isLocal();
128-
if (addingLocalIp.current) {
129-
if (manualLocal) {
130-
willShowConfirmationDialog.current = true;
131-
setConfirmAction(() => async () => {
132-
willShowConfirmationDialog.current = false;
133-
await add();
134-
});
135-
} else {
136-
await add();
137-
}
138-
} else {
127+
if (ipAddress.isLocal() && manualLocal) {
139128
willShowConfirmationDialog.current = true;
140-
setConfirmAction(() => async () => {
141-
willShowConfirmationDialog.current = false;
142-
await add();
143-
});
129+
setConfirmAction(() => add);
130+
} else {
131+
await add();
144132
}
145133
} catch {
146134
setInvalid();
@@ -172,25 +160,14 @@ export default function CustomDnsSettings() {
172160

173161
const ipAddress = IpAddress.fromString(newAddress);
174162
return new Promise<void>((resolve) => {
175-
addingLocalIp.current = ipAddress.isLocal();
176-
if (addingLocalIp.current) {
177-
if (manualLocal) {
178-
willShowConfirmationDialog.current = true;
179-
setConfirmAction(() => async () => {
180-
willShowConfirmationDialog.current = false;
181-
await edit();
182-
resolve();
183-
});
184-
} else {
185-
void edit().then(resolve);
186-
}
187-
} else {
163+
if (ipAddress.isLocal() && manualLocal) {
188164
willShowConfirmationDialog.current = true;
189165
setConfirmAction(() => async () => {
190-
willShowConfirmationDialog.current = false;
191166
await edit();
192167
resolve();
193168
});
169+
} else {
170+
void edit().then(resolve);
194171
}
195172
});
196173
},
@@ -304,7 +281,6 @@ export default function CustomDnsSettings() {
304281

305282
<ConfirmationDialog
306283
isOpen={confirmAction !== undefined}
307-
isLocal={addingLocalIp}
308284
confirm={confirm}
309285
abort={abortConfirmation}
310286
/>
@@ -405,33 +381,15 @@ function CellListItem(props: ICellListItemProps) {
405381

406382
interface IConfirmationDialogProps {
407383
isOpen: boolean;
408-
isLocal: React.RefObject<boolean>;
409384
confirm: () => void;
410385
abort: () => void;
411386
}
412387

413388
function ConfirmationDialog(props: IConfirmationDialogProps) {
414-
let message;
415-
if (props.isLocal.current) {
416-
message = messages.pgettext(
417-
'vpn-settings-view',
418-
'The DNS server you want to add is a private IP. You must ensure that your network interfaces are configured to use it.',
419-
);
420-
} else {
421-
message = sprintf(
422-
// TRANSLATORS: Available placeholders:
423-
// TRANSLATORS: %(tunnelProtocol)s - the name of the tunnel protocol setting
424-
// TRANSLATORS: %(wireguard)s - will be replaced with "WireGuard"
425-
messages.pgettext(
426-
'vpn-settings-view',
427-
'The DNS server you want to add is public and will only work with %(wireguard)s. To ensure that it always works, set the "%(tunnelProtocol)s" (in Advanced settings) to %(wireguard)s.',
428-
),
429-
{
430-
wireguard: strings.wireguard,
431-
tunnelProtocol: messages.pgettext('vpn-settings-view', 'Tunnel protocol'),
432-
},
433-
);
434-
}
389+
const message = messages.pgettext(
390+
'vpn-settings-view',
391+
'The DNS server you want to add is a private IP. You must ensure that your network interfaces are configured to use it.',
392+
);
435393
return (
436394
<ModalAlert
437395
isOpen={props.isOpen}
@@ -445,6 +403,7 @@ function ConfirmationDialog(props: IConfirmationDialogProps) {
445403
</AppButton.BlueButton>,
446404
]}
447405
close={props.abort}
448-
message={message}></ModalAlert>
406+
message={message}
407+
/>
449408
);
450409
}

desktop/packages/mullvad-vpn/src/renderer/components/OpenVpnSettings.tsx

+3-35
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,13 @@ import { useAppContext } from '../context';
1616
import { useRelaySettingsUpdater } from '../lib/constraint-updater';
1717
import { useHistory } from '../lib/history';
1818
import { formatHtml } from '../lib/html-formatter';
19-
import { useBoolean } from '../lib/utility-hooks';
2019
import { useSelector } from '../redux/store';
2120
import { AriaDescription, AriaInput, AriaInputGroup, AriaLabel } from './AriaGroup';
2221
import * as Cell from './cell';
2322
import Selector, { SelectorItem } from './cell/Selector';
2423
import { BackAction } from './KeyboardNavigation';
2524
import { Layout, SettingsContainer } from './Layout';
26-
import { ModalAlert, ModalAlertType, ModalMessage } from './Modal';
25+
import { ModalMessage } from './Modal';
2726
import {
2827
NavigationBar,
2928
NavigationContainer,
@@ -32,7 +31,6 @@ import {
3231
TitleBarItem,
3332
} from './NavigationBar';
3433
import SettingsHeader, { HeaderTitle } from './SettingsHeader';
35-
import { SmallButton } from './SmallButton';
3634

3735
const MIN_MSSFIX_VALUE = 1000;
3836
const MAX_MSSFIX_VALUE = 1450;
@@ -279,8 +277,6 @@ function BridgeModeSelector() {
279277
[tunnelProtocol, transportProtocol],
280278
);
281279

282-
const [confirmationDialogVisible, showConfirmationDialog, hideConfirmationDialog] = useBoolean();
283-
284280
const setBridgeState = useCallback(
285281
async (bridgeState: BridgeState) => {
286282
try {
@@ -295,20 +291,11 @@ function BridgeModeSelector() {
295291

296292
const onSelectBridgeState = useCallback(
297293
async (newValue: BridgeState) => {
298-
if (newValue === 'on') {
299-
showConfirmationDialog();
300-
} else {
301-
await setBridgeState(newValue);
302-
}
294+
await setBridgeState(newValue);
303295
},
304-
[showConfirmationDialog, setBridgeState],
296+
[setBridgeState],
305297
);
306298

307-
const confirmBridgeState = useCallback(async () => {
308-
hideConfirmationDialog();
309-
await setBridgeState('on');
310-
}, [hideConfirmationDialog, setBridgeState]);
311-
312299
const footerText = bridgeModeFooterText(bridgeState === 'on', tunnelProtocol, transportProtocol);
313300

314301
return (
@@ -355,25 +342,6 @@ function BridgeModeSelector() {
355342
</Cell.CellFooter>
356343
)}
357344
</AriaInputGroup>
358-
<ModalAlert
359-
isOpen={confirmationDialogVisible}
360-
type={ModalAlertType.caution}
361-
title={messages.pgettext('openvpn-settings-view', 'Enable bridge mode?')}
362-
message={
363-
// TRANSLATORS: Warning shown in dialog to users when they enable setting that increases
364-
// TRANSLATORS: network latency (decreases performance).
365-
messages.gettext('This setting increases latency. Use only if needed.')
366-
}
367-
gridButtons={[
368-
<SmallButton key="cancel" onClick={hideConfirmationDialog}>
369-
{messages.gettext('Cancel')}
370-
</SmallButton>,
371-
<SmallButton key="confirm" onClick={confirmBridgeState} data-testid="enable-confirm">
372-
{messages.gettext('Enable')}
373-
</SmallButton>,
374-
]}
375-
close={hideConfirmationDialog}
376-
/>
377345
</>
378346
);
379347
}

0 commit comments

Comments
 (0)