From 6a9305818e6af1c27f4652ee7d588ab140feba38 Mon Sep 17 00:00:00 2001 From: "Keith J. Grant" Date: Tue, 17 May 2022 14:57:57 -0700 Subject: [PATCH 1/2] use qs params when fetching new/updated jobs to preserve filters --- awx/ui/src/components/JobList/JobList.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/awx/ui/src/components/JobList/JobList.js b/awx/ui/src/components/JobList/JobList.js index 4471df2333..c1d89ff718 100644 --- a/awx/ui/src/components/JobList/JobList.js +++ b/awx/ui/src/components/JobList/JobList.js @@ -103,13 +103,13 @@ 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; }, - [location.search] + [location.search] // eslint-disable-line react-hooks/exhaustive-deps ); const jobs = useWsJobs(results, fetchJobsById, qsConfig); From 9972389a8de6f29e87dfb81ab80e3ba63482593e Mon Sep 17 00:00:00 2001 From: "Keith J. Grant" Date: Wed, 18 May 2022 14:40:18 -0700 Subject: [PATCH 2/2] fetch relevant jobs based on WS events --- awx/ui/src/components/JobList/JobList.js | 8 ++++++-- awx/ui/src/components/JobList/useWsJobs.js | 9 +-------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/awx/ui/src/components/JobList/JobList.js b/awx/ui/src/components/JobList/JobList.js index c1d89ff718..c2b2d7b472 100644 --- a/awx/ui/src/components/JobList/JobList.js +++ b/awx/ui/src/components/JobList/JobList.js @@ -106,8 +106,12 @@ function JobList({ 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] // eslint-disable-line react-hooks/exhaustive-deps ); diff --git a/awx/ui/src/components/JobList/useWsJobs.js b/awx/ui/src/components/JobList/useWsJobs.js index b2173950cc..0d60868c87 100644 --- a/awx/ui/src/components/JobList/useWsJobs.js +++ b/awx/ui/src/components/JobList/useWsJobs.js @@ -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 {