uptimeIssues.tsx 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 {IssueCategory} from 'sentry/types/group';
  7. import type {Project} from 'sentry/types/project';
  8. import {getUtcDateString} from 'sentry/utils/dates';
  9. import useOrganization from 'sentry/utils/useOrganization';
  10. import usePageFilters from 'sentry/utils/usePageFilters';
  11. interface Props {
  12. project: Project;
  13. ruleId: string;
  14. }
  15. export function UptimeIssues({project, ruleId}: Props) {
  16. const organization = useOrganization();
  17. const {selection} = usePageFilters();
  18. const {start, end, period} = selection.datetime;
  19. const timeProps =
  20. start && end
  21. ? {
  22. start: getUtcDateString(start),
  23. end: getUtcDateString(end),
  24. }
  25. : {
  26. statsPeriod: period,
  27. };
  28. // TODO(davidenwang): Replace this with an actual query for the specific uptime alert rule
  29. const query = `issue.category:${IssueCategory.UPTIME} tags[uptime_rule]:${ruleId}`;
  30. const emptyMessage = () => {
  31. return (
  32. <Panel>
  33. <PanelBody>
  34. <EmptyStateWarning>
  35. <p>{t('No issues relating to this uptime alert have been found.')}</p>
  36. </EmptyStateWarning>
  37. </PanelBody>
  38. </Panel>
  39. );
  40. };
  41. return (
  42. <GroupList
  43. orgSlug={organization.slug}
  44. queryParams={{
  45. query,
  46. project: project.id,
  47. limit: 20,
  48. ...timeProps,
  49. }}
  50. renderEmptyMessage={emptyMessage}
  51. />
  52. );
  53. }