processingIssueHint.tsx 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. import * as React 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 {IconSettings, IconWarning} from 'sentry/icons';
  7. import {t, tct, tn} from 'sentry/locale';
  8. import space from 'sentry/styles/space';
  9. import {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 icon: React.ReactNode = null;
  22. let alertType: React.ComponentProps<typeof Alert>['type'] = 'error';
  23. let project: React.ReactNode = null;
  24. if (showProject) {
  25. project = (
  26. <React.Fragment>
  27. <strong>{projectId}</strong> &mdash;{' '}
  28. </React.Fragment>
  29. );
  30. }
  31. if (issue.numIssues > 0) {
  32. icon = <IconWarning size="sm" color="red300" />;
  33. text = tn(
  34. 'There is %s issue blocking event processing',
  35. 'There are %s issues blocking event processing',
  36. issue.numIssues
  37. );
  38. lastEvent = (
  39. <React.Fragment>
  40. (
  41. {tct('last event from [ago]', {
  42. ago: <TimeSince date={issue.lastSeen} />,
  43. })}
  44. )
  45. </React.Fragment>
  46. );
  47. alertType = 'error';
  48. showButton = true;
  49. } else if (issue.issuesProcessing > 0) {
  50. icon = <IconSettings size="sm" color="blue300" />;
  51. alertType = 'info';
  52. text = tn(
  53. 'Reprocessing %s event …',
  54. 'Reprocessing %s events …',
  55. issue.issuesProcessing
  56. );
  57. } else if (issue.resolveableIssues > 0) {
  58. icon = <IconSettings size="sm" color="yellow300" />;
  59. alertType = 'warning';
  60. text = tn(
  61. 'There is %s event pending reprocessing.',
  62. 'There are %s events pending reprocessing.',
  63. issue.resolveableIssues
  64. );
  65. showButton = true;
  66. } else {
  67. /* we should not go here but what do we know */
  68. return null;
  69. }
  70. return (
  71. <StyledAlert type={alertType} icon={icon}>
  72. <Wrapper>
  73. <div>
  74. {project} <strong>{text}</strong> {lastEvent}
  75. </div>
  76. {showButton && (
  77. <div>
  78. <StyledButton size="xsmall" to={link}>
  79. {t('Show details')}
  80. </StyledButton>
  81. </div>
  82. )}
  83. </Wrapper>
  84. </StyledAlert>
  85. );
  86. }
  87. export default ProcessingIssueHint;
  88. const StyledAlert = styled(Alert)`
  89. border-width: 1px 0;
  90. border-radius: 0;
  91. margin: 0;
  92. font-size: ${p => p.theme.fontSizeMedium};
  93. `;
  94. const Wrapper = styled('div')`
  95. display: flex;
  96. justify-content: space-between;
  97. `;
  98. const StyledButton = styled(Button)`
  99. white-space: nowrap;
  100. margin-left: ${space(1)};
  101. `;