details.tsx 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import {Fragment} from 'react';
  2. import {RouteComponentProps} from 'react-router';
  3. import {Panel, PanelHeader} from 'sentry/components/panels';
  4. import {t} from 'sentry/locale';
  5. import AsyncView from 'sentry/views/asyncView';
  6. import MonitorCheckIns from './monitorCheckIns';
  7. import MonitorHeader from './monitorHeader';
  8. import MonitorIssues from './monitorIssues';
  9. import MonitorStats from './monitorStats';
  10. import MonitorOnboarding from './onboarding';
  11. import {Monitor} from './types';
  12. type Props = AsyncView['props'] &
  13. RouteComponentProps<{monitorId: string; orgId: string}, {}>;
  14. type State = AsyncView['state'] & {
  15. monitor: Monitor | null;
  16. };
  17. class MonitorDetails extends AsyncView<Props, State> {
  18. getEndpoints(): ReturnType<AsyncView['getEndpoints']> {
  19. const {params, location} = this.props;
  20. return [['monitor', `/monitors/${params.monitorId}/`, {query: location.query}]];
  21. }
  22. getTitle() {
  23. if (this.state.monitor) {
  24. return `${this.state.monitor.name} - Monitors - ${this.props.params.orgId}`;
  25. }
  26. return `Monitors - ${this.props.params.orgId}`;
  27. }
  28. onUpdate = (data: Monitor) =>
  29. this.setState(state => ({monitor: {...state.monitor, ...data}}));
  30. renderBody() {
  31. const {monitor} = this.state;
  32. if (monitor === null) {
  33. return null;
  34. }
  35. return (
  36. <Fragment>
  37. <MonitorHeader
  38. monitor={monitor}
  39. orgId={this.props.params.orgId}
  40. onUpdate={this.onUpdate}
  41. />
  42. {!monitor.lastCheckIn && <MonitorOnboarding monitor={monitor} />}
  43. <MonitorStats monitor={monitor} />
  44. <MonitorIssues monitor={monitor} orgId={this.props.params.orgId} />
  45. <Panel>
  46. <PanelHeader>{t('Recent Check-ins')}</PanelHeader>
  47. <MonitorCheckIns monitor={monitor} />
  48. </Panel>
  49. </Fragment>
  50. );
  51. }
  52. }
  53. export default MonitorDetails;