import {Fragment} from 'react'; import styled from '@emotion/styled'; import {Button} from 'sentry/components/button'; import Confirm from 'sentry/components/confirm'; import HookOrDefault from 'sentry/components/hookOrDefault'; import PanelItem from 'sentry/components/panels/panelItem'; import RoleSelectControl from 'sentry/components/roleSelectControl'; import Tag from 'sentry/components/tag'; import TeamSelector from 'sentry/components/teamSelector'; import {Tooltip} from 'sentry/components/tooltip'; import {IconCheckmark, IconClose} from 'sentry/icons'; import {t, tct} from 'sentry/locale'; import {space} from 'sentry/styles/space'; import {Member, Organization, OrgRole} from 'sentry/types'; type Props = { allRoles: OrgRole[]; inviteRequest: Member; inviteRequestBusy: {[key: string]: boolean}; onApprove: (inviteRequest: Member) => void; onDeny: (inviteRequest: Member) => void; onUpdate: (data: Partial) => void; organization: Organization; }; const InviteModalHook = HookOrDefault({ hookName: 'member-invite-modal:customization', defaultComponent: ({onSendInvites, children}) => children({sendInvites: onSendInvites, canSend: true}), }); type InviteModalRenderFunc = React.ComponentProps['children']; function InviteRequestRow({ inviteRequest, inviteRequestBusy, organization, onApprove, onDeny, onUpdate, allRoles, }: Props) { const role = allRoles.find(r => r.id === inviteRequest.role); const roleDisallowed = !(role && role.allowed); const {access} = organization; const canApprove = access.includes('member:admin'); const hookRenderer: InviteModalRenderFunc = ({sendInvites, canSend, headerInfo}) => (
{inviteRequest.email}
{inviteRequest.inviteStatus === 'requested_to_be_invited' ? ( inviteRequest.inviterName && ( {tct('Requested by [inviterName]', { inviterName: inviteRequest.inviterName, })} ) ) : ( {t('Join request')} )}
{canApprove ? ( onUpdate({role: r.value})} value={inviteRequest.role} roles={allRoles} /> ) : (
{inviteRequest.roleName}
)} {canApprove ? ( onUpdate({teams: (teams || []).map(team => team.value)})} value={inviteRequest.teams} clearable multiple /> ) : (
{inviteRequest.teams.join(', ')}
)} {tct('Are you sure you want to invite [email] to your organization?', { email: inviteRequest.email, })} {headerInfo} } >
); return ( onApprove(inviteRequest)} > {hookRenderer} ); } const JoinRequestIndicator = styled(Tag)` text-transform: uppercase; `; const StyledPanelItem = styled(PanelItem)` display: grid; grid-template-columns: minmax(150px, auto) minmax(100px, 140px) 220px max-content; gap: ${space(2)}; align-items: center; `; const UserName = styled('div')` font-size: ${p => p.theme.fontSizeLarge}; overflow: hidden; text-overflow: ellipsis; `; const Description = styled('div')` display: block; color: ${p => p.theme.subText}; font-size: 14px; overflow: hidden; text-overflow: ellipsis; `; const StyledRoleSelectControl = styled(RoleSelectControl)` max-width: 140px; `; const TeamSelectControl = styled(TeamSelector)` max-width: 220px; .Select-value-label { max-width: 150px; word-break: break-all; } `; const ButtonGroup = styled('div')` display: inline-grid; grid-template-columns: repeat(2, max-content); gap: ${space(1)}; `; export default InviteRequestRow;