processingIssueHint.tsx 2.4 KB

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