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
pull/69684/head
Sonia Aguilar 2 years ago committed by GitHub
parent 498f8ea4ea
commit 848eb01a89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      public/app/features/alerting/unified/components/rule-editor/util.test.ts
  2. 2
      public/app/features/alerting/unified/components/rule-editor/util.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',

@ -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) {

Loading…
Cancel
Save