From b9fc41fd19328ff6aa4816e6d536d806479ffdc6 Mon Sep 17 00:00:00 2001 From: Anish Sarkar <104695310+AnishSarkar22@users.noreply.github.com> Date: Mon, 13 Oct 2025 04:30:26 +0530 Subject: [PATCH] feat: add expandable message rows in LogsTable for better readability --- .../[search_space_id]/logs/(manage)/page.tsx | 157 ++++++++++++------ 1 file changed, 107 insertions(+), 50 deletions(-) diff --git a/surfsense_web/app/dashboard/[search_space_id]/logs/(manage)/page.tsx b/surfsense_web/app/dashboard/[search_space_id]/logs/(manage)/page.tsx index 6773d2aad..fc2105274 100644 --- a/surfsense_web/app/dashboard/[search_space_id]/logs/(manage)/page.tsx +++ b/surfsense_web/app/dashboard/[search_space_id]/logs/(manage)/page.tsx @@ -777,6 +777,12 @@ function LogsTable({ onRefresh: () => void; id: string; }) { + const [expandedRows, setExpandedRows] = useState>({}); + + const toggleRowExpanded = (rowId: string) => { + setExpandedRows((prev) => ({ ...prev, [rowId]: !prev[rowId] })); + }; + if (loading) { return ( - {table.getRowModel().rows?.length ? ( - table.getRowModel().rows.map((row: any, index: number) => ( - - {row.getVisibleCells().map((cell: any) => { - const isCreatedAt = cell.column.id === "created_at"; - const isMessage = cell.column.id === "message"; - return ( - - {flexRender(cell.column.columnDef.cell, cell.getContext())} - - ); - })} - - )) - ) : ( - - - No logs found. - - - )} - + {table.getRowModel().rows?.length ? ( + table.getRowModel().rows.map((row: any, index: number) => ( + + {row.getVisibleCells().map((cell: any) => { + const isCreatedAt = cell.column.id === "created_at"; + const isMessage = cell.column.id === "message"; + const isExpanded = Boolean(expandedRows[row.id]); + + // If this is the Message column, render custom inline expandable content + if (isMessage) { + const message = row.getValue("message") as string; + const taskName = row.original.log_metadata?.task_name; + const createdAt = row.getValue("created_at") as string; + + return ( + + {/* Click the preview to toggle expand/collapse */} + + + ); + } + + // Default rendering for other columns + return ( + + {flexRender(cell.column.columnDef.cell, cell.getContext())} + + ); + })} + + )) + ) : ( + + + No logs found. + + + )} +