From 419598c7453523027f7668d59ca5b4239678ca3e Mon Sep 17 00:00:00 2001 From: Sonia Aguilar <33540275+soniaAguilarPeiron@users.noreply.github.com> Date: Thu, 10 Oct 2024 09:56:15 +0200 Subject: [PATCH] Alerting: Fix getSimpleConditionFromExpressions (#94516) fix getSimpleConditionFromExpressions --- .../query-and-alert-condition/SimpleCondition.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/public/app/features/alerting/unified/components/rule-editor/query-and-alert-condition/SimpleCondition.tsx b/public/app/features/alerting/unified/components/rule-editor/query-and-alert-condition/SimpleCondition.tsx index 7307675defd..1e745c46da6 100644 --- a/public/app/features/alerting/unified/components/rule-editor/query-and-alert-condition/SimpleCondition.tsx +++ b/public/app/features/alerting/unified/components/rule-editor/query-and-alert-condition/SimpleCondition.tsx @@ -218,11 +218,17 @@ export function getSimpleConditionFromExpressions(expressions: Array query.model.type === ExpressionQueryType.threshold && query.refId === SIMPLE_CONDITION_THRESHOLD_ID ); const conditionsFromThreshold = thresholdExpression?.model.conditions ?? []; + const whenField = reduceExpression?.model.reducer ?? ReducerID.last; + const params = conditionsFromThreshold[0]?.evaluator?.params + ? [...conditionsFromThreshold[0]?.evaluator?.params] + : [0]; + const type = conditionsFromThreshold[0]?.evaluator?.type ?? EvalFunction.IsAbove; + return { - whenField: reduceExpression?.model.reducer ?? ReducerID.last, + whenField: whenField, evaluator: { - params: [...conditionsFromThreshold[0]?.evaluator?.params] ?? [0], - type: conditionsFromThreshold[0]?.evaluator?.type ?? EvalFunction.IsAbove, + params: params, + type: type, }, }; }