From e1f6229e56c5ec9b4a8947e90cd44ccf5e992cc1 Mon Sep 17 00:00:00 2001
From: Ildar Kamalov <ik@adguard.com>
Date: Mon, 28 Aug 2023 17:39:08 +0300
Subject: [PATCH] Pull request: trim empty lines in the logs and statistics
 configuration

Updates #6140

Squashed commit of the following:

commit 9ad618684a9a89314d8eb57028f34bd32be9fdbb
Merge: cd1cee0c6 3f7089d24
Author: Ildar Kamalov <ik@adguard.com>
Date:   Mon Aug 28 17:24:36 2023 +0300

    Merge branch 'master' into ADG-7414

commit cd1cee0c6235248f6f8670b2b8d0144468170b23
Author: Ildar Kamalov <ik@adguard.com>
Date:   Mon Aug 28 15:28:04 2023 +0300

    fix stats form

commit 88bb1adfd5da913bf0c260a092b2b6ac627b06ef
Author: Ildar Kamalov <ik@adguard.com>
Date:   Mon Aug 28 14:55:58 2023 +0300

    client: trim empty lines in the logs configuration textarea
---
 client/src/components/Settings/LogsConfig/Form.js  | 6 +++++-
 client/src/components/Settings/StatsConfig/Form.js | 2 ++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/client/src/components/Settings/LogsConfig/Form.js b/client/src/components/Settings/LogsConfig/Form.js
index 5553bbbc..7aa11a81 100644
--- a/client/src/components/Settings/LogsConfig/Form.js
+++ b/client/src/components/Settings/LogsConfig/Form.js
@@ -13,8 +13,11 @@ import flow from 'lodash/flow';
 import {
     CheckboxField,
     toFloatNumber,
-    renderTextareaField, renderInputField, renderRadioField,
+    renderTextareaField,
+    renderInputField,
+    renderRadioField,
 } from '../../../helpers/form';
+import { trimLinesAndRemoveEmpty } from '../../../helpers/helpers';
 import {
     FORM_NAME,
     QUERY_LOG_INTERVALS_DAYS,
@@ -147,6 +150,7 @@ let Form = (props) => {
                     component={renderTextareaField}
                     placeholder={t('ignore_domains')}
                     disabled={processing}
+                    normalizeOnBlur={trimLinesAndRemoveEmpty}
                 />
             </div>
             <div className="mt-5">
diff --git a/client/src/components/Settings/StatsConfig/Form.js b/client/src/components/Settings/StatsConfig/Form.js
index 6512639e..857c6d79 100644
--- a/client/src/components/Settings/StatsConfig/Form.js
+++ b/client/src/components/Settings/StatsConfig/Form.js
@@ -24,6 +24,7 @@ import {
     CUSTOM_INTERVAL,
     RETENTION_RANGE,
 } from '../../../helpers/constants';
+import { trimLinesAndRemoveEmpty } from '../../../helpers/helpers';
 import '../FormButton.css';
 
 const getIntervalTitle = (intervalMs, t) => {
@@ -135,6 +136,7 @@ let Form = (props) => {
                     component={renderTextareaField}
                     placeholder={t('ignore_domains')}
                     disabled={processing}
+                    normalizeOnBlur={trimLinesAndRemoveEmpty}
                 />
             </div>
             <div className="mt-5">