sentryAppComponentIcon.tsx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import styled from '@emotion/styled';
  2. import SentryAppAvatar from 'sentry/components/avatar/sentryAppAvatar';
  3. import ConfigStore from 'sentry/stores/configStore';
  4. import {SentryAppComponent} from 'sentry/types';
  5. type Props = {
  6. sentryAppComponent: SentryAppComponent;
  7. };
  8. /**
  9. * Icon Renderer for SentryAppComponents with UI
  10. * (e.g. Issue Linking, Stacktrace Linking)
  11. */
  12. const SentryAppComponentIcon = ({sentryAppComponent}: Props) => {
  13. const selectedAvatar = sentryAppComponent.sentryApp?.avatars?.find(
  14. ({color}) => color === false
  15. );
  16. const isDefault = selectedAvatar?.avatarType !== 'upload';
  17. const isDisabled = sentryAppComponent.error;
  18. return (
  19. <SentryAppAvatarWrapper
  20. isDark={ConfigStore.get('theme') === 'dark'}
  21. isDefault={isDefault}
  22. isDisabled={isDisabled}
  23. >
  24. <SentryAppAvatar
  25. sentryApp={sentryAppComponent.sentryApp}
  26. size={20}
  27. isColor={false}
  28. />
  29. </SentryAppAvatarWrapper>
  30. );
  31. };
  32. export default SentryAppComponentIcon;
  33. const SentryAppAvatarWrapper = styled('span')<{
  34. isDark: boolean;
  35. isDefault: boolean;
  36. isDisabled?: boolean;
  37. }>`
  38. color: ${({isDark, isDisabled, theme}) =>
  39. isDisabled ? theme.disabled : isDark ? 'white' : 'black'};
  40. filter: ${p => (p.isDark && !p.isDefault ? 'invert(1)' : 'invert(0)')};
  41. line-height: 0;
  42. flex-shrink: 0;
  43. `;