Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ml async assets loading #62403

Merged
merged 1 commit into from
Apr 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions x-pack/plugins/ml/public/application/management/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ import { LICENSE_CHECK_STATE } from '../../../../licensing/public';
import { PLUGIN_ID, PLUGIN_ICON } from '../../../common/constants/app';
import { MINIMUM_FULL_LICENSE } from '../../../common/license';

import { getJobsListBreadcrumbs } from './breadcrumbs';
import { renderApp } from './jobs_list';

export function initManagementSection(
pluginsSetup: MlSetupDependencies,
core: CoreSetup<MlStartDependencies>
Expand All @@ -47,10 +44,9 @@ export function initManagementSection(
defaultMessage: 'Jobs list',
}),
order: 10,
async mount({ element, setBreadcrumbs }) {
const [coreStart] = await core.getStartServices();
setBreadcrumbs(getJobsListBreadcrumbs());
return renderApp(element, coreStart);
async mount(params) {
const { mountApp } = await import('./jobs_list');
return mountApp(core, params);
},
});
}
Expand Down
16 changes: 14 additions & 2 deletions x-pack/plugins/ml/public/application/management/jobs_list/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,25 @@

import ReactDOM, { unmountComponentAtNode } from 'react-dom';
import React from 'react';
import { CoreStart } from 'kibana/public';
import { CoreSetup, CoreStart } from 'kibana/public';
import { ManagementAppMountParams } from '../../../../../../../src/plugins/management/public/';
import { MlStartDependencies } from '../../../plugin';
import { JobsListPage } from './components';
import { getJobsListBreadcrumbs } from '../breadcrumbs';

export const renderApp = (element: HTMLElement, coreStart: CoreStart) => {
const renderApp = (element: HTMLElement, coreStart: CoreStart) => {
const I18nContext = coreStart.i18n.Context;
ReactDOM.render(React.createElement(JobsListPage, { I18nContext }), element);
return () => {
unmountComponentAtNode(element);
};
};

export async function mountApp(
core: CoreSetup<MlStartDependencies>,
params: ManagementAppMountParams
) {
const [coreStart] = await core.getStartServices();
params.setBreadcrumbs(getJobsListBreadcrumbs());
return renderApp(params.element, coreStart);
}