import { css } from '@emotion/css'; import React from 'react'; import { dateMath, GrafanaTheme2, intervalToAbbreviatedDurationString } from '@grafana/data'; import { useStyles2 } from '@grafana/ui'; import SilencedAlertsTable from './SilencedAlertsTable'; import { SilenceTableItem } from './SilencesTable'; interface Props { silence: SilenceTableItem; } export const SilenceDetails = ({ silence }: Props) => { const { startsAt, endsAt, comment, createdBy, silencedAlerts } = silence; const styles = useStyles2(getStyles); const dateDisplayFormat = 'YYYY-MM-DD HH:mm'; const startsAtDate = dateMath.parse(startsAt); const endsAtDate = dateMath.parse(endsAt); const duration = intervalToAbbreviatedDurationString({ start: new Date(startsAt), end: new Date(endsAt) }); return (
Comment
{comment}
Schedule
{`${startsAtDate?.format(dateDisplayFormat)} - ${endsAtDate?.format(dateDisplayFormat)}`}
Duration
{duration}
Created by
{createdBy}
Affected alerts
); }; const getStyles = (theme: GrafanaTheme2) => ({ container: css` display: grid; grid-template-columns: 1fr 9fr; grid-row-gap: 1rem; `, title: css` color: ${theme.colors.text.primary}; `, row: css` margin: ${theme.spacing(1, 0)}; `, });