Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions src/gitops/components/shared/ApplicationList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,35 +109,35 @@ const ApplicationList: React.FC<ApplicationProps> = ({
return sortData(applications, sortBy, direction);
}, [applications, sortBy, direction]);

// 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(sortedApplications, filters);

// Filter applications by project or appset before rendering rows
const filteredByOwner = React.useMemo(
() => filteredData.filter(filterApp(project, appset)),
[filteredData, project, appset],
);
const [data, filteredData, onFilterChange] = useListPageFilter(ownedApps, 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]) => {
const labelSelector = `${key}=${value}`;
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]);
// Check if there are applications owned by this ApplicationSet initially (before filters/search)
const hasOwnedApplications = ownedApps.length > 0;
const empty = (
<Tbody>
<Tr key="loading" ouiaId="table-tr-loading">
Expand Down