teamAvatar.tsx 775 B

12345678910111213141516171819202122232425262728293031
  1. import BaseAvatar from 'sentry/components/avatar/baseAvatar';
  2. import {Team} from 'sentry/types';
  3. import {explodeSlug} from 'sentry/utils';
  4. type Props = {
  5. team: Team | null;
  6. } & Omit<BaseAvatar['props'], 'uploadPath' | 'uploadId'>;
  7. function TeamAvatar({team, tooltip: tooltipProp, ...props}: Props) {
  8. if (!team) {
  9. return null;
  10. }
  11. const slug = (team && team.slug) || '';
  12. const title = explodeSlug(slug);
  13. const tooltip = tooltipProp ?? `#${title}`;
  14. return (
  15. <BaseAvatar
  16. {...props}
  17. type={(team.avatar && team.avatar.avatarType) || 'letter_avatar'}
  18. uploadPath="team-avatar"
  19. uploadId={team.avatar && team.avatar.avatarUuid}
  20. letterId={slug}
  21. tooltip={tooltip}
  22. title={title}
  23. />
  24. );
  25. }
  26. export default TeamAvatar;