Provisioning: Fix getting finished job status (#103272)
* Provisioning: Improve finished job handling * Misc * Refactor
This commit is contained in:
@@ -28,11 +28,12 @@ export function JobStatus({ watch, onStatusChange, onRunningChange, onErrorChang
|
|||||||
watch: true,
|
watch: true,
|
||||||
});
|
});
|
||||||
const activeJob = activeQuery?.data?.items?.[0];
|
const activeJob = activeQuery?.data?.items?.[0];
|
||||||
|
const repoLabel = watch.metadata?.labels?.['provisioning.grafana.app/repository'];
|
||||||
const finishedQuery = useGetRepositoryJobsWithPathQuery(
|
const finishedQuery = useGetRepositoryJobsWithPathQuery(
|
||||||
activeJob
|
activeJob || activeQuery.isUninitialized || activeQuery.isLoading || !repoLabel
|
||||||
? skipToken
|
? skipToken
|
||||||
: {
|
: {
|
||||||
name: watch.metadata?.labels?.['provisioning.grafana.app/repository']!,
|
name: repoLabel,
|
||||||
uid: watch.metadata?.uid!,
|
uid: watch.metadata?.uid!,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -40,7 +41,7 @@ export function JobStatus({ watch, onStatusChange, onRunningChange, onErrorChang
|
|||||||
const job = activeJob || finishedQuery.data;
|
const job = activeJob || finishedQuery.data;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!job) {
|
if (!job && !finishedQuery.isUninitialized) {
|
||||||
finishedQuery.refetch();
|
finishedQuery.refetch();
|
||||||
}
|
}
|
||||||
}, [finishedQuery, job]);
|
}, [finishedQuery, job]);
|
||||||
@@ -122,7 +123,7 @@ export function JobStatus({ watch, onStatusChange, onRunningChange, onErrorChang
|
|||||||
<RepositoryLink name={job.metadata?.labels?.repository} />
|
<RepositoryLink name={job.metadata?.labels?.repository} />
|
||||||
) : (
|
) : (
|
||||||
<ControlledCollapse label={t('provisioning.job-status.label-view-details', 'View details')} isOpen={false}>
|
<ControlledCollapse label={t('provisioning.job-status.label-view-details', 'View details')} isOpen={false}>
|
||||||
<pre>{JSON.stringify(job, null, ' ')}</pre>
|
<pre>{JSON.stringify(job, null, 2)}</pre>
|
||||||
</ControlledCollapse>
|
</ControlledCollapse>
|
||||||
)}
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
Reference in New Issue
Block a user