diff --git a/x-pack/plugins/transform/public/app/mount_management_section.ts b/x-pack/plugins/transform/public/app/mount_management_section.ts new file mode 100644 index 0000000000000..f3a48975a68e6 --- /dev/null +++ b/x-pack/plugins/transform/public/app/mount_management_section.ts @@ -0,0 +1,52 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import { CoreSetup } from 'src/core/public'; +import { ManagementAppMountParams } from '../../../../../src/plugins/management/public/'; +import { Storage } from '../../../../../src/plugins/kibana_utils/public'; + +import { PluginsDependencies } from '../plugin'; + +import { AppDependencies } from './app_dependencies'; +import { breadcrumbService } from './services/navigation'; +import { docTitleService } from './services/navigation'; +import { textService } from './services/text'; +import { renderApp } from './app'; + +const localStorage = new Storage(window.localStorage); + +export async function mountManagementSection( + coreSetup: CoreSetup, + params: ManagementAppMountParams +) { + const { element, setBreadcrumbs } = params; + const { http, notifications, getStartServices } = coreSetup; + const startServices = await getStartServices(); + const [core, plugins] = startServices; + const { chrome, docLinks, i18n, overlays, savedObjects, uiSettings } = core; + const { data } = plugins; + const { docTitle } = chrome; + + // Initialize services + textService.init(); + docTitleService.init(docTitle.change); + breadcrumbService.setup(setBreadcrumbs); + + // AppCore/AppPlugins to be passed on as React context + const appDependencies: AppDependencies = { + chrome, + data, + docLinks, + http, + i18n, + notifications, + overlays, + savedObjects, + storage: localStorage, + uiSettings, + }; + + return renderApp(element, appDependencies); +} diff --git a/x-pack/plugins/transform/public/plugin.ts b/x-pack/plugins/transform/public/plugin.ts index 9a83f5b0e05f3..cfe84a5ab693d 100644 --- a/x-pack/plugins/transform/public/plugin.ts +++ b/x-pack/plugins/transform/public/plugin.ts @@ -9,16 +9,6 @@ import { CoreSetup } from 'src/core/public'; import { DataPublicPluginStart } from 'src/plugins/data/public'; import { ManagementSetup } from 'src/plugins/management/public'; -import { Storage } from '../../../../src/plugins/kibana_utils/public'; - -import { renderApp } from './app/app'; -import { AppDependencies } from './app/app_dependencies'; -import { breadcrumbService } from './app/services/navigation'; -import { docTitleService } from './app/services/navigation'; -import { textService } from './app/services/text'; - -const localStorage = new Storage(window.localStorage); - export interface PluginsDependencies { data: DataPublicPluginStart; management: ManagementSetup; @@ -37,34 +27,9 @@ export class TransformUiPlugin { defaultMessage: 'Transforms', }), order: 3, - mount: async ({ element, setBreadcrumbs }) => { - const { http, notifications, getStartServices } = coreSetup; - const startServices = await getStartServices(); - const [core, plugins] = startServices; - const { chrome, docLinks, i18n, overlays, savedObjects, uiSettings } = core; - const { data } = plugins; - const { docTitle } = chrome; - - // Initialize services - textService.init(); - docTitleService.init(docTitle.change); - breadcrumbService.setup(setBreadcrumbs); - - // AppCore/AppPlugins to be passed on as React context - const appDependencies: AppDependencies = { - chrome, - data, - docLinks, - http, - i18n, - notifications, - overlays, - savedObjects, - storage: localStorage, - uiSettings, - }; - - return renderApp(element, appDependencies); + mount: async params => { + const { mountManagementSection } = await import('./app/mount_management_section'); + return mountManagementSection(coreSetup, params); }, }); }