monitorIssues.tsx 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import EmptyStateWarning from 'sentry/components/emptyStateWarning';
  2. import GroupList from 'sentry/components/issues/groupList';
  3. import Panel from 'sentry/components/panels/panel';
  4. import PanelBody from 'sentry/components/panels/panelBody';
  5. import {t} from 'sentry/locale';
  6. import {getUtcDateString} from 'sentry/utils/dates';
  7. import usePageFilters from 'sentry/utils/usePageFilters';
  8. import {Monitor, MonitorEnvironment} from '../types';
  9. type Props = {
  10. monitor: Monitor;
  11. monitorEnvs: MonitorEnvironment[];
  12. orgSlug: string;
  13. };
  14. function MonitorIssuesEmptyMessage() {
  15. return (
  16. <Panel>
  17. <PanelBody>
  18. <EmptyStateWarning>
  19. <p>{t('No issues relating to this cron monitor have been found.')}</p>
  20. </EmptyStateWarning>
  21. </PanelBody>
  22. </Panel>
  23. );
  24. }
  25. function MonitorIssues({orgSlug, monitor, monitorEnvs}: Props) {
  26. const {selection} = usePageFilters();
  27. const {start, end, period} = selection.datetime;
  28. const timeProps =
  29. start && end
  30. ? {
  31. start: getUtcDateString(start),
  32. end: getUtcDateString(end),
  33. }
  34. : {
  35. statsPeriod: period,
  36. };
  37. // TODO(epurkhiser): We probably want to filter on envrionemnt
  38. return (
  39. <GroupList
  40. orgSlug={orgSlug}
  41. endpointPath={`/organizations/${orgSlug}/issues/`}
  42. queryParams={{
  43. query: `monitor.slug:"${monitor.slug}" environment:[${monitorEnvs
  44. .map(e => e.name)
  45. .join(',')}]`,
  46. project: monitor.project.id,
  47. limit: 5,
  48. ...timeProps,
  49. }}
  50. query=""
  51. renderEmptyMessage={MonitorIssuesEmptyMessage}
  52. canSelectGroups={false}
  53. withPagination={false}
  54. withChart={false}
  55. useTintRow={false}
  56. source="monitors"
  57. />
  58. );
  59. }
  60. export default MonitorIssues;