monitorBadge.tsx 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 {ColorOrAlias} from 'sentry/utils/theme';
  11. import {MonitorStatus} from '../types';
  12. interface MonitorBadgeProps {
  13. status: MonitorStatus;
  14. }
  15. interface StatusData {
  16. Icon: React.ComponentType<SVGIconProps>;
  17. color: ColorOrAlias;
  18. }
  19. function MonitorBadge({status}: MonitorBadgeProps) {
  20. const {Icon, color} = statusMap[status] ?? statusMap.ok;
  21. return <DiamondStatus icon={Icon} color={color} />;
  22. }
  23. // TODO(ts): Use satisfies
  24. const statusMap: Record<MonitorStatus, StatusData> = {
  25. ok: {
  26. Icon: IconCheckmark,
  27. color: 'successText',
  28. },
  29. error: {
  30. Icon: IconFire,
  31. color: 'errorText',
  32. },
  33. missed_checkin: {
  34. Icon: IconExclamation,
  35. color: 'warningText',
  36. },
  37. active: {
  38. Icon: IconTimer,
  39. color: 'subText',
  40. },
  41. disabled: {
  42. Icon: (p: SVGIconProps) => <IconPause {...p} size="xs" />,
  43. color: 'subText',
  44. },
  45. };
  46. export {MonitorBadge};