grafana/public/app/plugins/datasource/opentsdb/migrations.ts
Brendan O'Handley 20d0aa9904
OpenTsdb: migrate annotations from angular to react (#53856)
* remove annotation angular dependency and migrate annotations

* add nullish coalescing operator

* remove annotations angular partial

* make annotation queries code and errors more readable

* handle the betterer issue with '^ Unexpected any. Specify a different type' at top of file

* run precommits

* run prettier
2022-08-26 13:44:10 -04:00

24 lines
641 B
TypeScript

import { LegacyAnnotation } from './types';
// this becomes the target in the migrated annotations
const migrateLegacyAnnotation = (json: LegacyAnnotation) => {
// return the target annotation
const annotation: LegacyAnnotation = {
fromAnnotations: true,
target: json.target ?? '',
name: json.name ?? '',
isGlobal: json.isGlobal ?? false,
};
return annotation;
};
// eslint-ignore-next-line
export const prepareAnnotation = (json: any) => {
const resultingTarget = json.target && typeof json.target !== 'string' ? json.target : migrateLegacyAnnotation(json);
json.target = resultingTarget;
return json;
};