Skip to content

Commit

Permalink
tranform management section lazy loading
Browse files Browse the repository at this point in the history
  • Loading branch information
mshustov committed Apr 3, 2020
1 parent 60901b3 commit 58ffbc3
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 38 deletions.
52 changes: 52 additions & 0 deletions x-pack/plugins/transform/public/app/mount_management_section.ts
Original file line number Diff line number Diff line change
@@ -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<PluginsDependencies>,
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);
}
41 changes: 3 additions & 38 deletions x-pack/plugins/transform/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
},
});
}
Expand Down

0 comments on commit 58ffbc3

Please sign in to comment.