From 38079b2ad58919b4b69fe96a8d315e71774ffe98 Mon Sep 17 00:00:00 2001 From: Keith Grant Date: Fri, 5 Jun 2020 14:57:45 -0700 Subject: [PATCH] =?UTF-8?q?don=E2=80=99t=20add=20still=20running=20jobs=20?= =?UTF-8?q?to=20some=20jobs=20lists?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- awx/ui_next/src/components/JobList/JobList.jsx | 2 +- awx/ui_next/src/components/JobList/useWsJobs.js | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/awx/ui_next/src/components/JobList/JobList.jsx b/awx/ui_next/src/components/JobList/JobList.jsx index ccbb32159b..694d250b32 100644 --- a/awx/ui_next/src/components/JobList/JobList.jsx +++ b/awx/ui_next/src/components/JobList/JobList.jsx @@ -54,7 +54,7 @@ function JobList({ i18n, defaultParams, showTypeColumn = false }) { fetchJobs(); }, [fetchJobs]); - const jobs = useWsJobs(results, fetchJobs); + const jobs = useWsJobs(results, fetchJobs, !!defaultParams); const isAllSelected = selected.length === jobs.length && selected.length > 0; const { diff --git a/awx/ui_next/src/components/JobList/useWsJobs.js b/awx/ui_next/src/components/JobList/useWsJobs.js index 839ccd02af..8296dbd4de 100644 --- a/awx/ui_next/src/components/JobList/useWsJobs.js +++ b/awx/ui_next/src/components/JobList/useWsJobs.js @@ -1,6 +1,6 @@ import { useState, useEffect, useRef } from 'react'; -export default function useWsJobs(initialJobs, refetchJobs) { +export default function useWsJobs(initialJobs, refetchJobs, filtersApplied) { const [jobs, setJobs] = useState(initialJobs); const [lastMessage, setLastMessage] = useState(null); useEffect(() => { @@ -13,6 +13,12 @@ export default function useWsJobs(initialJobs, refetchJobs) { if (!lastMessage || !lastMessage.unified_job_id) { return; } + if (filtersApplied) { + if (['completed', 'failed', 'error'].includes(lastMessage.status)) { + refetchJobs(); + } + return; + } const jobId = lastMessage.unified_job_id; const index = jobs.findIndex(j => j.id === jobId);