create.tsx 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 useOrganization from 'sentry/utils/useOrganization';
  7. import {normalizeUrl} from 'sentry/utils/withDomainRequired';
  8. import CronsFeedbackButton from './components/cronsFeedbackButton';
  9. import MonitorForm from './components/monitorForm';
  10. import {Monitor} from './types';
  11. function CreateMonitor() {
  12. const {slug: orgSlug} = useOrganization();
  13. function onSubmitSuccess(data: Monitor) {
  14. const url = normalizeUrl(`/organizations/${orgSlug}/crons/${data.slug}/`);
  15. browserHistory.push(url);
  16. }
  17. return (
  18. <Fragment>
  19. <Layout.Header>
  20. <Layout.HeaderContent>
  21. <Breadcrumbs
  22. crumbs={[
  23. {
  24. label: t('Crons'),
  25. to: `/organizations/${orgSlug}/crons/`,
  26. },
  27. {
  28. label: t('Add Monitor'),
  29. },
  30. ]}
  31. />
  32. <Layout.Title>{t('Add Monitor')}</Layout.Title>
  33. </Layout.HeaderContent>
  34. <Layout.HeaderActions>
  35. <CronsFeedbackButton />
  36. </Layout.HeaderActions>
  37. </Layout.Header>
  38. <Layout.Body>
  39. <Layout.Main fullWidth>
  40. <MonitorForm
  41. apiMethod="POST"
  42. apiEndpoint={`/organizations/${orgSlug}/monitors/`}
  43. onSubmitSuccess={onSubmitSuccess}
  44. submitLabel={t('Next')}
  45. />
  46. </Layout.Main>
  47. </Layout.Body>
  48. </Fragment>
  49. );
  50. }
  51. export default CreateMonitor;