mirror of
https://github.com/elastic/kibana.git
synced 2025-06-28 11:05:39 -04:00
Changes 1. expose DashboardRenderer as lazy loaded component to reduce static page load size 2. Use `onApiAvailable` prop to pass DashboardApi to parent instead of `forwardRef` 3. Decouple DashboardApi from legacy embeddable system. This changed functions such as `updateInput` and using redux `select` to access state. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
64 lines
2.4 KiB
TypeScript
64 lines
2.4 KiB
TypeScript
/*
|
||
* 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 { AppMountParameters, CoreSetup, CoreStart, Plugin } from '@kbn/core/public';
|
||
import { DashboardStart } from '@kbn/dashboard-plugin/public';
|
||
import type { DataPublicPluginStart } from '@kbn/data-plugin/public';
|
||
import type { DeveloperExamplesSetup } from '@kbn/developer-examples-plugin/public';
|
||
import { EmbeddableSetup } from '@kbn/embeddable-plugin/public';
|
||
import type { NavigationPublicPluginStart } from '@kbn/navigation-plugin/public';
|
||
import { FILTER_DEBUGGER_EMBEDDABLE_ID, PLUGIN_ID } from './constants';
|
||
import img from './portable_dashboard_image.png';
|
||
|
||
interface SetupDeps {
|
||
developerExamples: DeveloperExamplesSetup;
|
||
embeddable: EmbeddableSetup;
|
||
}
|
||
|
||
export interface StartDeps {
|
||
dashboard: DashboardStart;
|
||
data: DataPublicPluginStart;
|
||
navigation: NavigationPublicPluginStart;
|
||
}
|
||
|
||
export class PortableDashboardsExamplePlugin implements Plugin<void, void, SetupDeps, StartDeps> {
|
||
public setup(core: CoreSetup<StartDeps>, { developerExamples, embeddable }: SetupDeps) {
|
||
core.application.register({
|
||
id: PLUGIN_ID,
|
||
title: 'Portable dashboard examples',
|
||
visibleIn: [],
|
||
async mount(params: AppMountParameters) {
|
||
const [coreStart, depsStart] = await core.getStartServices();
|
||
const { renderApp } = await import('./app');
|
||
return renderApp(coreStart, depsStart, params);
|
||
},
|
||
});
|
||
|
||
developerExamples.register({
|
||
appId: PLUGIN_ID,
|
||
title: 'Portable Dashboards',
|
||
description: `Showcases different ways to embed a dashboard into your app`,
|
||
image: img,
|
||
});
|
||
|
||
embeddable.registerReactEmbeddableFactory(FILTER_DEBUGGER_EMBEDDABLE_ID, async () => {
|
||
const { factory } = await import('./filter_debugger_embeddable');
|
||
return factory;
|
||
});
|
||
}
|
||
|
||
public async start(core: CoreStart, deps: StartDeps) {
|
||
deps.dashboard.registerDashboardPanelPlacementSetting(FILTER_DEBUGGER_EMBEDDABLE_ID, () => ({
|
||
width: 48,
|
||
height: 12,
|
||
}));
|
||
}
|
||
|
||
public stop() {}
|
||
}
|