Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate legacy maps service to NP & update refs #60942

Merged
merged 36 commits into from
Apr 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
52ba8a4
Get legacy maps into basic NP plugin form. Swap out legacy services f…
Mar 20, 2020
2b14538
Pull service settings from injected vars. Return new instance of serv…
Mar 23, 2020
ccb2333
Use NP service settings in vega maps. Clean up legacy shim
Mar 23, 2020
f4598cf
Use NP maps service in region maps. Clean up shim. Add exports to NP …
Mar 24, 2020
197e4ca
Merge remote-tracking branch 'upstream/master' into np-update-and-mig…
Mar 24, 2020
1556d40
Pull zoom precision out to separate module since it's dependent on co…
Mar 24, 2020
470bc8b
Update paths to point to NP resources
Mar 25, 2020
86b62e2
More path updates, clean up, use IServiceSettings
Mar 26, 2020
2a37f30
Remove dependency on legacy service settings. Add tile_map dependency…
Mar 26, 2020
159d592
More path cleanup. Use zoomPrecision provided through plugin inteface
Mar 26, 2020
a0307fc
Merge remote-tracking branch 'upstream/master' into np-update-and-mig…
Mar 26, 2020
78c6d89
Move getPrecision into contract-provided function since it depends on…
Mar 27, 2020
27d6dad
Merge remote-tracking branch 'upstream/master' into np-update-and-mig…
Mar 27, 2020
397af39
Move tests to new service location, remove vis dir
Mar 27, 2020
3a2a2f6
Update test paths. Move origin const declaration into public
Mar 27, 2020
2592258
Merge remote-tracking branch 'upstream/master' into np-update-and-mig…
Mar 31, 2020
dd13bf4
Clean up, fixes
Apr 1, 2020
df572f2
Merge remote-tracking branch 'upstream/master' into np-update-and-mig…
Apr 1, 2020
7adb212
Fix type errors. General cleaning
Apr 1, 2020
f1564bb
Inject toast service into map when needed
Apr 2, 2020
d082393
Merge remote-tracking branch 'upstream/master' into np-update-and-mig…
Apr 2, 2020
8a6849a
Fix typo in regionmap config
Apr 3, 2020
d33b9d3
i18n fixes
Apr 3, 2020
79f894e
Update jest test path
Apr 3, 2020
a17066d
Merge branch 'master' into np-update-and-migrate-legacy-maps
elasticmachine Apr 3, 2020
128d952
Fix karma tests
Apr 6, 2020
0d287db
Merge remote-tracking branch 'upstream/master' into np-update-and-mig…
Apr 6, 2020
d2b0433
i18n fixes
Apr 6, 2020
fbd967b
Merge branch 'np-update-and-migrate-legacy-maps' of github.com:aaronj…
Apr 6, 2020
d953423
Type updates. Add mapsLegacy to np karma mock
Apr 7, 2020
7726c63
Merge remote-tracking branch 'upstream/master' into np-update-and-mig…
Apr 7, 2020
a3278ca
Remove html sanitizer
Apr 7, 2020
b14ad08
Fix vega test that depends on serviceSettings
Apr 8, 2020
4fc42ac
Merge remote-tracking branch 'upstream/master' into np-update-and-mig…
Apr 8, 2020
f9a41e9
Revise xpack license handling to use NP serviceSettings. Remove angul…
Apr 9, 2020
9cd3949
Merge remote-tracking branch 'upstream/master' into np-update-and-mig…
Apr 13, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"src/legacy/core_plugins/management",
"src/plugins/management"
],
"maps_legacy": "src/plugins/maps_legacy",
"indexPatternManagement": "src/plugins/index_pattern_management",
"advancedSettings": "src/plugins/advanced_settings",
"kibana_legacy": "src/plugins/kibana_legacy",
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/core_plugins/kibana/public/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
@import './visualize/index';
// Has to come after visualize because of some
// bad cascading in the Editor layout
@import 'src/legacy/ui/public/vis/index';
@import '../../../../plugins/maps_legacy/public/index';

