import {Fragment} from 'react';
import styled from '@emotion/styled';
import {Button} from 'sentry/components/button';
import EmptyMessage from 'sentry/components/emptyMessage';
import {TeamBadge} from 'sentry/components/idBadge/teamBadge';
import Link from 'sentry/components/links/link';
import LoadingIndicator from 'sentry/components/loadingIndicator';
import Panel from 'sentry/components/panels/panel';
import PanelBody from 'sentry/components/panels/panelBody';
import PanelHeader from 'sentry/components/panels/panelHeader';
import PanelItem from 'sentry/components/panels/panelItem';
import TeamRoleSelect from 'sentry/components/teamRoleSelect';
import {TeamRoleColumnLabel} from 'sentry/components/teamRoleUtils';
import {IconSubtract} from 'sentry/icons';
import {t} from 'sentry/locale';
import {space} from 'sentry/styles/space';
import type {Member, Organization, Team} from 'sentry/types/organization';
import {useTeams} from 'sentry/utils/useTeams';
import {RoleOverwritePanelAlert} from 'sentry/views/settings/organizationTeams/roleOverwriteWarning';
import {getButtonHelpText} from 'sentry/views/settings/organizationTeams/utils';
import type {TeamSelectProps} from './utils';
import {DropdownAddTeam} from './utils';
type Props = TeamSelectProps & {
/**
* Member that this component is acting upon
*/
member: Member;
/**
* Used when showing Teams for a Member
*/
onChangeTeamRole: (teamSlug: string, teamRole: string) => void;
/**
* Used when showing Teams for a Member
*/
selectedOrgRole: Member['orgRole'];
/**
* Used when showing Teams for a Member
*/
selectedTeamRoles: Member['teamRoles'];
};
function TeamSelect({
disabled,
loadingTeams,
member,
selectedOrgRole,
selectedTeamRoles,
organization,
onAddTeam,
onRemoveTeam,
onCreateTeam,
onChangeTeamRole,
}: Props) {
const {teams, onSearch, fetching: isLoadingTeams} = useTeams();
const {orgRoleList, teamRoleList} = organization;
const selectedTeamSlugs = new Set(selectedTeamRoles.map(tm => tm.teamSlug));
const selectedTeams = teams.filter(tm => selectedTeamSlugs.has(tm.slug));
const renderBody = () => {
if (selectedTeams.length === 0) {
return {t('No Teams assigned')};
}
return (
{selectedOrgRole && (
)}
{selectedTeams.map(team => (
onRemoveTeam(slug)}
/>
))}
);
};
return (