details.tsx 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. <Panel style={{paddingBottom: 0}}>
  43. <PanelHeader>{t('Related Issues')}</PanelHeader>
  44. <MonitorIssues monitor={monitor} orgId={this.props.params.orgId} />
  45. </Panel>
  46. <Panel>
  47. <PanelHeader>{t('Recent Check-ins')}</PanelHeader>
  48. <MonitorCheckIns monitor={monitor} />
  49. </Panel>
  50. </Fragment>
  51. );
  52. }
  53. }
  54. export default MonitorDetails;