Skip to content

Commit

Permalink
🐛 Fix dashboard hook state for missing dataviews (#144005)
Browse files Browse the repository at this point in the history
  • Loading branch information
dej611 authored Oct 26, 2022
1 parent 8176ac7 commit 71f376f
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { useCallback, useEffect, useMemo, useState } from 'react';
import { BehaviorSubject, combineLatest, Observable, Subject } from 'rxjs';

import { ViewMode } from '@kbn/embeddable-plugin/public';
import type { DataView } from '@kbn/data-plugin/common';
import type { IKbnUrlStateStorage } from '@kbn/kibana-utils-plugin/public';

import {
Expand Down Expand Up @@ -225,7 +226,14 @@ export const useDashboardAppState = ({
dashboardContainer.controlGroup?.setRelevantDataViewId(newDataViewIds[0]);
}
// fetch all data views. These should be cached locally at this time so we will not need to query ES.
const allDataViews = await Promise.all(newDataViewIds.map((id) => dataViews.get(id)));
const responses = await Promise.allSettled(newDataViewIds.map((id) => dataViews.get(id)));
// Keep only fullfilled ones as each panel will handle the rejected ones already on their own
const allDataViews = responses
.filter(
(response): response is PromiseFulfilledResult<DataView> =>
response.status === 'fulfilled'
)
.map(({ value }) => value);
dashboardContainer.setAllDataViews(allDataViews);
setDashboardAppState((s) => ({ ...s, dataViews: allDataViews }));
},
Expand Down

0 comments on commit 71f376f

Please sign in to comment.