import {Fragment} from 'react'; import styled from '@emotion/styled'; 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 {defined} from 'sentry/utils'; import {getFormattedDate} from 'sentry/utils/dates'; import useCopyToClipboard from 'sentry/utils/useCopyToClipboard'; import {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 {ScheduleType} from 'sentry/views/monitors/types'; import {scheduleAsText} from 'sentry/views/monitors/utils'; 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 && ( ({schedule}) )} {t('Margins')} {defined(checkin_margin) ? tn( 'Check-ins missed after %s min', 'Check-ins missed after %s mins', checkin_margin ) : t('Check-ins that are missed')} {tn( 'Check-ins longer than %s min or errors', 'Check-ins longer than %s mins or errors', max_runtime ?? DEFAULT_MAX_RUNTIME )} {t('Cron Details')} {schedule_type === ScheduleType.CRONTAB && ( )} ); } 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; `;