Skip to content

Commit

Permalink
Refactor maps services code to be inline with master
Browse files Browse the repository at this point in the history
  • Loading branch information
stratoula committed Aug 18, 2020
1 parent dfe1083 commit c8fd6cc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 17 deletions.
13 changes: 3 additions & 10 deletions x-pack/plugins/maps/public/kibana_services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import { esFilters } from '../../../../src/plugins/data/public';
import { MapsLegacyConfigType } from '../../../../src/plugins/maps_legacy/public';
import { MapsConfigType } from '../config';
import { MapsPluginStartDependencies } from './plugin';
import { CoreStart, ApplicationStart } from '../../../../src/core/public';
import { SharePluginStart } from '../../../../src/plugins/share/public';
import { CoreStart } from '../../../../src/core/public';

export const SPATIAL_FILTER_TYPE = esFilters.FILTERS.SPATIAL_FILTER;

Expand Down Expand Up @@ -46,6 +45,7 @@ export const getToasts = () => coreStart.notifications.toasts;
export const getSavedObjectsClient = () => coreStart.savedObjects.client;
export const getCoreChrome = () => coreStart.chrome;
export const getMapsCapabilities = () => coreStart.application.capabilities.maps;
export const getVisualizeCapabilities = () => coreStart.application.capabilities.visualize;
export const getDocLinks = () => coreStart.docLinks;
export const getCoreOverlays = () => coreStart.overlays;
export const getData = () => pluginsStart.data;
Expand Down Expand Up @@ -83,11 +83,4 @@ export const getProxyElasticMapsServiceInMaps = () =>
export const getRegionmapLayers = () => _.get(getKibanaCommonConfig(), 'regionmap.layers', []);
export const getTilemap = () => _.get(getKibanaCommonConfig(), 'tilemap', []);

let coreApplication: ApplicationStart;
export const setApplication = (application: ApplicationStart) => (coreApplication = application);
export const getApplication = () => coreApplication;

let coreShareService: SharePluginStart;
export const setShareService = (shareService: SharePluginStart) =>
(coreShareService = shareService);
export const getShareService = () => coreShareService;
export const getShareService = () => pluginsStart.share;
4 changes: 0 additions & 4 deletions x-pack/plugins/maps/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ import {
setLicenseId,
setMapAppConfig,
setStartServices,
setApplication,
setShareService,
} from './kibana_services';
import { featureCatalogueEntry } from './feature_catalogue_entry';
// @ts-ignore
Expand Down Expand Up @@ -140,8 +138,6 @@ export class MapsPlugin
});
}
plugins.uiActions.addTriggerAction(VISUALIZE_GEO_FIELD_TRIGGER, visualizeGeoFieldAction);
setApplication(core.application);
setShareService(plugins.share);
setStartServices(core, plugins);

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ import {
VisualizeFieldContext,
} from '../../../../../src/plugins/ui_actions/public';
import {
getApplication,
getVisualizeCapabilities,
getIndexPatternService,
getData,
getShareService,
getNavigateToApp,
} from '../kibana_services';
import { MAPS_APP_URL_GENERATOR, MapsUrlGeneratorState } from '../url_generator';
import { LAYER_TYPE, SOURCE_TYPES, SCALING_TYPES, APP_ID, MAP_PATH } from '../../common/constants';
Expand All @@ -26,7 +27,7 @@ export const visualizeGeoFieldAction = createAction<typeof ACTION_VISUALIZE_GEO_
i18n.translate('xpack.maps.discover.visualizeFieldLabel', {
defaultMessage: 'Visualize in Maps',
}),
isCompatible: async () => !!getApplication().capabilities.visualize.show,
isCompatible: async () => !!getVisualizeCapabilities().show,
getHref: async (context) => {
const url = await getMapsLink(context);
return url;
Expand All @@ -35,7 +36,7 @@ export const visualizeGeoFieldAction = createAction<typeof ACTION_VISUALIZE_GEO_
const url = await getMapsLink(context);
const hash = url.split('#')[1];

getApplication().navigateToApp(APP_ID, {
getNavigateToApp()(APP_ID, {
path: `${MAP_PATH}/#${hash}`,
});
},
Expand Down

0 comments on commit c8fd6cc

Please sign in to comment.