import {Fragment} from 'react'; import {Breadcrumbs} from 'sentry/components/breadcrumbs'; import FeedbackWidgetButton from 'sentry/components/feedback/widget/feedbackWidgetButton'; import * as Layout from 'sentry/components/layouts/thirds'; import {t} from 'sentry/locale'; import HookStore from 'sentry/stores/hookStore'; import {browserHistory} from 'sentry/utils/browserHistory'; import useOrganization from 'sentry/utils/useOrganization'; import usePageFilters from 'sentry/utils/usePageFilters'; import {normalizeUrl} from 'sentry/utils/withDomainRequired'; import MonitorForm from './components/monitorForm'; import type {Monitor} from './types'; function CreateMonitor() { const organization = useOrganization(); const orgSlug = organization.slug; const {selection} = usePageFilters(); const monitorCreationCallbacks = HookStore.get('callback:on-monitor-created'); function onSubmitSuccess(data: Monitor) { const endpointOptions = { query: { project: selection.projects, environment: selection.environments, }, }; browserHistory.push( normalizeUrl({ pathname: `/organizations/${orgSlug}/crons/${data.project.slug}/${data.slug}/`, query: endpointOptions.query, }) ); monitorCreationCallbacks.map(cb => cb(organization)); } return ( {t('Add Monitor')} ); } export default CreateMonitor;