status.tsx 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import styled from '@emotion/styled';
  2. import * as Sentry from '@sentry/react';
  3. import Tag from 'sentry/components/tag';
  4. import {t} from 'sentry/locale';
  5. import {ImageStatus} from 'sentry/types/debugImage';
  6. type Props = {
  7. status: ImageStatus;
  8. };
  9. function Status({status}: Props) {
  10. switch (status) {
  11. case ImageStatus.OTHER:
  12. case ImageStatus.FETCHING_FAILED:
  13. case ImageStatus.MALFORMED:
  14. case ImageStatus.TIMEOUT: {
  15. return <StyledTag type="error">{t('Error')}</StyledTag>;
  16. }
  17. case ImageStatus.MISSING: {
  18. return <StyledTag type="error">{t('Missing')}</StyledTag>;
  19. }
  20. case ImageStatus.FOUND: {
  21. return <StyledTag type="success">{t('Ok')}</StyledTag>;
  22. }
  23. case ImageStatus.UNUSED: {
  24. return <StyledTag>{t('Unreferenced')}</StyledTag>;
  25. }
  26. default: {
  27. Sentry.withScope(scope => {
  28. scope.setLevel('warning');
  29. Sentry.captureException(new Error('Unknown image status'));
  30. });
  31. return <StyledTag>{t('Unknown')}</StyledTag>; // This shall not happen
  32. }
  33. }
  34. }
  35. export default Status;
  36. const StyledTag = styled(Tag)`
  37. &,
  38. span div {
  39. max-width: 100%;
  40. }
  41. `;