Skip to content

Commit

Permalink
[Maps] expose registerLayerWizard and registerSource in maps plugin s…
Browse files Browse the repository at this point in the history
…tart (#71553) (#71681)
  • Loading branch information
nreese authored Jul 14, 2020
1 parent c89d6e1 commit 984406e
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 2 deletions.
2 changes: 2 additions & 0 deletions x-pack/plugins/maps/public/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
*/

export { MapsStartApi } from './start_api';
export { createSecurityLayerDescriptors } from './create_security_layer_descriptors';
export { registerLayerWizard, registerSource } from './register';
19 changes: 19 additions & 0 deletions x-pack/plugins/maps/public/api/register.ts
Original file line number Diff line number Diff line change
@@ -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 { SourceRegistryEntry } from '../classes/sources/source_registry';
import { LayerWizard } from '../classes/layers/layer_wizard_registry';
import { lazyLoadMapModules } from '../lazy_load_bundle';

export async function registerLayerWizard(layerWizard: LayerWizard): Promise<void> {
const mapModules = await lazyLoadMapModules();
return mapModules.registerLayerWizard(layerWizard);
}

export async function registerSource(entry: SourceRegistryEntry): Promise<void> {
const mapModules = await lazyLoadMapModules();
return mapModules.registerSource(entry);
}
4 changes: 4 additions & 0 deletions x-pack/plugins/maps/public/api/start_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@
*/

import { LayerDescriptor } from '../../common/descriptor_types';
import { SourceRegistryEntry } from '../classes/sources/source_registry';
import { LayerWizard } from '../classes/layers/layer_wizard_registry';

export interface MapsStartApi {
createSecurityLayerDescriptors: (
indexPatternId: string,
indexPatternTitle: string
) => Promise<LayerDescriptor[]>;
registerLayerWizard(layerWizard: LayerWizard): Promise<void>;
registerSource(entry: SourceRegistryEntry): Promise<void>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { ISource } from './source';

type SourceRegistryEntry = {
export type SourceRegistryEntry = {
ConstructorFunction: new (
sourceDescriptor: any, // this is the source-descriptor that corresponds specifically to the particular ISource instance
inspectorAdapters?: object
Expand Down
8 changes: 8 additions & 0 deletions x-pack/plugins/maps/public/lazy_load_bundle/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { MapStore, MapStoreState } from '../reducers/store';
import { EventHandlers } from '../reducers/non_serializable_instances';
import { RenderToolTipContent } from '../classes/tooltips/tooltip_property';
import { MapEmbeddableConfig, MapEmbeddableInput, MapEmbeddableOutput } from '../embeddable/types';
import { SourceRegistryEntry } from '../classes/sources/source_registry';
import { LayerWizard } from '../classes/layers/layer_wizard_registry';

let loadModulesPromise: Promise<LazyLoadedMapModules>;

Expand Down Expand Up @@ -42,6 +44,8 @@ interface LazyLoadedMapModules {
indexPatternId: string,
indexPatternTitle: string
) => LayerDescriptor[];
registerLayerWizard(layerWizard: LayerWizard): void;
registerSource(entry: SourceRegistryEntry): void;
}

export async function lazyLoadMapModules(): Promise<LazyLoadedMapModules> {
Expand All @@ -65,6 +69,8 @@ export async function lazyLoadMapModules(): Promise<LazyLoadedMapModules> {
// @ts-expect-error
renderApp,
createSecurityLayerDescriptors,
registerLayerWizard,
registerSource,
} = await import('./lazy');

resolve({
Expand All @@ -80,6 +86,8 @@ export async function lazyLoadMapModules(): Promise<LazyLoadedMapModules> {
mergeInputWithSavedMap,
renderApp,
createSecurityLayerDescriptors,
registerLayerWizard,
registerSource,
});
});
return loadModulesPromise;
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/maps/public/lazy_load_bundle/lazy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ export * from '../../embeddable/merge_input_with_saved_map';
// @ts-expect-error
export * from '../../routing/maps_router';
export * from '../../classes/layers/solution_layers/security';
export { registerLayerWizard } from '../../classes/layers/layer_wizard_registry';
export { registerSource } from '../../classes/sources/source_registry';
4 changes: 3 additions & 1 deletion x-pack/plugins/maps/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import { getAppTitle } from '../common/i18n_getters';
import { ILicense } from '../../licensing/common/types';
import { lazyLoadMapModules } from './lazy_load_bundle';
import { MapsStartApi } from './api';
import { createSecurityLayerDescriptors } from './api/create_security_layer_descriptors';
import { createSecurityLayerDescriptors, registerLayerWizard, registerSource } from './api';

export interface MapsPluginSetupDependencies {
inspector: InspectorSetupContract;
Expand Down Expand Up @@ -170,6 +170,8 @@ export class MapsPlugin
bindStartCoreAndPlugins(core, plugins);
return {
createSecurityLayerDescriptors,
registerLayerWizard,
registerSource,
};
}
}

0 comments on commit 984406e

Please sign in to comment.