import {Fragment} from 'react'; import {WithRouterProps} from 'react-router'; import styled from '@emotion/styled'; import * as qs from 'query-string'; import onboardingImg from 'sentry-images/spot/onboarding-preview.svg'; import {Button, ButtonProps} from 'sentry/components/button'; import ButtonBar from 'sentry/components/buttonBar'; import FeatureBadge from 'sentry/components/featureBadge'; import IdBadge from 'sentry/components/idBadge'; import * as Layout from 'sentry/components/layouts/thirds'; import Link from 'sentry/components/links/link'; import NoProjectMessage from 'sentry/components/noProjectMessage'; import OnboardingPanel from 'sentry/components/onboardingPanel'; import {normalizeDateTimeParams} from 'sentry/components/organizations/pageFilters/parse'; import {PageHeadingQuestionTooltip} from 'sentry/components/pageHeadingQuestionTooltip'; import Pagination from 'sentry/components/pagination'; import {PanelTable} from 'sentry/components/panels'; import ProjectPageFilter from 'sentry/components/projectPageFilter'; import SearchBar from 'sentry/components/searchBar'; import TimeSince from 'sentry/components/timeSince'; import {t} from 'sentry/locale'; import space from 'sentry/styles/space'; import {Organization} from 'sentry/types'; import {decodeScalar} from 'sentry/utils/queryString'; import withRouteAnalytics, { WithRouteAnalyticsProps, } from 'sentry/utils/routeAnalytics/withRouteAnalytics'; import useOrganization from 'sentry/utils/useOrganization'; import withOrganization from 'sentry/utils/withOrganization'; // eslint-disable-next-line no-restricted-imports import withSentryRouter from 'sentry/utils/withSentryRouter'; import AsyncView from 'sentry/views/asyncView'; import CronsFeedbackButton from './cronsFeedbackButton'; import MonitorIcon from './monitorIcon'; import {Monitor} from './types'; type Props = AsyncView['props'] & WithRouteAnalyticsProps & WithRouterProps<{}> & { organization: Organization; }; type State = AsyncView['state'] & { monitorList: Monitor[] | null; }; function NewMonitorButton(props: ButtonProps) { const organization = useOrganization(); return ( ); } class Monitors extends AsyncView { get orgSlug() { return this.props.organization.slug; } getEndpoints(): ReturnType { const {location} = this.props; return [ [ 'monitorList', `/organizations/${this.orgSlug}/monitors/`, { query: location.query, }, ], ]; } getTitle() { return `Crons - ${this.orgSlug}`; } onRequestSuccess(response): void { this.props.setEventNames('monitors.page_viewed', 'Monitors: Page Viewed'); this.props.setRouteAnalyticsParams({ empty_state: response.data.length === 0, }); } handleSearch = (query: string) => { const {location, router} = this.props; router.push({ pathname: location.pathname, query: normalizeDateTimeParams({ ...(location.query || {}), query, }), }); }; renderBody() { const {monitorList, monitorListPageLinks} = this.state; const {organization} = this.props; return ( {t('Cron Monitors')} {t('Set Up Cron Monitor')} {monitorList?.length ? ( {monitorList?.map(monitor => ( {monitor.name} {monitor.nextCheckIn ? ( ) : (
{t('n/a')}
)}
))}
{monitorListPageLinks && ( )}
) : ( }>

{t('Let Sentry monitor your recurring jobs')}

{t( "We'll tell you if your recurring jobs are running on schedule, failing, or succeeding." )}

{t('Set up first cron monitor')}
)}
); } } const StyledLink = styled(Link)` flex: 1; margin-left: ${space(2)}; `; const StyledTimeSince = styled(TimeSince)` font-variant-numeric: tabular-nums; `; const Filters = styled('div')` display: grid; grid-template-columns: minmax(auto, 300px) 1fr; gap: ${space(1.5)}; margin-bottom: ${space(2)}; `; const MonitorName = styled('div')` display: flex; align-items: center; `; const StyledPanelTable = styled(PanelTable)` grid-template-columns: 1fr max-content max-content; `; const ButtonList = styled(ButtonBar)` grid-template-columns: repeat(auto-fit, minmax(130px, max-content)); `; export default withRouteAnalytics(withSentryRouter(withOrganization(Monitors)));