From 7a0f7d06447a1f7bc8f4583d91ec7e4e40b70989 Mon Sep 17 00:00:00 2001 From: Mikhail Shustov Date: Fri, 3 Apr 2020 15:26:55 +0200 Subject: [PATCH] tranform management section lazy loading (#62408) (#62423) --- .../public/app/mount_management_section.ts | 52 +++++++++++++++++++ x-pack/plugins/transform/public/plugin.ts | 41 ++------------- 2 files changed, 55 insertions(+), 38 deletions(-) create mode 100644 x-pack/plugins/transform/public/app/mount_management_section.ts 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); }, }); }