+ client: Display upstreams list loaded from a file

Squashed commit of the following:

commit b5abc9115806f345c8d0dd5ea00b8552d27813f9
Merge: 92708411 c1c8abdd
Author: ArtemBaskal <a.baskal@adguard.com>
Date:   Mon Sep 7 14:38:06 2020 +0300

    Merge branch '1680-upstreams-file' into feature/1680

commit 92708411f07638c037e049ee8012d15bdeda77e4
Author: ArtemBaskal <a.baskal@adguard.com>
Date:   Fri Sep 4 13:54:24 2020 +0300

    + client: Display upstreams list loaded from a file
This commit is contained in:
Artem Baskal
2020-09-08 14:06:19 +03:00
parent c1c8abdd0f
commit b04e12e189
5 changed files with 74 additions and 48 deletions

View File

@@ -12,15 +12,28 @@ const Upstream = () => {
upstream_dns,
bootstrap_dns,
upstream_mode,
processingSetConfig,
} = useSelector((state) => state.dnsConfig, shallowEqual);
const { processingTestUpstream } = useSelector((state) => state.settings, shallowEqual);
const upstream_dns_file = useSelector((state) => state.dnsConfig.upstream_dns_file);
const handleSubmit = (values) => {
dispatch(setDnsConfig(values));
const {
bootstrap_dns,
upstream_dns,
upstream_mode,
} = values;
const dnsConfig = {
bootstrap_dns,
upstream_mode,
...(upstream_dns_file ? null : { upstream_dns }),
};
dispatch(setDnsConfig(dnsConfig));
};
const upstreamDns = upstream_dns_file ? t('configured_in', { path: upstream_dns_file }) : upstream_dns;
return <Card
title={t('upstream_dns')}
subtitle={t('upstream_dns_hint')}
@@ -30,13 +43,11 @@ const Upstream = () => {
<div className="col">
<Form
initialValues={{
upstream_dns,
upstream_dns: upstreamDns,
bootstrap_dns,
upstream_mode,
}}
onSubmit={handleSubmit}
processingTestUpstream={processingTestUpstream}
processingSetConfig={processingSetConfig}
/>
</div>
</div>