create.tsx 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import {Fragment} from 'react';
  2. import {browserHistory} from 'react-router';
  3. import Breadcrumbs from 'sentry/components/breadcrumbs';
  4. import * as Layout from 'sentry/components/layouts/thirds';
  5. import {t} from 'sentry/locale';
  6. import {Organization} from 'sentry/types';
  7. import useOrganization from 'sentry/utils/useOrganization';
  8. import {normalizeUrl} from 'sentry/utils/withDomainRequired';
  9. import AsyncView from 'sentry/views/asyncView';
  10. import CronsFeedbackButton from './components/cronsFeedbackButton';
  11. import MonitorForm from './components/monitorForm';
  12. import {Monitor} from './types';
  13. type Props = AsyncView['props'] & {
  14. organization: Organization;
  15. };
  16. function CreateMonitor({}: Props) {
  17. const {slug: orgSlug} = useOrganization();
  18. function onSubmitSuccess(data: Monitor) {
  19. const url = normalizeUrl(`/organizations/${orgSlug}/crons/${data.slug}/`);
  20. browserHistory.push(url);
  21. }
  22. return (
  23. <Fragment>
  24. <Layout.Header>
  25. <Layout.HeaderContent>
  26. <Breadcrumbs
  27. crumbs={[
  28. {
  29. label: t('Crons'),
  30. to: `/organizations/${orgSlug}/crons/`,
  31. },
  32. {
  33. label: t('Add Monitor'),
  34. },
  35. ]}
  36. />
  37. <Layout.Title>{t('Add Monitor')}</Layout.Title>
  38. </Layout.HeaderContent>
  39. <Layout.HeaderActions>
  40. <CronsFeedbackButton />
  41. </Layout.HeaderActions>
  42. </Layout.Header>
  43. <Layout.Body>
  44. <Layout.Main fullWidth>
  45. <MonitorForm
  46. apiMethod="POST"
  47. apiEndpoint={`/organizations/${orgSlug}/monitors/`}
  48. onSubmitSuccess={onSubmitSuccess}
  49. submitLabel={t('Next Steps')}
  50. />
  51. </Layout.Main>
  52. </Layout.Body>
  53. </Fragment>
  54. );
  55. }
  56. export default CreateMonitor;