create.tsx 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 AsyncView from 'sentry/views/asyncView';
  6. import MonitorForm from './monitorForm';
  7. import {Monitor} from './types';
  8. type Props = AsyncView['props'] & RouteComponentProps<{orgId: string}, {}>;
  9. export default class CreateMonitor extends AsyncView<Props, AsyncView['state']> {
  10. getTitle() {
  11. return `Monitors - ${this.props.params.orgId}`;
  12. }
  13. onSubmitSuccess = (data: Monitor) => {
  14. browserHistory.push(`/organizations/${this.props.params.orgId}/monitors/${data.id}/`);
  15. };
  16. renderBody() {
  17. return (
  18. <Layout.Body>
  19. <Layout.Main fullWidth>
  20. <h1>{t('New Monitor')}</h1>
  21. <HelpText>
  22. {t(
  23. `Creating a monitor will allow you to track the executions of a scheduled
  24. job in your organization. For example, ensure a cron job that is
  25. scheduled to run once a day executes and finishes within a specified
  26. duration.`
  27. )}
  28. </HelpText>
  29. <MonitorForm
  30. apiMethod="POST"
  31. apiEndpoint={`/organizations/${this.props.params.orgId}/monitors/`}
  32. onSubmitSuccess={this.onSubmitSuccess}
  33. submitLabel={t('Next Steps')}
  34. />
  35. </Layout.Main>
  36. </Layout.Body>
  37. );
  38. }
  39. }
  40. const HelpText = styled('p')`
  41. color: ${p => p.theme.subText};
  42. max-width: 760px;
  43. `;