mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
🐛 Fix dashboard hook state for missing dataviews (#144005)
This commit is contained in:
parent
8176ac74f0
commit
71f376f6d9
1 changed files with 9 additions and 1 deletions
|
@ -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 {
|
||||
|
@ -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 }));
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue