Skip to content

Commit

Permalink
fix(ui): Filter when not defined sourcePath and case insensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
pando85 committed Jan 23, 2024
1 parent e4fe0d8 commit 872e7e9
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions server/web/ui/src/JobTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,19 +223,23 @@ const JobTable: React.FC<JobTableProps> = ({ token, setShowJobTable }) => {
}
};

jobs.forEach((job) => fetchJobDetails(job.id));
const statusFilteredJobs = selectedStatusFilter.length > 0
? jobs.filter((job) => selectedStatusFilter.includes(job.status))
: jobs;

const dateFilteredJobs = selectedDateFilter ? statusFilteredJobs.filter(
(job) => job.last_update >= getDateFromFilterOption(selectedDateFilter))
: statusFilteredJobs

const filteredJobs = nameFilter
? dateFilteredJobs.filter((job) => job.sourcePath.includes(nameFilter))
: dateFilteredJobs;
setFilteredJobs(filteredJobs);
const filterJobs = async () => {
await jobs.forEach((job) => fetchJobDetails(job.id));
const statusFilteredJobs = selectedStatusFilter.length > 0
? jobs.filter((job) => selectedStatusFilter.includes(job.status))
: jobs;

const dateFilteredJobs = selectedDateFilter ? statusFilteredJobs.filter(
(job) => job.last_update >= getDateFromFilterOption(selectedDateFilter))
: statusFilteredJobs

const filteredJobs = nameFilter
? dateFilteredJobs.filter((job) => job.sourcePath ? job.sourcePath.toLowerCase().includes(nameFilter.toLowerCase()) : false)
: dateFilteredJobs;
setFilteredJobs(filteredJobs);
};

filterJobs();
}, [token, jobs, fetchedDetails, selectedStatusFilter, selectedDateFilter, nameFilter, isSmallScreen]);

const deleteJobDetail = (jobId: string) => {
Expand Down

0 comments on commit 872e7e9

Please sign in to comment.