Close #2091
Squashed commit of the following:
commit 9acaa0331f3094a2b48c1f0cf846a30e5c9dfc43
Merge: c207ccc9 3a71374f
Author: ArtemBaskal <a.baskal@adguard.com>
Date: Fri Sep 18 17:45:20 2020 +0300
Merge branch 'master' into fix/2091
commit c207ccc9a12f225a6f0343f5273a3469b2709679
Author: ArtemBaskal <a.baskal@adguard.com>
Date: Fri Sep 18 17:14:24 2020 +0300
Remove unused imports
commit 750f60ffc40fd48d4bd09a4e2ac4a3143e0cf126
Author: ArtemBaskal <a.baskal@adguard.com>
Date: Fri Sep 18 16:47:24 2020 +0300
Update dnsproxy to v0.32.6
commit 1723267e0e7f512db532cd180a3e9d44182d96b3
Author: ArtemBaskal <a.baskal@adguard.com>
Date: Fri Sep 18 16:32:12 2020 +0300
Replace zeroes with empty string
43 lines
1.4 KiB
JavaScript
43 lines
1.4 KiB
JavaScript
import React from 'react';
|
|
import { useTranslation } from 'react-i18next';
|
|
import { shallowEqual, useDispatch, useSelector } from 'react-redux';
|
|
import Card from '../../../ui/Card';
|
|
import Form from './Form';
|
|
import { setDnsConfig } from '../../../../actions/dnsConfig';
|
|
import { replaceEmptyStringsWithZeroes, replaceZeroWithEmptyString } from '../../../../helpers/helpers';
|
|
|
|
const CacheConfig = () => {
|
|
const { t } = useTranslation();
|
|
const dispatch = useDispatch();
|
|
const {
|
|
cache_size, cache_ttl_max, cache_ttl_min,
|
|
} = useSelector((state) => state.dnsConfig, shallowEqual);
|
|
|
|
const handleFormSubmit = (values) => {
|
|
const completedFields = replaceEmptyStringsWithZeroes(values);
|
|
dispatch(setDnsConfig(completedFields));
|
|
};
|
|
|
|
return (
|
|
<Card
|
|
title={t('dns_cache_config')}
|
|
subtitle={t('dns_cache_config_desc')}
|
|
bodyType="card-body box-body--settings"
|
|
id="dns-config"
|
|
>
|
|
<div className="form">
|
|
<Form
|
|
initialValues={{
|
|
cache_size: replaceZeroWithEmptyString(cache_size),
|
|
cache_ttl_max: replaceZeroWithEmptyString(cache_ttl_max),
|
|
cache_ttl_min: replaceZeroWithEmptyString(cache_ttl_min),
|
|
}}
|
|
onSubmit={handleFormSubmit}
|
|
/>
|
|
</div>
|
|
</Card>
|
|
);
|
|
};
|
|
|
|
export default CacheConfig;
|