// Home styles
@import '../../../../plugins/home/public/application/index';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,18 @@ import _ from 'lodash';
import ChoroplethLayer from '../choropleth_layer';
import { ImageComparator } from 'test_utils/image_comparator';
import worldJson from './world.json';
import EMS_CATALOGUE from '../../../../ui/public/vis/__tests__/map/ems_mocks/sample_manifest.json';
import EMS_FILES from '../../../../ui/public/vis/__tests__/map/ems_mocks/sample_files.json';
import EMS_TILES from '../../../../ui/public/vis/__tests__/map/ems_mocks/sample_tiles.json';
import EMS_STYLE_ROAD_MAP_BRIGHT from '../../../../ui/public/vis/__tests__/map/ems_mocks/sample_style_bright';
import EMS_STYLE_ROAD_MAP_DESATURATED from '../../../../ui/public/vis/__tests__/map/ems_mocks/sample_style_desaturated';
import EMS_STYLE_DARK_MAP from '../../../../ui/public/vis/__tests__/map/ems_mocks/sample_style_dark';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import EMS_CATALOGUE from '../../../../../plugins/maps_legacy/public/__tests__/map/ems_mocks/sample_manifest.json';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import EMS_FILES from '../../../../../plugins/maps_legacy/public/__tests__/map/ems_mocks/sample_files.json';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import EMS_TILES from '../../../../../plugins/maps_legacy/public/__tests__/map/ems_mocks/sample_tiles.json';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import EMS_STYLE_ROAD_MAP_BRIGHT from '../../../../../plugins/maps_legacy/public/__tests__/map/ems_mocks/sample_style_bright';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import EMS_STYLE_ROAD_MAP_DESATURATED from '../../../../../plugins/maps_legacy/public/__tests__/map/ems_mocks/sample_style_desaturated';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import EMS_STYLE_DARK_MAP from '../../../../../plugins/maps_legacy/public/__tests__/map/ems_mocks/sample_style_dark';

import initialPng from './initial.png';
import toiso3Png from './toiso3.png';
Expand All @@ -44,6 +50,10 @@ import { createRegionMapTypeDefinition } from '../region_map_type';
import { ExprVis } from '../../../../../plugins/visualizations/public/expressions/vis';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { BaseVisType } from '../../../../../plugins/visualizations/public/vis_types/base_vis_type';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { setInjectedVarFunc } from '../../../../../plugins/maps_legacy/public/kibana_services';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { ServiceSettings } from '../../../../../plugins/maps_legacy/public/map/service_settings';

