Merge pull request #12249 from keithjgrant/filter-ws-jobs

use qs params when fetching new/updated jobs to preserve filters
This commit is contained in:
Jessica Steurer 2022-05-19 17:24:52 -03:00 committed by GitHub
commit 2ba68ef5d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 13 deletions

View File

@ -103,13 +103,17 @@ function JobList({
}, [fetchJobs]);
const fetchJobsById = useCallback(
async (ids, qs = {}) => {
const params = parseQueryString(qs, location.search);
async (ids) => {
const params = parseQueryString(qsConfig, location.search);
params.id__in = ids.join(',');
const { data } = await UnifiedJobsAPI.read(params);
return data.results;
try {
const { data } = await UnifiedJobsAPI.read(params);
return data.results;
} catch (e) {
return [];
}
},
[location.search]
[location.search] // eslint-disable-line react-hooks/exhaustive-deps
);
const jobs = useWsJobs(results, fetchJobsById, qsConfig);

View File

@ -47,16 +47,9 @@ export default function useWsJobs(initialJobs, fetchJobsById, qsConfig) {
return;
}
const params = parseQueryString(qsConfig, location.search);
const filtersApplied = Object.keys(params).length > 4;
if (
filtersApplied &&
!['completed', 'failed', 'error'].includes(lastMessage.status)
) {
return;
}
const jobId = lastMessage.unified_job_id;
const index = jobs.findIndex((j) => j.id === jobId);
if (index > -1) {
setJobs(sortJobs(updateJob(jobs, index, lastMessage), params));
} else {