import styled from '@emotion/styled'; import {Button} from 'sentry/components/button'; import IdBadge from 'sentry/components/idBadge'; import PanelItem from 'sentry/components/panels/panelItem'; import TeamRoleSelect from 'sentry/components/teamRoleSelect'; import {IconSubtract} from 'sentry/icons'; import {t} from 'sentry/locale'; import {space} from 'sentry/styles/space'; import type {Member, Organization, Team, TeamMember} from 'sentry/types/organization'; import type {User} from 'sentry/types/user'; import {getButtonHelpText} from 'sentry/views/settings/organizationTeams/utils'; interface Props { hasWriteAccess: boolean; member: TeamMember; organization: Organization; removeMember: (member: Member) => void; team: Team; updateMemberRole: (member: Member, newRole: string) => void; user: User; } function TeamMembersRow({ organization, team, member, user, hasWriteAccess, removeMember, updateMemberRole, }: Props) { const isSelf = user.email === member.email; return (
updateMemberRole(member, newRole)} />
removeMember(member)} member={member} />
); } function RemoveButton(props: { hasWriteAccess: boolean; isSelf: boolean; member: TeamMember; onClick: () => void; }) { const {member, hasWriteAccess, isSelf, onClick} = props; const canRemoveMember = hasWriteAccess || isSelf; if (!canRemoveMember) { return ( ); } const isIdpProvisioned = member.flags['idp:provisioned']; const buttonHelpText = getButtonHelpText(isIdpProvisioned); const buttonRemoveText = isSelf ? t('Leave') : t('Remove'); return ( ); } const RoleSelectWrapper = styled('div')` display: flex; flex-direction: row; align-items: center; > div:first-child { flex-grow: 1; } `; export const GRID_TEMPLATE = ` display: grid; grid-template-columns: minmax(100px, 1fr) 200px 150px; gap: ${space(1)}; `; const TeamRolesPanelItem = styled(PanelItem)` ${GRID_TEMPLATE}; align-items: center; > div:last-child { margin-left: auto; } `; export default TeamMembersRow;