Reduce index management plugin page load bundle size (#88656)
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
de44af3eeb
commit
88f76b5995
|
@ -23,7 +23,7 @@ import { notificationService } from '../../../public/application/services/notifi
|
||||||
import { ExtensionsService } from '../../../public/services';
|
import { ExtensionsService } from '../../../public/services';
|
||||||
import { UiMetricService } from '../../../public/application/services/ui_metric';
|
import { UiMetricService } from '../../../public/application/services/ui_metric';
|
||||||
import { setUiMetricService } from '../../../public/application/services/api';
|
import { setUiMetricService } from '../../../public/application/services/api';
|
||||||
import { setExtensionsService } from '../../../public/application/store/selectors';
|
import { setExtensionsService } from '../../../public/application/store/selectors/extension_service';
|
||||||
import {
|
import {
|
||||||
MappingsEditorProvider,
|
MappingsEditorProvider,
|
||||||
ComponentTemplatesProvider,
|
ComponentTemplatesProvider,
|
||||||
|
|
|
@ -27,7 +27,7 @@ import { notificationService } from '../../public/application/services/notificat
|
||||||
import { httpService } from '../../public/application/services/http';
|
import { httpService } from '../../public/application/services/http';
|
||||||
import { setUiMetricService } from '../../public/application/services/api';
|
import { setUiMetricService } from '../../public/application/services/api';
|
||||||
import { indexManagementStore } from '../../public/application/store';
|
import { indexManagementStore } from '../../public/application/store';
|
||||||
import { setExtensionsService } from '../../public/application/store/selectors';
|
import { setExtensionsService } from '../../public/application/store/selectors/extension_service';
|
||||||
import { BASE_PATH, API_BASE_PATH } from '../../common/constants';
|
import { BASE_PATH, API_BASE_PATH } from '../../common/constants';
|
||||||
import { ExtensionsService } from '../../public/services';
|
import { ExtensionsService } from '../../public/services';
|
||||||
import sinon from 'sinon';
|
import sinon from 'sinon';
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
* you may not use this file except in compliance with the Elastic License.
|
* you may not use this file except in compliance with the Elastic License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export { PLUGIN } from './plugin';
|
|
||||||
export { BASE_PATH } from './base_path';
|
export { BASE_PATH } from './base_path';
|
||||||
export { API_BASE_PATH } from './api_base_path';
|
export { API_BASE_PATH } from './api_base_path';
|
||||||
export { INVALID_INDEX_PATTERN_CHARS, INVALID_TEMPLATE_NAME_CHARS } from './invalid_characters';
|
export { INVALID_INDEX_PATTERN_CHARS, INVALID_TEMPLATE_NAME_CHARS } from './invalid_characters';
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* you may not use this file except in compliance with the Elastic License.
|
* you may not use this file except in compliance with the Elastic License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export { PLUGIN, API_BASE_PATH, BASE_PATH } from './constants';
|
export { API_BASE_PATH, BASE_PATH } from './constants';
|
||||||
|
|
||||||
export { getTemplateParameter } from './lib';
|
export { getTemplateParameter } from './lib';
|
||||||
|
|
||||||
|
|
|
@ -10,28 +10,46 @@ import { ManagementAppMountParams } from 'src/plugins/management/public/';
|
||||||
import { UsageCollectionSetup } from 'src/plugins/usage_collection/public';
|
import { UsageCollectionSetup } from 'src/plugins/usage_collection/public';
|
||||||
|
|
||||||
import { FleetSetup } from '../../../fleet/public';
|
import { FleetSetup } from '../../../fleet/public';
|
||||||
import { PLUGIN } from '../../common/constants';
|
import { UIM_APP_NAME } from '../../common/constants';
|
||||||
|
import { PLUGIN } from '../../common/constants/plugin';
|
||||||
import { ExtensionsService } from '../services';
|
import { ExtensionsService } from '../services';
|
||||||
import { StartDependencies } from '../types';
|
import { StartDependencies } from '../types';
|
||||||
import { AppDependencies } from './app_context';
|
import { AppDependencies } from './app_context';
|
||||||
import { breadcrumbService } from './services/breadcrumbs';
|
import { breadcrumbService } from './services/breadcrumbs';
|
||||||
import { documentationService } from './services/documentation';
|
import { documentationService } from './services/documentation';
|
||||||
import { HttpService, NotificationService, UiMetricService } from './services';
|
import { UiMetricService } from './services';
|
||||||
|
|
||||||
import { renderApp } from '.';
|
import { renderApp } from '.';
|
||||||
|
import { setUiMetricService } from './services/api';
|
||||||
|
import { notificationService } from './services/notification';
|
||||||
|
import { httpService } from './services/http';
|
||||||
|
|
||||||
interface InternalServices {
|
function initSetup({
|
||||||
httpService: HttpService;
|
usageCollection,
|
||||||
notificationService: NotificationService;
|
coreSetup,
|
||||||
uiMetricService: UiMetricService;
|
}: {
|
||||||
extensionsService: ExtensionsService;
|
coreSetup: CoreSetup<StartDependencies>;
|
||||||
|
usageCollection: UsageCollectionSetup;
|
||||||
|
}) {
|
||||||
|
const { http, notifications } = coreSetup;
|
||||||
|
|
||||||
|
httpService.setup(http);
|
||||||
|
notificationService.setup(notifications);
|
||||||
|
|
||||||
|
const uiMetricService = new UiMetricService(UIM_APP_NAME);
|
||||||
|
|
||||||
|
setUiMetricService(uiMetricService);
|
||||||
|
|
||||||
|
uiMetricService.setup(usageCollection);
|
||||||
|
|
||||||
|
return { uiMetricService };
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function mountManagementSection(
|
export async function mountManagementSection(
|
||||||
coreSetup: CoreSetup<StartDependencies>,
|
coreSetup: CoreSetup<StartDependencies>,
|
||||||
usageCollection: UsageCollectionSetup,
|
usageCollection: UsageCollectionSetup,
|
||||||
services: InternalServices,
|
|
||||||
params: ManagementAppMountParams,
|
params: ManagementAppMountParams,
|
||||||
|
extensionsService: ExtensionsService,
|
||||||
fleet?: FleetSetup
|
fleet?: FleetSetup
|
||||||
) {
|
) {
|
||||||
const { element, setBreadcrumbs, history } = params;
|
const { element, setBreadcrumbs, history } = params;
|
||||||
|
@ -50,6 +68,11 @@ export async function mountManagementSection(
|
||||||
breadcrumbService.setup(setBreadcrumbs);
|
breadcrumbService.setup(setBreadcrumbs);
|
||||||
documentationService.setup(docLinks);
|
documentationService.setup(docLinks);
|
||||||
|
|
||||||
|
const { uiMetricService } = initSetup({
|
||||||
|
usageCollection,
|
||||||
|
coreSetup,
|
||||||
|
});
|
||||||
|
|
||||||
const appDependencies: AppDependencies = {
|
const appDependencies: AppDependencies = {
|
||||||
core: {
|
core: {
|
||||||
fatalErrors,
|
fatalErrors,
|
||||||
|
@ -59,7 +82,7 @@ export async function mountManagementSection(
|
||||||
usageCollection,
|
usageCollection,
|
||||||
fleet,
|
fleet,
|
||||||
},
|
},
|
||||||
services,
|
services: { httpService, notificationService, uiMetricService, extensionsService },
|
||||||
history,
|
history,
|
||||||
setBreadcrumbs,
|
setBreadcrumbs,
|
||||||
uiSettings,
|
uiSettings,
|
||||||
|
|
|
@ -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;
|
||||||
|
* you may not use this file except in compliance with the Elastic License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { ExtensionsService } from '../../../services';
|
||||||
|
|
||||||
|
// Temporary hack to provide the extensionsService instance to this file.
|
||||||
|
// TODO: Refactor and export all the app selectors through the app dependencies context
|
||||||
|
|
||||||
|
let extensionsService;
|
||||||
|
export const setExtensionsService = (_extensionsService: ExtensionsService) => {
|
||||||
|
extensionsService = _extensionsService;
|
||||||
|
};
|
||||||
|
|
||||||
|
export { extensionsService };
|
||||||
|
|
||||||
|
// End hack
|
|
@ -9,15 +9,9 @@ import { createSelector } from 'reselect';
|
||||||
import * as qs from 'query-string';
|
import * as qs from 'query-string';
|
||||||
import { indexStatusLabels } from '../../lib/index_status_labels';
|
import { indexStatusLabels } from '../../lib/index_status_labels';
|
||||||
import { sortTable } from '../../services';
|
import { sortTable } from '../../services';
|
||||||
|
import { extensionsService } from './extension_service';
|
||||||
|
|
||||||
// Temporary hack to provide the extensionsService instance to this file.
|
export { extensionsService };
|
||||||
// TODO: Refactor and export all the app selectors through the app dependencies context
|
|
||||||
|
|
||||||
let extensionsService;
|
|
||||||
export const setExtensionsService = (_extensionsService) => {
|
|
||||||
extensionsService = _extensionsService;
|
|
||||||
};
|
|
||||||
// End hack
|
|
||||||
|
|
||||||
export const getDetailPanelData = (state) => state.detailPanel.data;
|
export const getDetailPanelData = (state) => state.detailPanel.data;
|
||||||
export const getDetailPanelError = (state) => state.detailPanel.error;
|
export const getDetailPanelError = (state) => state.detailPanel.error;
|
||||||
|
|
|
@ -4,9 +4,10 @@
|
||||||
* you may not use this file except in compliance with the Elastic License.
|
* you may not use this file except in compliance with the Elastic License.
|
||||||
*/
|
*/
|
||||||
import { ExtensionsService } from '../../../services';
|
import { ExtensionsService } from '../../../services';
|
||||||
import { getFilteredIndices, setExtensionsService } from '.';
|
import { getFilteredIndices } from '.';
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { defaultTableState } from '../reducers/table_state';
|
import { defaultTableState } from '../reducers/table_state';
|
||||||
|
import { setExtensionsService } from './extension_service';
|
||||||
|
|
||||||
describe('getFilteredIndices selector', () => {
|
describe('getFilteredIndices selector', () => {
|
||||||
let extensionService: ExtensionsService;
|
let extensionService: ExtensionsService;
|
||||||
|
|
|
@ -15,4 +15,4 @@ export { IndexManagementPluginSetup } from './types';
|
||||||
|
|
||||||
export { getIndexListUri } from './application/services/routing';
|
export { getIndexListUri } from './application/services/routing';
|
||||||
|
|
||||||
export { Index } from '../common';
|
export type { Index } from '../common';
|
||||||
|
|
|
@ -6,54 +6,43 @@
|
||||||
import { i18n } from '@kbn/i18n';
|
import { i18n } from '@kbn/i18n';
|
||||||
|
|
||||||
import { CoreSetup } from '../../../../src/core/public';
|
import { CoreSetup } from '../../../../src/core/public';
|
||||||
|
import { setExtensionsService } from './application/store/selectors/extension_service';
|
||||||
|
|
||||||
import { UIM_APP_NAME, PLUGIN } from '../common/constants';
|
|
||||||
|
|
||||||
import { httpService } from './application/services/http';
|
|
||||||
import { notificationService } from './application/services/notification';
|
|
||||||
import { UiMetricService } from './application/services/ui_metric';
|
|
||||||
|
|
||||||
import { setExtensionsService } from './application/store/selectors';
|
|
||||||
import { setUiMetricService } from './application/services/api';
|
|
||||||
|
|
||||||
import { IndexManagementPluginSetup, SetupDependencies, StartDependencies } from './types';
|
|
||||||
import { ExtensionsService } from './services';
|
import { ExtensionsService } from './services';
|
||||||
|
|
||||||
|
import { IndexManagementPluginSetup, SetupDependencies, StartDependencies } from './types';
|
||||||
|
|
||||||
|
// avoid import from index files in plugin.ts, use specific import paths
|
||||||
|
import { PLUGIN } from '../common/constants/plugin';
|
||||||
|
|
||||||
export class IndexMgmtUIPlugin {
|
export class IndexMgmtUIPlugin {
|
||||||
private uiMetricService = new UiMetricService(UIM_APP_NAME);
|
|
||||||
private extensionsService = new ExtensionsService();
|
private extensionsService = new ExtensionsService();
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
// Temporary hack to provide the service instances in module files in order to avoid a big refactor
|
// Temporary hack to provide the service instances in module files in order to avoid a big refactor
|
||||||
// For the selectors we should expose them through app dependencies and read them from there on each container component.
|
// For the selectors we should expose them through app dependencies and read them from there on each container component.
|
||||||
setExtensionsService(this.extensionsService);
|
setExtensionsService(this.extensionsService);
|
||||||
setUiMetricService(this.uiMetricService);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public setup(
|
public setup(
|
||||||
coreSetup: CoreSetup<StartDependencies>,
|
coreSetup: CoreSetup<StartDependencies>,
|
||||||
plugins: SetupDependencies
|
plugins: SetupDependencies
|
||||||
): IndexManagementPluginSetup {
|
): IndexManagementPluginSetup {
|
||||||
const { http, notifications } = coreSetup;
|
|
||||||
const { fleet, usageCollection, management } = plugins;
|
const { fleet, usageCollection, management } = plugins;
|
||||||
|
|
||||||
httpService.setup(http);
|
|
||||||
notificationService.setup(notifications);
|
|
||||||
this.uiMetricService.setup(usageCollection);
|
|
||||||
|
|
||||||
management.sections.section.data.registerApp({
|
management.sections.section.data.registerApp({
|
||||||
id: PLUGIN.id,
|
id: PLUGIN.id,
|
||||||
title: i18n.translate('xpack.idxMgmt.appTitle', { defaultMessage: 'Index Management' }),
|
title: i18n.translate('xpack.idxMgmt.appTitle', { defaultMessage: 'Index Management' }),
|
||||||
order: 0,
|
order: 0,
|
||||||
mount: async (params) => {
|
mount: async (params) => {
|
||||||
const { mountManagementSection } = await import('./application/mount_management_section');
|
const { mountManagementSection } = await import('./application/mount_management_section');
|
||||||
const services = {
|
return mountManagementSection(
|
||||||
httpService,
|
coreSetup,
|
||||||
notificationService,
|
usageCollection,
|
||||||
uiMetricService: this.uiMetricService,
|
params,
|
||||||
extensionsService: this.extensionsService,
|
this.extensionsService,
|
||||||
};
|
fleet
|
||||||
return mountManagementSection(coreSetup, usageCollection, services, params, fleet);
|
);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ import {
|
||||||
ILegacyCustomClusterClient,
|
ILegacyCustomClusterClient,
|
||||||
} from 'src/core/server';
|
} from 'src/core/server';
|
||||||
|
|
||||||
import { PLUGIN } from '../common';
|
import { PLUGIN } from '../common/constants/plugin';
|
||||||
import { Dependencies } from './types';
|
import { Dependencies } from './types';
|
||||||
import { ApiRoutes } from './routes';
|
import { ApiRoutes } from './routes';
|
||||||
import { License, IndexDataEnricher } from './services';
|
import { License, IndexDataEnricher } from './services';
|
||||||
|
|
Loading…
Reference in a new issue