diff --git a/src/pages/audit-report/components/View/GlobalFilters.tsx b/src/pages/audit-report/components/View/GlobalFilters.tsx index 15d89af1a..ade1a7875 100644 --- a/src/pages/audit-report/components/View/GlobalFilters.tsx +++ b/src/pages/audit-report/components/View/GlobalFilters.tsx @@ -72,7 +72,7 @@ const GlobalFilters: React.FC = ({ variables }) => { } return ( -
+
{filterComponents}
diff --git a/src/pages/views/components/SingleView.tsx b/src/pages/views/components/SingleView.tsx index c6dce2fb1..470ea946f 100644 --- a/src/pages/views/components/SingleView.tsx +++ b/src/pages/views/components/SingleView.tsx @@ -163,7 +163,7 @@ const SingleView: React.FC = ({ id }) => { // Render the main view through ViewSection to reuse its spacing/scroll styling; // rendering the raw View here caused padding/overflow glitches alongside sections. const primaryViewSection = { - title: "", + title: title || name, viewRef: { namespace: namespace || "", name: name @@ -185,7 +185,7 @@ const SingleView: React.FC = ({ id }) => { ) } > -
+
{/* Render aggregated variables once at the top */} {aggregatedVariables && aggregatedVariables.length > 0 && ( = ({ id }) => {
)} -
+
= ({ id }) => { {viewResult.sections.map((section) => (
diff --git a/src/pages/views/components/ViewSection.tsx b/src/pages/views/components/ViewSection.tsx index 4c3d8067e..a60dcd3d8 100644 --- a/src/pages/views/components/ViewSection.tsx +++ b/src/pages/views/components/ViewSection.tsx @@ -1,5 +1,6 @@ -import React from "react"; +import React, { useState } from "react"; import { useQuery } from "@tanstack/react-query"; +import { IoChevronDownOutline } from "react-icons/io5"; import { getViewDataByNamespace } from "../../../api/services/views"; import View from "../../audit-report/components/View/View"; import { Icon } from "../../../ui/Icons/Icon"; @@ -16,6 +17,7 @@ const ViewSection: React.FC = ({ section, hideVariables }) => { + const [isExpanded, setIsExpanded] = useState(true); const { namespace, name } = section.viewRef; // Use prefixed search params for view variables @@ -37,50 +39,96 @@ const ViewSection: React.FC = ({ staleTime: 5 * 60 * 1000 }); - if (isLoading) { - return ( -
-
-
-
- ); - } + const handleHeaderKeyDown = (event: React.KeyboardEvent) => { + if (event.key === "Enter" || event.key === " ") { + event.preventDefault(); + setIsExpanded(!isExpanded); + } + }; - if (error || !sectionViewResult) { + if (error || (!isLoading && !sectionViewResult)) { + const errorContentId = `section-${namespace}-${name}-error`; return ( <> -
+
setIsExpanded(!isExpanded)} + onKeyDown={handleHeaderKeyDown} + > + {section.icon && ( - + )} -

{section.title}

-
-
- {error instanceof Error ? error.message : "Failed to load section"} +

+ {section.title} +

+ {isExpanded && ( +
+ {error instanceof Error ? error.message : "Failed to load section"} +
+ )} ); } + const contentId = `section-${namespace}-${name}`; + return ( <> -
- {section.icon && } -

{section.title}

+
setIsExpanded(!isExpanded)} + onKeyDown={handleHeaderKeyDown} + > + + {section.icon && ( + + )} +

{section.title}

- + {isExpanded && ( +
+ {isLoading ? ( +
+
+
+
+ ) : ( + + )} +
+ )} ); };