import type { RoleInfo } from "../../../lib/types"; import { FormSectionHeader } from "./formRow"; import { RoleGrantsEditor } from "./RoleGrantsEditor"; interface Props { connectionId: string; item: RoleInfo; } interface AttributeRow { label: string; value: string; highlight?: boolean; } export function RoleDetail({ connectionId, item }: Props) { const attributes: AttributeRow[] = [ { label: "Can login", value: item.can_login ? "Yes" : "No", highlight: item.can_login }, { label: "Superuser", value: item.superuser ? "Yes" : "No", highlight: item.superuser }, { label: "Create databases", value: item.create_db ? "Yes" : "No", highlight: item.create_db }, { label: "Create roles", value: item.create_role ? "Yes" : "No", highlight: item.create_role }, { label: "Inherit privileges", value: item.inherit ? "Yes" : "No", highlight: item.inherit }, { label: "Replication", value: item.replication ? "Yes" : "No", highlight: item.replication }, { label: "Bypass RLS", value: item.bypass_rls ? "Yes" : "No", highlight: item.bypass_rls }, { label: "Connection limit", value: String(item.connection_limit) }, { label: "Valid until", value: item.valid_until ?? "Never" }, ]; return (
Role
Name {item.name}
Attributes
{attributes.map((attr) => (
{attr.label}
{attr.value}
))}
{item.memberships.length === 0 && (

Not a member of any role.

)} {item.memberships.map((m, i) => (
Role {m.member} of {m.role} {m.admin_option && ( admin )}
))}
); }