diff --git a/frontend/src/pages/pam/PamSessionsByIDPage/components/HttpEventView.tsx b/frontend/src/pages/pam/PamSessionsByIDPage/components/HttpEventView.tsx index 3ecd7cf4a..e0cf045b7 100644 --- a/frontend/src/pages/pam/PamSessionsByIDPage/components/HttpEventView.tsx +++ b/frontend/src/pages/pam/PamSessionsByIDPage/components/HttpEventView.tsx @@ -12,6 +12,7 @@ type Props = { export const HttpEventView = ({ events }: Props) => { const [search, setSearch] = useState(""); + const [expandedEvents, setExpandedEvents] = useState>({}); const [expandedSections, setExpandedSections] = useState< Record >({}); @@ -122,6 +123,24 @@ export const HttpEventView = ({ events }: Props) => { return headerKey ? headers[headerKey]?.[0] : undefined; }; + const toggleEvent = (eventKey: string) => { + const willBeExpanded = !expandedEvents[eventKey]; + setExpandedEvents((prev) => ({ + ...prev, + [eventKey]: willBeExpanded + })); + // When expanding, show headers by default (but keep body collapsed) + if (willBeExpanded) { + setExpandedSections((prev) => ({ + ...prev, + [eventKey]: { + headers: true, + body: prev[eventKey]?.body ?? false + } + })); + } + }; + const toggleSection = (eventKey: string, section: "headers" | "body") => { setExpandedSections((prev) => ({ ...prev, @@ -132,6 +151,10 @@ export const HttpEventView = ({ events }: Props) => { })); }; + const isEventExpanded = (eventKey: string) => { + return expandedEvents[eventKey] ?? false; + }; + const isSectionExpanded = (eventKey: string, section: "headers" | "body") => { return expandedSections[eventKey]?.[section] ?? false; }; @@ -156,13 +179,23 @@ export const HttpEventView = ({ events }: Props) => { const isRequest = event.eventType === "request"; const kubectlCommand = getKubectlCommand(event.headers); + const isExpanded = isEventExpanded(eventKey); + return (
-
+
+ -
- {isRequest ? ( -
- {event.method}{" "} - -
- ) : ( -
- Status:{" "} - -
- )} + {isExpanded && ( +
+ {isRequest ? ( +
+ {event.method}{" "} + +
+ ) : ( +
+ Status:{" "} + +
+ )} - {Object.keys(event.headers).length > 0 && ( -
- - {isSectionExpanded(eventKey, "headers") && ( -
- -
- )} -
- )} - - {event.body && ( -
- - {isSectionExpanded(eventKey, "body") && ( -
- 0 && ( +
+
- )} -
- )} -
+ Headers: + + {isSectionExpanded(eventKey, "headers") && ( +
+ +
+ )} +
+ )} + + {event.body && ( +
+ + {isSectionExpanded(eventKey, "body") && ( +
+ +
+ )} +
+ )} +
+ )}
); })