diff --git a/cyclops-ctrl/internal/mapper/modules.go b/cyclops-ctrl/internal/mapper/modules.go index 2ed94ffe..6a42456d 100644 --- a/cyclops-ctrl/internal/mapper/modules.go +++ b/cyclops-ctrl/internal/mapper/modules.go @@ -62,12 +62,13 @@ func ModuleListToDTO(modules []cyclopsv1alpha1.Module) []dto.Module { for _, module := range modules { values := make(map[string]interface{}) out = append(out, dto.Module{ - Name: module.Name, - Namespace: module.Namespace, - Version: module.Spec.TemplateRef.Version, - Template: k8sTemplateRefToDTO(module.Spec.TemplateRef, module.Status.TemplateResolvedVersion), - Values: values, - IconURL: module.Status.IconURL, + Name: module.Name, + Namespace: module.Namespace, + TargetNamespace: mapTargetNamespace(module.Spec.TargetNamespace), + Version: module.Spec.TemplateRef.Version, + Template: k8sTemplateRefToDTO(module.Spec.TemplateRef, module.Status.TemplateResolvedVersion), + Values: values, + IconURL: module.Status.IconURL, }) } diff --git a/cyclops-ui/src/components/pages/Modules/Modules.tsx b/cyclops-ui/src/components/pages/Modules/Modules.tsx index 8f8519a2..2873dab8 100644 --- a/cyclops-ui/src/components/pages/Modules/Modules.tsx +++ b/cyclops-ui/src/components/pages/Modules/Modules.tsx @@ -22,7 +22,7 @@ import styles from "./styles.module.css"; import { PlusCircleOutlined, FilterOutlined } from "@ant-design/icons"; import { mapResponseError } from "../../../utils/api/errors"; -const { Title } = Typography; +const { Title, Text } = Typography; const Modules = () => { const [allData, setAllData] = useState([]); @@ -34,8 +34,12 @@ const Modules = () => { "Progressing", "Unknown", ]); + const [moduleNamespaceFilter, setModuleNamespaceFilter] = useState( + [], + ); const [searchInputFilter, setsearchInputFilter] = useState(""); const resourceFilter = ["Healthy", "Unhealthy", "Progressing", "Unknown"]; + const [namespaceFilterData, setNamespaceFilterData] = useState([]); const [error, setError] = useState({ message: "", description: "", @@ -44,6 +48,16 @@ const Modules = () => { useEffect(() => { setLoadingModules(true); + axios + .get(`/api/namespaces`) + .then((res) => { + setNamespaceFilterData(res.data); + setModuleNamespaceFilter(res.data); + }) + .catch((error) => { + setError(mapResponseError(error)); + }); + function fetchModules() { axios .get(`/api/modules/list`) @@ -72,13 +86,17 @@ const Modules = () => { -1 ); }); - const newfilteredData = updatedList.filter((module: any) => - moduleHealthFilter - .map((status) => status.toLowerCase()) - .includes(module.status.toLowerCase()), + const newfilteredData = updatedList.filter( + (module: any) => + moduleHealthFilter + .map((status) => status.toLowerCase()) + .includes(module.status.toLowerCase()) && + moduleNamespaceFilter + .map((targetNamespace) => targetNamespace.toLowerCase()) + .includes(module.targetNamespace.toLowerCase()), ); setFilteredData(newfilteredData); - }, [moduleHealthFilter, allData, searchInputFilter]); + }, [moduleNamespaceFilter, moduleHealthFilter, allData, searchInputFilter]); const handleClick = () => { window.location.href = "/modules/new"; @@ -86,20 +104,40 @@ const Modules = () => { const handleSelectItem = (selectedItems: any[]) => { setModuleHealthFilter(selectedItems); }; + const handleNamespaceSelectItem = (selectedItems: any[]) => { + setModuleNamespaceFilter(selectedItems); + }; const resourceFilterPopover = () => { return ( - - {resourceFilter.map((item, index) => ( - - {item} - - ))} - + <> + + Health +
+ {resourceFilter.map((item, index) => ( + + {item} + + ))} +
+ + Namespace +
+ {namespaceFilterData.map((item, index) => ( + + {item} + + ))} +
+ ); }; const handleSearch = (event: any) => {