processingIssueHint.tsx 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. import {Fragment} from 'react';
  2. import styled from '@emotion/styled';
  3. import type {AlertProps} from 'sentry/components/alert';
  4. import {Alert} from 'sentry/components/alert';
  5. import {Button} from 'sentry/components/button';
  6. import TimeSince from 'sentry/components/timeSince';
  7. import {t, tct, tn} from 'sentry/locale';
  8. import {space} from 'sentry/styles/space';
  9. import type {ProcessingIssue} from 'sentry/types';
  10. type Props = {
  11. issue: ProcessingIssue;
  12. orgId: string;
  13. projectId: string;
  14. showProject: boolean;
  15. };
  16. function ProcessingIssueHint({orgId, projectId, issue, showProject}: Props) {
  17. const link = `/settings/${orgId}/projects/${projectId}/processing-issues/`;
  18. let showButton = false;
  19. let text = '';
  20. let lastEvent: React.ReactNode = null;
  21. let alertType: AlertProps['type'] = 'error';
  22. let project: React.ReactNode = null;
  23. if (showProject) {
  24. project = (
  25. <Fragment>
  26. <strong>{projectId}</strong> &mdash;{' '}
  27. </Fragment>
  28. );
  29. }
  30. if (issue.numIssues > 0) {
  31. text = tn(
  32. 'There is %s issue blocking event processing',
  33. 'There are %s issues blocking event processing',
  34. issue.numIssues
  35. );
  36. lastEvent = (
  37. <Fragment>
  38. (
  39. {tct('last event from [ago]', {
  40. ago: <TimeSince date={issue.lastSeen} />,
  41. })}
  42. )
  43. </Fragment>
  44. );
  45. alertType = 'error';
  46. showButton = true;
  47. } else if (issue.issuesProcessing > 0) {
  48. alertType = 'info';
  49. text = tn(
  50. 'Reprocessing %s event …',
  51. 'Reprocessing %s events …',
  52. issue.issuesProcessing
  53. );
  54. } else if (issue.resolveableIssues > 0) {
  55. alertType = 'warning';
  56. text = tn(
  57. 'There is %s event pending reprocessing.',
  58. 'There are %s events pending reprocessing.',
  59. issue.resolveableIssues
  60. );
  61. showButton = true;
  62. } else {
  63. /* we should not go here but what do we know */
  64. return null;
  65. }
  66. return (
  67. <StyledAlert
  68. type={alertType}
  69. showIcon
  70. trailingItems={
  71. showButton && (
  72. <StyledButton size="xs" to={link}>
  73. {t('Show details')}
  74. </StyledButton>
  75. )
  76. }
  77. >
  78. {project} <strong>{text}</strong> {lastEvent}
  79. </StyledAlert>
  80. );
  81. }
  82. export default ProcessingIssueHint;
  83. const StyledAlert = styled(Alert)`
  84. border-width: 1px 0;
  85. border-radius: 0;
  86. margin: 0;
  87. font-size: ${p => p.theme.fontSizeMedium};
  88. `;
  89. const StyledButton = styled(Button)`
  90. white-space: nowrap;
  91. margin-left: ${space(1)};
  92. `;