From 4d192e616ea06a498c6e575638ed8db33a92b91f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Dudfield?= Date: Mon, 4 Nov 2024 10:25:40 +0100 Subject: [PATCH] frontend: CustomResourceInstancesList: Fix to work with multi cluster MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before the page would crash with multi clusters selected. Now it does not crash, instead the related cluster is listed next to each instance in multi cluster mode. In single cluster mode it is the same as before. Signed-off-by: René Dudfield --- .../components/crd/CustomResourceInstancesList.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/crd/CustomResourceInstancesList.tsx b/frontend/src/components/crd/CustomResourceInstancesList.tsx index 01646c08c7..c0f1186b19 100644 --- a/frontend/src/components/crd/CustomResourceInstancesList.tsx +++ b/frontend/src/components/crd/CustomResourceInstancesList.tsx @@ -10,8 +10,14 @@ import { ResourceListView } from '../common/Resource'; function CrInstancesView({ crds }: { crds: CRD[]; key: string }) { const { t } = useTranslation(['glossary', 'translation']); - const crdInfo = useMemo(() => crds.map(crd => crd.makeCRClass()), [crds]); - const queries = crdInfo.map(cr => cr.useList()); + const dataClassCrds = crds.map(crd => { + const crdClass = crd.makeCRClass(); + const data = crdClass.useList({ cluster: crd.cluster }); + return { data, crdClass, crd }; + }); + + const queries = dataClassCrds.map(it => it.data); + const [isWarningClosed, setIsWarningClosed] = useState(false); const { crInstancesList, getCRDForCR, isLoading, crdsFailedToLoad, allFailed } = useMemo(() => { @@ -112,6 +118,7 @@ function CrInstancesView({ crds }: { crds: CRD[]; key: string }) { ); }, }, + 'cluster', { label: 'Categories', getValue: cr => {