Skip to content

Commit 743efe3

Browse files
feat(ui): Allow SentryMemberTeamSelectorField to show other teams (#69143)
Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
1 parent 355bd4a commit 743efe3

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

static/app/components/forms/fields/sentryMemberTeamSelectorField.tsx

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import {useContext, useEffect, useMemo} from 'react';
2+
import partition from 'lodash/partition';
23

34
import Avatar from 'sentry/components/avatar';
45
import {t} from 'sentry/locale';
6+
import type {Team} from 'sentry/types';
57
import {useMembers} from 'sentry/utils/useMembers';
68
import {useTeams} from 'sentry/utils/useTeams';
79
import {useTeamsById} from 'sentry/utils/useTeamsById';
@@ -75,13 +77,18 @@ function SentryMemberTeamSelectorField({
7577
fetching: fetchingTeams,
7678
onSearch: onTeamSearch,
7779
loadMore: loadMoreTeams,
78-
} = useTeams({provideUserTeams: true});
80+
} = useTeams();
7981

80-
const teamOptions = teams?.map(team => ({
82+
const makeTeamOption = (team: Team) => ({
8183
value: `team:${team.id}`,
8284
label: `#${team.slug}`,
8385
leadingItems: <Avatar team={team} size={avatarSize} />,
84-
}));
86+
});
87+
88+
const [myTeams, otherTeams] = partition(teams, team => team.isMember);
89+
90+
const myTeamOptions = myTeams.map(makeTeamOption);
91+
const otherTeamOptions = otherTeams.map(makeTeamOption);
8592

8693
// TODO(epurkhiser): This is an unfortunate hack right now since we don't
8794
// actually load members anywhere and the useMembers and useTeams hook don't
@@ -114,8 +121,12 @@ function SentryMemberTeamSelectorField({
114121
options: memberOptions,
115122
},
116123
{
117-
label: t('Teams'),
118-
options: teamOptions,
124+
label: t('My Teams'),
125+
options: myTeamOptions,
126+
},
127+
{
128+
label: t('Other Teams'),
129+
options: otherTeamOptions,
119130
},
120131
]}
121132
{...props}

0 commit comments

Comments
 (0)