From fba42a52852e73131e2e07256d3f8344d484c6e9 Mon Sep 17 00:00:00 2001 From: Amardeepsingh Siglani Date: Thu, 30 Nov 2023 15:05:10 -0800 Subject: [PATCH] validate fields only when group by enabled; update default window to 5 min (#810) Signed-off-by: Amardeepsingh Siglani --- .../containers/CorrelationRuleFormModel.ts | 2 +- .../containers/CreateCorrelationRule.tsx | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/public/pages/Correlations/containers/CorrelationRuleFormModel.ts b/public/pages/Correlations/containers/CorrelationRuleFormModel.ts index 6bad7ef45..775b07523 100644 --- a/public/pages/Correlations/containers/CorrelationRuleFormModel.ts +++ b/public/pages/Correlations/containers/CorrelationRuleFormModel.ts @@ -7,7 +7,7 @@ import { CorrelationRuleModel } from '../../../../types'; export const correlationRuleStateDefaultValue: CorrelationRuleModel = { name: '', - time_window: 60000, + time_window: 300000, queries: [ { logType: '', diff --git a/public/pages/Correlations/containers/CreateCorrelationRule.tsx b/public/pages/Correlations/containers/CreateCorrelationRule.tsx index 28423331f..b7e490b42 100644 --- a/public/pages/Correlations/containers/CreateCorrelationRule.tsx +++ b/public/pages/Correlations/containers/CreateCorrelationRule.tsx @@ -709,15 +709,17 @@ export const CreateCorrelationRule: React.FC = ( errors.time_window = 'Invalid time window.'; } - values.queries.forEach((query, idx) => { - if (!query.field) { - if (!errors.queries) { - errors.queries = Array(values.queries.length).fill(null); - } + if (groupByEnabled) { + values.queries.forEach((query, idx) => { + if (!query.field) { + if (!errors.queries) { + errors.queries = Array(values.queries.length).fill(null); + } - (errors.queries as Array<{ field: string }>)[idx] = { field: 'Field is required.' }; - } - }); + (errors.queries as Array<{ field: string }>)[idx] = { field: 'Field is required.' }; + } + }); + } return errors; }}