// AK-P17a Interim-UI (AD-28) — vault detail composed from ~/ui (D-HR // "Passwort-Safe Detail", archetype A3 + reveal). SECURITY-CRITICAL: secret // values are NEVER in the list — each entry shows only "hasX" flags. A value is // fetched ONLY on an explicit, audited reveal (route action) and, once copied, the // clipboard is wiped after copyAutoClearMs (30s, DoD #3). Create-entry / grant- // access run through injected actions. Final Subframe optics = design-nachzug. import { useEffect, useRef, useState } from "react"; import { useTranslation } from "react-i18next"; import { FeatherPlus } from "@subframe/core"; import type { EntryRow, VaultDetailVM } from "@hivegrid/view-models"; import { Breadcrumbs } from "~/ui/components/Breadcrumbs"; import { Button } from "~/ui/components/Button"; import { Card } from "~/ui/components/Card"; import { CopyToClipboardButton } from "~/ui/components/CopyToClipboardButton"; import { Dialog } from "~/ui/components/Dialog"; import { EmptyState } from "~/ui/components/EmptyState"; import { LinkButton } from "~/ui/components/LinkButton"; import { Select } from "~/ui/components/Select"; import { Tag_Label } from "~/ui/components/Tag_Label"; import { TextInput } from "~/ui/components/TextInput"; export type VaultSecretField = "username" | "password" | "notes"; export type VaultAccessLevel = "read" | "write" | "admin"; export type HrVaultDetailActions = { /** Reveal ONE field of ONE entry (audited server-side); resolves the plaintext. */ onReveal: (entryId: string, field: VaultSecretField) => Promise; onCreateEntry: (input: { title: string; url: string; username: string; password: string; notes: string }) => void; onArchiveEntry: (entryId: string) => void; onGrantAccess: (input: { targetUserId: string; permissionLevel: VaultAccessLevel }) => void; }; export type HrVaultDetailPageProps = { vm: VaultDetailVM; backHref: string; submitting: boolean; actions: HrVaultDetailActions; }; /** One revealable secret field: reveal on demand, copy, wipe clipboard after the * VM-supplied window (30s). The value is held only in local component state. */ function SecretField({ entryId, field, labelKey, autoClearMs, onReveal, }: { entryId: string; field: VaultSecretField; labelKey: string; autoClearMs: number; onReveal: HrVaultDetailActions["onReveal"]; }) { const { t } = useTranslation(); const [value, setValue] = useState(null); const [loading, setLoading] = useState(false); const [copied, setCopied] = useState(false); const clearTimer = useRef | null>(null); useEffect(() => () => { if (clearTimer.current) clearTimeout(clearTimer.current); }, []); async function reveal() { setLoading(true); try { setValue(await onReveal(entryId, field)); } finally { setLoading(false); } } function scheduleClipboardWipe() { setCopied(true); if (clearTimer.current) clearTimeout(clearTimer.current); clearTimer.current = setTimeout(() => { // Wipe the clipboard so a copied secret does not linger (DoD #3). void navigator.clipboard?.writeText("").catch(() => {}); setCopied(false); }, autoClearMs); } return (
{t(labelKey)} {value === null ? ( ) : (
{value}
)} {copied ? ( {t("hr.passwordSafe.detail.copyCleared")} ) : null}
); } function EntryCard({ entry, autoClearMs, canWrite, submitting, onReveal, onArchive, }: { entry: EntryRow; autoClearMs: number; canWrite: boolean; submitting: boolean; onReveal: HrVaultDetailActions["onReveal"]; onArchive: (entryId: string) => void; }) { const { t } = useTranslation(); return (
{entry.title} {entry.url ? ( {entry.url} ) : null} {entry.tags.length > 0 ? (
{entry.tags.map((tag) => ( {tag} ))}
) : null}
{canWrite ? ( ) : null}
{entry.hasUsername ? ( ) : null} {entry.hasPassword ? ( ) : null} {entry.hasNotes ? ( ) : null}
); } export function HrVaultDetailPage({ vm, backHref, submitting, actions }: HrVaultDetailPageProps) { const { t } = useTranslation(); const [entryOpen, setEntryOpen] = useState(false); const [accessOpen, setAccessOpen] = useState(false); const [entry, setEntry] = useState({ title: "", url: "", username: "", password: "", notes: "" }); const [access, setAccess] = useState<{ targetUserId: string; permissionLevel: VaultAccessLevel }>({ targetUserId: "", permissionLevel: "read" }); if (vm.status !== "ready" || !vm.data) { return
; } const { vaultName, rows, canWrite, canManageAccess, copyAutoClearMs, exportHref, emptyHeadlineKey, emptyBodyKey } = vm.data; function submitEntry() { actions.onCreateEntry(entry); setEntryOpen(false); setEntry({ title: "", url: "", username: "", password: "", notes: "" }); } function submitAccess() { actions.onGrantAccess(access); setAccessOpen(false); setAccess({ targetUserId: "", permissionLevel: "read" }); } return (
{t("hr.passwordSafe.detail.back")} {vaultName}
{vaultName} {t("hr.passwordSafe.detail.subtitle")}
{t("hr.passwordSafe.detail.export")} {canManageAccess ? ( ) : null} {canWrite ? ( ) : null}
{rows.length === 0 ? (
) : (
{rows.map((row) => ( ))}
)} {/* New entry dialog (canWrite) */}
{t("hr.passwordSafe.detail.newEntry")}
setEntry((s) => ({ ...s, title: e.target.value }))} data-ui-id="ui.hr.vault.createEntry.title" /> setEntry((s) => ({ ...s, url: e.target.value }))} /> setEntry((s) => ({ ...s, username: e.target.value }))} /> setEntry((s) => ({ ...s, password: e.target.value }))} /> setEntry((s) => ({ ...s, notes: e.target.value }))} />
{/* Grant access dialog (canManageAccess) */}
{t("hr.passwordSafe.detail.manageAccess")}
setAccess((s) => ({ ...s, targetUserId: e.target.value }))} data-ui-id="ui.hr.vault.grantAccess.user" />
); }