diff --git a/pkg/frontend/src/components/CompositeResourcesList.tsx b/pkg/frontend/src/components/CompositeResourcesList.tsx index 92f0cc9..74bdfc6 100644 --- a/pkg/frontend/src/components/CompositeResourcesList.tsx +++ b/pkg/frontend/src/components/CompositeResourcesList.tsx @@ -1,4 +1,5 @@ -import {Card, CardContent, Grid} from '@mui/material'; +import {Box, Alert, Stack, List, Card, CardContent, Grid, Accordion, AccordionSummary, AccordionDetails} from '@mui/material'; +import {ExpandMore as ExpandMoreIcon} from '@mui/icons-material'; import {CompositeResource, CompositeResourceExtended, ItemList, K8sReference, K8sResource} from "../types.ts"; import Typography from "@mui/material/Typography"; import ReadySynced from "./ReadySynced.tsx"; @@ -44,6 +45,7 @@ export default function CompositeResourcesList({items}: ItemListProps) { const [isDrawerOpen, setDrawerOpen] = useState(focusedName != undefined); const nullFocused = {metadata: {name: ""}, kind: "", apiVersion: ""}; const [focused, setFocused] = useState(nullFocused); + const [expandedItems, setExpandedItems] = useState<{[itemIndex: string]: boolean}>({}); const navigate = useNavigate(); const onClose = () => { @@ -98,13 +100,85 @@ export default function CompositeResourcesList({items}: ItemListProps) { ) } + // Define Grouped Items + const groupedItems: { [itemIndex: string]: CompositeResource[] } = {}; + items.items.forEach((item) => { + const itemIndex = item.kind + if (!groupedItems[itemIndex]) { + groupedItems[itemIndex] = []; + } + groupedItems[itemIndex].push(item); + }); + + // Accordion State + const handleAccordionChange = (itemIndex: string) => { + setExpandedItems((prevState) => ({ + ...prevState, + [itemIndex]: !prevState[itemIndex], + })); + }; + return ( <> - - {items?.items?.map((item: CompositeResource) => ( - - ))} - + {Object.entries(groupedItems).map(([itemIndex, items]) => ( + + handleAccordionChange(itemIndex)}> + }> + + {itemIndex} + + *': { + py: '4px !important', + },}} + severity="success"> + Ready: {items.filter((item) => item.status?.conditions?.find((condition) => + condition.status === "True" && condition.type === "Ready")).length} + + + { + items.filter((item) => !item.status?.conditions?.find((condition) => + condition.status === "True" && condition.type === "Ready")).length > 0 ? ( + + *': { + py: '4px !important', + },}} + severity="error" color="warning"> + Not Ready: {items.filter((item) => !item.status?.conditions?.find((condition) => + condition.status === "True" && condition.type === "Ready")).length} + + + ) : null + } + { + items.filter((item) => !item.status?.conditions?.find((condition) => + condition.status === "True" && condition.type === "Synced")).length > 0 ? ( + + *': { + py: '4px !important', + },}} + severity="info" color="info"> + Not Synced: {items.filter((item) => !item.status?.conditions?.find((condition) => + condition.status === "True" && condition.type === "Sync")).length} + + + ) : null + } + + + + + {items.map((item: CompositeResource) => ( + + ))} + + + + + ))}