mirror of
https://github.com/grafana/grafana.git
synced 2026-09-05 04:40:13 -05:00
Datasources: Use getDefaultQuery in annotations editors (#61870)
+ Add Cloudwatch default annotation
This commit is contained in:
@@ -24,7 +24,6 @@ import {
|
||||
import { toDataQueryError } from '@grafana/runtime';
|
||||
import { isExpressionReference } from '@grafana/runtime/src/utils/DataSourceWithBackend';
|
||||
import { backendSrv } from 'app/core/services/backend_srv';
|
||||
import { queryIsEmpty } from 'app/core/utils/query';
|
||||
import { dataSource as expressionDatasource } from 'app/features/expressions/ExpressionDatasource';
|
||||
import { ExpressionQuery } from 'app/features/expressions/types';
|
||||
|
||||
@@ -176,10 +175,11 @@ export function callQueryMethod(
|
||||
request: DataQueryRequest,
|
||||
queryFunction?: typeof datasource.query
|
||||
) {
|
||||
// If the datasource has defined a default query, make sure it's applied if the query is empty
|
||||
request.targets = request.targets.map((t) =>
|
||||
queryIsEmpty(t) ? { ...datasource?.getDefaultQuery?.(CoreApp.PanelEditor), ...t } : t
|
||||
);
|
||||
// If the datasource has defined a default query, make sure it's applied
|
||||
request.targets = request.targets.map((t) => ({
|
||||
...datasource?.getDefaultQuery?.(CoreApp.PanelEditor),
|
||||
...t,
|
||||
}));
|
||||
|
||||
// If its a public datasource, just return the result. Expressions will be handled on the backend.
|
||||
if (datasource.type === 'public-ds') {
|
||||
|
||||
Reference in New Issue
Block a user