Annotations: Fix annotation title (#85614)

This commit is contained in:
Adela Almasan 2024-04-05 16:39:10 -06:00 committed by GitHub
parent 391d2ba7c7
commit 5f0ca1429b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 24 additions and 3 deletions

View File

@ -1533,7 +1533,8 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Do not use any type assertions.", "2"], [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": [ "public/app/features/alerting/state/query_part.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],

View File

@ -207,6 +207,25 @@ function getAlertAnnotationInfo(ah: any) {
return ''; 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 { export default {
alertQueryDef: alertQueryDef, alertQueryDef: alertQueryDef,
getStateDisplayModel: getStateDisplayModel, getStateDisplayModel: getStateDisplayModel,
@ -218,5 +237,6 @@ export default {
reducerTypes: reducerTypes, reducerTypes: reducerTypes,
createReducerPart: createReducerPart, createReducerPart: createReducerPart,
getAlertAnnotationInfo: getAlertAnnotationInfo, getAlertAnnotationInfo: getAlertAnnotationInfo,
getAlertAnnotationText: getAlertAnnotationText,
alertStateSortScore: alertStateSortScore, alertStateSortScore: alertStateSortScore,
}; };

View File

@ -54,9 +54,9 @@ export const AnnotationTooltip2 = ({ annoVals, annoIdx, timeZone, onEdit }: Prop
</div> </div>
); );
// alertText = alertDef.getAlertAnnotationInfo(annotation); // @TODO ?? alertText = annoVals.data?.[annoIdx] ? alertDef.getAlertAnnotationText(annoVals.data[annoIdx]) : '';
} else if (annoVals.title?.[annoIdx]) { } else if (annoVals.title?.[annoIdx]) {
text = annoVals.title[annoIdx] + text ? `<br />${text}` : ''; text = annoVals.title[annoIdx] + (text ? `<br />${text}` : '');
} }
return ( return (