/** UsersTab — Authentik access metadata, not an effective-permissions calculation. */ import { useState } from "react"; import { Alert, AlertDescription } from "@/components/ui/alert"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@/components/ui/table"; import type { ServiceInstance } from "../../types"; import { useAuthentikAccessSummary } from "../../hooks/useAuthentik"; const PAGE_SIZE = 25; export function UsersTab({ instance }: { instance: ServiceInstance }) { const [search, setSearch] = useState(""); const [page, setPage] = useState(1); const [committedSearch, setCommittedSearch] = useState(""); const { data, isLoading } = useAuthentikAccessSummary(instance.id, { search: committedSearch, page, page_size: PAGE_SIZE, }); const users = data?.items ?? []; const total = data?.total ?? 0; const totalPages = Math.max(1, Math.ceil(total / PAGE_SIZE)); function handleSearch() { setPage(1); setCommittedSearch(search); } return (
Shows Authentik group membership and explicit staff/superuser flags. This is access metadata, not a complete effective-authorization calculation. {data?.error ? ( {data.error} ) : null}
setSearch(event.target.value)} onKeyDown={(event) => { if (event.key === "Enter") handleSearch(); }} className="max-w-xs" />
Name Username Groups Privileges Status {isLoading && users.length === 0 ? ( Loading… ) : null} {!isLoading && users.length === 0 ? ( No users found. ) : null} {users.map((user) => ( {user.name || "—"} {user.username || "—"}
{user.groups.length ? ( user.groups.map((group) => ( {group.name} )) ) : ( None )}
{user.is_superuser ? ( Superuser ) : null} {user.is_staff ? Staff : null} {!user.is_superuser && !user.is_staff ? ( None ) : null}
{user.is_active ? "Active" : "Inactive"}
))}
{total > 0 ? (
{total} user{total === 1 ? "" : "s"} · Page {page} of {totalPages}
) : null}
); }