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)}
)}