From 1ee7273514a4511095a9eca859071ceb41beb5ce Mon Sep 17 00:00:00 2001 From: Aaron Caldwell Date: Wed, 22 Apr 2020 17:45:17 -0600 Subject: [PATCH 01/12] Add kibana services for region maps to leverage. Start swapping out services --- .../region_map/public/kibana_services.ts | 30 +++++++++++++++++++ .../core_plugins/region_map/public/plugin.ts | 15 ++++++++-- .../public/region_map_visualization.js | 9 +++--- 3 files changed, 46 insertions(+), 8 deletions(-) create mode 100644 src/legacy/core_plugins/region_map/public/kibana_services.ts diff --git a/src/legacy/core_plugins/region_map/public/kibana_services.ts b/src/legacy/core_plugins/region_map/public/kibana_services.ts new file mode 100644 index 0000000000000..c094b8cbfab81 --- /dev/null +++ b/src/legacy/core_plugins/region_map/public/kibana_services.ts @@ -0,0 +1,30 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { NotificationsStart } from 'kibana/public'; +import { createGetterSetter } from '../../../../plugins/kibana_utils/public'; +import { DataPublicPluginStart } from '../../../../plugins/data/public'; + +export const [getFormatService, setFormatService] = createGetterSetter< + DataPublicPluginStart['fieldFormats'] +>('data.fieldFormats'); + +export const [getNotifications, setNotifications] = createGetterSetter( + 'Notifications' +); diff --git a/src/legacy/core_plugins/region_map/public/plugin.ts b/src/legacy/core_plugins/region_map/public/plugin.ts index 08a73517dc13b..9310c70a94aba 100644 --- a/src/legacy/core_plugins/region_map/public/plugin.ts +++ b/src/legacy/core_plugins/region_map/public/plugin.ts @@ -34,6 +34,8 @@ import { IServiceSettings, MapsLegacyPluginSetup, } from '../../../../plugins/maps_legacy/public'; +import { setFormatService, setNotifications } from './kibana_services'; +import { DataPublicPluginStart } from '../../../../plugins/data/public'; /** @private */ interface RegionMapVisualizationDependencies { @@ -41,6 +43,7 @@ interface RegionMapVisualizationDependencies { regionmapsConfig: RegionMapsConfig; serviceSettings: IServiceSettings; BaseMapsVisualization: any; + notifications: CoreStart['notifications'] | undefined; } /** @internal */ @@ -50,6 +53,11 @@ export interface RegionMapPluginSetupDependencies { mapsLegacy: MapsLegacyPluginSetup; } +/** @internal */ +export interface RegionMapPluginStartDependencies { + data: DataPublicPluginStart; +} + /** @internal */ export interface RegionMapsConfig { includeElasticMapsService: boolean; @@ -66,8 +74,9 @@ export class RegionMapPlugin implements Plugin, void> { public async setup( core: CoreSetup, - { expressions, visualizations, mapsLegacy }: RegionMapPluginSetupDependencies + { expressions, visualizations, mapsLegacy, notifications }: RegionMapPluginSetupDependencies ) { + setNotifications(notifications); const visualizationDependencies: Readonly = { uiSettings: core.uiSettings, regionmapsConfig: core.injectedMetadata.getInjectedVar('regionmap') as RegionMapsConfig, @@ -82,7 +91,7 @@ export class RegionMapPlugin implements Plugin, void> { ); } - public start(core: CoreStart) { - // nothing to do here yet + public start(core: CoreStart, { data }: RegionMapPluginStartDependencies) { + setFormatService(data.fieldFormats); } } diff --git a/src/legacy/core_plugins/region_map/public/region_map_visualization.js b/src/legacy/core_plugins/region_map/public/region_map_visualization.js index 5dbc1ecad277f..7d08e2dceaac8 100644 --- a/src/legacy/core_plugins/region_map/public/region_map_visualization.js +++ b/src/legacy/core_plugins/region_map/public/region_map_visualization.js @@ -19,8 +19,7 @@ import { i18n } from '@kbn/i18n'; import ChoroplethLayer from './choropleth_layer'; -import { getFormat } from 'ui/visualize/loader/pipeline_helpers/utilities'; -import { toastNotifications } from 'ui/notify'; +import { getFormatService, getNotifications } from './kibana_services'; import { truncatedColorMaps } from '../../../../plugins/charts/public'; import { tooltipFormatter } from './tooltip_formatter'; import { mapTooltipProvider } from '../../../../plugins/maps_legacy/public'; @@ -75,7 +74,7 @@ export function createRegionMapVisualization({ results ); - const metricFieldFormatter = getFormat(this._params.metric.format); + const metricFieldFormatter = getFormatService(this._params.metric.format); this._choroplethLayer.setMetrics(results, metricFieldFormatter, valueColumn.name); if (termColumn && valueColumn) { @@ -108,7 +107,7 @@ export function createRegionMapVisualization({ this._params.showAllShapes ); - const metricFieldFormatter = getFormat(this._params.metric.format); + const metricFieldFormatter = getFormatService(this._params.metric.format); this._choroplethLayer.setJoinField(visParams.selectedJoinField.name); this._choroplethLayer.setColorRamp(truncatedColorMaps[visParams.colorSchema].value); @@ -177,7 +176,7 @@ export function createRegionMapVisualization({ const shouldShowWarning = this._params.isDisplayWarning && uiSettings.get('visualization:regionmap:showWarnings'); if (event.mismatches.length > 0 && shouldShowWarning) { - toastNotifications.addWarning({ + getNotifications().toasts.addWarning({ title: i18n.translate('regionMap.visualization.unableToShowMismatchesWarningTitle', { defaultMessage: 'Unable to show {mismatchesLength} {oneMismatch, plural, one {result} other {results}} on map', From bc19b37d913ea2fc00e16bdb9e422b17c1002975 Mon Sep 17 00:00:00 2001 From: Aaron Caldwell Date: Tue, 28 Apr 2020 09:02:17 -0600 Subject: [PATCH 02/12] Finish up service init. Clean up type issues --- src/legacy/core_plugins/region_map/public/choropleth_layer.js | 4 ++-- src/legacy/core_plugins/region_map/public/plugin.ts | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/legacy/core_plugins/region_map/public/choropleth_layer.js b/src/legacy/core_plugins/region_map/public/choropleth_layer.js index 4ea9cc1f7bfbf..7876143c0efe1 100644 --- a/src/legacy/core_plugins/region_map/public/choropleth_layer.js +++ b/src/legacy/core_plugins/region_map/public/choropleth_layer.js @@ -23,7 +23,7 @@ import _ from 'lodash'; import d3 from 'd3'; import { i18n } from '@kbn/i18n'; import * as topojson from 'topojson-client'; -import { toastNotifications } from 'ui/notify'; +import { getNotifications } from './kibana_services'; import { colorUtil, KibanaMapLayer } from '../../../../plugins/maps_legacy/public'; import { truncatedColorMaps } from '../../../../plugins/charts/public'; @@ -181,7 +181,7 @@ CORS configuration of the server permits requests from the Kibana application on ); } - toastNotifications.addDanger({ + getNotifications().toasts.addDanger({ title: i18n.translate( 'regionMap.choroplethLayer.downloadingVectorDataErrorMessageTitle', { diff --git a/src/legacy/core_plugins/region_map/public/plugin.ts b/src/legacy/core_plugins/region_map/public/plugin.ts index 9310c70a94aba..0f939f02eed82 100644 --- a/src/legacy/core_plugins/region_map/public/plugin.ts +++ b/src/legacy/core_plugins/region_map/public/plugin.ts @@ -22,6 +22,7 @@ import { Plugin, PluginInitializerContext, IUiSettingsClient, + NotificationsSetup, } from '../../../../core/public'; import { Plugin as ExpressionsPublicPlugin } from '../../../../plugins/expressions/public'; import { VisualizationsSetup } from '../../../../plugins/visualizations/public'; @@ -43,7 +44,6 @@ interface RegionMapVisualizationDependencies { regionmapsConfig: RegionMapsConfig; serviceSettings: IServiceSettings; BaseMapsVisualization: any; - notifications: CoreStart['notifications'] | undefined; } /** @internal */ @@ -51,6 +51,7 @@ export interface RegionMapPluginSetupDependencies { expressions: ReturnType; visualizations: VisualizationsSetup; mapsLegacy: MapsLegacyPluginSetup; + notifications: NotificationsSetup; } /** @internal */ From 2d3d312a68374a7837d9832bb9364db8170fcd4e Mon Sep 17 00:00:00 2001 From: Aaron Caldwell Date: Tue, 28 Apr 2020 20:05:39 -0600 Subject: [PATCH 03/12] Add config handling and files needed in NP --- src/legacy/core_plugins/region_map/config.ts | 47 +++++++++++++++++++ .../core_plugins/region_map/kibana.json | 14 ++++++ .../core_plugins/region_map/server/index.ts | 34 ++++++++++++++ 3 files changed, 95 insertions(+) create mode 100644 src/legacy/core_plugins/region_map/config.ts create mode 100644 src/legacy/core_plugins/region_map/kibana.json create mode 100644 src/legacy/core_plugins/region_map/server/index.ts diff --git a/src/legacy/core_plugins/region_map/config.ts b/src/legacy/core_plugins/region_map/config.ts new file mode 100644 index 0000000000000..1710d3f55f553 --- /dev/null +++ b/src/legacy/core_plugins/region_map/config.ts @@ -0,0 +1,47 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { schema, TypeOf } from '@kbn/config-schema'; + +export const configSchema = schema.object({ + includeElasticMapsService: schema.boolean({ defaultValue: true }), + layers: schema.maybe( + schema.arrayOf( + schema.object({ + url: schema.string(), + format: schema.object({ + type: schema.string({ defaultValue: 'geojson' }), + }), + meta: schema.object({ + feature_collection_path: schema.string({ defaultValue: 'data' }), + }), + attribution: schema.string(), + name: schema.string(), + fields: schema.arrayOf( + schema.object({ + name: schema.string(), + description: schema.string(), + }) + ), + }) + ) + ), +}); + +export type ConfigSchema = TypeOf; diff --git a/src/legacy/core_plugins/region_map/kibana.json b/src/legacy/core_plugins/region_map/kibana.json new file mode 100644 index 0000000000000..20f0a3ead53aa --- /dev/null +++ b/src/legacy/core_plugins/region_map/kibana.json @@ -0,0 +1,14 @@ +{ + "id": "tileMap", + "version": "8.0.0", + "kibanaVersion": "kibana", + "configPath": ["map", "regionmap"], + "ui": true, + "server": true, + "requiredPlugins": [ + "visualizations", + "expressions", + "mapsLegacy", + "notifications" + ] +} diff --git a/src/legacy/core_plugins/region_map/server/index.ts b/src/legacy/core_plugins/region_map/server/index.ts new file mode 100644 index 0000000000000..e2c544d2d0ba6 --- /dev/null +++ b/src/legacy/core_plugins/region_map/server/index.ts @@ -0,0 +1,34 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { PluginConfigDescriptor } from 'kibana/server'; +import { configSchema, ConfigSchema } from '../config'; + +export const config: PluginConfigDescriptor = { + exposeToBrowser: { + includeElasticMapsService: true, + layers: true, + }, + schema: configSchema, +}; + +export const plugin = () => ({ + setup() {}, + start() {}, +}); From 3799dfdea1f59b2acc5c582a133deeba66d4d165 Mon Sep 17 00:00:00 2001 From: Aaron Caldwell Date: Tue, 28 Apr 2020 20:11:45 -0600 Subject: [PATCH 04/12] Publish region maps config --- src/legacy/core_plugins/region_map/public/index.ts | 5 +++++ src/legacy/core_plugins/region_map/public/plugin.ts | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/src/legacy/core_plugins/region_map/public/index.ts b/src/legacy/core_plugins/region_map/public/index.ts index a29f5aa247026..3c7582dd6cbd8 100644 --- a/src/legacy/core_plugins/region_map/public/index.ts +++ b/src/legacy/core_plugins/region_map/public/index.ts @@ -20,6 +20,11 @@ import { PluginInitializerContext } from '../../../../core/public'; import { RegionMapPlugin as Plugin } from './plugin'; +export interface RegionMapsConfigType { + includeElasticMapsService: boolean; + layers: any[]; +} + export function plugin(initializerContext: PluginInitializerContext) { return new Plugin(initializerContext); } diff --git a/src/legacy/core_plugins/region_map/public/plugin.ts b/src/legacy/core_plugins/region_map/public/plugin.ts index 0f939f02eed82..c00a46cc429ea 100644 --- a/src/legacy/core_plugins/region_map/public/plugin.ts +++ b/src/legacy/core_plugins/region_map/public/plugin.ts @@ -37,6 +37,7 @@ import { } from '../../../../plugins/maps_legacy/public'; import { setFormatService, setNotifications } from './kibana_services'; import { DataPublicPluginStart } from '../../../../plugins/data/public'; +import { RegionMapsConfigType } from './index'; /** @private */ interface RegionMapVisualizationDependencies { @@ -90,6 +91,11 @@ export class RegionMapPlugin implements Plugin, void> { visualizations.createBaseVisualization( createRegionMapTypeDefinition(visualizationDependencies) ); + + const config = this.initializerContext.config.get(); + return { + config, + }; } public start(core: CoreStart, { data }: RegionMapPluginStartDependencies) { From 58b8b52397984522e3b5463ad6d5b042beacba20 Mon Sep 17 00:00:00 2001 From: Aaron Caldwell Date: Tue, 28 Apr 2020 20:15:33 -0600 Subject: [PATCH 05/12] Move region maps files to NP --- src/legacy/core_plugins/region_map/index.ts | 49 ------------------ .../core_plugins/region_map/public/legacy.ts | 35 ------------- .../region_map/config.ts | 0 .../region_map/kibana.json | 0 .../region_map/package.json | 0 .../__snapshots__/region_map_fn.test.js.snap | 0 .../public/__tests__/aftercolorchange.png | Bin .../public/__tests__/afterdatachange.png | Bin .../__tests__/afterdatachangeandresize.png | Bin .../public/__tests__/afterresize.png | Bin .../public/__tests__/changestartup.png | Bin .../region_map/public/__tests__/initial.png | Bin .../__tests__/region_map_visualization.js | 22 ++++---- .../region_map/public/__tests__/toiso3.png | Bin .../region_map/public/__tests__/world.json | 0 .../region_map/public/choropleth_layer.js | 4 +- .../public/components/region_map_options.tsx | 16 ++---- .../region_map/public/index.ts | 2 +- .../region_map/public/kibana_services.ts | 4 +- .../region_map/public/plugin.ts | 14 ++--- .../region_map/public/region_map_fn.js | 0 .../region_map/public/region_map_fn.test.js | 2 +- .../region_map/public/region_map_type.js | 6 +-- .../public/region_map_visualization.js | 4 +- .../region_map/public/tooltip_formatter.js | 0 .../region_map/public/util.ts | 4 +- .../region_map/server/index.ts | 0 27 files changed, 33 insertions(+), 129 deletions(-) delete mode 100644 src/legacy/core_plugins/region_map/index.ts delete mode 100644 src/legacy/core_plugins/region_map/public/legacy.ts rename src/{legacy/core_plugins => plugins}/region_map/config.ts (100%) rename src/{legacy/core_plugins => plugins}/region_map/kibana.json (100%) rename src/{legacy/core_plugins => plugins}/region_map/package.json (100%) rename src/{legacy/core_plugins => plugins}/region_map/public/__snapshots__/region_map_fn.test.js.snap (100%) rename src/{legacy/core_plugins => plugins}/region_map/public/__tests__/aftercolorchange.png (100%) rename src/{legacy/core_plugins => plugins}/region_map/public/__tests__/afterdatachange.png (100%) rename src/{legacy/core_plugins => plugins}/region_map/public/__tests__/afterdatachangeandresize.png (100%) rename src/{legacy/core_plugins => plugins}/region_map/public/__tests__/afterresize.png (100%) rename src/{legacy/core_plugins => plugins}/region_map/public/__tests__/changestartup.png (100%) rename src/{legacy/core_plugins => plugins}/region_map/public/__tests__/initial.png (100%) rename src/{legacy/core_plugins => plugins}/region_map/public/__tests__/region_map_visualization.js (92%) rename src/{legacy/core_plugins => plugins}/region_map/public/__tests__/toiso3.png (100%) rename src/{legacy/core_plugins => plugins}/region_map/public/__tests__/world.json (100%) rename src/{legacy/core_plugins => plugins}/region_map/public/choropleth_layer.js (98%) rename src/{legacy/core_plugins => plugins}/region_map/public/components/region_map_options.tsx (95%) rename src/{legacy/core_plugins => plugins}/region_map/public/index.ts (94%) rename src/{legacy/core_plugins => plugins}/region_map/public/kibana_services.ts (87%) rename src/{legacy/core_plugins => plugins}/region_map/public/plugin.ts (88%) rename src/{legacy/core_plugins => plugins}/region_map/public/region_map_fn.js (100%) rename src/{legacy/core_plugins => plugins}/region_map/public/region_map_fn.test.js (94%) rename src/{legacy/core_plugins => plugins}/region_map/public/region_map_type.js (95%) rename src/{legacy/core_plugins => plugins}/region_map/public/region_map_visualization.js (97%) rename src/{legacy/core_plugins => plugins}/region_map/public/tooltip_formatter.js (100%) rename src/{legacy/core_plugins => plugins}/region_map/public/util.ts (86%) rename src/{legacy/core_plugins => plugins}/region_map/server/index.ts (100%) diff --git a/src/legacy/core_plugins/region_map/index.ts b/src/legacy/core_plugins/region_map/index.ts deleted file mode 100644 index 8c059314786bc..0000000000000 --- a/src/legacy/core_plugins/region_map/index.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { resolve } from 'path'; -import { Legacy } from 'kibana'; - -import { LegacyPluginApi, LegacyPluginInitializer } from '../../../../src/legacy/types'; - -const regionMapPluginInitializer: LegacyPluginInitializer = ({ Plugin }: LegacyPluginApi) => - new Plugin({ - id: 'region_map', - require: ['kibana', 'elasticsearch'], - publicDir: resolve(__dirname, 'public'), - uiExports: { - hacks: [resolve(__dirname, 'public/legacy')], - injectDefaultVars(server) { - const { regionmap } = server.config().get('map'); - - return { - regionmap, - }; - }, - }, - init: (server: Legacy.Server) => ({}), - config(Joi: any) { - return Joi.object({ - enabled: Joi.boolean().default(true), - }).default(); - }, - } as Legacy.PluginSpecOptions); - -// eslint-disable-next-line import/no-default-export -export default regionMapPluginInitializer; diff --git a/src/legacy/core_plugins/region_map/public/legacy.ts b/src/legacy/core_plugins/region_map/public/legacy.ts deleted file mode 100644 index 4bbd839331e56..0000000000000 --- a/src/legacy/core_plugins/region_map/public/legacy.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { PluginInitializerContext } from 'kibana/public'; -import { npSetup, npStart } from 'ui/new_platform'; - -import { RegionMapPluginSetupDependencies } from './plugin'; -import { plugin } from '.'; - -const plugins: Readonly = { - expressions: npSetup.plugins.expressions, - visualizations: npSetup.plugins.visualizations, - mapsLegacy: npSetup.plugins.mapsLegacy, -}; - -const pluginInstance = plugin({} as PluginInitializerContext); - -export const setup = pluginInstance.setup(npSetup.core, plugins); -export const start = pluginInstance.start(npStart.core); diff --git a/src/legacy/core_plugins/region_map/config.ts b/src/plugins/region_map/config.ts similarity index 100% rename from src/legacy/core_plugins/region_map/config.ts rename to src/plugins/region_map/config.ts diff --git a/src/legacy/core_plugins/region_map/kibana.json b/src/plugins/region_map/kibana.json similarity index 100% rename from src/legacy/core_plugins/region_map/kibana.json rename to src/plugins/region_map/kibana.json diff --git a/src/legacy/core_plugins/region_map/package.json b/src/plugins/region_map/package.json similarity index 100% rename from src/legacy/core_plugins/region_map/package.json rename to src/plugins/region_map/package.json diff --git a/src/legacy/core_plugins/region_map/public/__snapshots__/region_map_fn.test.js.snap b/src/plugins/region_map/public/__snapshots__/region_map_fn.test.js.snap similarity index 100% rename from src/legacy/core_plugins/region_map/public/__snapshots__/region_map_fn.test.js.snap rename to src/plugins/region_map/public/__snapshots__/region_map_fn.test.js.snap diff --git a/src/legacy/core_plugins/region_map/public/__tests__/aftercolorchange.png b/src/plugins/region_map/public/__tests__/aftercolorchange.png similarity index 100% rename from src/legacy/core_plugins/region_map/public/__tests__/aftercolorchange.png rename to src/plugins/region_map/public/__tests__/aftercolorchange.png diff --git a/src/legacy/core_plugins/region_map/public/__tests__/afterdatachange.png b/src/plugins/region_map/public/__tests__/afterdatachange.png similarity index 100% rename from src/legacy/core_plugins/region_map/public/__tests__/afterdatachange.png rename to src/plugins/region_map/public/__tests__/afterdatachange.png diff --git a/src/legacy/core_plugins/region_map/public/__tests__/afterdatachangeandresize.png b/src/plugins/region_map/public/__tests__/afterdatachangeandresize.png similarity index 100% rename from src/legacy/core_plugins/region_map/public/__tests__/afterdatachangeandresize.png rename to src/plugins/region_map/public/__tests__/afterdatachangeandresize.png diff --git a/src/legacy/core_plugins/region_map/public/__tests__/afterresize.png b/src/plugins/region_map/public/__tests__/afterresize.png similarity index 100% rename from src/legacy/core_plugins/region_map/public/__tests__/afterresize.png rename to src/plugins/region_map/public/__tests__/afterresize.png diff --git a/src/legacy/core_plugins/region_map/public/__tests__/changestartup.png b/src/plugins/region_map/public/__tests__/changestartup.png similarity index 100% rename from src/legacy/core_plugins/region_map/public/__tests__/changestartup.png rename to src/plugins/region_map/public/__tests__/changestartup.png diff --git a/src/legacy/core_plugins/region_map/public/__tests__/initial.png b/src/plugins/region_map/public/__tests__/initial.png similarity index 100% rename from src/legacy/core_plugins/region_map/public/__tests__/initial.png rename to src/plugins/region_map/public/__tests__/initial.png diff --git a/src/legacy/core_plugins/region_map/public/__tests__/region_map_visualization.js b/src/plugins/region_map/public/__tests__/region_map_visualization.js similarity index 92% rename from src/legacy/core_plugins/region_map/public/__tests__/region_map_visualization.js rename to src/plugins/region_map/public/__tests__/region_map_visualization.js index 87592cf4e750e..3932f364f2f02 100644 --- a/src/legacy/core_plugins/region_map/public/__tests__/region_map_visualization.js +++ b/src/plugins/region_map/public/__tests__/region_map_visualization.js @@ -24,17 +24,17 @@ import ChoroplethLayer from '../choropleth_layer'; import { ImageComparator } from 'test_utils/image_comparator'; import worldJson from './world.json'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import EMS_CATALOGUE from '../../../../../plugins/maps_legacy/public/__tests__/map/ems_mocks/sample_manifest.json'; +import EMS_CATALOGUE from '../../../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'; +import EMS_FILES from '../../../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'; +import EMS_TILES from '../../../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'; +import EMS_STYLE_ROAD_MAP_BRIGHT from '../../../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'; +import EMS_STYLE_ROAD_MAP_DESATURATED from '../../../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 EMS_STYLE_DARK_MAP from '../../../maps_legacy/public/__tests__/map/ems_mocks/sample_style_dark'; import initialPng from './initial.png'; import toiso3Png from './toiso3.png'; @@ -47,14 +47,14 @@ import changestartupPng from './changestartup.png'; import { createRegionMapVisualization } from '../region_map_visualization'; import { createRegionMapTypeDefinition } from '../region_map_type'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { ExprVis } from '../../../../../plugins/visualizations/public/expressions/vis'; +import { ExprVis } from '../../../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 { BaseVisType } from '../../../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'; +import { setInjectedVarFunc } from '../../../maps_legacy/public/kibana_services'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { ServiceSettings } from '../../../../../plugins/maps_legacy/public/map/service_settings'; -import { getBaseMapsVis } from '../../../../../plugins/maps_legacy/public'; +import { ServiceSettings } from '../../../maps_legacy/public/map/service_settings'; +import { getBaseMapsVis } from '../../../maps_legacy/public'; const THRESHOLD = 0.45; const PIXEL_DIFF = 96; diff --git a/src/legacy/core_plugins/region_map/public/__tests__/toiso3.png b/src/plugins/region_map/public/__tests__/toiso3.png similarity index 100% rename from src/legacy/core_plugins/region_map/public/__tests__/toiso3.png rename to src/plugins/region_map/public/__tests__/toiso3.png diff --git a/src/legacy/core_plugins/region_map/public/__tests__/world.json b/src/plugins/region_map/public/__tests__/world.json similarity index 100% rename from src/legacy/core_plugins/region_map/public/__tests__/world.json rename to src/plugins/region_map/public/__tests__/world.json diff --git a/src/legacy/core_plugins/region_map/public/choropleth_layer.js b/src/plugins/region_map/public/choropleth_layer.js similarity index 98% rename from src/legacy/core_plugins/region_map/public/choropleth_layer.js rename to src/plugins/region_map/public/choropleth_layer.js index 7876143c0efe1..0e4e7d416d78c 100644 --- a/src/legacy/core_plugins/region_map/public/choropleth_layer.js +++ b/src/plugins/region_map/public/choropleth_layer.js @@ -24,8 +24,8 @@ import d3 from 'd3'; import { i18n } from '@kbn/i18n'; import * as topojson from 'topojson-client'; import { getNotifications } from './kibana_services'; -import { colorUtil, KibanaMapLayer } from '../../../../plugins/maps_legacy/public'; -import { truncatedColorMaps } from '../../../../plugins/charts/public'; +import { colorUtil, KibanaMapLayer } from '../../maps_legacy/public'; +import { truncatedColorMaps } from '../../charts/public'; const EMPTY_STYLE = { weight: 1, diff --git a/src/legacy/core_plugins/region_map/public/components/region_map_options.tsx b/src/plugins/region_map/public/components/region_map_options.tsx similarity index 95% rename from src/legacy/core_plugins/region_map/public/components/region_map_options.tsx rename to src/plugins/region_map/public/components/region_map_options.tsx index 5604067433f13..47eb321dbbf95 100644 --- a/src/legacy/core_plugins/region_map/public/components/region_map_options.tsx +++ b/src/plugins/region_map/public/components/region_map_options.tsx @@ -20,19 +20,11 @@ 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 { FormattedMessage } from '@kbn/i18n/target/types/react'; import { VisOptionsProps } from 'src/plugins/vis_default_editor/public'; -import { - FileLayerField, - VectorLayer, - IServiceSettings, -} from '../../../../../plugins/maps_legacy/public'; -import { - NumberInputOption, - SelectOption, - SwitchOption, -} from '../../../../../plugins/charts/public'; -import { RegionMapVisParams, WmsOptions } from '../../../../../plugins/maps_legacy/public'; +import { FileLayerField, VectorLayer, IServiceSettings } from '../../../maps_legacy/public'; +import { NumberInputOption, SelectOption, SwitchOption } from '../../../charts/public'; +import { RegionMapVisParams, WmsOptions } from '../../../maps_legacy/public'; const mapLayerForOption = ({ layerId, name }: VectorLayer) => ({ text: name, diff --git a/src/legacy/core_plugins/region_map/public/index.ts b/src/plugins/region_map/public/index.ts similarity index 94% rename from src/legacy/core_plugins/region_map/public/index.ts rename to src/plugins/region_map/public/index.ts index 3c7582dd6cbd8..3f920ad16683a 100644 --- a/src/legacy/core_plugins/region_map/public/index.ts +++ b/src/plugins/region_map/public/index.ts @@ -17,7 +17,7 @@ * under the License. */ -import { PluginInitializerContext } from '../../../../core/public'; +import { PluginInitializerContext } from 'kibana/public'; import { RegionMapPlugin as Plugin } from './plugin'; export interface RegionMapsConfigType { diff --git a/src/legacy/core_plugins/region_map/public/kibana_services.ts b/src/plugins/region_map/public/kibana_services.ts similarity index 87% rename from src/legacy/core_plugins/region_map/public/kibana_services.ts rename to src/plugins/region_map/public/kibana_services.ts index c094b8cbfab81..1ef58c69c5bef 100644 --- a/src/legacy/core_plugins/region_map/public/kibana_services.ts +++ b/src/plugins/region_map/public/kibana_services.ts @@ -18,8 +18,8 @@ */ import { NotificationsStart } from 'kibana/public'; -import { createGetterSetter } from '../../../../plugins/kibana_utils/public'; -import { DataPublicPluginStart } from '../../../../plugins/data/public'; +import { createGetterSetter } from '../../kibana_utils/public'; +import { DataPublicPluginStart } from '../../data/public'; export const [getFormatService, setFormatService] = createGetterSetter< DataPublicPluginStart['fieldFormats'] diff --git a/src/legacy/core_plugins/region_map/public/plugin.ts b/src/plugins/region_map/public/plugin.ts similarity index 88% rename from src/legacy/core_plugins/region_map/public/plugin.ts rename to src/plugins/region_map/public/plugin.ts index c00a46cc429ea..17236ca6d5563 100644 --- a/src/legacy/core_plugins/region_map/public/plugin.ts +++ b/src/plugins/region_map/public/plugin.ts @@ -23,20 +23,16 @@ import { PluginInitializerContext, IUiSettingsClient, NotificationsSetup, -} from '../../../../core/public'; -import { Plugin as ExpressionsPublicPlugin } from '../../../../plugins/expressions/public'; -import { VisualizationsSetup } from '../../../../plugins/visualizations/public'; +} from 'kibana/public'; +import { Plugin as ExpressionsPublicPlugin } from '../../expressions/public'; +import { VisualizationsSetup } from '../../visualizations/public'; // @ts-ignore import { createRegionMapFn } from './region_map_fn'; // @ts-ignore import { createRegionMapTypeDefinition } from './region_map_type'; -import { - getBaseMapsVis, - IServiceSettings, - MapsLegacyPluginSetup, -} from '../../../../plugins/maps_legacy/public'; +import { getBaseMapsVis, IServiceSettings, MapsLegacyPluginSetup } from '../../maps_legacy/public'; import { setFormatService, setNotifications } from './kibana_services'; -import { DataPublicPluginStart } from '../../../../plugins/data/public'; +import { DataPublicPluginStart } from '../../data/public'; import { RegionMapsConfigType } from './index'; /** @private */ diff --git a/src/legacy/core_plugins/region_map/public/region_map_fn.js b/src/plugins/region_map/public/region_map_fn.js similarity index 100% rename from src/legacy/core_plugins/region_map/public/region_map_fn.js rename to src/plugins/region_map/public/region_map_fn.js diff --git a/src/legacy/core_plugins/region_map/public/region_map_fn.test.js b/src/plugins/region_map/public/region_map_fn.test.js similarity index 94% rename from src/legacy/core_plugins/region_map/public/region_map_fn.test.js rename to src/plugins/region_map/public/region_map_fn.test.js index 07b4e33b85e27..91139c02179e8 100644 --- a/src/legacy/core_plugins/region_map/public/region_map_fn.test.js +++ b/src/plugins/region_map/public/region_map_fn.test.js @@ -18,7 +18,7 @@ */ // eslint-disable-next-line -import { functionWrapper } from '../../../../plugins/expressions/common/expression_functions/specs/tests/utils'; +import { functionWrapper } from '../../expressions/common/expression_functions/specs/tests/utils'; import { createRegionMapFn } from './region_map_fn'; jest.mock('ui/new_platform'); diff --git a/src/legacy/core_plugins/region_map/public/region_map_type.js b/src/plugins/region_map/public/region_map_type.js similarity index 95% rename from src/legacy/core_plugins/region_map/public/region_map_type.js rename to src/plugins/region_map/public/region_map_type.js index b7ed14ed3706e..d29360a9589ab 100644 --- a/src/legacy/core_plugins/region_map/public/region_map_type.js +++ b/src/plugins/region_map/public/region_map_type.js @@ -21,9 +21,9 @@ import { i18n } from '@kbn/i18n'; import { mapToLayerWithId } from './util'; import { createRegionMapVisualization } from './region_map_visualization'; import { RegionMapOptions } from './components/region_map_options'; -import { truncatedColorSchemas } from '../../../../plugins/charts/public'; -import { Schemas } from '../../../../plugins/vis_default_editor/public'; -import { ORIGIN } from '../../../../plugins/maps_legacy/public'; +import { truncatedColorSchemas } from '../../charts/public'; +import { Schemas } from '../../vis_default_editor/public'; +import { ORIGIN } from '../../maps_legacy/public'; export function createRegionMapTypeDefinition(dependencies) { const { uiSettings, regionmapsConfig, serviceSettings } = dependencies; diff --git a/src/legacy/core_plugins/region_map/public/region_map_visualization.js b/src/plugins/region_map/public/region_map_visualization.js similarity index 97% rename from src/legacy/core_plugins/region_map/public/region_map_visualization.js rename to src/plugins/region_map/public/region_map_visualization.js index 7d08e2dceaac8..3b4a92edea565 100644 --- a/src/legacy/core_plugins/region_map/public/region_map_visualization.js +++ b/src/plugins/region_map/public/region_map_visualization.js @@ -20,9 +20,9 @@ import { i18n } from '@kbn/i18n'; import ChoroplethLayer from './choropleth_layer'; import { getFormatService, getNotifications } from './kibana_services'; -import { truncatedColorMaps } from '../../../../plugins/charts/public'; +import { truncatedColorMaps } from '../../charts/public'; import { tooltipFormatter } from './tooltip_formatter'; -import { mapTooltipProvider } from '../../../../plugins/maps_legacy/public'; +import { mapTooltipProvider } from '../../maps_legacy/public'; export function createRegionMapVisualization({ serviceSettings, diff --git a/src/legacy/core_plugins/region_map/public/tooltip_formatter.js b/src/plugins/region_map/public/tooltip_formatter.js similarity index 100% rename from src/legacy/core_plugins/region_map/public/tooltip_formatter.js rename to src/plugins/region_map/public/tooltip_formatter.js diff --git a/src/legacy/core_plugins/region_map/public/util.ts b/src/plugins/region_map/public/util.ts similarity index 86% rename from src/legacy/core_plugins/region_map/public/util.ts rename to src/plugins/region_map/public/util.ts index b4e0dcd5f3510..0160a32e81522 100644 --- a/src/legacy/core_plugins/region_map/public/util.ts +++ b/src/plugins/region_map/public/util.ts @@ -17,8 +17,8 @@ * under the License. */ -import { FileLayer, VectorLayer } from '../../../../plugins/maps_legacy/public'; -import { ORIGIN } from '../../../../plugins/maps_legacy/public'; +import { FileLayer, VectorLayer } from '../../maps_legacy/public'; +import { ORIGIN } from '../../maps_legacy/public'; export const mapToLayerWithId = (prefix: string, layer: FileLayer): VectorLayer => ({ ...layer, diff --git a/src/legacy/core_plugins/region_map/server/index.ts b/src/plugins/region_map/server/index.ts similarity index 100% rename from src/legacy/core_plugins/region_map/server/index.ts rename to src/plugins/region_map/server/index.ts From b062fdce3a1bd49f83448379020030113b5f2f9b Mon Sep 17 00:00:00 2001 From: Aaron Caldwell Date: Tue, 28 Apr 2020 20:16:48 -0600 Subject: [PATCH 06/12] Clean up jest test --- src/plugins/region_map/public/region_map_fn.test.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/plugins/region_map/public/region_map_fn.test.js b/src/plugins/region_map/public/region_map_fn.test.js index 91139c02179e8..684cc5e897df4 100644 --- a/src/plugins/region_map/public/region_map_fn.test.js +++ b/src/plugins/region_map/public/region_map_fn.test.js @@ -21,8 +21,6 @@ import { functionWrapper } from '../../expressions/common/expression_functions/specs/tests/utils'; import { createRegionMapFn } from './region_map_fn'; -jest.mock('ui/new_platform'); - describe('interpreter/functions#regionmap', () => { const fn = functionWrapper(createRegionMapFn()); const context = { From 40c103a3ba5a3eee9555367561fcb9122ece2e13 Mon Sep 17 00:00:00 2001 From: Aaron Caldwell Date: Wed, 29 Apr 2020 16:24:05 -0600 Subject: [PATCH 07/12] Add new path to i18n --- .i18nrc.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.i18nrc.json b/.i18nrc.json index b04c02f6b2265..f53a9f30aee92 100644 --- a/.i18nrc.json +++ b/.i18nrc.json @@ -33,7 +33,7 @@ "kibana_utils": "src/plugins/kibana_utils", "navigation": "src/plugins/navigation", "newsfeed": "src/plugins/newsfeed", - "regionMap": "src/legacy/core_plugins/region_map", + "regionMap": "src/plugins/region_map", "savedObjects": "src/plugins/saved_objects", "savedObjectsManagement": "src/plugins/saved_objects_management", "server": "src/legacy/server", From 785e62c5760a59371011f328f7f558708a4425d8 Mon Sep 17 00:00:00 2001 From: Aaron Caldwell Date: Wed, 29 Apr 2020 16:24:35 -0600 Subject: [PATCH 08/12] Clean up --- src/plugins/region_map/kibana.json | 2 +- .../region_map/public/components/region_map_options.tsx | 2 +- src/plugins/region_map/public/plugin.ts | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/region_map/kibana.json b/src/plugins/region_map/kibana.json index 20f0a3ead53aa..9336faae9253a 100644 --- a/src/plugins/region_map/kibana.json +++ b/src/plugins/region_map/kibana.json @@ -1,5 +1,5 @@ { - "id": "tileMap", + "id": "regionMap", "version": "8.0.0", "kibanaVersion": "kibana", "configPath": ["map", "regionmap"], diff --git a/src/plugins/region_map/public/components/region_map_options.tsx b/src/plugins/region_map/public/components/region_map_options.tsx index 47eb321dbbf95..9a6987b981539 100644 --- a/src/plugins/region_map/public/components/region_map_options.tsx +++ b/src/plugins/region_map/public/components/region_map_options.tsx @@ -20,7 +20,7 @@ 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/target/types/react'; +import { FormattedMessage } from '@kbn/i18n/react'; import { VisOptionsProps } from 'src/plugins/vis_default_editor/public'; import { FileLayerField, VectorLayer, IServiceSettings } from '../../../maps_legacy/public'; import { NumberInputOption, SelectOption, SwitchOption } from '../../../charts/public'; diff --git a/src/plugins/region_map/public/plugin.ts b/src/plugins/region_map/public/plugin.ts index 17236ca6d5563..4d39c822dfa8a 100644 --- a/src/plugins/region_map/public/plugin.ts +++ b/src/plugins/region_map/public/plugin.ts @@ -75,9 +75,10 @@ export class RegionMapPlugin implements Plugin, void> { { expressions, visualizations, mapsLegacy, notifications }: RegionMapPluginSetupDependencies ) { setNotifications(notifications); + const config = this.initializerContext.config.get(); const visualizationDependencies: Readonly = { uiSettings: core.uiSettings, - regionmapsConfig: core.injectedMetadata.getInjectedVar('regionmap') as RegionMapsConfig, + regionmapsConfig: config as RegionMapsConfig, serviceSettings: mapsLegacy.serviceSettings, BaseMapsVisualization: getBaseMapsVis(core, mapsLegacy.serviceSettings), }; @@ -88,7 +89,6 @@ export class RegionMapPlugin implements Plugin, void> { createRegionMapTypeDefinition(visualizationDependencies) ); - const config = this.initializerContext.config.get(); return { config, }; From 76d2a747ca5b3bc92816ac9fb1fe5cb810878e97 Mon Sep 17 00:00:00 2001 From: Aaron Caldwell Date: Wed, 29 Apr 2020 17:38:26 -0600 Subject: [PATCH 09/12] More cleanup --- src/plugins/region_map/kibana.json | 2 +- src/plugins/region_map/public/plugin.ts | 16 +++++++++++----- .../public/region_map_visualization.js | 4 ++-- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/plugins/region_map/kibana.json b/src/plugins/region_map/kibana.json index 9336faae9253a..3a6f64e92bcba 100644 --- a/src/plugins/region_map/kibana.json +++ b/src/plugins/region_map/kibana.json @@ -9,6 +9,6 @@ "visualizations", "expressions", "mapsLegacy", - "notifications" + "data" ] } diff --git a/src/plugins/region_map/public/plugin.ts b/src/plugins/region_map/public/plugin.ts index 4d39c822dfa8a..b7859503ed0f5 100644 --- a/src/plugins/region_map/public/plugin.ts +++ b/src/plugins/region_map/public/plugin.ts @@ -22,7 +22,7 @@ import { Plugin, PluginInitializerContext, IUiSettingsClient, - NotificationsSetup, + NotificationsStart, } from 'kibana/public'; import { Plugin as ExpressionsPublicPlugin } from '../../expressions/public'; import { VisualizationsSetup } from '../../visualizations/public'; @@ -48,12 +48,12 @@ export interface RegionMapPluginSetupDependencies { expressions: ReturnType; visualizations: VisualizationsSetup; mapsLegacy: MapsLegacyPluginSetup; - notifications: NotificationsSetup; } /** @internal */ export interface RegionMapPluginStartDependencies { data: DataPublicPluginStart; + notifications: NotificationsStart; } /** @internal */ @@ -62,8 +62,14 @@ export interface RegionMapsConfig { layers: any[]; } +export interface RegionMapPluginSetup { + config: any; +} +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface RegionMapPluginStart {} + /** @internal */ -export class RegionMapPlugin implements Plugin, void> { +export class RegionMapPlugin implements Plugin { initializerContext: PluginInitializerContext; constructor(initializerContext: PluginInitializerContext) { @@ -72,9 +78,8 @@ export class RegionMapPlugin implements Plugin, void> { public async setup( core: CoreSetup, - { expressions, visualizations, mapsLegacy, notifications }: RegionMapPluginSetupDependencies + { expressions, visualizations, mapsLegacy }: RegionMapPluginSetupDependencies ) { - setNotifications(notifications); const config = this.initializerContext.config.get(); const visualizationDependencies: Readonly = { uiSettings: core.uiSettings, @@ -96,5 +101,6 @@ export class RegionMapPlugin implements Plugin, void> { public start(core: CoreStart, { data }: RegionMapPluginStartDependencies) { setFormatService(data.fieldFormats); + setNotifications(core.notifications); } } diff --git a/src/plugins/region_map/public/region_map_visualization.js b/src/plugins/region_map/public/region_map_visualization.js index 3b4a92edea565..ed6a3ed2c10c8 100644 --- a/src/plugins/region_map/public/region_map_visualization.js +++ b/src/plugins/region_map/public/region_map_visualization.js @@ -74,7 +74,7 @@ export function createRegionMapVisualization({ results ); - const metricFieldFormatter = getFormatService(this._params.metric.format); + const metricFieldFormatter = getFormatService().deserialize(this._params.metric.format); this._choroplethLayer.setMetrics(results, metricFieldFormatter, valueColumn.name); if (termColumn && valueColumn) { @@ -107,7 +107,7 @@ export function createRegionMapVisualization({ this._params.showAllShapes ); - const metricFieldFormatter = getFormatService(this._params.metric.format); + const metricFieldFormatter = getFormatService().deserialize(this._params.metric.format); this._choroplethLayer.setJoinField(visParams.selectedJoinField.name); this._choroplethLayer.setColorRamp(truncatedColorMaps[visParams.colorSchema].value); From f260585c35d8e3c24ec5a8e7d41d38d0d21959a3 Mon Sep 17 00:00:00 2001 From: Aaron Caldwell Date: Wed, 29 Apr 2020 21:36:17 -0600 Subject: [PATCH 10/12] Change how popup is instantiated and bound to map --- src/plugins/maps_legacy/public/map/kibana_map.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/plugins/maps_legacy/public/map/kibana_map.js b/src/plugins/maps_legacy/public/map/kibana_map.js index c7cec1b14159a..ebf53b281d741 100644 --- a/src/plugins/maps_legacy/public/map/kibana_map.js +++ b/src/plugins/maps_legacy/public/map/kibana_map.js @@ -20,6 +20,7 @@ import { EventEmitter } from 'events'; import { createZoomWarningMsg } from './map_messages'; import L from 'leaflet'; +import { ResponsivePopup } from 'leaflet-responsive-popup'; import $ from 'jquery'; import _ from 'lodash'; import { zoomToPrecision } from './zoom_to_precision'; @@ -228,10 +229,10 @@ export class KibanaMap extends EventEmitter { } if (!this._popup) { - this._popup = L.responsivePopup({ autoPan: false }); + this._popup = new ResponsivePopup({ autoPan: false }); this._popup.setLatLng(event.position); this._popup.setContent(event.content); - this._popup.openOn(this._leafletMap); + this._leafletMap.openPopup(this._popup); } else { if (!this._popup.getLatLng().equals(event.position)) { this._popup.setLatLng(event.position); From e07891cf77727b42214258f4621d17932964052b Mon Sep 17 00:00:00 2001 From: Aaron Caldwell Date: Wed, 6 May 2020 16:59:54 -0600 Subject: [PATCH 11/12] Mostly config updates to account for latest tilemap work merged in --- src/plugins/maps_legacy/config.ts | 26 +---------------- src/plugins/maps_legacy/public/index.ts | 1 + src/plugins/region_map/config.ts | 39 ++++++++++++------------- src/plugins/region_map/public/plugin.ts | 14 +++++++-- 4 files changed, 32 insertions(+), 48 deletions(-) diff --git a/src/plugins/maps_legacy/config.ts b/src/plugins/maps_legacy/config.ts index 13a0ad6b393a3..67e46d2270583 100644 --- a/src/plugins/maps_legacy/config.ts +++ b/src/plugins/maps_legacy/config.ts @@ -19,31 +19,7 @@ import { schema, TypeOf } from '@kbn/config-schema'; import { configSchema as tilemapSchema } from '../tile_map/config'; - -// TODO: Pull this portion from region_map -export const regionmapSchema = schema.object({ - includeElasticMapsService: schema.boolean({ defaultValue: true }), - layers: schema.arrayOf( - schema.object({ - url: schema.string(), - format: schema.object({ - type: schema.string({ defaultValue: 'geojson' }), - }), - meta: schema.object({ - feature_collection_path: schema.string({ defaultValue: 'data' }), - }), - attribution: schema.string(), - name: schema.string(), - fields: schema.arrayOf( - schema.object({ - name: schema.string(), - description: schema.string(), - }) - ), - }), - { defaultValue: [] } - ), -}); +import { configSchema as regionmapSchema } from '../region_map/config'; export const configSchema = schema.object({ includeElasticMapsService: schema.boolean({ defaultValue: true }), diff --git a/src/plugins/maps_legacy/public/index.ts b/src/plugins/maps_legacy/public/index.ts index 3fe377fbdc41f..a7f5427909334 100644 --- a/src/plugins/maps_legacy/public/index.ts +++ b/src/plugins/maps_legacy/public/index.ts @@ -45,6 +45,7 @@ import { import { mapTooltipProvider } from './tooltip_provider'; export interface MapsLegacyConfigType { + regionmap: any; emsTileLayerId: string; includeElasticMapsService: boolean; proxyElasticMapsServiceInMaps: boolean; diff --git a/src/plugins/region_map/config.ts b/src/plugins/region_map/config.ts index 1710d3f55f553..a721a76ca0a82 100644 --- a/src/plugins/region_map/config.ts +++ b/src/plugins/region_map/config.ts @@ -21,26 +21,25 @@ import { schema, TypeOf } from '@kbn/config-schema'; export const configSchema = schema.object({ includeElasticMapsService: schema.boolean({ defaultValue: true }), - layers: schema.maybe( - schema.arrayOf( - schema.object({ - url: schema.string(), - format: schema.object({ - type: schema.string({ defaultValue: 'geojson' }), - }), - meta: schema.object({ - feature_collection_path: schema.string({ defaultValue: 'data' }), - }), - attribution: schema.string(), - name: schema.string(), - fields: schema.arrayOf( - schema.object({ - name: schema.string(), - description: schema.string(), - }) - ), - }) - ) + layers: schema.arrayOf( + schema.object({ + url: schema.string(), + format: schema.object({ + type: schema.string({ defaultValue: 'geojson' }), + }), + meta: schema.object({ + feature_collection_path: schema.string({ defaultValue: 'data' }), + }), + attribution: schema.string(), + name: schema.string(), + fields: schema.arrayOf( + schema.object({ + name: schema.string(), + description: schema.string(), + }) + ), + }), + { defaultValue: [] } ), }); diff --git a/src/plugins/region_map/public/plugin.ts b/src/plugins/region_map/public/plugin.ts index b7859503ed0f5..09a13fbe9774e 100644 --- a/src/plugins/region_map/public/plugin.ts +++ b/src/plugins/region_map/public/plugin.ts @@ -34,6 +34,7 @@ import { getBaseMapsVis, IServiceSettings, MapsLegacyPluginSetup } from '../../m import { setFormatService, setNotifications } from './kibana_services'; import { DataPublicPluginStart } from '../../data/public'; import { RegionMapsConfigType } from './index'; +import { ConfigSchema } from '../../maps_legacy/config'; /** @private */ interface RegionMapVisualizationDependencies { @@ -70,17 +71,23 @@ export interface RegionMapPluginStart {} /** @internal */ export class RegionMapPlugin implements Plugin { - initializerContext: PluginInitializerContext; + readonly _initializerContext: PluginInitializerContext; constructor(initializerContext: PluginInitializerContext) { - this.initializerContext = initializerContext; + this._initializerContext = initializerContext; } public async setup( core: CoreSetup, { expressions, visualizations, mapsLegacy }: RegionMapPluginSetupDependencies ) { - const config = this.initializerContext.config.get(); + const config = { + ...this._initializerContext.config.get(), + // The maps legacy plugin updates the regionmap config directly in service_settings, + // future work on how configurations across the different plugins are organized would + // ideally constrain regionmap config updates to occur only from this plugin + ...mapsLegacy.config.regionmap, + }; const visualizationDependencies: Readonly = { uiSettings: core.uiSettings, regionmapsConfig: config as RegionMapsConfig, @@ -99,6 +106,7 @@ export class RegionMapPlugin implements Plugin Date: Thu, 7 May 2020 09:08:51 -0600 Subject: [PATCH 12/12] Uncomment region map test --- .../test_suites/run_pipeline/basic.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/test/interpreter_functional/test_suites/run_pipeline/basic.ts b/test/interpreter_functional/test_suites/run_pipeline/basic.ts index 51ad789143c54..a2172dd2da1ba 100644 --- a/test/interpreter_functional/test_suites/run_pipeline/basic.ts +++ b/test/interpreter_functional/test_suites/run_pipeline/basic.ts @@ -113,11 +113,10 @@ export default function({ await expectExpression('partial_test_2', metricExpr, context).toMatchSnapshot() ).toMatchScreenshot(); - // TODO: should be uncommented when the region map is migrated to the new platform - // const regionMapExpr = `regionmap visConfig='{"metric":{"accessor":1,"format":{"id":"number"}},"bucket":{"accessor":0}}'`; - // await ( - // await expectExpression('partial_test_3', regionMapExpr, context).toMatchSnapshot() - // ).toMatchScreenshot(); + const regionMapExpr = `regionmap visConfig='{"metric":{"accessor":1,"format":{"id":"number"}},"bucket":{"accessor":0}}'`; + await ( + await expectExpression('partial_test_3', regionMapExpr, context).toMatchSnapshot() + ).toMatchScreenshot(); }); }); });