create.tsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import {Fragment} from 'react';
  2. import {browserHistory, RouteComponentProps} from 'react-router';
  3. import styled from '@emotion/styled';
  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. <Fragment>
  19. <h1>New Monitor</h1>
  20. <HelpText>
  21. {t(
  22. `Creating a monitor will allow you to track the executions of a scheduled
  23. job in your organization. For example, ensure a cron job that is
  24. scheduled to run once a day executes and finishes within a specified
  25. duration.`
  26. )}
  27. </HelpText>
  28. <MonitorForm
  29. apiMethod="POST"
  30. apiEndpoint={`/organizations/${this.props.params.orgId}/monitors/`}
  31. onSubmitSuccess={this.onSubmitSuccess}
  32. submitLabel={t('Next Steps')}
  33. />
  34. </Fragment>
  35. );
  36. }
  37. }
  38. const HelpText = styled('p')`
  39. color: ${p => p.theme.subText};
  40. max-width: 760px;
  41. `;