Skip to content

Commit

Permalink
fixes on maps plugin file after merge
Browse files Browse the repository at this point in the history
  • Loading branch information
stratoula committed Aug 18, 2020
1 parent bde9c73 commit 33777d0
Showing 1 changed file with 28 additions and 85 deletions.
113 changes: 28 additions & 85 deletions x-pack/plugins/maps/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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';
Expand All @@ -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';
Expand All @@ -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<MapsUrlGeneratorState>;
}
}

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;
Expand All @@ -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<MapsUrlGeneratorState>;
}
}

/**
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 33777d0

Please sign in to comment.