diff --git a/.betterer.results b/.betterer.results index 1a5368dc24e..879e6b2b17e 100644 --- a/.betterer.results +++ b/.betterer.results @@ -1436,7 +1436,8 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], [0, 0, 0, "Do not use any type assertions.", "2"], - [0, 0, 0, "Unexpected any. Specify a different type.", "3"] + [0, 0, 0, "Unexpected any. Specify a different type.", "3"], + [0, 0, 0, "Unexpected any. Specify a different type.", "4"] ], "public/app/features/alerting/state/query_part.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], diff --git a/public/app/features/alerting/state/alertDef.ts b/public/app/features/alerting/state/alertDef.ts index 7ce82133ac5..348d89f91bc 100644 --- a/public/app/features/alerting/state/alertDef.ts +++ b/public/app/features/alerting/state/alertDef.ts @@ -207,6 +207,25 @@ function getAlertAnnotationInfo(ah: any) { return ''; } +// Copy of getAlertAnnotationInfo, used in annotation tooltip +function getAlertAnnotationText(annotationData: any) { + // backward compatibility, can be removed in grafana 5.x + // old way stored evalMatches in data property directly, + // new way stores it in evalMatches property on new data object + + if (isArray(annotationData)) { + return joinEvalMatches(annotationData, ', '); + } else if (isArray(annotationData.evalMatches)) { + return joinEvalMatches(annotationData.evalMatches, ', '); + } + + if (annotationData.error) { + return 'Error: ' + annotationData.error; + } + + return ''; +} + export default { alertQueryDef: alertQueryDef, getStateDisplayModel: getStateDisplayModel, @@ -218,5 +237,6 @@ export default { reducerTypes: reducerTypes, createReducerPart: createReducerPart, getAlertAnnotationInfo: getAlertAnnotationInfo, + getAlertAnnotationText: getAlertAnnotationText, alertStateSortScore: alertStateSortScore, }; diff --git a/public/app/plugins/panel/timeseries/plugins/annotations2/AnnotationTooltip2.tsx b/public/app/plugins/panel/timeseries/plugins/annotations2/AnnotationTooltip2.tsx index 641f0044a43..b7c7f5290eb 100644 --- a/public/app/plugins/panel/timeseries/plugins/annotations2/AnnotationTooltip2.tsx +++ b/public/app/plugins/panel/timeseries/plugins/annotations2/AnnotationTooltip2.tsx @@ -54,9 +54,9 @@ export const AnnotationTooltip2 = ({ annoVals, annoIdx, timeZone, onEdit }: Prop ); - // alertText = alertDef.getAlertAnnotationInfo(annotation); // @TODO ?? + alertText = annoVals.data?.[annoIdx] ? alertDef.getAlertAnnotationText(annoVals.data[annoIdx]) : ''; } else if (annoVals.title?.[annoIdx]) { - text = annoVals.title[annoIdx] + text ? `
${text}` : ''; + text = annoVals.title[annoIdx] + (text ? `
${text}` : ''); } return (