Skip to content

Commit a1ddade

Browse files
authored
Merge pull request #145 from aali309/fixGeneratedAppsSorting
fix: AppSet's list of applications tab shows incorrect number of apps in the filter
2 parents 04342eb + 47b5685 commit a1ddade

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/gitops/components/shared/ApplicationList.tsx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -109,35 +109,35 @@ const ApplicationList: React.FC<ApplicationProps> = ({
109109
return sortData(applications, sortBy, direction);
110110
}, [applications, sortBy, direction]);
111111

112+
// Filter applications by project or appset FIRST - before PatternFly filters
113+
// This ensures PF filters work on the correct dataset (owned apps only)
114+
const ownedApps = React.useMemo(
115+
() => sortedApplications.filter(filterApp(project, appset)),
116+
[sortedApplications, project, appset],
117+
);
118+
112119
// TODO: use alternate filter since it is deprecated. See DataTableView potentially
120+
// PatternFly filters work on owned apps only (the dataset that will be displayed)
113121
const filters = getFilters(t);
114-
const [data, filteredData, onFilterChange] = useListPageFilter(sortedApplications, filters);
115-
116-
// Filter applications by project or appset before rendering rows
117-
const filteredByOwner = React.useMemo(
118-
() => filteredData.filter(filterApp(project, appset)),
119-
[filteredData, project, appset],
120-
);
122+
const [data, filteredData, onFilterChange] = useListPageFilter(ownedApps, filters);
121123

122124
// Filter by search query if present (after other filters)
123125
const filteredBySearch = React.useMemo(() => {
124-
if (!searchQuery) return filteredByOwner;
126+
if (!searchQuery) return filteredData;
125127

126-
return filteredByOwner.filter((app) => {
128+
return filteredData.filter((app) => {
127129
const labels = app.metadata?.labels || {};
128130
// Check if any label matches the search query
129131
return Object.entries(labels).some(([key, value]) => {
130132
const labelSelector = `${key}=${value}`;
131133
return labelSelector.includes(searchQuery) || key.includes(searchQuery);
132134
});
133135
});
134-
}, [filteredByOwner, searchQuery]);
136+
}, [filteredData, searchQuery]);
135137
const rows = useApplicationRowsDV(filteredBySearch, namespace);
136138

137-
// Check if there are applications owned by this ApplicationSet initially (before search)
138-
const hasOwnedApplications = React.useMemo(() => {
139-
return sortedApplications.some(filterApp(project, appset));
140-
}, [sortedApplications, project, appset]);
139+
// Check if there are applications owned by this ApplicationSet initially (before filters/search)
140+
const hasOwnedApplications = ownedApps.length > 0;
141141
const empty = (
142142
<Tbody>
143143
<Tr key="loading" ouiaId="table-tr-loading">

0 commit comments

Comments
 (0)