|
1 | 1 | import {useContext, useEffect, useMemo} from 'react'; |
| 2 | +import partition from 'lodash/partition'; |
2 | 3 |
|
3 | 4 | import Avatar from 'sentry/components/avatar'; |
4 | 5 | import {t} from 'sentry/locale'; |
| 6 | +import type {Team} from 'sentry/types'; |
5 | 7 | import {useMembers} from 'sentry/utils/useMembers'; |
6 | 8 | import {useTeams} from 'sentry/utils/useTeams'; |
7 | 9 | import {useTeamsById} from 'sentry/utils/useTeamsById'; |
@@ -75,13 +77,18 @@ function SentryMemberTeamSelectorField({ |
75 | 77 | fetching: fetchingTeams, |
76 | 78 | onSearch: onTeamSearch, |
77 | 79 | loadMore: loadMoreTeams, |
78 | | - } = useTeams({provideUserTeams: true}); |
| 80 | + } = useTeams(); |
79 | 81 |
|
80 | | - const teamOptions = teams?.map(team => ({ |
| 82 | + const makeTeamOption = (team: Team) => ({ |
81 | 83 | value: `team:${team.id}`, |
82 | 84 | label: `#${team.slug}`, |
83 | 85 | 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); |
85 | 92 |
|
86 | 93 | // TODO(epurkhiser): This is an unfortunate hack right now since we don't |
87 | 94 | // actually load members anywhere and the useMembers and useTeams hook don't |
@@ -114,8 +121,12 @@ function SentryMemberTeamSelectorField({ |
114 | 121 | options: memberOptions, |
115 | 122 | }, |
116 | 123 | { |
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, |
119 | 130 | }, |
120 | 131 | ]} |
121 | 132 | {...props} |
|
0 commit comments