create.tsx 2.1 KB

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