Pull request #2251: ADG-8776 clear query log filter fix

Merge in DNS/adguard-home from ADG-8776 to master

Squashed commit of the following:

commit d9f3acf729
Author: Igor Lobanov <bniwredyc@gmail.com>
Date:   Wed Jul 3 17:55:18 2024 +0200

    clear query log filter fix
This commit is contained in:
Igor Lobanov 2024-07-04 12:43:47 +03:00
parent 93e4005125
commit 9a29aa9232
2 changed files with 8 additions and 15 deletions

View file

@ -1,6 +1,6 @@
import React, { useEffect } from 'react';
import { Field, reduxForm } from 'redux-form';
import { Field, type InjectedFormProps, reduxForm } from 'redux-form';
import { useTranslation } from 'react-i18next';
import { shallowEqual, useDispatch, useSelector } from 'react-redux';
@ -104,14 +104,13 @@ const FORM_NAMES = {
response_status: 'response_status',
};
interface FiltersFormProps {
type FiltersFormProps = {
className?: string;
responseStatusClass?: string;
change: (...args: unknown[]) => unknown;
setIsLoading?: (...args: unknown[]) => unknown;
}
setIsLoading: (...args: unknown[]) => unknown;
};
const Form = (props: FiltersFormProps) => {
const Form = (props: FiltersFormProps & InjectedFormProps) => {
const { className = '', responseStatusClass, setIsLoading, change } = props;
const { t } = useTranslation();
@ -142,7 +141,6 @@ const Form = (props: FiltersFormProps) => {
const onInputClear = async () => {
setIsLoading(true);
change(FORM_NAMES.search, DEFAULT_LOGS_FILTER[FORM_NAMES.search]);
setIsLoading(false);
};
@ -195,7 +193,7 @@ const Form = (props: FiltersFormProps) => {
);
};
export default reduxForm({
export const FiltersForm = reduxForm<Record<string, any>, FiltersFormProps>({
form: FORM_NAME.LOGS_FILTER,
enableReinitialize: true,
})(Form);

View file

@ -2,7 +2,7 @@ import React from 'react';
import { useTranslation } from 'react-i18next';
import { useDispatch } from 'react-redux';
import Form from './Form';
import { FiltersForm } from './Form';
import { refreshFilteredLogs } from '../../../actions/queryLogs';
import { addSuccessToast } from '../../../actions/toasts';
@ -38,12 +38,7 @@ const Filters = ({ filter, setIsLoading }: FiltersProps) => {
</svg>
</button>
</h1>
<Form
// responseStatusClass="d-sm-block"
// setIsLoading={setIsLoading}
initialValues={filter}
/>
<FiltersForm responseStatusClass="d-sm-block" setIsLoading={setIsLoading} initialValues={filter} />
</div>
);
};