From 3c8d6b41196b3d2bb3f20759a9631dbda705a4ec Mon Sep 17 00:00:00 2001 From: Alex Khomenko Date: Wed, 2 Apr 2025 15:41:21 +0300 Subject: [PATCH] Provisioning: Fix getting finished job status (#103272) * Provisioning: Improve finished job handling * Misc * Refactor --- public/app/features/provisioning/Job/JobStatus.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/public/app/features/provisioning/Job/JobStatus.tsx b/public/app/features/provisioning/Job/JobStatus.tsx index 0d4fba4b113..d5e84a06673 100644 --- a/public/app/features/provisioning/Job/JobStatus.tsx +++ b/public/app/features/provisioning/Job/JobStatus.tsx @@ -28,11 +28,12 @@ export function JobStatus({ watch, onStatusChange, onRunningChange, onErrorChang watch: true, }); const activeJob = activeQuery?.data?.items?.[0]; + const repoLabel = watch.metadata?.labels?.['provisioning.grafana.app/repository']; const finishedQuery = useGetRepositoryJobsWithPathQuery( - activeJob + activeJob || activeQuery.isUninitialized || activeQuery.isLoading || !repoLabel ? skipToken : { - name: watch.metadata?.labels?.['provisioning.grafana.app/repository']!, + name: repoLabel, uid: watch.metadata?.uid!, } ); @@ -40,7 +41,7 @@ export function JobStatus({ watch, onStatusChange, onRunningChange, onErrorChang const job = activeJob || finishedQuery.data; useEffect(() => { - if (!job) { + if (!job && !finishedQuery.isUninitialized) { finishedQuery.refetch(); } }, [finishedQuery, job]); @@ -122,7 +123,7 @@ export function JobStatus({ watch, onStatusChange, onRunningChange, onErrorChang ) : ( -
{JSON.stringify(job, null, ' ')}
+
{JSON.stringify(job, null, 2)}
)}