RuleDetailsAnnotations.tsx 721 B

123456789101112131415161718192021222324252627282930313233
  1. import { css } from '@emotion/css';
  2. import React from 'react';
  3. import { useStyles2 } from '@grafana/ui';
  4. import { AnnotationDetailsField } from '../AnnotationDetailsField';
  5. type Props = {
  6. annotations: Array<[string, string]>;
  7. };
  8. export function RuleDetailsAnnotations(props: Props): JSX.Element | null {
  9. const { annotations } = props;
  10. const styles = useStyles2(getStyles);
  11. if (annotations.length === 0) {
  12. return null;
  13. }
  14. return (
  15. <div className={styles.annotations}>
  16. {annotations.map(([key, value]) => (
  17. <AnnotationDetailsField key={key} annotationKey={key} value={value} />
  18. ))}
  19. </div>
  20. );
  21. }
  22. const getStyles = () => ({
  23. annotations: css`
  24. margin-top: 46px;
  25. `,
  26. });