mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[canvas] Reduce bundle by registering Canvas Plugin API on mount (#104264)
This commit is contained in:
parent
fa8dd5603e
commit
11b7e33a0e
4 changed files with 16 additions and 13 deletions
|
@ -34,7 +34,9 @@ interface Props {
|
|||
}
|
||||
|
||||
export function RenderExpressionsExample({ expressions, inspector }: Props) {
|
||||
const [expression, updateExpression] = useState('markdown "## expressions explorer rendering"');
|
||||
const [expression, updateExpression] = useState(
|
||||
'markdownVis "## expressions explorer rendering"'
|
||||
);
|
||||
|
||||
const expressionChanged = (value: string) => {
|
||||
updateExpression(value);
|
||||
|
|
|
@ -35,7 +35,7 @@ interface Props {
|
|||
}
|
||||
|
||||
export function RunExpressionsExample({ expressions, inspector }: Props) {
|
||||
const [expression, updateExpression] = useState('markdown "## expressions explorer"');
|
||||
const [expression, updateExpression] = useState('markdownVis "## expressions explorer"');
|
||||
const [result, updateResult] = useState<unknown>({});
|
||||
|
||||
const expressionChanged = (value: string) => {
|
||||
|
|
|
@ -22,7 +22,7 @@ export default function ({ getService }: PluginFunctionalProviderContext) {
|
|||
await retry.try(async () => {
|
||||
const text = await testSubjects.getVisibleText('expressionResult');
|
||||
expect(text).to.be(
|
||||
'{\n "type": "render",\n "as": "markdown",\n "value": {\n "content": "## expressions explorer",\n "font": {\n "type": "style",\n "spec": {\n "fontFamily": "\'Open Sans\', Helvetica, Arial, sans-serif",\n "fontWeight": "normal",\n "fontStyle": "normal",\n "textDecoration": "none",\n "textAlign": "left",\n "fontSize": "14px",\n "lineHeight": "1"\n },\n "css": "font-family:\'Open Sans\', Helvetica, Arial, sans-serif;font-weight:normal;font-style:normal;text-decoration:none;text-align:left;font-size:14px;line-height:1"\n },\n "openLinksInNewTab": false\n }\n}'
|
||||
'{\n "type": "render",\n "as": "markdown_vis",\n "value": {\n "visType": "markdown",\n "visParams": {\n "markdown": "## expressions explorer",\n "openLinksInNewTab": false,\n "fontSize": 12\n }\n }\n}'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -30,8 +30,6 @@ import { Start as InspectorStart } from '../../../../src/plugins/inspector/publi
|
|||
import { BfetchPublicSetup } from '../../../../src/plugins/bfetch/public';
|
||||
import { PresentationUtilPluginStart } from '../../../../src/plugins/presentation_util/public';
|
||||
import { getPluginApi, CanvasApi } from './plugin_api';
|
||||
import { CanvasSrcPlugin } from '../canvas_plugin_src/plugin';
|
||||
import { pluginServices } from './services';
|
||||
import { pluginServiceRegistry } from './services/kibana';
|
||||
|
||||
export { CoreStart, CoreSetup };
|
||||
|
@ -75,14 +73,10 @@ export type CanvasStart = void;
|
|||
export class CanvasPlugin
|
||||
implements Plugin<CanvasSetup, CanvasStart, CanvasSetupDeps, CanvasStartDeps> {
|
||||
private appUpdater = new BehaviorSubject<AppUpdater>(() => ({}));
|
||||
// TODO: Do we want to completely move canvas_plugin_src into it's own plugin?
|
||||
private srcPlugin = new CanvasSrcPlugin();
|
||||
|
||||
public setup(coreSetup: CoreSetup<CanvasStartDeps>, setupPlugins: CanvasSetupDeps) {
|
||||
const { api: canvasApi, registries } = getPluginApi(setupPlugins.expressions);
|
||||
|
||||
this.srcPlugin.setup(coreSetup, { canvas: canvasApi });
|
||||
|
||||
// Set the nav link to the last saved url if we have one in storage
|
||||
const lastPath = getSessionStorage().get(
|
||||
`${SESSIONSTORAGE_LASTPATH}:${coreSetup.http.basePath.get()}`
|
||||
|
@ -101,12 +95,21 @@ export class CanvasPlugin
|
|||
order: 3000,
|
||||
updater$: this.appUpdater,
|
||||
mount: async (params: AppMountParameters) => {
|
||||
// Load application bundle
|
||||
const { renderApp, initializeCanvas, teardownCanvas } = await import('./application');
|
||||
const { CanvasSrcPlugin } = await import('../canvas_plugin_src/plugin');
|
||||
const srcPlugin = new CanvasSrcPlugin();
|
||||
srcPlugin.setup(coreSetup, { canvas: canvasApi });
|
||||
|
||||
// Get start services
|
||||
const [coreStart, startPlugins] = await coreSetup.getStartServices();
|
||||
|
||||
srcPlugin.start(coreStart, startPlugins);
|
||||
|
||||
const { pluginServices } = await import('./services');
|
||||
pluginServices.setRegistry(pluginServiceRegistry.start({ coreStart, startPlugins }));
|
||||
|
||||
// Load application bundle
|
||||
const { renderApp, initializeCanvas, teardownCanvas } = await import('./application');
|
||||
|
||||
const canvasStore = await initializeCanvas(
|
||||
coreSetup,
|
||||
coreStart,
|
||||
|
@ -145,8 +148,6 @@ export class CanvasPlugin
|
|||
}
|
||||
|
||||
public start(coreStart: CoreStart, startPlugins: CanvasStartDeps) {
|
||||
this.srcPlugin.start(coreStart, startPlugins);
|
||||
pluginServices.setRegistry(pluginServiceRegistry.start({ coreStart, startPlugins }));
|
||||
initLoadingIndicator(coreStart.http.addLoadingCountSource);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue