|
@@ -3,14 +3,18 @@ import {RouteComponentProps} from 'react-router';
|
|
|
import styled from '@emotion/styled';
|
|
|
import sortBy from 'lodash/sortBy';
|
|
|
|
|
|
+import {updateMonitor} from 'sentry/actionCreators/monitors';
|
|
|
+import Alert from 'sentry/components/alert';
|
|
|
import * as Layout from 'sentry/components/layouts/thirds';
|
|
|
import LoadingIndicator from 'sentry/components/loadingIndicator';
|
|
|
import {DatePageFilter} from 'sentry/components/organizations/datePageFilter';
|
|
|
import {EnvironmentPageFilter} from 'sentry/components/organizations/environmentPageFilter';
|
|
|
import PageFilterBar from 'sentry/components/organizations/pageFilterBar';
|
|
|
import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle';
|
|
|
+import {t} from 'sentry/locale';
|
|
|
import {space} from 'sentry/styles/space';
|
|
|
import {setApiQueryData, useApiQuery, useQueryClient} from 'sentry/utils/queryClient';
|
|
|
+import useApi from 'sentry/utils/useApi';
|
|
|
import useOrganization from 'sentry/utils/useOrganization';
|
|
|
import usePageFilters from 'sentry/utils/usePageFilters';
|
|
|
import {CronDetailsTimeline} from 'sentry/views/monitors/components/cronDetailsTimeline';
|
|
@@ -21,6 +25,7 @@ import MonitorHeader from './components/monitorHeader';
|
|
|
import MonitorIssues from './components/monitorIssues';
|
|
|
import MonitorStats from './components/monitorStats';
|
|
|
import MonitorOnboarding from './components/onboarding';
|
|
|
+import {StatusToggleButton} from './components/statusToggleButton';
|
|
|
import {Monitor} from './types';
|
|
|
|
|
|
const DEFAULT_POLL_INTERVAL_MS = 5000;
|
|
@@ -32,6 +37,7 @@ function hasLastCheckIn(monitor: Monitor) {
|
|
|
}
|
|
|
|
|
|
function MonitorDetails({params, location}: Props) {
|
|
|
+ const api = useApi();
|
|
|
const {selection} = usePageFilters();
|
|
|
|
|
|
const organization = useOrganization();
|
|
@@ -70,6 +76,14 @@ function MonitorDetails({params, location}: Props) {
|
|
|
setApiQueryData(queryClient, queryKey, updatedMonitor);
|
|
|
}
|
|
|
|
|
|
+ const handleUpdate = async (data: Partial<Monitor>) => {
|
|
|
+ if (monitor === undefined) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const resp = await updateMonitor(api, organization.slug, monitor.slug, data);
|
|
|
+ onUpdate(resp);
|
|
|
+ };
|
|
|
+
|
|
|
if (!monitor) {
|
|
|
return (
|
|
|
<Layout.Page>
|
|
@@ -90,6 +104,23 @@ function MonitorDetails({params, location}: Props) {
|
|
|
<DatePageFilter />
|
|
|
<EnvironmentPageFilter />
|
|
|
</StyledPageFilterBar>
|
|
|
+ {monitor.status === 'disabled' && (
|
|
|
+ <Alert
|
|
|
+ type="muted"
|
|
|
+ showIcon
|
|
|
+ trailingItems={
|
|
|
+ <StatusToggleButton
|
|
|
+ monitor={monitor}
|
|
|
+ size="xs"
|
|
|
+ onClick={() => handleUpdate({status: 'active'})}
|
|
|
+ >
|
|
|
+ {t('Reactivate')}
|
|
|
+ </StatusToggleButton>
|
|
|
+ }
|
|
|
+ >
|
|
|
+ {t('This monitor is disabled and is not accepting check-ins.')}
|
|
|
+ </Alert>
|
|
|
+ )}
|
|
|
{!hasLastCheckIn(monitor) ? (
|
|
|
<MonitorOnboarding monitor={monitor} />
|
|
|
) : (
|