[dashboard] optimize chunk loading (#216207)

### Before
<img width="300" alt="Screenshot 2025-03-27 at 10 25 03 AM"
src="https://github.com/user-attachments/assets/b161e177-e450-4266-9374-515e6b60bc70"
/>

### After
<img width="300" alt="Screenshot 2025-03-27 at 10 24 21 AM"
src="https://github.com/user-attachments/assets/d692dffa-7d12-4866-8b11-d4ac0ef2cd00"
/>

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
Nathan Reese 2025-04-02 08:11:34 -06:00 committed by GitHub
parent d92ecd4a17
commit 58508856be
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 48 additions and 52 deletions

View file

@ -1,16 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
export { ClonePanelAction } from './clone_panel_action';
export { ExpandPanelAction } from './expand_panel_action';
export { FiltersNotificationAction } from './filters_notification_action';
export { ExportCSVAction } from './export_csv_action';
export { AddToLibraryAction } from './library_add_action';
export { UnlinkFromLibraryAction } from './library_unlink_action';
export { CopyToDashboardAction } from './copy_to_dashboard_action';

View file

@ -29,26 +29,26 @@ export const registerActions = async ({
const { uiActions, share } = plugins;
uiActions.registerActionAsync(ACTION_CLONE_PANEL, async () => {
const { ClonePanelAction } = await import('./actions_module');
const { ClonePanelAction } = await import('../dashboard_renderer/dashboard_module');
return new ClonePanelAction();
});
uiActions.attachAction(CONTEXT_MENU_TRIGGER, ACTION_CLONE_PANEL);
uiActions.registerActionAsync(ACTION_EXPAND_PANEL, async () => {
const { ExpandPanelAction } = await import('./actions_module');
const { ExpandPanelAction } = await import('../dashboard_renderer/dashboard_module');
return new ExpandPanelAction();
});
uiActions.attachAction(CONTEXT_MENU_TRIGGER, ACTION_EXPAND_PANEL);
uiActions.registerActionAsync(BADGE_FILTERS_NOTIFICATION, async () => {
const { FiltersNotificationAction } = await import('./actions_module');
const { FiltersNotificationAction } = await import('../dashboard_renderer/dashboard_module');
return new FiltersNotificationAction();
});
uiActions.attachAction(PANEL_NOTIFICATION_TRIGGER, BADGE_FILTERS_NOTIFICATION);
if (share) {
uiActions.registerActionAsync(ACTION_EXPORT_CSV, async () => {
const { ExportCSVAction } = await import('./actions_module');
const { ExportCSVAction } = await import('../dashboard_renderer/dashboard_module');
return new ExportCSVAction();
});
uiActions.attachAction(CONTEXT_MENU_TRIGGER, ACTION_EXPORT_CSV);
@ -56,19 +56,19 @@ export const registerActions = async ({
if (allowByValueEmbeddables) {
uiActions.registerActionAsync(ACTION_ADD_TO_LIBRARY, async () => {
const { AddToLibraryAction } = await import('./actions_module');
const { AddToLibraryAction } = await import('../dashboard_renderer/dashboard_module');
return new AddToLibraryAction();
});
uiActions.attachAction(CONTEXT_MENU_TRIGGER, ACTION_ADD_TO_LIBRARY);
uiActions.registerActionAsync(ACTION_UNLINK_FROM_LIBRARY, async () => {
const { UnlinkFromLibraryAction } = await import('./actions_module');
const { UnlinkFromLibraryAction } = await import('../dashboard_renderer/dashboard_module');
return new UnlinkFromLibraryAction();
});
uiActions.attachAction(CONTEXT_MENU_TRIGGER, ACTION_UNLINK_FROM_LIBRARY);
uiActions.registerActionAsync(ACTION_COPY_TO_DASHBOARD, async () => {
const { CopyToDashboardAction } = await import('./actions_module');
const { CopyToDashboardAction } = await import('../dashboard_renderer/dashboard_module');
return new CopyToDashboardAction();
});
uiActions.attachAction(CONTEXT_MENU_TRIGGER, ACTION_COPY_TO_DASHBOARD);

View file

@ -78,6 +78,3 @@ export const DashboardListingTable = ({
</I18nProvider>
);
};
// eslint-disable-next-line import/no-default-export
export default DashboardListingTable;

View file

@ -17,16 +17,13 @@ const ListingTableLoadingIndicator = () => {
return <EuiEmptyPrompt icon={<EuiLoadingSpinner size="l" />} />;
};
const LazyDashboardListing = React.lazy(() =>
(async () => {
const modulePromise = import('./dashboard_listing_table');
const [module] = await Promise.all([modulePromise, untilPluginStartServicesReady()]);
return {
default: module.DashboardListingTable,
};
})().then((module) => module)
);
const LazyDashboardListing = React.lazy(async () => {
const [{ DashboardListingTable }] = await Promise.all([
import('../dashboard_renderer/dashboard_module'),
untilPluginStartServicesReady(),
]);
return { default: DashboardListingTable };
});
export const DashboardListingTable = (props: DashboardListingProps) => {
return (

View file

@ -0,0 +1,19 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
export { DashboardRenderer } from './dashboard_renderer';
export { DashboardTopNavWithContext } from '../dashboard_top_nav/dashboard_top_nav_with_context';
export { DashboardListingTable } from '../dashboard_listing/dashboard_listing_table';
export { ClonePanelAction } from '../dashboard_actions/clone_panel_action';
export { ExpandPanelAction } from '../dashboard_actions/expand_panel_action';
export { FiltersNotificationAction } from '../dashboard_actions/filters_notification_action';
export { ExportCSVAction } from '../dashboard_actions/export_csv_action';
export { AddToLibraryAction } from '../dashboard_actions/library_add_action';
export { UnlinkFromLibraryAction } from '../dashboard_actions/library_unlink_action';
export { CopyToDashboardAction } from '../dashboard_actions/copy_to_dashboard_action';

View file

@ -14,7 +14,7 @@ import { untilPluginStartServicesReady } from '../services/kibana_services';
const Component = dynamic(async () => {
const [{ DashboardRenderer }] = await Promise.all([
import('./dashboard_renderer'),
import('./dashboard_module'),
untilPluginStartServicesReady(),
]);
return {

View file

@ -23,6 +23,3 @@ export const DashboardTopNavWithContext = (props: DashboardTopNavProps) => (
<InternalDashboardTopNav {...props} />
</DashboardContext.Provider>
);
// eslint-disable-next-line import/no-default-export
export default DashboardTopNavWithContext;

View file

@ -11,16 +11,15 @@ import React, { Suspense } from 'react';
import { DashboardTopNavProps } from './dashboard_top_nav_with_context';
import { untilPluginStartServicesReady } from '../services/kibana_services';
const LazyDashboardTopNav = React.lazy(() =>
(async () => {
const modulePromise = import('./dashboard_top_nav_with_context');
const [module] = await Promise.all([modulePromise, untilPluginStartServicesReady()]);
return {
default: module.DashboardTopNavWithContext,
};
})().then((module) => module)
);
const LazyDashboardTopNav = React.lazy(async () => {
const [{ DashboardTopNavWithContext }] = await Promise.all([
import('../dashboard_renderer/dashboard_module'),
untilPluginStartServicesReady(),
]);
return {
default: DashboardTopNavWithContext,
};
});
export const DashboardTopNav = (props: DashboardTopNavProps) => {
return (

View file

@ -230,8 +230,11 @@ export class DashboardPlugin
mount: async (params: AppMountParameters) => {
this.currentHistory = params.history;
params.element.classList.add(APP_WRAPPER_CLASS);
await untilPluginStartServicesReady();
const { mountApp } = await import('./dashboard_app/dashboard_router');
const [{ mountApp }] = await Promise.all([
import('./dashboard_app/dashboard_router'),
import('./dashboard_renderer/dashboard_module'),
untilPluginStartServicesReady(),
]);
appMounted();
const [coreStart] = await core.getStartServices();