create.tsx 1.7 KB

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