From c73abc8608ceac797e5575e58c71e9884d27534f Mon Sep 17 00:00:00 2001 From: x032205 Date: Tue, 4 Nov 2025 15:26:35 -0500 Subject: [PATCH] pam: simplify log output --- .../components/PamSessionLogOutput.tsx | 116 ------------------ .../components/PamSessionLogsSection.tsx | 18 +-- 2 files changed, 3 insertions(+), 131 deletions(-) delete mode 100644 frontend/src/pages/pam/PamSessionsByIDPage/components/PamSessionLogOutput.tsx diff --git a/frontend/src/pages/pam/PamSessionsByIDPage/components/PamSessionLogOutput.tsx b/frontend/src/pages/pam/PamSessionsByIDPage/components/PamSessionLogOutput.tsx deleted file mode 100644 index 99e30627d..000000000 --- a/frontend/src/pages/pam/PamSessionsByIDPage/components/PamSessionLogOutput.tsx +++ /dev/null @@ -1,116 +0,0 @@ -import { useState } from "react"; - -import { HighlightText } from "@app/components/v2/HighlightText"; -import { PamResourceType } from "@app/hooks/api/pam"; - -type TableLog = { - command?: string; - data_rows: Record[]; - total_rows?: number; -}; - -export const PamSessionLogOutput = ({ - content, - resourceType, - search -}: { - content: string; - resourceType: PamResourceType; - search: string; -}) => { - const [isRawView, setIsRawView] = useState(false); - - let parsedContent: TableLog | null = null; - - if (resourceType === PamResourceType.Postgres || resourceType === PamResourceType.MySQL) { - try { - const parsed = JSON.parse(content); - - if ( - parsed && - typeof parsed === "object" && - !Array.isArray(parsed) && - parsed.data_rows && - Array.isArray(parsed.data_rows) && - parsed.data_rows.length > 0 && - typeof parsed.data_rows[0] === "object" && - parsed.data_rows[0] !== null - ) { - parsedContent = parsed; - } - } catch { - // Not a valid JSON or doesn't match structure, will render as plain text - } - } - - if (parsedContent) { - const headers = Object.keys(parsedContent.data_rows[0]); - return ( -
- {isRawView ? ( -
- -
- ) : ( - <> - {parsedContent.command && ( -
{`> ${parsedContent.command}`}
- )} -
- - - - {headers.map((header) => ( - - ))} - - - - {parsedContent.data_rows.map((row, rowIndex) => ( - - {headers.map((header) => ( - - ))} - - ))} - -
- -
- -
-
- - )} -
- - - {parsedContent.total_rows !== undefined && ( -
- Total rows: {parsedContent.total_rows} -
- )} -
-
- ); - } - - return ( -
- -
- ); -}; diff --git a/frontend/src/pages/pam/PamSessionsByIDPage/components/PamSessionLogsSection.tsx b/frontend/src/pages/pam/PamSessionsByIDPage/components/PamSessionLogsSection.tsx index 0fbccbc9b..7a4945540 100644 --- a/frontend/src/pages/pam/PamSessionsByIDPage/components/PamSessionLogsSection.tsx +++ b/frontend/src/pages/pam/PamSessionsByIDPage/components/PamSessionLogsSection.tsx @@ -7,7 +7,6 @@ import { Input } from "@app/components/v2"; import { HighlightText } from "@app/components/v2/HighlightText"; import { TPamSession } from "@app/hooks/api/pam"; -import { PamSessionLogOutput } from "./PamSessionLogOutput"; import { formatLogContent } from "./PamSessionLogsSection.utils"; type Props = { @@ -104,20 +103,9 @@ export const PamSessionLogsSection = ({ session }: Props) => { >
{log.output && ( - <> -
-
- OUTPUT -
-
-
- -
- +
+ +
)}