monitorIssues.tsx 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. import {Fragment} from 'react';
  2. import styled from '@emotion/styled';
  3. import Alert from 'sentry/components/alert';
  4. import EmptyStateWarning from 'sentry/components/emptyStateWarning';
  5. import GroupList from 'sentry/components/issues/groupList';
  6. import Link from 'sentry/components/links/link';
  7. import {Panel, PanelBody} from 'sentry/components/panels';
  8. import {t, tct} from 'sentry/locale';
  9. import space from 'sentry/styles/space';
  10. import {getUtcDateString} from 'sentry/utils/dates';
  11. import usePageFilters from 'sentry/utils/usePageFilters';
  12. import {Monitor, MonitorEnvironment} from '../types';
  13. type Props = {
  14. monitor: Monitor;
  15. monitorEnv: MonitorEnvironment;
  16. orgId: string;
  17. };
  18. function MonitorIssuesEmptyMessage() {
  19. return (
  20. <Panel>
  21. <PanelBody>
  22. <EmptyStateWarning>
  23. <p>{t('No issues relating to this cron monitor have been found.')}</p>
  24. </EmptyStateWarning>
  25. </PanelBody>
  26. </Panel>
  27. );
  28. }
  29. function MonitorIssues({orgId, monitor}: Props) {
  30. const {selection} = usePageFilters();
  31. const {start, end, period} = selection.datetime;
  32. const timeProps =
  33. start && end
  34. ? {
  35. start: getUtcDateString(start),
  36. end: getUtcDateString(end),
  37. }
  38. : {
  39. statsPeriod: period,
  40. };
  41. // TODO(epurkhiser): We probably want to filter on envrionemnt
  42. const issueStreamLink = {
  43. pathname: '/issues',
  44. query: {query: `monitor.id:"${monitor.id}"`},
  45. };
  46. return (
  47. <Fragment>
  48. <StyledAlert type="warning" showIcon>
  49. {tct(
  50. 'Some older issues may be missing from this list, visit the [link:issue stream] for older related issues.',
  51. {
  52. link: <Link to={issueStreamLink} />,
  53. }
  54. )}
  55. </StyledAlert>
  56. <GroupList
  57. orgId={orgId}
  58. endpointPath={`/organizations/${orgId}/issues/`}
  59. queryParams={{
  60. query: `monitor.slug:"${monitor.slug}"`,
  61. project: monitor.project.id,
  62. limit: 5,
  63. ...timeProps,
  64. }}
  65. query=""
  66. renderEmptyMessage={MonitorIssuesEmptyMessage}
  67. canSelectGroups={false}
  68. withPagination={false}
  69. withChart={false}
  70. useTintRow={false}
  71. source="monitors"
  72. />
  73. </Fragment>
  74. );
  75. }
  76. const StyledAlert = styled(Alert)`
  77. margin-bottom: ${space(0.5)};
  78. `;
  79. export default MonitorIssues;