import React from 'react'; import { themedColor } from '../../theme'; import { ActivityIndicator, Pressable, Text, TextInput, View } from 'react-native'; import { Building2, Info, UserPlus } from 'lucide-react-native'; import { CollaboratorRow } from './CollaboratorRow'; import { editorShellStyles } from '../editor/editorShellStyles'; import { sharingPanelStyles as localStyles } from './sharingPanelStyles'; import { formatEmailList } from './sharingPanelUtils'; import { styles as sharedStyles } from '../../styles'; import { useSharingPanel } from './useSharingPanel'; import { useSuperagentCollaborators } from '../../runtime/runtimeContext'; import type { SuperagentAgent } from '../../types'; type SharingPanelProps = { agent: SuperagentAgent; // Closes the settings drawer — used before navigating out to workspace members. onClose: () => void; }; /** * Sharing & access settings page (invite collaborators + who has access), rendered * inside the shared `EditorDrawer` shell — which provides the modal chrome, X-header, * "Sharing & access" title, and scroll container. Invite state/actions live in * `useSharingPanel`; this component is pure UI. */ export function SharingPanel({ agent, onClose }: SharingPanelProps) { const { collaborators = [], isLoadingCollaborators: isLoading } = useSuperagentCollaborators(); const { emailText, setEmailText, error, success, guestInvitePrompt, isInviting, hasInput, invite, inviteGuests, openWorkspaceMembers, } = useSharingPanel({ agent, onClose }); return ( Invite collaborators Give people access to chat with this agent [ localStyles.inviteButton, hasInput && localStyles.inviteButtonActive, isInviting && localStyles.disabledButton, pressed && sharedStyles.pressed, ]} > {isInviting ? ( ) : ( Invite )} {error ? {error} : null} {success ? {success} : null} {guestInvitePrompt ? ( Invite outside workspace? {formatEmailList(guestInvitePrompt.emails)} {guestInvitePrompt.emails.length === 1 ? 'is' : 'are'} not in this workspace. Add {guestInvitePrompt.emails.length === 1 ? 'them' : 'these people'} as guests to this Superagent, or manage workspace members first. {guestInvitePrompt.pendingInvitationEmails.length > 0 ? ( Pending workspace invite: {formatEmailList(guestInvitePrompt.pendingInvitationEmails)} ) : null} [ localStyles.guestPrimaryButton, isInviting && localStyles.disabledButton, pressed && sharedStyles.pressed, ]} > {isInviting ? : } Add as guest [ localStyles.guestSecondaryButton, pressed && sharedStyles.pressed, ]} > Add to workspace ) : null} People with access {isLoading ? ( ) : ( {collaborators.length} )} {collaborators.map((collaborator) => ( ))} {!isLoading && collaborators.length === 0 ? ( No collaborators loaded yet. ) : null} All collaborators consume credits from the workspace. ); }