diff --git a/x-pack/plugins/maps/public/plugin.ts b/x-pack/plugins/maps/public/plugin.ts index b60811a5c930c..b793e26ecd86e 100644 --- a/x-pack/plugins/maps/public/plugin.ts +++ b/x-pack/plugins/maps/public/plugin.ts @@ -15,7 +15,6 @@ import { PluginInitializerContext, DEFAULT_APP_CATEGORIES, } from '../../../../src/core/public'; -import { SharePluginSetup, UrlGeneratorState } from '../../../../src/plugins/share/public'; // @ts-ignore import { MapView } from './inspector/views/map_view'; import { @@ -24,33 +23,23 @@ import { setKibanaVersion, setLicenseId, setMapAppConfig, - setMapsCapabilities, - setNavigation, - setSavedObjectsClient, - setSearchService, - setTimeFilter, - setToasts, - setUiActions, - setUiSettings, - setVisualizations, + setStartServices, setApplication, setShareService, - setEmbeddableService, - setNavigateToApp, - setStartServices, } from './kibana_services'; import { featureCatalogueEntry } from './feature_catalogue_entry'; // @ts-ignore import { getMapsVisTypeAlias } from './maps_vis_type_alias'; import { HomePublicPluginSetup } from '../../../../src/plugins/home/public'; import { VisualizationsSetup } from '../../../../src/plugins/visualizations/public'; +import { APP_ICON, APP_ID, MAP_SAVED_OBJECT_TYPE } from '../common/constants'; import { VISUALIZE_GEO_FIELD_TRIGGER } from '../../../../src/plugins/ui_actions/public'; import { MapsUrlGeneratorState, MAPS_APP_URL_GENERATOR, createMapsUrlGenerator, } from './url_generator'; -import { APP_ICON, APP_ID, MAP_SAVED_OBJECT_TYPE } from '../common/constants'; +import { visualizeGeoFieldAction } from './trigger_actions/visualize_geo_field_action'; import { MapEmbeddableFactory } from './embeddable/map_embeddable_factory'; import { EmbeddableSetup } from '../../../../src/plugins/embeddable/public'; import { MapsXPackConfig, MapsConfigType } from '../config'; @@ -59,7 +48,11 @@ import { ILicense } from '../../licensing/common/types'; import { lazyLoadMapModules } from './lazy_load_bundle'; import { MapsStartApi } from './api'; import { createSecurityLayerDescriptors, registerLayerWizard, registerSource } from './api'; -import { visualizeGeoFieldAction } from './trigger_actions/visualize_geo_field_action'; +import { + SharePluginSetup, + UrlGeneratorState, + SharePluginStart, +} from '../../../../src/plugins/share/public'; import { EmbeddableStart } from '../../../../src/plugins/embeddable/public'; import { MapsLegacyConfigType } from '../../../../src/plugins/maps_legacy/public'; import { DataPublicPluginStart } from '../../../../src/plugins/data/public'; @@ -71,78 +64,10 @@ export interface MapsPluginSetupDependencies { home: HomePublicPluginSetup; visualizations: VisualizationsSetup; embeddable: EmbeddableSetup; - share: SharePluginSetup; mapsLegacy: { config: MapsLegacyConfigType }; + share: SharePluginSetup; } -declare module '../../../../src/plugins/share/public' { - export interface UrlGeneratorStateMapping { - [MAPS_APP_URL_GENERATOR]: UrlGeneratorState; - } -} - -export const bindSetupCoreAndPlugins = ( - core: CoreSetup, - plugins: any, - config: MapsConfigType, - kibanaVersion: string -) => { - const { licensing, mapsLegacy, share } = plugins; - const { uiSettings, http, notifications } = core; - if (licensing) { - licensing.license$.subscribe(({ uid }: { uid: string }) => setLicenseId(uid)); - } - setHttp(http); - setToasts(notifications.toasts); - setVisualizations(plugins.visualizations); - setUiSettings(uiSettings); - setKibanaCommonConfig(mapsLegacy.config); - setMapAppConfig(config); - setKibanaVersion(kibanaVersion); - share.urlGenerators.registerUrlGenerator( - createMapsUrlGenerator(async () => { - const [coreStart] = await core.getStartServices(); - return { - appBasePath: coreStart.application.getUrlForApp('maps'), - useHashedUrl: coreStart.uiSettings.get('state:storeInSessionStorage'), - }; - }) - ); -}; - -export const bindStartCoreAndPlugins = (core: CoreStart, plugins: any) => { - const { fileUpload, data, inspector, licensing } = plugins; - if (licensing) { - licensing.license$.subscribe((license: ILicense) => { - const gold = license.check(APP_ID, 'gold'); - setIsGoldPlus(gold.state === 'valid'); - }); - } - - plugins.uiActions.addTriggerAction(VISUALIZE_GEO_FIELD_TRIGGER, visualizeGeoFieldAction); - - setInspector(inspector); - setFileUpload(fileUpload); - setIndexPatternSelect(data.ui.IndexPatternSelect); - setTimeFilter(data.query.timefilter.timefilter); - setSearchService(data.search); - setIndexPatternService(data.indexPatterns); - setAutocompleteService(data.autocomplete); - setCore(core); - setSavedObjectsClient(core.savedObjects.client); - setCoreChrome(core.chrome); - setCoreOverlays(core.overlays); - setMapsCapabilities(core.application.capabilities.maps); - setDocLinks(core.docLinks); - setData(plugins.data); - setUiActions(plugins.uiActions); - setNavigation(plugins.navigation); - setCoreI18n(core.i18n); - setApplication(core.application); - setShareService(plugins.share); - setEmbeddableService(plugins.embeddable); - setNavigateToApp(core.application.navigateToApp); -}; export interface MapsPluginStartDependencies { data: DataPublicPluginStart; embeddable: EmbeddableStart; @@ -151,6 +76,13 @@ export interface MapsPluginStartDependencies { licensing: LicensingPluginStart; navigation: NavigationPublicPluginStart; uiActions: UiActionsStart; + share: SharePluginStart; +} + +declare module '../../../../src/plugins/share/public' { + export interface UrlGeneratorStateMapping { + [MAPS_APP_URL_GENERATOR]: UrlGeneratorState; + } } /** @@ -181,6 +113,15 @@ export class MapsPlugin setKibanaCommonConfig(plugins.mapsLegacy.config); setMapAppConfig(config); setKibanaVersion(this._initializerContext.env.packageInfo.version); + plugins.share.urlGenerators.registerUrlGenerator( + createMapsUrlGenerator(async () => { + const [coreStart] = await core.getStartServices(); + return { + appBasePath: coreStart.application.getUrlForApp('maps'), + useHashedUrl: coreStart.uiSettings.get('state:storeInSessionStorage'), + }; + }) + ); plugins.inspector.registerView(MapView); plugins.home.featureCatalogue.register(featureCatalogueEntry); @@ -212,7 +153,9 @@ export class MapsPlugin setLicenseId(license.uid); }); } - + plugins.uiActions.addTriggerAction(VISUALIZE_GEO_FIELD_TRIGGER, visualizeGeoFieldAction); + setApplication(core.application); + setShareService(plugins.share); setStartServices(core, plugins); return {