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 Access from 'sentry/components/acl/access'; import Button, {ButtonProps} from 'sentry/components/button'; 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 OnboardingPanel from 'sentry/components/onboardingPanel'; import {normalizeDateTimeParams} from 'sentry/components/organizations/pageFilters/parse'; 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 MonitorIcon from './monitorIcon'; import {Monitor} from './types'; type Props = AsyncView['props'] & WithRouteAnalyticsProps & WithRouterProps<{orgId: string}> & { organization: Organization; }; type State = AsyncView['state'] & { monitorList: Monitor[] | null; }; function NewMonitorButton(props: ButtonProps) { const organization = useOrganization(); return ( {({hasAccess}) => ( {props.children} )} ); } 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 `Monitors - ${this.orgSlug}`; } componentDidMount() { this.props.setEventNames('monitors.page_viewed', 'Monitors: Page Viewed'); } 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('Monitors')} {t('New Monitor')} {monitorList?.length ? ( {monitorList?.map(monitor => ( {monitor.name} {monitor.nextCheckIn ? ( ) : ( {t('n/a')} )} ))} {monitorListPageLinks && ( )} ) : ( }> {t('Monitor your recurring jobs')} {t( 'Stop worrying about the status of your cron jobs. Let us notify you when your jobs take too long or do not execute on schedule.' )} {t('Create a Monitor')} )} ); } } const HeaderTitle = styled(Layout.Title)` margin-top: 0; `; 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; `; export default withRouteAnalytics(withSentryRouter(withOrganization(Monitors)));
{t( 'Stop worrying about the status of your cron jobs. Let us notify you when your jobs take too long or do not execute on schedule.' )}