From 8220c38031273229244cbc4e35a684e288371892 Mon Sep 17 00:00:00 2001 From: Riya <69919272+riysaxen-amzn@users.noreply.github.com> Date: Wed, 9 Oct 2024 16:39:05 -0700 Subject: [PATCH] edit correlation Alert Trigger fix (#1180) * edit correlation Alert Trigger fix Signed-off-by: Riya Saxena * delete correlation alert trigger fix Signed-off-by: Riya Saxena * delete correlation alert trigger fix Signed-off-by: Riya Saxena * edit correlation rule trigger fix Signed-off-by: Riya Saxena * edit correlation rule trigger fix Signed-off-by: Riya Saxena * edit correlation rule trigger fix Signed-off-by: Riya Saxena * extra spacing removed Signed-off-by: Riya Saxena --------- Signed-off-by: Riya Saxena --- .../Correlations/containers/CreateCorrelationRule.tsx | 7 +++++-- public/store/CorrelationsStore.ts | 2 ++ types/Correlations.ts | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/public/pages/Correlations/containers/CreateCorrelationRule.tsx b/public/pages/Correlations/containers/CreateCorrelationRule.tsx index 8225915c..df8423df 100644 --- a/public/pages/Correlations/containers/CreateCorrelationRule.tsx +++ b/public/pages/Correlations/containers/CreateCorrelationRule.tsx @@ -244,7 +244,6 @@ export const CreateCorrelationRule: React.FC = ( setInitialValues(ruleRes); } }; - setAction('Edit'); setInitialRuleValues(); } @@ -1079,7 +1078,11 @@ export const CreateCorrelationRule: React.FC = ( data-test-subj="delete-alert-trigger-icon" iconType="trash" color="danger" - onClick={() => setShowForm(false)} + onClick={() => { + // Clear the trigger values by setting them to an empty object or your initial state + props.setFieldValue('trigger', {}); + setShowForm(false); + }} /> diff --git a/public/store/CorrelationsStore.ts b/public/store/CorrelationsStore.ts index 229fbc91..28b36931 100644 --- a/public/store/CorrelationsStore.ts +++ b/public/store/CorrelationsStore.ts @@ -150,6 +150,7 @@ export class CorrelationsStore implements ICorrelationsStore { name: hit._source.name, time_window: hit._source.time_window || 300000, queries, + trigger: hit._source?.trigger }; } @@ -175,6 +176,7 @@ export class CorrelationsStore implements ICorrelationsStore { name: hit._source.name, time_window: hit._source.time_window || 300000, queries, + trigger: hit._source?.trigger }; }); } diff --git a/types/Correlations.ts b/types/Correlations.ts index 1bb33189..6a10fb2a 100644 --- a/types/Correlations.ts +++ b/types/Correlations.ts @@ -54,7 +54,7 @@ export interface CorrelationRuleModel { name: string; time_window: number; // Time in milliseconds queries: CorrelationRuleQuery[]; - trigger: CorrelationRuleTrigger | undefined; + trigger?: CorrelationRuleTrigger; } export interface CorrelationRule extends CorrelationRuleModel { @@ -76,7 +76,7 @@ export interface CorrelationRuleSource { name: string; time_window: number; correlate: CorrelationRuleSourceQueries[]; - trigger?: CorrelationRuleTrigger | undefined; + trigger?: CorrelationRuleTrigger; } export interface CorrelationRuleHit {