From 396c30fecc8c5bcd2c6767bf2232f22fbb0f9c10 Mon Sep 17 00:00:00 2001
From: Taras-Hlukhovetskyi
<155433425+Taras-Hlukhovetskyi@users.noreply.github.com>
Date: Wed, 8 Jan 2025 13:31:04 +0200
Subject: [PATCH] Fix [Job Artifacts] artifacts tab fails to load for workflow
job (#2995)
---
.../DetailsArtifacts/DetailsArtifacts.js | 45 ++++++++++---------
src/components/JobWizard/JobWizard.js | 1 +
src/components/Jobs/Jobs.js | 15 ++++---
.../ProjectsJobsMonitoring.js | 16 ++++++-
.../WorkflowsMonitoring.js | 4 --
src/elements/JobsTable/JobsTable.js | 4 +-
src/elements/WorkflowsTable/WorkflowsTable.js | 8 ++--
src/reducers/jobReducer.js | 31 +++++++++----
8 files changed, 76 insertions(+), 48 deletions(-)
diff --git a/src/components/DetailsArtifacts/DetailsArtifacts.js b/src/components/DetailsArtifacts/DetailsArtifacts.js
index bfd9a0048..fd29e618c 100644
--- a/src/components/DetailsArtifacts/DetailsArtifacts.js
+++ b/src/components/DetailsArtifacts/DetailsArtifacts.js
@@ -68,6 +68,7 @@ const DetailsArtifacts = ({
const dispatch = useDispatch()
const artifactsStore = useSelector(store => store.artifactsStore)
+ const isJobLoading = useSelector(store => Boolean(store.jobsStore.jobLoadingCounter))
const showArtifact = useCallback(
id => {
@@ -148,7 +149,7 @@ const DetailsArtifacts = ({
if (workflowId) {
return dispatch(
- fetchJob({
+ fetchJob({ // todo remove this request in ML-8608 and use data from the selectedJob (it will be up to date)
project: job.project || params.projectName,
jobId: params.jobId,
iter: iteration
@@ -166,39 +167,39 @@ const DetailsArtifacts = ({
}
}
)
- }
+ } else {
+ if (iteration) {
+ config.params.iter = iteration
+ }
- if (iteration) {
- config.params.iter = iteration
+ dispatch(
+ fetchArtifacts({
+ project: job.project || params.projectName,
+ filters: {},
+ config,
+ setRequestErrorMessage
+ })
+ )
+ .unwrap()
+ .then(result => {
+ if (result) {
+ setArtifactsPreviewContent(generateArtifactsPreviewContent(job, result))
+ }
+ })
}
-
- dispatch(
- fetchArtifacts({
- project: job.project || params.projectName,
- filters: {},
- config,
- setRequestErrorMessage
- })
- )
- .unwrap()
- .then(result => {
- if (result) {
- setArtifactsPreviewContent(generateArtifactsPreviewContent(job, result))
- }
- })
},
[dispatch, params.jobId, params.projectName]
)
useEffect(() => {
- if (params.jobId === selectedItem.uid || isDetailsPopUp) {
+ if ((params.jobId === selectedItem.uid || isDetailsPopUp) && !isJobLoading) {
if (selectedItem.iterationStats?.length > 0 && iteration) {
getJobArtifacts(selectedItem, iteration)
} else if (selectedItem.iterationStats?.length === 0) {
getJobArtifacts(selectedItem, null)
}
}
- }, [getJobArtifacts, iteration, params.jobId, params.projectName, selectedItem, isDetailsPopUp])
+ }, [getJobArtifacts, iteration, params.jobId, params.projectName, selectedItem, isDetailsPopUp, isJobLoading])
useEffect(() => {
return () => {
@@ -208,7 +209,7 @@ const DetailsArtifacts = ({
}, [params.jobId, params.projectName, selectedItem, iteration])
return artifactsStore.loading ? (
-
+
) : artifactsPreviewContent.length === 0 ? (
) : (
diff --git a/src/components/JobWizard/JobWizard.js b/src/components/JobWizard/JobWizard.js
index bd6179bdb..fb61aa02e 100644
--- a/src/components/JobWizard/JobWizard.js
+++ b/src/components/JobWizard/JobWizard.js
@@ -545,6 +545,7 @@ const JobWizard = ({
{(functionsStore.loading ||
functionsStore.funcLoading ||
jobsStore.loading ||
+ Boolean(jobsStore.jobLoadingCounter) ||
projectIsLoading) && }
>
)
diff --git a/src/components/Jobs/Jobs.js b/src/components/Jobs/Jobs.js
index deafc0a68..b212dd3be 100755
--- a/src/components/Jobs/Jobs.js
+++ b/src/components/Jobs/Jobs.js
@@ -143,7 +143,10 @@ const Jobs = () => {
return defaultsDeep(
{
[MONITOR_JOBS_TAB]: {
- handleRefresh: handleRefreshJobs
+ handleRefresh: (...args) => {
+ setSelectedJob({})
+ handleRefreshJobs(...args)
+ }
},
[MONITOR_WORKFLOWS_TAB]: {
handleRefresh: getWorkflows
@@ -231,7 +234,11 @@ const Jobs = () => {
onClick: () => handleMonitoring(selectedJob, true)
}
]}
- autoRefreshIsStopped={jobWizardIsOpened || jobsStore.loading}
+ autoRefreshIsStopped={
+ jobWizardIsOpened ||
+ jobsStore.loading ||
+ Boolean(jobsStore.jobLoadingCounter)
+ }
autoRefreshStopTrigger={!isEmpty(selectedJob)}
filters={filters}
filtersConfig={initialTabData[selectedTab].filtersConfig}
@@ -292,10 +299,8 @@ const Jobs = () => {
>
- {(jobsStore.loading ||
- workflowsStore.workflows.loading ||
+ {(Boolean(jobsStore.jobLoadingCounter) ||
workflowsStore.activeWorkflow.loading ||
- functionsStore.loading ||
functionsStore.funcLoading) && }
diff --git a/src/components/ProjectsJobsMonitoring/ProjectsJobsMonitoring.js b/src/components/ProjectsJobsMonitoring/ProjectsJobsMonitoring.js
index ddae3774b..15cdadca9 100644
--- a/src/components/ProjectsJobsMonitoring/ProjectsJobsMonitoring.js
+++ b/src/components/ProjectsJobsMonitoring/ProjectsJobsMonitoring.js
@@ -30,6 +30,7 @@ import ActionBar from '../ActionBar/ActionBar'
import JobsMonitoringFilters from './JobsMonitoring/JobsMonitoringFilters'
import ScheduledMonitoringFilters from './ScheduledMonitoring/ScheduledMonitoringFilters'
import WorkflowsMonitoringFilters from './WorkflowsMonitoring/WorkflowsMonitoringFilters'
+import Loader from '../../common/Loader/Loader'
import { STATS_TOTAL_CARD, tabs } from './projectsJobsMotinoring.util'
import {
@@ -67,6 +68,8 @@ const ProjectsJobsMonitoring = () => {
const navigate = useNavigate()
const artifactsStore = useSelector(store => store.artifactsStore)
const jobsStore = useSelector(store => store.jobsStore)
+ const workflowsStore = useSelector(store => store.workflowsStore)
+ const functionsStore = useSelector(store => store.functionsStore)
const jobsFiltersConfig = useMemo(
() => getJobsFiltersConfig(params.jobName, true),
@@ -145,7 +148,10 @@ const ProjectsJobsMonitoring = () => {
return defaultsDeep(
{
[JOBS_MONITORING_JOBS_TAB]: {
- handleRefresh: handleRefreshJobs
+ handleRefresh: (...args) => {
+ setSelectedJob({})
+ handleRefreshJobs(...args)
+ }
},
[JOBS_MONITORING_WORKFLOWS_TAB]: {
handleRefresh: getWorkflows
@@ -182,7 +188,10 @@ const ProjectsJobsMonitoring = () => {
{
>
+ {(Boolean(jobsStore.jobLoadingCounter) ||
+ workflowsStore.activeWorkflow.loading ||
+ functionsStore.funcLoading) && }
)}
diff --git a/src/components/ProjectsJobsMonitoring/WorkflowsMonitoring/WorkflowsMonitoring.js b/src/components/ProjectsJobsMonitoring/WorkflowsMonitoring/WorkflowsMonitoring.js
index 26afa4a8d..022a22cd8 100644
--- a/src/components/ProjectsJobsMonitoring/WorkflowsMonitoring/WorkflowsMonitoring.js
+++ b/src/components/ProjectsJobsMonitoring/WorkflowsMonitoring/WorkflowsMonitoring.js
@@ -24,7 +24,6 @@ import { isEmpty } from 'lodash'
import WorkflowsTable from '../../../elements/WorkflowsTable/WorkflowsTable'
import { ProjectJobsMonitoringContext } from '../ProjectsJobsMonitoring'
-import Loader from '../../../common/Loader/Loader'
import {
JOBS_MONITORING_PAGE,
@@ -46,8 +45,6 @@ const WorkflowsMonitoring = ({ fetchFunctionLogs }) => {
const [itemIsSelected, setItemIsSelected] = useState(false)
const [selectedJob, setSelectedJob] = useState({})
const workflowsStore = useSelector(state => state.workflowsStore)
- const jobIsLoading = useSelector(store => store.jobsStore.loading)
- const funcIsLoading = useSelector(store => store.functionsStore.funcLoading)
const params = useParams()
const dispatch = useDispatch()
const { isStagingMode } = useMode()
@@ -109,7 +106,6 @@ const WorkflowsMonitoring = ({ fetchFunctionLogs }) => {
return (
<>
- {(jobIsLoading || funcIsLoading || workflowsStore.activeWorkflow.loading) && }
{
+ useLayoutEffect(() => {
checkForSelectedJob(
paginatedJobs,
params.jobName,
diff --git a/src/elements/WorkflowsTable/WorkflowsTable.js b/src/elements/WorkflowsTable/WorkflowsTable.js
index 97c7ca9b1..391fa24b3 100644
--- a/src/elements/WorkflowsTable/WorkflowsTable.js
+++ b/src/elements/WorkflowsTable/WorkflowsTable.js
@@ -687,10 +687,10 @@ const WorkflowsTable = React.forwardRef(
return (
<>
{workflowsStore.workflows.loading && }
- {(!workflowsStore.workflows.loading &&
- !params.workflowId &&
- workflowsStore.workflows.data.length === 0) ||
- requestErrorMessage ? (
+ {workflowsStore.workflows.loading ? null : (!workflowsStore.workflows.loading &&
+ !params.workflowId &&
+ workflowsStore.workflows.data.length === 0) ||
+ requestErrorMessage ? (
{
+ state.jobLoadingCounter++
+ })
builder.addCase(fetchJob.fulfilled, (state, action) => {
state.error = null
state.job = action.payload
- state.loading = false
+ state.jobLoadingCounter--
+ })
+ builder.addCase(fetchJob.rejected, (state, action) => {
+ state.jobLoadingCounter--
+ })
+ builder.addCase(fetchJobFunction.pending, (state, action) => {
+ state.jobLoadingCounter++
})
- builder.addCase(fetchJob.rejected, hideLoading)
- builder.addCase(fetchJobFunction.pending, showLoading)
builder.addCase(fetchJobFunction.fulfilled, (state, action) => {
state.error = null
state.jobFunc = action.payload
- state.loading = false
+ state.jobLoadingCounter--
+ })
+ builder.addCase(fetchJobFunction.rejected, (state, action) => {
+ state.jobLoadingCounter--
+ })
+ builder.addCase(fetchJobFunctions.rejected, (state, action) => {
+ state.jobLoadingCounter--
+ })
+ builder.addCase(fetchJobFunctions.pending, (state, action) => {
+ state.jobLoadingCounter++
})
- builder.addCase(fetchJobFunction.rejected, hideLoading)
- builder.addCase(fetchJobFunctions.pending, showLoading)
builder.addCase(fetchJobFunctions.fulfilled, (state, action) => {
state.error = null
state.jobFunc = action.payload
- state.loading = false
+ state.jobLoadingCounter--
})
- builder.addCase(fetchJobFunctions.rejected, hideLoading)
builder.addCase(fetchJobLogs.pending, (state, action) => {
state.logs.loading = true
state.logs.error = null