relocationBadge.tsx 924 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import type {Theme} from '@emotion/react';
  2. import {Tag} from 'sentry/components/core/badge/tag';
  3. import type {Relocation} from 'admin/types';
  4. type Props = {
  5. data: Relocation;
  6. };
  7. function RelocationBadge({data}: Props) {
  8. let text = '';
  9. let theme: keyof Theme['tag'] = 'default';
  10. switch (data.status) {
  11. case 'IN_PROGRESS':
  12. text = 'Working';
  13. theme = 'highlight';
  14. break;
  15. case 'FAILURE':
  16. text = 'Failed';
  17. theme = 'error';
  18. break;
  19. case 'SUCCESS':
  20. text = 'Succeeded';
  21. theme = 'success';
  22. break;
  23. case 'PAUSE':
  24. text = 'Paused';
  25. theme = 'warning';
  26. break;
  27. default:
  28. break;
  29. }
  30. if (
  31. (data.status === 'IN_PROGRESS' || data.status === 'PAUSE') &&
  32. data.scheduledCancelAtStep !== null
  33. ) {
  34. text = 'Cancelling';
  35. theme = 'promotion';
  36. }
  37. return <Tag type={theme}>{text}</Tag>;
  38. }
  39. export default RelocationBadge;