import { useId } from "react"; import { cn } from "../../lib/utils"; import type { ConnectionOwnership } from "../../types"; import { Dialog, DialogHeader, DialogTitle, DialogDescription } from "../../../ui/dialog"; import { Button } from "../../../ui/button"; import { CapabilityDialogContent } from "./detail-dialog"; // Imported where its classes are used: a module that only re-exported // would be dropped with its stylesheet by tree shaking. import "./session-capability-card.css"; export function OwnershipSelector({ value, onChange, compact = false, credentialBased = false, }: { value: ConnectionOwnership; onChange: (value: ConnectionOwnership) => void; compact?: boolean | undefined; credentialBased?: boolean | undefined; }) { const groupName = useId(); const workspaceDescription = credentialBased ? "Workspace agents and automations can act through the account these credentials authorize." : "Workspace agents and automations can act through your account."; const personalDescription = credentialBased ? "Only your authorized work can use these credentials." : "Only your authorized work can use your account."; if (compact) { const descriptionId = `${groupName}-description`; return (
Connect for
{(["workspace", "personal"] as const).map((ownership) => ( ))}

{value === "workspace" ? workspaceDescription : personalDescription}

); } return (
Who can use this connection? onChange("workspace")} /> onChange("personal")} />
); } function OwnershipOption({ groupName, checked, value, title, description, onChange, }: { groupName: string; checked: boolean; value: ConnectionOwnership; title: string; description: string; onChange: () => void; }) { return ( ); } export function ConnectionOwnershipDialog({ name, value, onChange, onContinue, onClose, }: { name: string; value: ConnectionOwnership; onChange(value: ConnectionOwnership): void; onContinue(): void; onClose(): void; }) { return ( { if (!open) onClose(); }} > Connect {name} Choose who can use this account. ); }