From e1466bf47e0b7f9fae021fac5e3f106a6f4a670b Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Wed, 7 Jun 2023 13:49:43 +0100 Subject: [PATCH] =?UTF-8?q?[v10.0.x]=20Alerting:=20Fix=20broken=20UI=20bec?= =?UTF-8?q?ause=20of=20query=20being=20optional=20for=20some=20ExpressionQ?= =?UTF-8?q?uer=E2=80=A6=20(#69683)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Alerting: Fix broken UI because of query being optional for some ExpressionQuer… (#69650) * Fix broken UI because of query being optional for some ExpressionQuery coditions field * Delete query field from conditions in utils.test.ts (cherry picked from commit 848eb01a896595498fb88bbbefb73be7a69978e8) Co-authored-by: Sonia Aguilar <33540275+soniaAguilarPeiron@users.noreply.github.com> --- .../unified/components/rule-editor/util.test.ts | 10 ---------- .../alerting/unified/components/rule-editor/util.ts | 2 +- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/public/app/features/alerting/unified/components/rule-editor/util.test.ts b/public/app/features/alerting/unified/components/rule-editor/util.test.ts index 64b24bc9b87..edb7407b3b9 100644 --- a/public/app/features/alerting/unified/components/rule-editor/util.test.ts +++ b/public/app/features/alerting/unified/components/rule-editor/util.test.ts @@ -396,16 +396,6 @@ function createThresholdExample(thresholdType: string): AlertQuery[] { params: [0, 10], type: thresholdType ?? 'gt', }, - operator: { - type: 'and', - }, - query: { - params: ['B'], - }, - reducer: { - params: [], - type: 'last', - }, }, ], expression: 'B', diff --git a/public/app/features/alerting/unified/components/rule-editor/util.ts b/public/app/features/alerting/unified/components/rule-editor/util.ts index 626551539af..8b02e10f153 100644 --- a/public/app/features/alerting/unified/components/rule-editor/util.ts +++ b/public/app/features/alerting/unified/components/rule-editor/util.ts @@ -150,7 +150,7 @@ export function getThresholdsForQueries(queries: AlertQuery[]) { const threshold = condition.evaluator.params; // "classic_conditions" use `condition.query.params[]` and "threshold" uses `query.model.expression` - const refId = condition.query.params[0] ?? query.model.expression; + const refId = condition.query?.params[0] ?? query.model.expression; // if an expression hasn't been linked to a data query yet, it won't have a refId if (!refId) {