create.tsx 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import {Fragment} from 'react';
  2. import {browserHistory} from 'react-router';
  3. import styled from '@emotion/styled';
  4. import Breadcrumbs from 'sentry/components/breadcrumbs';
  5. import * as Layout from 'sentry/components/layouts/thirds';
  6. import {t} from 'sentry/locale';
  7. import {Organization} from 'sentry/types';
  8. import useOrganization from 'sentry/utils/useOrganization';
  9. import {normalizeUrl} from 'sentry/utils/withDomainRequired';
  10. import AsyncView from 'sentry/views/asyncView';
  11. import CronsFeedbackButton from './components/cronsFeedbackButton';
  12. import MonitorForm from './components/monitorForm';
  13. import {Monitor} from './types';
  14. type Props = AsyncView['props'] & {
  15. organization: Organization;
  16. };
  17. function CreateMonitor({}: Props) {
  18. const {slug: orgSlug} = useOrganization();
  19. function onSubmitSuccess(data: Monitor) {
  20. const url = normalizeUrl(`/organizations/${orgSlug}/crons/${data.slug}/`);
  21. browserHistory.push(url);
  22. }
  23. return (
  24. <Fragment>
  25. <Layout.Header>
  26. <Layout.HeaderContent>
  27. <Breadcrumbs
  28. crumbs={[
  29. {
  30. label: t('Crons'),
  31. to: `/organizations/${orgSlug}/crons/`,
  32. },
  33. {
  34. label: t('Set Up Cron Monitor'),
  35. },
  36. ]}
  37. />
  38. <Layout.Title>{t('Set Up Cron Monitor')}</Layout.Title>
  39. </Layout.HeaderContent>
  40. <Layout.HeaderActions>
  41. <CronsFeedbackButton />
  42. </Layout.HeaderActions>
  43. </Layout.Header>
  44. <Layout.Body>
  45. <Layout.Main fullWidth>
  46. <HelpText>
  47. {t(
  48. `Sentry will tell you if your recurring jobs are running on schedule, failing, or succeeding.`
  49. )}
  50. </HelpText>
  51. <MonitorForm
  52. apiMethod="POST"
  53. apiEndpoint={`/organizations/${orgSlug}/monitors/`}
  54. onSubmitSuccess={onSubmitSuccess}
  55. submitLabel={t('Next Steps')}
  56. />
  57. </Layout.Main>
  58. </Layout.Body>
  59. </Fragment>
  60. );
  61. }
  62. export default CreateMonitor;
  63. const HelpText = styled('p')`
  64. color: ${p => p.theme.subText};
  65. max-width: 760px;
  66. `;