details.tsx 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 {Monitor} from './types';
  11. type Props = AsyncView['props'] &
  12. RouteComponentProps<{monitorId: string; orgId: string}, {}>;
  13. type State = AsyncView['state'] & {
  14. monitor: Monitor | null;
  15. };
  16. class MonitorDetails extends AsyncView<Props, State> {
  17. getEndpoints(): ReturnType<AsyncView['getEndpoints']> {
  18. const {params, location} = this.props;
  19. return [['monitor', `/monitors/${params.monitorId}/`, {query: location.query}]];
  20. }
  21. getTitle() {
  22. if (this.state.monitor) {
  23. return `${this.state.monitor.name} - Monitors - ${this.props.params.orgId}`;
  24. }
  25. return `Monitors - ${this.props.params.orgId}`;
  26. }
  27. onUpdate = (data: Monitor) =>
  28. this.setState(state => ({monitor: {...state.monitor, ...data}}));
  29. renderBody() {
  30. const {monitor} = this.state;
  31. if (monitor === null) {
  32. return null;
  33. }
  34. return (
  35. <Fragment>
  36. <MonitorHeader
  37. monitor={monitor}
  38. orgId={this.props.params.orgId}
  39. onUpdate={this.onUpdate}
  40. />
  41. <MonitorStats monitor={monitor} />
  42. <MonitorIssues monitor={monitor} orgId={this.props.params.orgId} />
  43. <Panel>
  44. <PanelHeader>{t('Recent Check-ins')}</PanelHeader>
  45. <MonitorCheckIns monitor={monitor} />
  46. </Panel>
  47. </Fragment>
  48. );
  49. }
  50. }
  51. export default MonitorDetails;