Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/components/common/UserSearchPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
}) {
Expand Down Expand Up @@ -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 (
<div ref={containerRef} className="space-y-1.5">
Expand Down Expand Up @@ -129,7 +133,9 @@ export function UserSearchPicker({
</div>
) : filtered.length === 0 ? (
<p className="text-sm text-verde/50 text-center py-4">
{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"}
</p>
) : (
filtered.map((user) => (
Expand Down
3 changes: 3 additions & 0 deletions src/components/pages/ProjectAccessTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down Expand Up @@ -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..."
/>
Expand Down
Loading