monitorIssues.tsx 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. import {Fragment} from 'react';
  2. import Alert from 'sentry/components/alert';
  3. import {Button, LinkButton} from 'sentry/components/button';
  4. import ButtonBar from 'sentry/components/buttonBar';
  5. import EmptyStateWarning from 'sentry/components/emptyStateWarning';
  6. import GroupList from 'sentry/components/issues/groupList';
  7. import Panel from 'sentry/components/panels/panel';
  8. import PanelBody from 'sentry/components/panels/panelBody';
  9. import {IconClose} from 'sentry/icons';
  10. import {t} from 'sentry/locale';
  11. import {getUtcDateString} from 'sentry/utils/dates';
  12. import useDismissAlert from 'sentry/utils/useDismissAlert';
  13. import usePageFilters from 'sentry/utils/usePageFilters';
  14. import {Monitor, MonitorEnvironment} from '../types';
  15. type Props = {
  16. monitor: Monitor;
  17. monitorEnvs: MonitorEnvironment[];
  18. orgSlug: string;
  19. };
  20. function MonitorIssuesEmptyMessage() {
  21. return (
  22. <Panel>
  23. <PanelBody>
  24. <EmptyStateWarning>
  25. <p>{t('No issues relating to this cron monitor have been found.')}</p>
  26. </EmptyStateWarning>
  27. </PanelBody>
  28. </Panel>
  29. );
  30. }
  31. function MonitorIssues({orgSlug, monitor, monitorEnvs}: Props) {
  32. const {dismiss, isDismissed} = useDismissAlert({
  33. key: `${orgSlug}:thresholds-setting-alert-dismissed`,
  34. });
  35. const {selection} = usePageFilters();
  36. const {start, end, period} = selection.datetime;
  37. const timeProps =
  38. start && end
  39. ? {
  40. start: getUtcDateString(start),
  41. end: getUtcDateString(end),
  42. }
  43. : {
  44. statsPeriod: period,
  45. };
  46. // TODO(epurkhiser): We probably want to filter on envrionemnt
  47. return (
  48. <Fragment>
  49. {!isDismissed && (
  50. <Alert
  51. type="warning"
  52. showIcon
  53. trailingItems={
  54. <ButtonBar gap={1}>
  55. <LinkButton
  56. size="xs"
  57. to={{
  58. pathname: `/organizations/${orgSlug}/crons/${monitor.slug}/edit/`,
  59. query: {
  60. environment: selection.environments,
  61. project: selection.projects,
  62. },
  63. }}
  64. >
  65. {t('Monitor Settings')}
  66. </LinkButton>
  67. <Button
  68. aria-label={t('Dismiss')}
  69. size="xs"
  70. borderless
  71. icon={<IconClose />}
  72. onClick={dismiss}
  73. />
  74. </ButtonBar>
  75. }
  76. >
  77. {t('Too many issues? Configure thresholds in your monitor settings')}
  78. </Alert>
  79. )}
  80. <GroupList
  81. orgSlug={orgSlug}
  82. endpointPath={`/organizations/${orgSlug}/issues/`}
  83. queryParams={{
  84. query: `monitor.slug:"${monitor.slug}" environment:[${monitorEnvs
  85. .map(e => e.name)
  86. .join(',')}]`,
  87. project: monitor.project.id,
  88. limit: 20,
  89. ...timeProps,
  90. }}
  91. query=""
  92. renderEmptyMessage={MonitorIssuesEmptyMessage}
  93. canSelectGroups={false}
  94. withPagination={false}
  95. withChart={false}
  96. useTintRow={false}
  97. source="monitors"
  98. />
  99. </Fragment>
  100. );
  101. }
  102. export default MonitorIssues;