+ client: Allow Fastest IP address and Parallel requests to toggle each other: Merge pull request #619 in DNS/adguard-home from feature/1678 to master
Close #1678 Squashed commit of the following: commit 9251ed0f1b58426104d1b9bdaa4b7af5f92be83e Author: ArtemBaskal <a.baskal@adguard.com> Date: Thu May 21 18:25:18 2020 +0300 + client: Allow `Fastest IP address` and `Parallel requests` to toggle each other
This commit is contained in:
@@ -1,13 +1,27 @@
|
||||
import React, { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { withTranslation } from 'react-i18next';
|
||||
import cn from 'classnames';
|
||||
|
||||
import Form from './Form';
|
||||
import Card from '../../../ui/Card';
|
||||
import { DNS_REQUEST_OPTIONS } from '../../../../helpers/constants';
|
||||
|
||||
|
||||
class Upstream extends Component {
|
||||
handleSubmit = (values) => {
|
||||
this.props.setDnsConfig(values);
|
||||
handleSubmit = ({ bootstrap_dns, upstream_dns, dnsRequestOption }) => {
|
||||
const disabledOption = dnsRequestOption === DNS_REQUEST_OPTIONS.PARALLEL_REQUESTS
|
||||
? DNS_REQUEST_OPTIONS.FASTEST_ADDR
|
||||
: DNS_REQUEST_OPTIONS.PARALLEL_REQUESTS;
|
||||
|
||||
const formattedValues = {
|
||||
bootstrap_dns,
|
||||
upstream_dns,
|
||||
[dnsRequestOption]: true,
|
||||
[disabledOption]: false,
|
||||
};
|
||||
|
||||
this.props.setDnsConfig(formattedValues);
|
||||
};
|
||||
|
||||
handleTest = (values) => {
|
||||
@@ -27,6 +41,11 @@ class Upstream extends Component {
|
||||
},
|
||||
} = this.props;
|
||||
|
||||
const dnsRequestOption = cn({
|
||||
parallel_requests,
|
||||
fastest_addr,
|
||||
});
|
||||
|
||||
return (
|
||||
<Card
|
||||
title={t('upstream_dns')}
|
||||
@@ -39,8 +58,7 @@ class Upstream extends Component {
|
||||
initialValues={{
|
||||
upstream_dns,
|
||||
bootstrap_dns,
|
||||
fastest_addr,
|
||||
parallel_requests,
|
||||
dnsRequestOption,
|
||||
}}
|
||||
testUpstream={this.handleTest}
|
||||
onSubmit={this.handleSubmit}
|
||||
|
||||
Reference in New Issue
Block a user