Annotations: Everything working, just types to fix...

This commit is contained in:
Ashley Harrison 2021-07-01 10:38:52 +01:00
parent 460ebabac7
commit a82b5a0871
2 changed files with 9 additions and 7 deletions

View File

@ -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<GrafanaAnnotationType>) =>
onChange({

View File

@ -25,11 +25,13 @@ export class GrafanaDatasource extends DataSourceApi<GrafanaQuery> {
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<GrafanaQuery> {
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(),
})
);