diff --git a/client/src/components/Filters/Form.tsx b/client/src/components/Filters/Form.tsx
index 3f79ba02..700d7480 100644
--- a/client/src/components/Filters/Form.tsx
+++ b/client/src/components/Filters/Form.tsx
@@ -37,7 +37,6 @@ const renderIcons = (iconsData: any) =>
));
interface renderCheckboxFieldProps {
- // https://redux-form.com/8.3.0/docs/api/field.md/#props
input: {
name: string;
value: string;
diff --git a/client/src/components/Settings/FiltersConfig/Form.tsx b/client/src/components/Settings/FiltersConfig/Form.tsx
deleted file mode 100644
index 8222d524..00000000
--- a/client/src/components/Settings/FiltersConfig/Form.tsx
+++ /dev/null
@@ -1,85 +0,0 @@
-import React from 'react';
-
-import { Field, reduxForm } from 'redux-form';
-import { Trans, withTranslation } from 'react-i18next';
-import flow from 'lodash/flow';
-
-import { CheckboxField, toNumber } from '../../../helpers/form';
-import { FILTERS_INTERVALS_HOURS, FILTERS_RELATIVE_LINK, FORM_NAME } from '../../../helpers/constants';
-
-const getTitleForInterval = (interval: any, t: any) => {
- if (interval === 0) {
- return t('disabled');
- }
- if (interval === 72 || interval === 168) {
- return t('interval_days', { count: interval / 24 });
- }
-
- return t('interval_hours', { count: interval });
-};
-
-const getIntervalSelect = (processing: any, t: any, handleChange: any, toNumber: any) => (
-
- {FILTERS_INTERVALS_HOURS.map((interval) => (
-
- ))}
-
-);
-
-interface FormProps {
- handleSubmit: (...args: unknown[]) => string;
- handleChange?: (...args: unknown[]) => unknown;
- change: (...args: unknown[]) => unknown;
- submitting: boolean;
- invalid: boolean;
- processing: boolean;
- t: (...args: unknown[]) => string;
-}
-
-const Form = (props: FormProps) => {
- const { handleSubmit, handleChange, processing, t } = props;
-
- const components = {
- a: ,
- };
-
- return (
-
- );
-};
-
-export default flow([withTranslation(), reduxForm({ form: FORM_NAME.FILTER_CONFIG })])(Form);
diff --git a/client/src/components/Settings/FiltersConfig/index.tsx b/client/src/components/Settings/FiltersConfig/index.tsx
index c9a8577a..157475dc 100644
--- a/client/src/components/Settings/FiltersConfig/index.tsx
+++ b/client/src/components/Settings/FiltersConfig/index.tsx
@@ -1,39 +1,105 @@
-import React from 'react';
-import { withTranslation } from 'react-i18next';
-import debounce from 'lodash/debounce';
+import React, { useEffect, useRef } from 'react';
+import { useForm } from 'react-hook-form';
+import { Trans, useTranslation } from 'react-i18next';
-import { DEBOUNCE_TIMEOUT } from '../../../helpers/constants';
+import { toNumber } from '../../../helpers/form';
+import { FILTERS_INTERVALS_HOURS, FILTERS_RELATIVE_LINK } from '../../../helpers/constants';
-import Form from './Form';
+const getTitleForInterval = (interval: any, t: any) => {
+ if (interval === 0) {
+ return t('disabled');
+ }
+ if (interval === 72 || interval === 168) {
+ return t('interval_days', { count: interval / 24 });
+ }
-import { getObjDiff } from '../../../helpers/helpers';
-
-interface FiltersConfigProps {
- initialValues: object;
- processing: boolean;
- setFiltersConfig: (...args: unknown[]) => unknown;
- t: (...args: unknown[]) => string;
-}
-
-const FiltersConfig = (props: FiltersConfigProps) => {
- const { initialValues, processing } = props;
-
- const handleFormChange = debounce((values) => {
- const diff = getObjDiff(initialValues, values);
-
- if (Object.values(diff).length > 0) {
- props.setFiltersConfig(values);
- }
- }, DEBOUNCE_TIMEOUT);
-
- return (
-
- );
+ return t('interval_hours', { count: interval });
};
-export default withTranslation()(FiltersConfig);
+export type FormValues = {
+ enabled: boolean;
+ interval: number;
+};
+
+type Props = {
+ initialValues: FormValues;
+ setFiltersConfig: (values: FormValues) => void;
+ processing: boolean;
+};
+
+export const FiltersConfig = ({ initialValues, setFiltersConfig, processing }: Props) => {
+ const { t } = useTranslation();
+ const prevFormValuesRef = useRef(initialValues);
+
+ const { register, watch } = useForm({
+ mode: 'onChange',
+ defaultValues: initialValues,
+ });
+
+ const formValues = watch();
+
+ useEffect(() => {
+ const prevFormValues = prevFormValuesRef.current;
+
+ if (JSON.stringify(prevFormValues) !== JSON.stringify(formValues)) {
+ setFiltersConfig(formValues);
+ prevFormValuesRef.current = formValues;
+ }
+ }, [formValues]);
+
+ const components = {
+ a: ,
+ };
+
+ return (
+ <>
+
+
+
+
+
+ filters_block_toggle_hint
+
+
+
+
+
+
+
+
+
+
+
+ >
+ );
+};
diff --git a/client/src/components/Settings/index.tsx b/client/src/components/Settings/index.tsx
index 71669cca..f6fac0ec 100644
--- a/client/src/components/Settings/index.tsx
+++ b/client/src/components/Settings/index.tsx
@@ -5,7 +5,7 @@ import StatsConfig from './StatsConfig';
import LogsConfig from './LogsConfig';
-import FiltersConfig from './FiltersConfig';
+import { FiltersConfig } from './FiltersConfig';
import Checkbox from '../ui/Checkbox';
@@ -136,23 +136,14 @@ class Settings extends Component {
render() {
const {
settings,
-
setStatsConfig,
-
resetStats,
-
stats,
-
queryLogs,
-
setLogsConfig,
-
clearLogs,
-
filtering,
-
setFiltersConfig,
-
t,
} = this.props;
@@ -163,6 +154,7 @@ class Settings extends Component {
{!isDataReady && }
+
{isDataReady && (
diff --git a/client/src/helpers/validators.ts b/client/src/helpers/validators.ts
index 3815339a..41722b2d 100644
--- a/client/src/helpers/validators.ts
+++ b/client/src/helpers/validators.ts
@@ -24,7 +24,6 @@ import { ip4ToInt, isValidAbsolutePath } from './form';
import { isIpInCidr, parseSubnetMask } from './helpers';
// Validation functions
-// https://redux-form.com/8.3.0/examples/fieldlevelvalidation/
// If the value is valid, the validation function should return undefined.
/**
* @param value {string|number}
diff --git a/client/src/install/Setup/Devices.tsx b/client/src/install/Setup/Devices.tsx
index 64c66150..8378a138 100644
--- a/client/src/install/Setup/Devices.tsx
+++ b/client/src/install/Setup/Devices.tsx
@@ -42,6 +42,4 @@ const Devices = ({ interfaces, dnsIp, dnsPort }: DevicesProps) => (
);
-export default flow([
- withTranslation(),
-])(Devices);
+export default flow([withTranslation()])(Devices);
diff --git a/client/src/install/Setup/Submit.tsx b/client/src/install/Setup/Submit.tsx
index 44af2c69..2ac980f4 100644
--- a/client/src/install/Setup/Submit.tsx
+++ b/client/src/install/Setup/Submit.tsx
@@ -26,11 +26,8 @@ const Submit = (props: SubmitProps) => (
- {/* TODO props webIp webPort */}
);
-export default flow([
- withTranslation(),
-])(Submit);
+export default flow([withTranslation()])(Submit);