diff --git a/x-pack/plugins/reporting/public/components/panel_spinner.tsx b/x-pack/plugins/reporting/public/components/panel_spinner.tsx
new file mode 100644
index 000000000000..841b7063361b
--- /dev/null
+++ b/x-pack/plugins/reporting/public/components/panel_spinner.tsx
@@ -0,0 +1,22 @@
+/*
+ * 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 * as React from 'react';
+import { EuiSpacer, EuiFlexGroup, EuiFlexItem, EuiLoadingSpinner } from '@elastic/eui';
+
+export const PanelSpinner: React.FC = (props) => {
+ return (
+ <>
+
+
+
+
+
+
+
+ >
+ );
+};
diff --git a/x-pack/plugins/reporting/public/components/reporting_panel_content.tsx b/x-pack/plugins/reporting/public/components/reporting_panel_content.tsx
index 22b97f45db18..18895f9e623e 100644
--- a/x-pack/plugins/reporting/public/components/reporting_panel_content.tsx
+++ b/x-pack/plugins/reporting/public/components/reporting_panel_content.tsx
@@ -13,7 +13,7 @@ import { toMountPoint } from '../../../../../src/plugins/kibana_react/public';
import { BaseParams } from '../../common/types';
import { ReportingAPIClient } from '../lib/reporting_api_client';
-interface Props {
+export interface Props {
apiClient: ReportingAPIClient;
toasts: ToastsSetup;
reportType: string;
diff --git a/x-pack/plugins/reporting/public/components/reporting_panel_content_lazy.tsx b/x-pack/plugins/reporting/public/components/reporting_panel_content_lazy.tsx
new file mode 100644
index 000000000000..45a7d60a6096
--- /dev/null
+++ b/x-pack/plugins/reporting/public/components/reporting_panel_content_lazy.tsx
@@ -0,0 +1,24 @@
+/*
+ * 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 * as React from 'react';
+import { lazy, Suspense, FC } from 'react';
+import { PanelSpinner } from './panel_spinner';
+import type { Props } from './reporting_panel_content';
+
+const LazyComponent = lazy(() =>
+ import('./reporting_panel_content').then(({ ReportingPanelContent }) => ({
+ default: ReportingPanelContent,
+ }))
+);
+
+export const ReportingPanelContent: FC> = (props) => {
+ return (
+ }>
+
+
+ );
+};
diff --git a/x-pack/plugins/reporting/public/components/screen_capture_panel_content.tsx b/x-pack/plugins/reporting/public/components/screen_capture_panel_content.tsx
index 4a62ab2b7650..ff81ced43e0b 100644
--- a/x-pack/plugins/reporting/public/components/screen_capture_panel_content.tsx
+++ b/x-pack/plugins/reporting/public/components/screen_capture_panel_content.tsx
@@ -12,7 +12,7 @@ import { BaseParams } from '../../common/types';
import { ReportingAPIClient } from '../lib/reporting_api_client';
import { ReportingPanelContent } from './reporting_panel_content';
-interface Props {
+export interface Props {
apiClient: ReportingAPIClient;
toasts: ToastsSetup;
reportType: string;
diff --git a/x-pack/plugins/reporting/public/components/screen_capture_panel_content_lazy.tsx b/x-pack/plugins/reporting/public/components/screen_capture_panel_content_lazy.tsx
new file mode 100644
index 000000000000..52080e16dd6a
--- /dev/null
+++ b/x-pack/plugins/reporting/public/components/screen_capture_panel_content_lazy.tsx
@@ -0,0 +1,24 @@
+/*
+ * 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 * as React from 'react';
+import { lazy, Suspense, FC } from 'react';
+import { PanelSpinner } from './panel_spinner';
+import type { Props } from './screen_capture_panel_content';
+
+const LazyComponent = lazy(() =>
+ import('./screen_capture_panel_content').then(({ ScreenCapturePanelContent }) => ({
+ default: ScreenCapturePanelContent,
+ }))
+);
+
+export const ScreenCapturePanelContent: FC = (props) => {
+ return (
+ }>
+
+
+ );
+};
diff --git a/x-pack/plugins/reporting/public/mount_management_section.tsx b/x-pack/plugins/reporting/public/mount_management_section.tsx
new file mode 100644
index 000000000000..ac737e4a318a
--- /dev/null
+++ b/x-pack/plugins/reporting/public/mount_management_section.tsx
@@ -0,0 +1,42 @@
+/*
+ * 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 * as React from 'react';
+import { render, unmountComponentAtNode } from 'react-dom';
+import { I18nProvider } from '@kbn/i18n/react';
+import { CoreSetup, CoreStart } from 'src/core/public';
+import { Observable } from 'rxjs';
+import { ReportListing } from './components/report_listing';
+import { ManagementAppMountParams } from '../../../../src/plugins/management/public';
+import { ILicense } from '../../licensing/public';
+import { ClientConfigType } from './plugin';
+import { ReportingAPIClient } from './lib/reporting_api_client';
+
+export async function mountManagementSection(
+ coreSetup: CoreSetup,
+ coreStart: CoreStart,
+ license$: Observable,
+ pollConfig: ClientConfigType['poll'],
+ apiClient: ReportingAPIClient,
+ params: ManagementAppMountParams
+) {
+ render(
+
+
+ ,
+ params.element
+ );
+
+ return () => {
+ unmountComponentAtNode(params.element);
+ };
+}
diff --git a/x-pack/plugins/reporting/public/plugin.tsx b/x-pack/plugins/reporting/public/plugin.ts
similarity index 78%
rename from x-pack/plugins/reporting/public/plugin.tsx
rename to x-pack/plugins/reporting/public/plugin.ts
index cc5964f73798..33f4fd4abf72 100644
--- a/x-pack/plugins/reporting/public/plugin.tsx
+++ b/x-pack/plugins/reporting/public/plugin.ts
@@ -5,9 +5,6 @@
*/
import { i18n } from '@kbn/i18n';
-import { I18nProvider } from '@kbn/i18n/react';
-import React from 'react';
-import ReactDOM from 'react-dom';
import * as Rx from 'rxjs';
import { catchError, filter, map, mergeMap, takeUntil } from 'rxjs/operators';
import {
@@ -17,21 +14,21 @@ import {
Plugin,
PluginInitializerContext,
} from 'src/core/public';
-import { UiActionsSetup } from 'src/plugins/ui_actions/public';
+import { UiActionsSetup, UiActionsStart } from 'src/plugins/ui_actions/public';
import { CONTEXT_MENU_TRIGGER } from '../../../../src/plugins/embeddable/public';
import {
FeatureCatalogueCategory,
HomePublicPluginSetup,
+ HomePublicPluginStart,
} from '../../../../src/plugins/home/public';
-import { ManagementSetup } from '../../../../src/plugins/management/public';
-import { SharePluginSetup } from '../../../../src/plugins/share/public';
-import { LicensingPluginSetup } from '../../licensing/public';
+import { ManagementSetup, ManagementStart } from '../../../../src/plugins/management/public';
+import { SharePluginSetup, SharePluginStart } from '../../../../src/plugins/share/public';
+import { LicensingPluginSetup, LicensingPluginStart } from '../../licensing/public';
import { durationToNumber } from '../common/schema_utils';
import { JobId, ReportingConfigType } from '../common/types';
import { JOB_COMPLETION_NOTIFICATIONS_SESSION_KEY } from '../constants';
import { JobSummarySet } from './';
import { getGeneralErrorToast } from './components';
-import { ReportListing } from './components/report_listing';
import { ReportingAPIClient } from './lib/reporting_api_client';
import { ReportingNotifierStreamHandler as StreamHandler } from './lib/stream_handler';
import { GetCsvReportPanelAction } from './panel_actions/get_csv_panel_action';
@@ -60,7 +57,25 @@ function handleError(notifications: NotificationsSetup, err: Error): Rx.Observab
return Rx.of({ completed: [], failed: [] });
}
-export class ReportingPublicPlugin implements Plugin {
+export interface ReportingPublicPluginSetupDendencies {
+ home: HomePublicPluginSetup;
+ management: ManagementSetup;
+ licensing: LicensingPluginSetup;
+ uiActions: UiActionsSetup;
+ share: SharePluginSetup;
+}
+
+export interface ReportingPublicPluginStartDendencies {
+ home: HomePublicPluginStart;
+ management: ManagementStart;
+ licensing: LicensingPluginStart;
+ uiActions: UiActionsStart;
+ share: SharePluginStart;
+}
+
+export class ReportingPublicPlugin
+ implements
+ Plugin {
private config: ClientConfigType;
private readonly stop$ = new Rx.ReplaySubject(1);
private readonly title = i18n.translate('xpack.reporting.management.reportingTitle', {
@@ -76,19 +91,7 @@ export class ReportingPublicPlugin implements Plugin {
public setup(
core: CoreSetup,
- {
- home,
- management,
- licensing,
- uiActions,
- share,
- }: {
- home: HomePublicPluginSetup;
- management: ManagementSetup;
- licensing: LicensingPluginSetup;
- uiActions: UiActionsSetup;
- share: SharePluginSetup;
- }
+ { home, management, licensing, uiActions, share }: ReportingPublicPluginSetupDendencies
) {
const {
http,
@@ -119,24 +122,19 @@ export class ReportingPublicPlugin implements Plugin {
title: this.title,
order: 1,
mount: async (params) => {
- const [start] = await getStartServices();
params.setBreadcrumbs([{ text: this.breadcrumbText }]);
- ReactDOM.render(
-
-
- ,
- params.element
+ const [[start], { mountManagementSection }] = await Promise.all([
+ getStartServices(),
+ import('./mount_management_section'),
+ ]);
+ return await mountManagementSection(
+ core,
+ start,
+ license$,
+ this.config.poll,
+ apiClient,
+ params
);
-
- return () => {
- ReactDOM.unmountComponentAtNode(params.element);
- };
},
});
diff --git a/x-pack/plugins/reporting/public/share_context_menu/register_csv_reporting.tsx b/x-pack/plugins/reporting/public/share_context_menu/register_csv_reporting.tsx
index 451d907199c4..e90d6786b58f 100644
--- a/x-pack/plugins/reporting/public/share_context_menu/register_csv_reporting.tsx
+++ b/x-pack/plugins/reporting/public/share_context_menu/register_csv_reporting.tsx
@@ -11,7 +11,7 @@ import { IUiSettingsClient, ToastsSetup } from 'src/core/public';
import { ShareContext } from '../../../../../src/plugins/share/public';
import { LicensingPluginSetup } from '../../../licensing/public';
import { JobParamsCSV, SearchRequest } from '../../server/export_types/csv/types';
-import { ReportingPanelContent } from '../components/reporting_panel_content';
+import { ReportingPanelContent } from '../components/reporting_panel_content_lazy';
import { checkLicense } from '../lib/license_check';
import { ReportingAPIClient } from '../lib/reporting_api_client';
diff --git a/x-pack/plugins/reporting/public/share_context_menu/register_pdf_png_reporting.tsx b/x-pack/plugins/reporting/public/share_context_menu/register_pdf_png_reporting.tsx
index 2dab66187bb2..d17d4af3c010 100644
--- a/x-pack/plugins/reporting/public/share_context_menu/register_pdf_png_reporting.tsx
+++ b/x-pack/plugins/reporting/public/share_context_menu/register_pdf_png_reporting.tsx
@@ -13,7 +13,7 @@ import { LicensingPluginSetup } from '../../../licensing/public';
import { LayoutParams } from '../../common/types';
import { JobParamsPNG } from '../../server/export_types/png/types';
import { JobParamsPDF } from '../../server/export_types/printable_pdf/types';
-import { ScreenCapturePanelContent } from '../components/screen_capture_panel_content';
+import { ScreenCapturePanelContent } from '../components/screen_capture_panel_content_lazy';
import { checkLicense } from '../lib/license_check';
import { ReportingAPIClient } from '../lib/reporting_api_client';