From a82b5a0871cf5ebe3c38ab092a73abf357b8d5b5 Mon Sep 17 00:00:00 2001 From: Ashley Harrison Date: Thu, 1 Jul 2021 10:38:52 +0100 Subject: [PATCH] Annotations: Everything working, just types to fix... --- .../grafana/components/AnnotationQueryEditor.tsx | 2 +- .../app/plugins/datasource/grafana/datasource.ts | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/public/app/plugins/datasource/grafana/components/AnnotationQueryEditor.tsx b/public/app/plugins/datasource/grafana/components/AnnotationQueryEditor.tsx index ea51fa7af7c..97490d3d652 100644 --- a/public/app/plugins/datasource/grafana/components/AnnotationQueryEditor.tsx +++ b/public/app/plugins/datasource/grafana/components/AnnotationQueryEditor.tsx @@ -49,7 +49,7 @@ interface Props { } export default function AnnotationQueryEditor({ query, onChange }: Props) { - const { limit = 100, matchAny = false, tags = [], type = GrafanaAnnotationType.Dashboard } = query; + const { limit, matchAny, tags, type } = query; const onFilterByChange = (newValue: SelectableValue) => onChange({ diff --git a/public/app/plugins/datasource/grafana/datasource.ts b/public/app/plugins/datasource/grafana/datasource.ts index 530f915e813..0b0011725ce 100644 --- a/public/app/plugins/datasource/grafana/datasource.ts +++ b/public/app/plugins/datasource/grafana/datasource.ts @@ -25,11 +25,13 @@ export class GrafanaDatasource extends DataSourceApi { this.annotations = { QueryEditor: AnnotationQueryEditor, prepareAnnotation(json: any): GrafanaAnnotationQuery { + // Previously, these properties lived outside of target + // This should handle migrating them json.target = json.target ?? { - type: json.type, - limit: json.limit, - tags: json.tags, - matchAny: json.matchAny, + type: json.type ?? GrafanaAnnotationType.Dashboard, + limit: json.limit ?? 100, + tags: json.tags ?? [], + matchAny: json.matchAny ?? false, }; // using spread syntax caused an infinite loop in StandardAnnotationQueryEditor return json; }, @@ -50,8 +52,8 @@ export class GrafanaDatasource extends DataSourceApi { return from( this.getAnnotations({ range: request.range, - rangeRaw: request.rangeRaw!, - annotation: target as any, + rangeRaw: request.range.raw, + annotation: target.target as any, dashboard: getDashboardSrv().getCurrent(), }) );