monitorBadge.tsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import {DiamondStatus} from 'sentry/components/diamondStatus';
  2. import {
  3. IconCheckmark,
  4. IconExclamation,
  5. IconFire,
  6. IconPause,
  7. IconTimer,
  8. } from 'sentry/icons';
  9. import {SVGIconProps} from 'sentry/icons/svgIcon';
  10. import {ObjectStatus} from 'sentry/types';
  11. import {ColorOrAlias} from 'sentry/utils/theme';
  12. import {MonitorStatus} from '../types';
  13. interface MonitorBadgeProps {
  14. status: MonitorStatus | ObjectStatus;
  15. }
  16. interface StatusData {
  17. Icon: React.ComponentType<SVGIconProps>;
  18. color: ColorOrAlias;
  19. }
  20. function MonitorBadge({status}: MonitorBadgeProps) {
  21. const {Icon, color} = statusMap[status] ?? statusMap.ok;
  22. return <DiamondStatus icon={Icon} color={color} />;
  23. }
  24. // TODO(ts): Use satisfies
  25. const statusMap: Record<MonitorStatus, StatusData> = {
  26. ok: {
  27. Icon: IconCheckmark,
  28. color: 'successText',
  29. },
  30. error: {
  31. Icon: IconFire,
  32. color: 'errorText',
  33. },
  34. timeout: {
  35. Icon: IconFire,
  36. color: 'errorText',
  37. },
  38. missed_checkin: {
  39. Icon: IconExclamation,
  40. color: 'warningText',
  41. },
  42. active: {
  43. Icon: IconTimer,
  44. color: 'subText',
  45. },
  46. disabled: {
  47. Icon: (p: SVGIconProps) => <IconPause {...p} size="xs" />,
  48. color: 'subText',
  49. },
  50. };
  51. export {MonitorBadge};