Annotations Panel: Show annotations end time if present (#38425)

* Annotation Panel: Show annotation end time if present

* Added hyphen between dates
This commit is contained in:
Villena Guillaume 2021-08-24 05:57:44 +02:00 committed by GitHub
parent 6548cd89af
commit 4cb87b6b60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -23,7 +23,7 @@ export const AnnotationListItem: FC<Props> = ({
}) => {
const styles = useStyles2(getStyles);
const { showUser, showTags, showTime } = options;
const { text, login, email, avatarUrl, tags, time } = annotation;
const { text, login, email, avatarUrl, tags, time, timeEnd } = annotation;
const onItemClick = (e: MouseEvent) => {
e.stopPropagation();
onClick(annotation);
@ -33,6 +33,7 @@ export const AnnotationListItem: FC<Props> = ({
};
const showAvatar = login && showUser;
const showTimeStamp = time && showTime;
const showTimeStampEnd = timeEnd && timeEnd !== time && showTime;
return (
<div>
@ -40,6 +41,8 @@ export const AnnotationListItem: FC<Props> = ({
<div className={styles.title}>
<span>{text}</span>
{showTimeStamp ? <TimeStamp formatDate={formatDate} time={time!} /> : null}
{showTimeStampEnd ? <span className={styles.time}>-</span> : null}
{showTimeStampEnd ? <TimeStamp formatDate={formatDate} time={timeEnd!} /> : null}
</div>
<div className={styles.login}>
{showAvatar ? <Avatar email={email} login={login!} avatarUrl={avatarUrl} onClick={onLoginClick} /> : null}
@ -129,6 +132,7 @@ function getStyles(theme: GrafanaTheme2) {
`,
time: css`
margin-left: ${theme.spacing(1)};
margin-right: ${theme.spacing(1)}
font-size: ${theme.typography.bodySmall.fontSize};
color: ${theme.colors.text.secondary};
`,