mirror of
https://github.com/ansible/awx.git
synced 2026-03-28 22:35:08 -02:30
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:
@@ -103,13 +103,17 @@ function JobList({
|
|||||||
}, [fetchJobs]);
|
}, [fetchJobs]);
|
||||||
|
|
||||||
const fetchJobsById = useCallback(
|
const fetchJobsById = useCallback(
|
||||||
async (ids, qs = {}) => {
|
async (ids) => {
|
||||||
const params = parseQueryString(qs, location.search);
|
const params = parseQueryString(qsConfig, location.search);
|
||||||
params.id__in = ids.join(',');
|
params.id__in = ids.join(',');
|
||||||
const { data } = await UnifiedJobsAPI.read(params);
|
try {
|
||||||
return data.results;
|
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);
|
const jobs = useWsJobs(results, fetchJobsById, qsConfig);
|
||||||
|
|||||||
@@ -47,16 +47,9 @@ export default function useWsJobs(initialJobs, fetchJobsById, qsConfig) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const params = parseQueryString(qsConfig, location.search);
|
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 jobId = lastMessage.unified_job_id;
|
||||||
const index = jobs.findIndex((j) => j.id === jobId);
|
const index = jobs.findIndex((j) => j.id === jobId);
|
||||||
|
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
setJobs(sortJobs(updateJob(jobs, index, lastMessage), params));
|
setJobs(sortJobs(updateJob(jobs, index, lastMessage), params));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user