kibana/examples/embeddable_explorer/public/plugin.tsx
Anton Dosov 65fd7ad260
Clean up saved object based embeddable examples (#162987)
## Summary

These examples are outdated and don't show recent embeddable best
practices. They also use client-side saved object client and block
making `SavedObjectFinder` backward compatible
https://github.com/elastic/kibana/pull/162904 as the `foobar` saved
objects need to be added to content management. We decided that it is
better to clean them up, as fixing them is not a small effort and it is
not worth it on this point as a large embeddable refactor is coming.
2023-08-03 03:14:36 -07:00

82 lines
3.1 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 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 or the Server
* Side Public License, v 1.
*/
import { EmbeddableExamplesStart } from '@kbn/embeddable-examples-plugin/public/plugin';
import { Plugin, CoreSetup, AppMountParameters, AppNavLinkStatus } from '@kbn/core/public';
import { UiActionsService } from '@kbn/ui-actions-plugin/public';
import { EmbeddableStart } from '@kbn/embeddable-plugin/public';
import { Start as InspectorStart } from '@kbn/inspector-plugin/public';
import { DeveloperExamplesSetup } from '@kbn/developer-examples-plugin/public';
import img from './embeddables.png';
interface StartDeps {
uiActions: UiActionsService;
embeddable: EmbeddableStart;
inspector: InspectorStart;
embeddableExamples: EmbeddableExamplesStart;
}
interface SetupDeps {
developerExamples: DeveloperExamplesSetup;
}
export class EmbeddableExplorerPlugin implements Plugin<void, void, {}, StartDeps> {
public setup(core: CoreSetup<StartDeps>, { developerExamples }: SetupDeps) {
core.application.register({
id: 'embeddableExplorer',
title: 'Embeddable explorer',
navLinkStatus: AppNavLinkStatus.hidden,
async mount(params: AppMountParameters) {
const [coreStart, depsStart] = await core.getStartServices();
const { renderApp } = await import('./app');
try {
await depsStart.embeddableExamples.createSampleData();
} catch (error) {
// eslint-disable-next-line no-console
console.error('Failed to create sample data', error);
}
return renderApp(
{
notifications: coreStart.notifications,
inspector: depsStart.inspector,
embeddableApi: depsStart.embeddable,
uiActionsApi: depsStart.uiActions,
basename: params.appBasePath,
uiSettingsClient: coreStart.uiSettings,
overlays: coreStart.overlays,
navigateToApp: coreStart.application.navigateToApp,
embeddableExamples: depsStart.embeddableExamples,
},
params.element
);
},
});
developerExamples.register({
appId: 'embeddableExplorer',
title: 'Embeddables',
description: `Multiple embeddable examples showcase how to build custom dashboard widgets, how to build your own custom "container"
(like a dashboard but imagine you want to render the panels differently), and how to embed anything that can show up in a dashboard
in your own UI and app, that comes pre-connected with actions built by other developers.
`,
links: [
{
label: 'README',
href: 'https://github.com/elastic/kibana/tree/main/src/plugins/embeddable/README.asciidoc',
iconType: 'logoGithub',
target: '_blank',
size: 's',
},
],
image: img,
});
}
public start() {}
public stop() {}
}