From 43525b54944dd4a6c649bd95a02e8e1b18e44aa9 Mon Sep 17 00:00:00 2001 From: Fang-Pen Lin Date: Thu, 4 Dec 2025 13:49:35 -0800 Subject: [PATCH] Update http view --- .../components/HttpEventView.tsx | 78 +++++++++++++++++-- 1 file changed, 73 insertions(+), 5 deletions(-) diff --git a/frontend/src/pages/pam/PamSessionsByIDPage/components/HttpEventView.tsx b/frontend/src/pages/pam/PamSessionsByIDPage/components/HttpEventView.tsx index 9ab228942..5d77ff385 100644 --- a/frontend/src/pages/pam/PamSessionsByIDPage/components/HttpEventView.tsx +++ b/frontend/src/pages/pam/PamSessionsByIDPage/components/HttpEventView.tsx @@ -1,5 +1,5 @@ import { useMemo, useState } from "react"; -import { faMagnifyingGlass } from "@fortawesome/free-solid-svg-icons"; +import { faChevronDown, faChevronUp, faMagnifyingGlass } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { Input } from "@app/components/v2"; @@ -12,6 +12,9 @@ type Props = { export const HttpEventView = ({ events }: Props) => { const [search, setSearch] = useState(""); + const [expandedSections, setExpandedSections] = useState< + Record + >({}); const filteredEvents = useMemo( () => @@ -48,6 +51,25 @@ export const HttpEventView = ({ events }: Props) => { .join("\n"); }; + const getKubectlCommand = (headers: Record) => { + const headerKey = Object.keys(headers).find((key) => key.toLowerCase() === "kubectl-command"); + return headerKey ? headers[headerKey]?.[0] : undefined; + }; + + const toggleSection = (eventKey: string, section: "headers" | "body") => { + setExpandedSections((prev) => ({ + ...prev, + [eventKey]: { + ...prev[eventKey], + [section]: !prev[eventKey]?.[section] + } + })); + }; + + const isSectionExpanded = (eventKey: string, section: "headers" | "body") => { + return expandedSections[eventKey]?.[section] ?? false; + }; + return ( <>
@@ -66,6 +88,7 @@ export const HttpEventView = ({ events }: Props) => { filteredEvents.map((event, index) => { const eventKey = `${event.timestamp}-${event.requestId}-${index}`; const isRequest = event.eventType === "request"; + const kubectlCommand = getKubectlCommand(event.headers); return (
{ > {isRequest ? "REQUEST" : "RESPONSE"} + {kubectlCommand && ( + + kubectl: {kubectlCommand} + + )} {new Date(event.timestamp).toLocaleString()} • {event.requestId} @@ -104,12 +135,49 @@ export const HttpEventView = ({ events }: Props) => { {Object.keys(event.headers).length > 0 && (
-
Headers:
-
- -
+ + {isSectionExpanded(eventKey, "headers") && ( +
+ +
+ )}
)} + +
+ + {isSectionExpanded(eventKey, "body") && ( +
+
+ {isRequest + ? "Request body content will be displayed here when available." + : "Response body content will be displayed here when available."} +
+
+ )} +
);