const THRESHOLD = 0.45;
const PIXEL_DIFF = 96;
Expand Down Expand Up @@ -92,7 +102,31 @@ describe('RegionMapsVisualizationTests', function() {
let getManifestStub;
beforeEach(
ngMock.inject((Private, $injector) => {
const serviceSettings = $injector.get('serviceSettings');
setInjectedVarFunc(injectedVar => {
switch (injectedVar) {
case 'mapConfig':
return {
emsFileApiUrl: '',
emsTileApiUrl: '',
emsLandingPageUrl: '',
};
case 'tilemapsConfig':
return {
deprecated: {
config: {
options: {
attribution: '123',
},
},
},
};
case 'version':
return '123';
default:
return 'not found';
}
});
const serviceSettings = new ServiceSettings();
const uiSettings = $injector.get('config');
const regionmapsConfig = {
includeElasticMapsService: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ import L from 'leaflet';
import _ from 'lodash';
import d3 from 'd3';
import { i18n } from '@kbn/i18n';
import { KibanaMapLayer } from 'ui/vis/map/kibana_map_layer';
import * as topojson from 'topojson-client';
import { toastNotifications } from 'ui/notify';
import * as colorUtil from 'ui/vis/map/color_util';

import { colorUtil, KibanaMapLayer } from '../../../../plugins/maps_legacy/public';
import { truncatedColorMaps } from '../../../../plugins/charts/public';

const EMPTY_STYLE = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ import React, { useCallback, useMemo } from 'react';
import { EuiIcon, EuiLink, EuiPanel, EuiSpacer, EuiText, EuiTitle } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';

import { FileLayerField, VectorLayer, ServiceSettings } from 'ui/vis/map/service_settings';
import { VisOptionsProps } from 'src/plugins/vis_default_editor/public';
import {
FileLayerField,
VectorLayer,
IServiceSettings,
} from '../../../../../plugins/maps_legacy/public';
import {
NumberInputOption,
SelectOption,
Expand All @@ -43,7 +46,7 @@ const mapFieldForOption = ({ description, name }: FileLayerField) => ({
});

export type RegionMapOptionsProps = {
serviceSettings: ServiceSettings;
serviceSettings: IServiceSettings;
} & VisOptionsProps<RegionMapVisParams>;

function RegionMapOptions(props: RegionMapOptionsProps) {
Expand Down
9 changes: 3 additions & 6 deletions src/legacy/core_plugins/region_map/public/legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,18 @@
import { PluginInitializerContext } from 'kibana/public';
import { npSetup, npStart } from 'ui/new_platform';

import { RegionMapPluginSetupDependencies, RegionMapsConfig } from './plugin';
import { RegionMapPluginSetupDependencies } from './plugin';
import { LegacyDependenciesPlugin } from './shim';
import { plugin } from '.';

const regionmapsConfig = npSetup.core.injectedMetadata.getInjectedVar(
'regionmap'
) as RegionMapsConfig;

const plugins: Readonly<RegionMapPluginSetupDependencies> = {
expressions: npSetup.plugins.expressions,
visualizations: npSetup.plugins.visualizations,
mapsLegacy: npSetup.plugins.mapsLegacy,

// Temporary solution
// It will be removed when all dependent services are migrated to the new platform.
__LEGACY: new LegacyDependenciesPlugin(regionmapsConfig),
__LEGACY: new LegacyDependenciesPlugin(),
};

const pluginInstance = plugin({} as PluginInitializerContext);
Expand Down
10 changes: 9 additions & 1 deletion src/legacy/core_plugins/region_map/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,22 @@ import { LegacyDependenciesPlugin, LegacyDependenciesPluginSetup } from './shim'
import { createRegionMapFn } from './region_map_fn';
// @ts-ignore
import { createRegionMapTypeDefinition } from './region_map_type';
import { IServiceSettings, MapsLegacyPluginSetup } from '../../../../plugins/maps_legacy/public';

/** @private */
interface RegionMapVisualizationDependencies extends LegacyDependenciesPluginSetup {
uiSettings: IUiSettingsClient;
regionmapsConfig: RegionMapsConfig;
serviceSettings: IServiceSettings;
notificationService: any;
}

/** @internal */
export interface RegionMapPluginSetupDependencies {
expressions: ReturnType<ExpressionsPublicPlugin['setup']>;
visualizations: VisualizationsSetup;
__LEGACY: LegacyDependenciesPlugin;
mapsLegacy: MapsLegacyPluginSetup;
}

/** @internal */
Expand All @@ -61,10 +66,13 @@ export class RegionMapPlugin implements Plugin<Promise<void>, void> {

public async setup(
core: CoreSetup,
{ expressions, visualizations, __LEGACY }: RegionMapPluginSetupDependencies
{ expressions, visualizations, mapsLegacy, __LEGACY }: RegionMapPluginSetupDependencies
) {
const visualizationDependencies: Readonly<RegionMapVisualizationDependencies> = {
uiSettings: core.uiSettings,
regionmapsConfig: core.injectedMetadata.getInjectedVar('regionmap') as RegionMapsConfig,
serviceSettings: mapsLegacy.serviceSettings,
notificationService: core.notifications.toasts,
...(await __LEGACY.setup()),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,16 @@ import { truncatedColorMaps } from '../../../../plugins/charts/public';
// TODO: reference to TILE_MAP plugin should be removed
import { BaseMapsVisualizationProvider } from '../../tile_map/public/base_maps_visualization';

export function createRegionMapVisualization({ serviceSettings, $injector, uiSettings }) {
const BaseMapsVisualization = new BaseMapsVisualizationProvider(serviceSettings);
export function createRegionMapVisualization({
serviceSettings,
$injector,
uiSettings,
notificationService,
}) {
const BaseMapsVisualization = new BaseMapsVisualizationProvider(
serviceSettings,
notificationService
);
const tooltipFormatter = new TileMapTooltipFormatter($injector);

return class RegionMapsVisualization extends BaseMapsVisualization {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,20 @@

import chrome from 'ui/chrome';
import { CoreStart, Plugin } from 'kibana/public';
import 'ui/vis/map/service_settings';
import { RegionMapsConfig } from '../plugin';

/** @internal */
export interface LegacyDependenciesPluginSetup {
$injector: any;
serviceSettings: any;
regionmapsConfig: RegionMapsConfig;
}

export class LegacyDependenciesPlugin
implements Plugin<Promise<LegacyDependenciesPluginSetup>, void> {
constructor(private readonly regionmapsConfig: RegionMapsConfig) {}

public async setup() {
const $injector = await chrome.dangerouslyGetActiveInjector();

return {
$injector,
regionmapsConfig: this.regionmapsConfig,
// Settings for EMSClient.
// EMSClient, which currently lives in the tile_map vis,
// will probably end up being exposed from the future vis_type_maps plugin,
// which would register both the tile_map and the region_map vis plugins.
serviceSettings: $injector.get('serviceSettings'),
} as LegacyDependenciesPluginSetup;
}

Expand Down
2 changes: 1 addition & 1 deletion src/legacy/core_plugins/region_map/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { VectorLayer, FileLayerField } from 'ui/vis/map/service_settings';
import { VectorLayer, FileLayerField } from '../../../../plugins/maps_legacy/public';
import { WMSOptions } from '../../tile_map/public/types';

export interface RegionMapVisParams {
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/core_plugins/region_map/public/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { FileLayer, VectorLayer } from 'ui/vis/map/service_settings';
import { FileLayer, VectorLayer } from '../../../../plugins/maps_legacy/public';
// TODO: reference to TILE_MAP plugin should be removed
import { ORIGIN } from '../../../../legacy/core_plugins/tile_map/common/origin';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,34 @@ import initial from './initial.png';
import blues from './blues.png';
import shadedGeohashGrid from './shadedGeohashGrid.png';
import heatmapRaw from './heatmap_raw.png';
import EMS_CATALOGUE from '../../../../ui/public/vis/__tests__/map/ems_mocks/sample_manifest.json';
import EMS_FILES from '../../../../ui/public/vis/__tests__/map/ems_mocks/sample_files.json';
import EMS_TILES from '../../../../ui/public/vis/__tests__/map/ems_mocks/sample_tiles.json';
import EMS_STYLE_ROAD_MAP_BRIGHT from '../../../../ui/public/vis/__tests__/map/ems_mocks/sample_style_bright';
import EMS_STYLE_ROAD_MAP_DESATURATED from '../../../../ui/public/vis/__tests__/map/ems_mocks/sample_style_desaturated';
import EMS_STYLE_DARK_MAP from '../../../../ui/public/vis/__tests__/map/ems_mocks/sample_style_dark';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import EMS_CATALOGUE from '../../../../../plugins/maps_legacy/public/__tests__/map/ems_mocks/sample_manifest.json';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import EMS_FILES from '../../../../../plugins/maps_legacy/public/__tests__/map/ems_mocks/sample_files.json';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import EMS_TILES from '../../../../../plugins/maps_legacy/public/__tests__/map/ems_mocks/sample_tiles.json';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import EMS_STYLE_ROAD_MAP_BRIGHT from '../../../../../plugins/maps_legacy/public/__tests__/map/ems_mocks/sample_style_bright';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import EMS_STYLE_ROAD_MAP_DESATURATED from '../../../../../plugins/maps_legacy/public/__tests__/map/ems_mocks/sample_style_desaturated';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import EMS_STYLE_DARK_MAP from '../../../../../plugins/maps_legacy/public/__tests__/map/ems_mocks/sample_style_dark';

import { createTileMapVisualization } from '../tile_map_visualization';
import { createTileMapTypeDefinition } from '../tile_map_type';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { ExprVis } from '../../../../../plugins/visualizations/public/expressions/vis';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { BaseVisType } from '../../../../../plugins/visualizations/public/vis_types/base_vis_type';
import {
getPrecision,
getZoomPrecision,
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
} from '../../../../../plugins/maps_legacy/public/map/precision';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { ServiceSettings } from '../../../../../plugins/maps_legacy/public/map/service_settings';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { setInjectedVarFunc } from '../../../../../plugins/maps_legacy/public/kibana_services';

function mockRawData() {
const stack = [dummyESResponse];
Expand Down Expand Up @@ -75,13 +90,39 @@ describe('CoordinateMapsVisualizationTest', function() {
beforeEach(ngMock.module('kibana'));
beforeEach(
ngMock.inject((Private, $injector) => {
const serviceSettings = $injector.get('serviceSettings');
setInjectedVarFunc(injectedVar => {
switch (injectedVar) {
case 'mapConfig':
return {
emsFileApiUrl: '',
emsTileApiUrl: '',
emsLandingPageUrl: '',
};
case 'tilemapsConfig':
return {
deprecated: {
config: {
options: {
attribution: '123',
},
},
},
};
case 'version':
return '123';
default:
return 'not found';
}
});
const serviceSettings = new ServiceSettings();
const uiSettings = $injector.get('config');

dependencies = {
serviceSettings,
uiSettings,
$injector,
getPrecision,
getZoomPrecision,
};

visType = new BaseVisType(createTileMapTypeDefinition(dependencies));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
*/

import expect from '@kbn/expect';
import { KibanaMap } from 'ui/vis/map/kibana_map';
import { GeohashLayer } from '../geohash_layer';
// import heatmapPng from './heatmap.png';
import scaledCircleMarkersPng from './scaledCircleMarkers.png';
// import shadedCircleMarkersPng from './shadedCircleMarkers.png';
import { ImageComparator } from 'test_utils/image_comparator';
import GeoHashSampleData from './dummy_es_response.json';
import { KibanaMap } from '../../../../../plugins/maps_legacy/public';

describe('geohash_layer', function() {
let domNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,25 @@

import _ from 'lodash';
import { i18n } from '@kbn/i18n';
import { KibanaMap } from 'ui/vis/map/kibana_map';
import { KibanaMap } from '../../../../plugins/maps_legacy/public';
import * as Rx from 'rxjs';
import { filter, first } from 'rxjs/operators';
import 'ui/vis/map/service_settings';
import { toastNotifications } from 'ui/notify';
import chrome from 'ui/chrome';

const WMS_MINZOOM = 0;
const WMS_MAXZOOM = 22; //increase this to 22. Better for WMS

export function BaseMapsVisualizationProvider(serviceSettings) {
export function BaseMapsVisualizationProvider(mapServiceSettings, notificationService) {
/**
* Abstract base class for a visualization consisting of a map with a single baselayer.
* @class BaseMapsVisualization
* @constructor
*/

const serviceSettings = mapServiceSettings;
const toastService = notificationService;

return class BaseMapsVisualization {
constructor(element, vis) {
this.vis = vis;
Expand Down Expand Up @@ -94,8 +97,9 @@ export function BaseMapsVisualizationProvider(serviceSettings) {
const centerFromUIState = uiState.get('mapCenter');
options.zoom = !isNaN(zoomFromUiState) ? zoomFromUiState : this.vis.params.mapZoom;
options.center = centerFromUIState ? centerFromUIState : this.vis.params.mapCenter;
const services = { toastService };

this._kibanaMap = new KibanaMap(this._container, options);
this._kibanaMap = new KibanaMap(this._container, options, services);
this._kibanaMap.setMinZoom(WMS_MINZOOM); //use a default
this._kibanaMap.setMaxZoom(WMS_MAXZOOM); //use a default

Expand Down
Loading