diff --git a/src/components/common/UserSearchPicker.tsx b/src/components/common/UserSearchPicker.tsx index 5c4fa05..57d82cf 100644 --- a/src/components/common/UserSearchPicker.tsx +++ b/src/components/common/UserSearchPicker.tsx @@ -12,12 +12,14 @@ export function UserSearchPicker({ selectedUser, onSelect, excludeIds, + excludePlatformAdmins, label, placeholder, }: { selectedUser: UserListResponse | null onSelect: (user: UserListResponse | null) => void excludeIds?: string[] + excludePlatformAdmins?: boolean label?: string placeholder?: string }) { @@ -68,9 +70,11 @@ export function UserSearchPicker({ return () => document.removeEventListener("mousedown", handleClickOutside) }, []) - const filtered = excludeIds - ? results.filter((u) => !excludeIds.includes(u.id)) - : results + const filtered = results.filter( + (u) => + !(excludePlatformAdmins && u.is_platform_admin) && + !excludeIds?.includes(u.id), + ) return (
- {results.length > 0 && excludeIds ? "All results already added" : "No users found"} + {results.length > 0 + ? "All matching users are already added or unavailable" + : "No users found"}
) : ( filtered.map((user) => ( diff --git a/src/components/pages/ProjectAccessTab.tsx b/src/components/pages/ProjectAccessTab.tsx index 3613d16..9bd9081 100644 --- a/src/components/pages/ProjectAccessTab.tsx +++ b/src/components/pages/ProjectAccessTab.tsx @@ -322,6 +322,8 @@ export function ProjectAccessTab({ projectId }: { projectId: string }) { ?.status if (status === 409) { toast.error("This user already has access to the project") + } else if (status === 400) { + toast.error("Platform admins can't be added to a project") } else { toast.error("Failed to grant user access") } @@ -420,6 +422,7 @@ export function ProjectAccessTab({ projectId }: { projectId: string }) { selectedUser={selectedUser} onSelect={setSelectedUser} excludeIds={userAccess.map((u) => u.user_id)} + excludePlatformAdmins label="User" placeholder="Search users by email or name..." />