From c2aeac51414485b83fc9cbb9f681f47dbf26fc93 Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Wed, 6 Oct 2021 18:24:15 -0600 Subject: [PATCH] [Maps] do not lazy load setup API methods (#114150) * [Maps] do not lazy load setup API methods * remove test code --- x-pack/plugins/maps/public/api/index.ts | 1 - x-pack/plugins/maps/public/api/register.ts | 20 ------------------- x-pack/plugins/maps/public/api/setup_api.ts | 4 ++-- .../classes/layers/layer_wizard_registry.ts | 2 +- .../public/classes/sources/source_registry.ts | 2 +- .../maps/public/lazy_load_bundle/index.ts | 8 -------- .../public/lazy_load_bundle/lazy/index.ts | 2 -- x-pack/plugins/maps/public/plugin.ts | 4 ++-- 8 files changed, 6 insertions(+), 37 deletions(-) delete mode 100644 x-pack/plugins/maps/public/api/register.ts diff --git a/x-pack/plugins/maps/public/api/index.ts b/x-pack/plugins/maps/public/api/index.ts index feded3e16f375..9cf7577f448be 100644 --- a/x-pack/plugins/maps/public/api/index.ts +++ b/x-pack/plugins/maps/public/api/index.ts @@ -8,5 +8,4 @@ export { MapsStartApi } from './start_api'; export { MapsSetupApi } from './setup_api'; export { createLayerDescriptors } from './create_layer_descriptors'; -export { registerLayerWizard, registerSource } from './register'; export { suggestEMSTermJoinConfig } from './ems'; diff --git a/x-pack/plugins/maps/public/api/register.ts b/x-pack/plugins/maps/public/api/register.ts deleted file mode 100644 index 037eeadc48df7..0000000000000 --- a/x-pack/plugins/maps/public/api/register.ts +++ /dev/null @@ -1,20 +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; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import type { SourceRegistryEntry } from '../classes/sources/source_registry'; -import type { LayerWizard } from '../classes/layers/layer_wizard_registry'; -import { lazyLoadMapModules } from '../lazy_load_bundle'; - -export async function registerLayerWizard(layerWizard: LayerWizard): Promise { - const mapModules = await lazyLoadMapModules(); - return mapModules.registerLayerWizard(layerWizard); -} - -export async function registerSource(entry: SourceRegistryEntry): Promise { - const mapModules = await lazyLoadMapModules(); - return mapModules.registerSource(entry); -} diff --git a/x-pack/plugins/maps/public/api/setup_api.ts b/x-pack/plugins/maps/public/api/setup_api.ts index 1b4fee968aad4..3fb80afc665c2 100644 --- a/x-pack/plugins/maps/public/api/setup_api.ts +++ b/x-pack/plugins/maps/public/api/setup_api.ts @@ -9,6 +9,6 @@ import type { SourceRegistryEntry } from '../classes/sources/source_registry'; import type { LayerWizard } from '../classes/layers/layer_wizard_registry'; export interface MapsSetupApi { - registerLayerWizard(layerWizard: LayerWizard): Promise; - registerSource(entry: SourceRegistryEntry): Promise; + registerLayerWizard(layerWizard: LayerWizard): void; + registerSource(entry: SourceRegistryEntry): void; } diff --git a/x-pack/plugins/maps/public/classes/layers/layer_wizard_registry.ts b/x-pack/plugins/maps/public/classes/layers/layer_wizard_registry.ts index 4f43d0384940c..1c4ff5a457ba3 100644 --- a/x-pack/plugins/maps/public/classes/layers/layer_wizard_registry.ts +++ b/x-pack/plugins/maps/public/classes/layers/layer_wizard_registry.ts @@ -8,7 +8,7 @@ /* eslint-disable @typescript-eslint/consistent-type-definitions */ import { ReactElement, FunctionComponent } from 'react'; -import { LayerDescriptor } from '../../../common/descriptor_types'; +import type { LayerDescriptor } from '../../../common/descriptor_types'; import { LAYER_WIZARD_CATEGORY } from '../../../common/constants'; export type RenderWizardArguments = { diff --git a/x-pack/plugins/maps/public/classes/sources/source_registry.ts b/x-pack/plugins/maps/public/classes/sources/source_registry.ts index b67c2668dd1ec..7be7343889d48 100644 --- a/x-pack/plugins/maps/public/classes/sources/source_registry.ts +++ b/x-pack/plugins/maps/public/classes/sources/source_registry.ts @@ -7,7 +7,7 @@ /* eslint-disable @typescript-eslint/consistent-type-definitions */ -import { ISource } from './source'; +import type { ISource } from './source'; import { Adapters } from '../../../../../../src/plugins/inspector/common/adapters'; export type SourceRegistryEntry = { diff --git a/x-pack/plugins/maps/public/lazy_load_bundle/index.ts b/x-pack/plugins/maps/public/lazy_load_bundle/index.ts index 1cbf009ffd5fa..8fdae1ae6d197 100644 --- a/x-pack/plugins/maps/public/lazy_load_bundle/index.ts +++ b/x-pack/plugins/maps/public/lazy_load_bundle/index.ts @@ -14,8 +14,6 @@ import type { MapEmbeddableInput, MapEmbeddableType, } from '../embeddable/types'; -import { SourceRegistryEntry } from '../classes/sources/source_registry'; -import { LayerWizard } from '../classes/layers/layer_wizard_registry'; import type { CreateLayerDescriptorParams } from '../classes/sources/es_search_source'; import type { EMSTermJoinConfig, SampleValuesConfig } from '../ems_autosuggest'; import type { CreateTileMapLayerDescriptorParams } from '../classes/layers/create_tile_map_layer_descriptor'; @@ -36,8 +34,6 @@ export interface LazyLoadedMapModules { indexPatternId: string, indexPatternTitle: string ) => LayerDescriptor[]; - registerLayerWizard: (layerWizard: LayerWizard) => void; - registerSource(entry: SourceRegistryEntry): void; createTileMapLayerDescriptor: ({ label, mapType, @@ -77,8 +73,6 @@ export async function lazyLoadMapModules(): Promise { getMapsCapabilities, renderApp, createSecurityLayerDescriptors, - registerLayerWizard, - registerSource, createTileMapLayerDescriptor, createRegionMapLayerDescriptor, createBasemapLayerDescriptor, @@ -91,8 +85,6 @@ export async function lazyLoadMapModules(): Promise { getMapsCapabilities, renderApp, createSecurityLayerDescriptors, - registerLayerWizard, - registerSource, createTileMapLayerDescriptor, createRegionMapLayerDescriptor, createBasemapLayerDescriptor, diff --git a/x-pack/plugins/maps/public/lazy_load_bundle/lazy/index.ts b/x-pack/plugins/maps/public/lazy_load_bundle/lazy/index.ts index 4ccc19ae988da..114fa86bc1d99 100644 --- a/x-pack/plugins/maps/public/lazy_load_bundle/lazy/index.ts +++ b/x-pack/plugins/maps/public/lazy_load_bundle/lazy/index.ts @@ -10,8 +10,6 @@ export * from '../../embeddable/map_embeddable'; export * from '../../kibana_services'; export { renderApp } from '../../render_app'; export * from '../../classes/layers/solution_layers/security'; -export { registerLayerWizard } from '../../classes/layers/layer_wizard_registry'; -export { registerSource } from '../../classes/sources/source_registry'; export { createTileMapLayerDescriptor } from '../../classes/layers/create_tile_map_layer_descriptor'; export { createRegionMapLayerDescriptor } from '../../classes/layers/create_region_map_layer_descriptor'; export { createBasemapLayerDescriptor } from '../../classes/layers/create_basemap_layer_descriptor'; diff --git a/x-pack/plugins/maps/public/plugin.ts b/x-pack/plugins/maps/public/plugin.ts index ee3202ba022c9..76fac23e57b57 100644 --- a/x-pack/plugins/maps/public/plugin.ts +++ b/x-pack/plugins/maps/public/plugin.ts @@ -48,12 +48,12 @@ import { getAppTitle } from '../common/i18n_getters'; import { lazyLoadMapModules } from './lazy_load_bundle'; import { createLayerDescriptors, - registerLayerWizard, - registerSource, MapsSetupApi, MapsStartApi, suggestEMSTermJoinConfig, } from './api'; +import { registerLayerWizard } from './classes/layers/layer_wizard_registry'; +import { registerSource } from './classes/sources/source_registry'; import type { SharePluginSetup, SharePluginStart } from '../../../../src/plugins/share/public'; import type { MapsEmsPluginSetup } from '../../../../src/plugins/maps_ems/public'; import type { DataPublicPluginStart } from '../../../../src/plugins/data/public';