summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOskar Nyberg <oskar@mullvad.net>2021-02-02 12:50:17 +0100
committerOskar Nyberg <oskar@mullvad.net>2021-02-02 12:50:17 +0100
commit0258346401f1512fd1bc6007a64d5a369de0ae49 (patch)
tree18c0bde38dd053550885a2fb3197c4c08a050f48
parente3ec8bc85aa1cea4711a3549bcae04bc74e5965b (diff)
parenta5de39af0209aec63e8de5defb0ebd277c975409 (diff)
downloadmullvadvpn-0258346401f1512fd1bc6007a64d5a369de0ae49.tar.xz
mullvadvpn-0258346401f1512fd1bc6007a64d5a369de0ae49.zip
Merge branch 'dont-enable-custom-dns-without-ips'
-rw-r--r--gui/src/renderer/components/AdvancedSettings.tsx26
-rw-r--r--gui/src/renderer/components/cell/Input.tsx2
2 files changed, 15 insertions, 13 deletions
diff --git a/gui/src/renderer/components/AdvancedSettings.tsx b/gui/src/renderer/components/AdvancedSettings.tsx
index 7c97f0d844..f0510a91be 100644
--- a/gui/src/renderer/components/AdvancedSettings.tsx
+++ b/gui/src/renderer/components/AdvancedSettings.tsx
@@ -449,18 +449,19 @@ export default class AdvancedSettings extends React.Component<IProps, IState> {
<AriaInput>
<Cell.Switch
ref={this.customDnsSwitchRef}
- isOn={this.props.dns.custom}
+ isOn={this.props.dns.custom || this.state.showAddCustomDns}
onChange={this.setCustomDnsEnabled}
/>
</AriaInput>
</AriaInputGroup>
</StyledCustomDnsSwitchContainer>
- <Accordion expanded={this.props.dns.custom}>
+ <Accordion expanded={this.props.dns.custom || this.state.showAddCustomDns}>
<CellList items={this.customDnsItems()} onRemove={this.removeDnsAddress} />
{this.state.showAddCustomDns && (
<div ref={this.customDnsInputContainerRef}>
<Cell.RowInput
+ placeholder={messages.pgettext('advanced-settings-view', 'e.g. 10.0.0.4')}
onSubmit={this.addDnsAddress}
onChange={this.addDnsInputChange}
invalid={this.state.invalidDnsIp}
@@ -511,10 +512,12 @@ export default class AdvancedSettings extends React.Component<IProps, IState> {
}
private setCustomDnsEnabled = async (enabled: boolean) => {
- await this.props.setDnsOptions({
- custom: enabled,
- addresses: this.props.dns.addresses,
- });
+ if (this.props.dns.addresses.length > 0) {
+ await this.props.setDnsOptions({
+ custom: enabled,
+ addresses: this.props.dns.addresses,
+ });
+ }
if (enabled && this.props.dns.addresses.length === 0) {
this.showAddCustomDnsRow();
@@ -548,16 +551,13 @@ export default class AdvancedSettings extends React.Component<IProps, IState> {
) {
event?.target.focus();
} else {
- this.hideAddCustomDnsRow(false);
+ this.hideAddCustomDnsRow();
}
};
- private hideAddCustomDnsRow(justAdded: boolean) {
+ private hideAddCustomDnsRow() {
if (!this.state.publicDnsIpToConfirm) {
this.setState({ showAddCustomDns: false });
- if (!justAdded && this.props.dns.addresses.length === 0) {
- consumePromise(this.setCustomDnsEnabled(false));
- }
}
}
@@ -581,10 +581,10 @@ export default class AdvancedSettings extends React.Component<IProps, IState> {
} else {
try {
await this.props.setDnsOptions({
- custom: this.props.dns.custom,
+ custom: this.props.dns.custom || this.state.showAddCustomDns,
addresses: [...this.props.dns.addresses, address],
});
- this.hideAddCustomDnsRow(true);
+ this.hideAddCustomDnsRow();
} catch (_e) {
this.setState({ invalidDnsIp: true });
}
diff --git a/gui/src/renderer/components/cell/Input.tsx b/gui/src/renderer/components/cell/Input.tsx
index 0ab5b4c493..f464adf269 100644
--- a/gui/src/renderer/components/cell/Input.tsx
+++ b/gui/src/renderer/components/cell/Input.tsx
@@ -244,6 +244,7 @@ interface IRowInputProps {
paddingLeft?: number;
invalid?: boolean;
autofocus?: boolean;
+ placeholder?: string;
}
export function RowInput(props: IRowInputProps) {
@@ -309,6 +310,7 @@ export function RowInput(props: IRowInputProps) {
invalid={props.invalid}
onFocus={props.onFocus}
onBlur={props.onBlur}
+ placeholder={props.placeholder}
/>
</StyledInputWrapper>
<StyledSubmitButton onClick={submit}>