Chore: define base panel type in @grafana/data (#37766)

This commit is contained in:
Ryan McKinley
2021-08-11 00:23:41 -07:00
committed by GitHub
parent 7a8e861c1f
commit 36c798eb2f
14 changed files with 117 additions and 69 deletions

View File

@@ -8,6 +8,7 @@ import {
DataQueryResponse,
DataSourceApi,
DataSourceInstanceSettings,
DatasourceRef,
isValidLiveChannelAddress,
parseLiveChannelAddress,
StreamingFrameOptions,
@@ -17,6 +18,7 @@ import {
import { GrafanaAnnotationQuery, GrafanaAnnotationType, GrafanaQuery, GrafanaQueryType } from './types';
import AnnotationQueryEditor from './components/AnnotationQueryEditor';
import { getDashboardSrv } from '../../../features/dashboard/services/DashboardSrv';
import { isString } from 'lodash';
let counter = 100;
@@ -37,7 +39,11 @@ export class GrafanaDatasource extends DataSourceApi<GrafanaQuery> {
return json;
},
prepareQuery(anno: AnnotationQuery<GrafanaAnnotationQuery>): GrafanaQuery {
return { ...anno, refId: anno.name, queryType: GrafanaQueryType.Annotations };
let datasource: DatasourceRef | undefined | null = undefined;
if (isString(anno.datasource)) {
datasource = anno.datasource as DatasourceRef;
}
return { ...anno, refId: anno.name, queryType: GrafanaQueryType.Annotations, datasource };
},
};
}

View File

@@ -1,4 +1,4 @@
import { PanelModel, FieldConfigSource } from '@grafana/data';
import { PanelModel, FieldConfigSource, DataQuery } from '@grafana/data';
import { graphPanelMigrationHandler } from './GraphMigrations';
describe('Graph Panel Migrations', () => {
@@ -52,7 +52,7 @@ describe('Graph Panel Migrations', () => {
spaceLength: 10,
stack: false,
steppedLine: false,
targets: [
targets: ([
{
alias: 'Foo datacenter',
labels: 'datacenter=foo,region=us-east-1',
@@ -71,7 +71,7 @@ describe('Graph Panel Migrations', () => {
refId: 'C',
scenarioId: 'random_walk',
},
],
] as unknown) as DataQuery[],
thresholds: [],
timeFrom: null,
timeRegions: [],