Files
grafana/public/app/features/alerting/unified/components/rules/RuleDetailsAnnotations.tsx
Konrad Lalik 0a73ac36ad Alerting: Add dashboard and panel links to rule and instance annotations (#63243)
* Add dashboard and panel links in rule and instance annotations

* Use clean annotations in RuleViewer
2023-02-22 13:17:13 +01:00

37 lines
880 B
TypeScript

import { css } from '@emotion/css';
import React from 'react';
import { useStyles2 } from '@grafana/ui';
import { useAnnotationLinks } from '../../utils/annotations';
import { AnnotationDetailsField } from '../AnnotationDetailsField';
type Props = {
annotations: Array<[string, string]>;
};
export function RuleDetailsAnnotations(props: Props): JSX.Element | null {
const styles = useStyles2(getStyles);
const { annotations } = props;
const annotationLinks = useAnnotationLinks(annotations);
if (annotations.length === 0) {
return null;
}
return (
<div className={styles.annotations}>
{annotations.map(([key, value]) => (
<AnnotationDetailsField key={key} annotationKey={key} value={value} valueLink={annotationLinks.get(key)} />
))}
</div>
);
}
const getStyles = () => ({
annotations: css`
margin-top: 46px;
`,
});