From 848eb01a896595498fb88bbbefb73be7a69978e8 Mon Sep 17 00:00:00 2001 From: Sonia Aguilar <33540275+soniaAguilarPeiron@users.noreply.github.com> Date: Wed, 7 Jun 2023 10:58:08 +0200 Subject: [PATCH] =?UTF-8?q?Alerting:=20Fix=20broken=20UI=20because=20of=20?= =?UTF-8?q?query=20being=20optional=20for=20some=20ExpressionQuer=E2=80=A6?= =?UTF-8?q?=20(#69650)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix broken UI because of query being optional for some ExpressionQuery coditions field * Delete query field from conditions in utils.test.ts --- .../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 b1161f5a1f1..902f8d7276e 100644 --- a/public/app/features/alerting/unified/components/rule-editor/util.ts +++ b/public/app/features/alerting/unified/components/rule-editor/util.ts @@ -152,7 +152,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) {