mirror of
https://github.com/grafana/grafana.git
synced 2026-07-30 00:08:10 -05:00
Alerting: Fix preview getting the correct queries from the form (#80458)
* fix preview getting the correct queries from the form
* Remove setting queries in onChangeQueries handler as it only contains data queries and not expressions
* Keep setValue('queries') but also adding expressions
This commit is contained in:
+4
-3
@@ -186,8 +186,9 @@ export const QueryAndExpressionsStep = ({ editingExistingRule, onDataChange }: P
|
||||
// Invocation cycle => onChange -> dispatch(setDataQueries) -> onRunQueries -> setDataQueries Reducer
|
||||
// As a workaround we update form values as soon as possible to avoid stale state
|
||||
// This way we can access up to date queries in runQueriesPreview without waiting for re-render
|
||||
setValue('queries', updatedQueries, { shouldValidate: false });
|
||||
|
||||
const previousQueries = getValues('queries');
|
||||
const expressionQueries = previousQueries.filter((query) => isExpressionQuery(query.model));
|
||||
setValue('queries', [...updatedQueries, ...expressionQueries], { shouldValidate: false });
|
||||
updateExpressionAndDatasource(updatedQueries);
|
||||
|
||||
dispatch(setDataQueries(updatedQueries));
|
||||
@@ -199,7 +200,7 @@ export const QueryAndExpressionsStep = ({ editingExistingRule, onDataChange }: P
|
||||
dispatch(rewireExpressions({ oldRefId, newRefId }));
|
||||
}
|
||||
},
|
||||
[queries, setValue, updateExpressionAndDatasource]
|
||||
[queries, updateExpressionAndDatasource, getValues, setValue]
|
||||
);
|
||||
|
||||
const onChangeRecordingRulesQueries = useCallback(
|
||||
|
||||
Reference in New Issue
Block a user