import { css } from '@emotion/css';
import React from 'react';
import { GrafanaTheme2 } from '@grafana/data';
import { TextLink, Tooltip, useStyles2 } from '@grafana/ui';
import { Annotation, annotationLabels } from '../utils/constants';
import { DetailsField } from './DetailsField';
import { Tokenize } from './Tokenize';
import { Well } from './Well';
const wellableAnnotationKeys = ['message', 'description'];
interface Props {
annotationKey: string;
value: string;
valueLink?: string;
}
export const AnnotationDetailsField = ({ annotationKey, value, valueLink }: Props) => {
const annotation = annotationKey as Annotation;
const label = annotationLabels[annotation] ? (
{annotationLabels[annotation]}
) : (
annotationKey
);
return (
);
};
const AnnotationValue = ({ annotationKey, value, valueLink }: Props) => {
const styles = useStyles2(getStyles);
const needsWell = wellableAnnotationKeys.includes(annotationKey);
const needsExternalLink = value && value.startsWith('http');
const tokenizeValue = ;
if (valueLink) {
return (
{value}
);
}
if (needsWell) {
return {tokenizeValue};
}
if (needsExternalLink) {
return (
{value}
);
}
return <>{tokenizeValue}>;
};
export const getStyles = (theme: GrafanaTheme2) => ({
well: css`
word-break: break-word;
`,
});