Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@
$: explore = useExplore(instanceId, exploreName, {
refetchInterval: (data) => {
if (!data) return false;
if (isDashboardReconcilingForFirstTime(data))
if (isExploreReconcilingForFirstTime(data))
return PollIntervalWhenDashboardFirstReconciling;
if (isDashboardErrored(data)) return PollIntervalWhenDashboardErrored;
if (isExploreErrored(data)) return PollIntervalWhenDashboardErrored;
return false;
},
});
Expand Down Expand Up @@ -92,38 +92,30 @@
}
});

function isDashboardReconcilingForFirstTime(
function isExploreReconcilingForFirstTime(
exploreResponse: V1GetExploreResponse,
) {
if (!exploreResponse) return undefined;
const isMetricsViewReconcilingForFirstTime =
!exploreResponse.metricsView?.metricsView?.state?.validSpec &&
!exploreResponse.metricsView?.meta?.reconcileError;
const isExploreReconcilingForFirstTime =
!exploreResponse.explore?.explore?.state?.validSpec &&
!exploreResponse.explore?.meta?.reconcileError;
return (
isMetricsViewReconcilingForFirstTime || isExploreReconcilingForFirstTime
);
return isExploreReconcilingForFirstTime;
}

function isDashboardErrored(exploreResponse: V1GetExploreResponse) {
function isExploreErrored(exploreResponse: V1GetExploreResponse) {
if (!exploreResponse) return undefined;
// We only consider a dashboard errored (from the end-user perspective) when BOTH a reconcile error exists AND a validSpec does not exist.
// If there's any validSpec (which can persist from a previous, non-current spec), then we serve that version of the dashboard to the user,
// so the user does not see an error state.
const isMetricsViewErrored =
!exploreResponse.metricsView?.metricsView?.state?.validSpec &&
!!exploreResponse.metricsView?.meta?.reconcileError;
const isExploreErrored =
!exploreResponse.explore?.explore?.state?.validSpec &&
!!exploreResponse.explore?.meta?.reconcileError;
return isMetricsViewErrored || isExploreErrored;
return isExploreErrored;
}

let reconcilingForFirstTime: boolean | undefined;
$: if ($explore.isSuccess) {
const newReconcilingForFirstTime = isDashboardReconcilingForFirstTime(
const newReconcilingForFirstTime = isExploreReconcilingForFirstTime(
$explore.data,
);
// reconcilingForFirstTime means the dashboard is reconciling for the 1st time in the current deployment.
Expand All @@ -144,9 +136,9 @@
</svelte:head>

{#if $explore.isSuccess}
{#if isDashboardReconcilingForFirstTime($explore.data)}
{#if isExploreReconcilingForFirstTime($explore.data)}
<DashboardBuilding />
{:else if isDashboardErrored($explore.data)}
{:else if isExploreErrored($explore.data)}
<DashboardErrored organization={orgName} project={projectName} />
{:else if metricsViewName}
{#key exploreName}
Expand Down
Loading