From e302a70b410413cff2ec90dfd507e2284050a4ce Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Thu, 10 Oct 2024 16:37:24 -0700 Subject: [PATCH] edit correlation Alert Trigger fix (#1180) (#1183) * edit correlation Alert Trigger fix * delete correlation alert trigger fix * delete correlation alert trigger fix * edit correlation rule trigger fix * edit correlation rule trigger fix * edit correlation rule trigger fix * extra spacing removed --------- (cherry picked from commit 8220c38031273229244cbc4e35a684e288371892) Signed-off-by: Riya Saxena Signed-off-by: github-actions[bot] Co-authored-by: github-actions[bot] --- .../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 7cc6fd17..cd5175c8 100644 --- a/public/pages/Correlations/containers/CreateCorrelationRule.tsx +++ b/public/pages/Correlations/containers/CreateCorrelationRule.tsx @@ -243,7 +243,6 @@ export const CreateCorrelationRule: React.FC = ( setInitialValues(ruleRes); } }; - setAction('Edit'); setInitialRuleValues(); } @@ -1064,7 +1063,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 4c0e81f9..b1d3b4b7 100644 --- a/public/store/CorrelationsStore.ts +++ b/public/store/CorrelationsStore.ts @@ -148,6 +148,7 @@ export class CorrelationsStore implements ICorrelationsStore { name: hit._source.name, time_window: hit._source.time_window || 300000, queries, + trigger: hit._source?.trigger }; } @@ -173,6 +174,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 0e35c25e..51881e6d 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 {