eventIdFieldStatusIcon.tsx 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import styled from '@emotion/styled';
  2. import ControlState from 'sentry/components/forms/field/controlState';
  3. import Tooltip from 'sentry/components/tooltip';
  4. import {IconCheckmark, IconClose} from 'sentry/icons';
  5. import {t} from 'sentry/locale';
  6. import {EventIdStatus} from '../../types';
  7. type Props = {
  8. onClickIconClose: () => void;
  9. status?: EventIdStatus;
  10. };
  11. const EventIdFieldStatusIcon = ({status, onClickIconClose}: Props) => {
  12. switch (status) {
  13. case EventIdStatus.ERROR:
  14. case EventIdStatus.INVALID:
  15. case EventIdStatus.NOT_FOUND:
  16. return (
  17. <CloseIcon onClick={onClickIconClose}>
  18. <Tooltip title={t('Clear event ID')}>
  19. <StyledIconClose size="xs" />
  20. </Tooltip>
  21. </CloseIcon>
  22. );
  23. case EventIdStatus.LOADING:
  24. return <ControlState isSaving />;
  25. case EventIdStatus.LOADED:
  26. return <IconCheckmark color="green300" />;
  27. default:
  28. return null;
  29. }
  30. };
  31. export default EventIdFieldStatusIcon;
  32. const CloseIcon = styled('div')`
  33. :first-child {
  34. line-height: 0;
  35. }
  36. `;
  37. const StyledIconClose = styled(IconClose)`
  38. color: ${p => p.theme.gray200};
  39. :hover {
  40. color: ${p => p.theme.gray300};
  41. }
  42. cursor: pointer;
  43. `;