From cbd3ec6872f1915382ac2beb60d08f407e62706f Mon Sep 17 00:00:00 2001 From: Atif Ali Date: Fri, 14 Nov 2025 15:14:06 -0500 Subject: [PATCH 1/2] fix: AppSet's list of applications tab shows incorrect number of apps in the filter Signed-off-by: Atif Ali --- .../components/shared/ApplicationList.tsx | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/gitops/components/shared/ApplicationList.tsx b/src/gitops/components/shared/ApplicationList.tsx index ce35b0a9..ca79d74f 100644 --- a/src/gitops/components/shared/ApplicationList.tsx +++ b/src/gitops/components/shared/ApplicationList.tsx @@ -109,21 +109,21 @@ const ApplicationList: React.FC = ({ return sortData(applications, sortBy, direction); }, [applications, sortBy, direction]); - // TODO: use alternate filter since it is deprecated. See DataTableView potentially - const filters = getFilters(t); - const [data, filteredData, onFilterChange] = useListPageFilter(sortedApplications, filters); - - // Filter applications by project or appset before rendering rows + // Filter applications by project or appset BEFORE calculating filter counts const filteredByOwner = React.useMemo( - () => filteredData.filter(filterApp(project, appset)), - [filteredData, project, appset], + () => sortedApplications.filter(filterApp(project, appset)), + [sortedApplications, project, appset], ); + // TODO: use alternate filter since it is deprecated. See DataTableView potentially + const filters = getFilters(t); + const [data, filteredData, onFilterChange] = useListPageFilter(filteredByOwner, filters); + // Filter by search query if present (after other filters) const filteredBySearch = React.useMemo(() => { - if (!searchQuery) return filteredByOwner; + if (!searchQuery) return filteredData; - return filteredByOwner.filter((app) => { + return filteredData.filter((app) => { const labels = app.metadata?.labels || {}; // Check if any label matches the search query return Object.entries(labels).some(([key, value]) => { @@ -131,13 +131,13 @@ const ApplicationList: React.FC = ({ return labelSelector.includes(searchQuery) || key.includes(searchQuery); }); }); - }, [filteredByOwner, searchQuery]); + }, [filteredData, searchQuery]); const rows = useApplicationRowsDV(filteredBySearch, namespace); // Check if there are applications owned by this ApplicationSet initially (before search) const hasOwnedApplications = React.useMemo(() => { - return sortedApplications.some(filterApp(project, appset)); - }, [sortedApplications, project, appset]); + return filteredByOwner.length > 0; + }, [filteredByOwner]); const empty = ( From 47b568555bd99454a3ea1d3633b99d4bf387ec80 Mon Sep 17 00:00:00 2001 From: Atif Ali Date: Wed, 19 Nov 2025 17:50:56 -0500 Subject: [PATCH 2/2] refactor filter behaviour Signed-off-by: Atif Ali --- src/gitops/components/shared/ApplicationList.tsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/gitops/components/shared/ApplicationList.tsx b/src/gitops/components/shared/ApplicationList.tsx index ca79d74f..dc9850ca 100644 --- a/src/gitops/components/shared/ApplicationList.tsx +++ b/src/gitops/components/shared/ApplicationList.tsx @@ -109,15 +109,17 @@ const ApplicationList: React.FC = ({ return sortData(applications, sortBy, direction); }, [applications, sortBy, direction]); - // Filter applications by project or appset BEFORE calculating filter counts - const filteredByOwner = React.useMemo( + // Filter applications by project or appset FIRST - before PatternFly filters + // This ensures PF filters work on the correct dataset (owned apps only) + const ownedApps = React.useMemo( () => sortedApplications.filter(filterApp(project, appset)), [sortedApplications, project, appset], ); // TODO: use alternate filter since it is deprecated. See DataTableView potentially + // PatternFly filters work on owned apps only (the dataset that will be displayed) const filters = getFilters(t); - const [data, filteredData, onFilterChange] = useListPageFilter(filteredByOwner, filters); + const [data, filteredData, onFilterChange] = useListPageFilter(ownedApps, filters); // Filter by search query if present (after other filters) const filteredBySearch = React.useMemo(() => { @@ -134,10 +136,8 @@ const ApplicationList: React.FC = ({ }, [filteredData, searchQuery]); const rows = useApplicationRowsDV(filteredBySearch, namespace); - // Check if there are applications owned by this ApplicationSet initially (before search) - const hasOwnedApplications = React.useMemo(() => { - return filteredByOwner.length > 0; - }, [filteredByOwner]); + // Check if there are applications owned by this ApplicationSet initially (before filters/search) + const hasOwnedApplications = ownedApps.length > 0; const empty = (