From 3a53a86ce036f2e9d03a01b93ab62e833a9f85e7 Mon Sep 17 00:00:00 2001 From: Bobban Rydh Date: Tue, 15 Sep 2026 12:01:00 +0200 Subject: [PATCH] Show real target names in the Audit Log instead of type #id The Target column only ever printed " #", so newly created integrations (and other records) appeared as "integration 1", "integration 2", etc. instead of the display name set in the form. Audit entries already log the name in their detail JSON on create/update/delete; parse it and show it when present. Co-Authored-By: Claude Sonnet 5 --- web/src/pages/AuditLog.tsx | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/web/src/pages/AuditLog.tsx b/web/src/pages/AuditLog.tsx index e51f379..9176350 100644 --- a/web/src/pages/AuditLog.tsx +++ b/web/src/pages/AuditLog.tsx @@ -1,6 +1,22 @@ import { useEffect, useState } from "react"; import { api, type AuditLogEntry } from "../api/client"; +function targetLabel(e: AuditLogEntry): string { + if (!e.targetType) return "—"; + let detail: Record | null = null; + if (e.detail) { + try { + detail = JSON.parse(e.detail); + } catch { + detail = null; + } + } + const name = detail?.name ?? detail?.targetLabel ?? detail?.ipAddress; + const typeLabel = e.targetType.replace(/_/g, " "); + if (typeof name === "string" && name) return `${typeLabel} "${name}"`; + return `${typeLabel}${e.targetId ? ` #${e.targetId}` : ""}`; +} + export default function AuditLog() { const [entries, setEntries] = useState(null); const [error, setError] = useState(null); @@ -37,9 +53,7 @@ export default function AuditLog() { {e.category} {e.action} - - {e.targetType ? `${e.targetType}${e.targetId ? ` #${e.targetId}` : ""}` : "—"} - + {targetLabel(e)} ))} {entries?.length === 0 && (