import {Fragment} from 'react'; import styled from '@emotion/styled'; import ActorAvatar from 'sentry/components/avatar/actorAvatar'; import {SectionHeading} from 'sentry/components/charts/styles'; import {KeyValueTable, KeyValueTableRow} from 'sentry/components/keyValueTable'; import Text from 'sentry/components/text'; import TimeSince from 'sentry/components/timeSince'; import {Tooltip} from 'sentry/components/tooltip'; import {IconCopy} from 'sentry/icons'; import {t, tn} from 'sentry/locale'; import {space} from 'sentry/styles/space'; import {getFormattedDate} from 'sentry/utils/dates'; import useCopyToClipboard from 'sentry/utils/useCopyToClipboard'; import { DEFAULT_CHECKIN_MARGIN, DEFAULT_MAX_RUNTIME, } from 'sentry/views/monitors/components/monitorForm'; import {MonitorIndicator} from 'sentry/views/monitors/components/monitorIndicator'; import type {Monitor, MonitorEnvironment} from 'sentry/views/monitors/types'; import {CheckInStatus, ScheduleType} from 'sentry/views/monitors/types'; import {scheduleAsText} from 'sentry/views/monitors/utils/scheduleAsText'; interface Props { monitor: Monitor; monitorEnv?: MonitorEnvironment; } export default function DetailsSidebar({monitorEnv, monitor}: Props) { const {checkin_margin, schedule, schedule_type, max_runtime, timezone} = monitor.config; const {onClick, label} = useCopyToClipboard({text: monitor.slug}); const slug = ( {monitor.slug} ); return ( {t('Last Check-In')} {t('Next Check-In')}
{monitorEnv?.lastCheckIn ? ( ) : ( '-' )}
{monitor.status !== 'disabled' && monitorEnv?.nextCheckIn ? ( ) : ( '-' )}
{t('Schedule')} {scheduleAsText(monitor.config)}{' '} {schedule_type === ScheduleType.CRONTAB && `(${timezone})`} {schedule_type === ScheduleType.CRONTAB && ( ({schedule}) )} {t('Legend')} {tn( 'Check-in missed after %s min', 'Check-in missed after %s mins', checkin_margin ?? DEFAULT_CHECKIN_MARGIN )} {t('Check-in reported as failed')} {tn( 'Check-in timed out after %s min', 'Check-in timed out after %s mins', max_runtime ?? DEFAULT_MAX_RUNTIME )} {t('Cron Details')} ) : ( t('Unassigned') ) } />
); } const CheckIns = styled('div')` display: grid; grid-template-columns: 1fr 1fr; margin-bottom: ${space(2)}; `; const Schedule = styled('div')` margin-bottom: ${space(2)}; display: flex; flex-wrap: wrap; gap: ${space(1)}; `; const CrontabText = styled(Text)` font-family: ${p => p.theme.text.familyMono}; color: ${p => p.theme.subText}; `; const Thresholds = styled('div')` display: grid; grid-template-columns: max-content 1fr; margin-bottom: ${space(2)}; align-items: center; gap: ${space(1)}; `; const MonitorSlug = styled('button')` display: grid; grid-template-columns: 1fr max-content; align-items: center; gap: ${space(0.5)}; background: transparent; border: none; &:hover { color: ${p => p.theme.textColor}; } `; const SlugText = styled(Text)` white-space: nowrap; overflow: hidden; text-overflow: ellipsis; `;