teamBadge.tsx 961 B

12345678910111213141516171819202122232425262728293031323334
  1. import TeamStore from 'sentry/stores/teamStore';
  2. import {useLegacyStore} from 'sentry/stores/useLegacyStore';
  3. import type {Team} from 'sentry/types/organization';
  4. import BadgeDisplayName from './badgeDisplayName';
  5. import {BaseBadge, type BaseBadgeProps} from './baseBadge';
  6. export interface TeamBadgeProps extends BaseBadgeProps {
  7. team: Team;
  8. /**
  9. * When true will default max-width, or specify one as a string
  10. */
  11. hideOverflow?: boolean | string;
  12. }
  13. function TeamBadge({hideOverflow = true, team, ...props}: TeamBadgeProps) {
  14. const {teams} = useLegacyStore(TeamStore);
  15. // Get the most up-to-date team from the store
  16. const resolvedTeam = teams.find(t => t.id === team.id) ?? team;
  17. const teamName = `#${resolvedTeam.slug}`;
  18. return (
  19. <BaseBadge
  20. displayName={
  21. <BadgeDisplayName hideOverflow={hideOverflow}>{teamName}</BadgeDisplayName>
  22. }
  23. team={resolvedTeam}
  24. {...props}
  25. />
  26. );
  27. }
  28. export {TeamBadge};