forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove dashboard embeddable (elastic#194892)
Closes elastic#197281 PR replaces `DashboardContainer`, which implements legacy Container and Embeddable interfaces, with plain old javascript object implementation returned from `getDashboardApi`. The following are out of scope for this PR and will be accomplished at a later time: 1) re-factoring dashboard folder structure 2) removing all uses of Embeddable and EmbeddableInput types 3) removing legacy types like DashboardContainerInput --------- Co-authored-by: Elastic Machine <[email protected]> Co-authored-by: kibanamachine <[email protected]> Co-authored-by: Hannah Mudge <[email protected]> Co-authored-by: Devon Thomson <[email protected]>
- Loading branch information
1 parent
9d8783d
commit 93c3deb
Showing
82 changed files
with
2,470 additions
and
5,212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
src/plugins/dashboard/public/dashboard_api/data_loading_manager.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the "Elastic License | ||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
* Public License v 1"; you may not use this file except in compliance with, at | ||
* your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
import { BehaviorSubject, debounceTime, first, map } from 'rxjs'; | ||
import { | ||
PublishesDataLoading, | ||
PublishingSubject, | ||
apiPublishesDataLoading, | ||
} from '@kbn/presentation-publishing'; | ||
import { combineCompatibleChildrenApis } from '@kbn/presentation-containers'; | ||
|
||
export function initializeDataLoadingManager( | ||
children$: PublishingSubject<{ [key: string]: unknown }> | ||
) { | ||
const dataLoading$ = new BehaviorSubject<boolean | undefined>(undefined); | ||
|
||
const dataLoadingSubscription = combineCompatibleChildrenApis< | ||
PublishesDataLoading, | ||
boolean | undefined | ||
>( | ||
{ children$ }, | ||
'dataLoading', | ||
apiPublishesDataLoading, | ||
undefined, | ||
// flatten method | ||
(values) => { | ||
return values.some((isLoading) => isLoading); | ||
} | ||
).subscribe((isAtLeastOneChildLoading) => { | ||
dataLoading$.next(isAtLeastOneChildLoading); | ||
}); | ||
|
||
return { | ||
api: { | ||
dataLoading: dataLoading$, | ||
}, | ||
internalApi: { | ||
waitForPanelsToLoad$: dataLoading$.pipe( | ||
// debounce to give time for panels to start loading if they are going to load | ||
debounceTime(300), | ||
first((isLoading: boolean | undefined) => { | ||
return !isLoading; | ||
}), | ||
map(() => { | ||
// Observable notifies subscriber when loading is finished | ||
// Return void to not expose internal implementation details of observable | ||
return; | ||
}) | ||
), | ||
}, | ||
cleanup: () => { | ||
dataLoadingSubscription.unsubscribe(); | ||
}, | ||
}; | ||
} |
72 changes: 72 additions & 0 deletions
72
src/plugins/dashboard/public/dashboard_api/data_views_manager.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the "Elastic License | ||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
* Public License v 1"; you may not use this file except in compliance with, at | ||
* your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
import { uniqBy } from 'lodash'; | ||
import { BehaviorSubject, combineLatest, Observable, of, switchMap } from 'rxjs'; | ||
|
||
import { DataView } from '@kbn/data-views-plugin/common'; | ||
import { combineCompatibleChildrenApis } from '@kbn/presentation-containers'; | ||
import { | ||
apiPublishesDataViews, | ||
PublishesDataViews, | ||
PublishingSubject, | ||
} from '@kbn/presentation-publishing'; | ||
|
||
import { ControlGroupApi } from '@kbn/controls-plugin/public'; | ||
import { dataService } from '../services/kibana_services'; | ||
|
||
export function initializeDataViewsManager( | ||
controlGroupApi$: PublishingSubject<ControlGroupApi | undefined>, | ||
children$: PublishingSubject<{ [key: string]: unknown }> | ||
) { | ||
const dataViews = new BehaviorSubject<DataView[] | undefined>([]); | ||
|
||
const controlGroupDataViewsPipe: Observable<DataView[] | undefined> = controlGroupApi$.pipe( | ||
switchMap((controlGroupApi) => { | ||
return controlGroupApi ? controlGroupApi.dataViews : of([]); | ||
}) | ||
); | ||
|
||
const childDataViewsPipe = combineCompatibleChildrenApis<PublishesDataViews, DataView[]>( | ||
{ children$ }, | ||
'dataViews', | ||
apiPublishesDataViews, | ||
[] | ||
); | ||
|
||
const dataViewsSubscription = combineLatest([controlGroupDataViewsPipe, childDataViewsPipe]) | ||
.pipe( | ||
switchMap(async ([controlGroupDataViews, childDataViews]) => { | ||
const allDataViews = [...(controlGroupDataViews ?? []), ...childDataViews]; | ||
if (allDataViews.length === 0) { | ||
try { | ||
const defaultDataView = await dataService.dataViews.getDefaultDataView(); | ||
if (defaultDataView) { | ||
allDataViews.push(defaultDataView); | ||
} | ||
} catch (error) { | ||
// ignore error getting default data view | ||
} | ||
} | ||
return uniqBy(allDataViews, 'id'); | ||
}) | ||
) | ||
.subscribe((newDataViews) => { | ||
dataViews.next(newDataViews); | ||
}); | ||
|
||
return { | ||
api: { | ||
dataViews, | ||
}, | ||
cleanup: () => { | ||
dataViewsSubscription.unsubscribe(); | ||
}, | ||
}; | ||
} |
Oops, something went wrong.