Skip to content

Commit 9767d7f

Browse files
ref(ui): Consolidate TeamBadge (#68927)
This had an extraneous second component for some reason --------- Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
1 parent 154bf3b commit 9767d7f

File tree

5 files changed

+41
-58
lines changed

5 files changed

+41
-58
lines changed

static/app/components/idBadge/getBadge.tsx

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
1-
import type {BaseBadgeProps} from 'sentry/components/idBadge/baseBadge';
2-
import type {MemberBadgeProps} from 'sentry/components/idBadge/memberBadge';
3-
import MemberBadge from 'sentry/components/idBadge/memberBadge';
4-
import type {OrganizationBadgeProps} from 'sentry/components/idBadge/organizationBadge';
5-
import OrganizationBadge from 'sentry/components/idBadge/organizationBadge';
6-
import type {ProjectBadgeProps} from 'sentry/components/idBadge/projectBadge';
7-
import ProjectBadge from 'sentry/components/idBadge/projectBadge';
8-
import {TeamBadge} from 'sentry/components/idBadge/teamBadge';
9-
import type {UserBadgeProps} from 'sentry/components/idBadge/userBadge';
10-
import UserBadge from 'sentry/components/idBadge/userBadge';
11-
12-
import type {TeamBadgeProps} from './teamBadge/badge';
1+
import type {BaseBadgeProps} from './baseBadge';
2+
import MemberBadge, {type MemberBadgeProps} from './memberBadge';
3+
import OrganizationBadge, {type OrganizationBadgeProps} from './organizationBadge';
4+
import ProjectBadge, {type ProjectBadgeProps} from './projectBadge';
5+
import {TeamBadge, type TeamBadgeProps} from './teamBadge';
6+
import UserBadge, {type UserBadgeProps} from './userBadge';
137

148
type DisplayName = BaseBadgeProps['displayName'];
159

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

static/app/components/idBadge/teamBadge/badge.tsx

Lines changed: 0 additions & 30 deletions
This file was deleted.

static/app/components/idBadge/teamBadge/index.tsx

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)