From fb23b203cbe9b9555685f0798ca6916b9ab3252b Mon Sep 17 00:00:00 2001 From: Thomas Neirynck Date: Mon, 11 Jan 2021 12:07:58 -0500 Subject: [PATCH 01/13] init --- .../plugins/maps/public/licensed_features.ts | 24 ++++++++++++------- x-pack/plugins/maps/public/plugin.ts | 4 ++-- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/x-pack/plugins/maps/public/licensed_features.ts b/x-pack/plugins/maps/public/licensed_features.ts index f709dd529e375..f16fcac900683 100644 --- a/x-pack/plugins/maps/public/licensed_features.ts +++ b/x-pack/plugins/maps/public/licensed_features.ts @@ -54,17 +54,23 @@ export function registerLicensedFeatures(licensingPlugin: LicensingPluginSetup) } let licensingPluginStart: LicensingPluginStart; -export function setLicensingPluginStart(licensingPlugin: LicensingPluginStart) { - licensingPluginStart = licensingPlugin; - licensingPluginStart.license$.subscribe((license: ILicense) => { - const gold = license.check(APP_ID, 'gold'); - isGoldPlus = gold.state === 'valid'; - const enterprise = license.check(APP_ID, 'enterprise'); - isEnterprisePlus = enterprise.state === 'valid'; +function updateLicenseState(license: ILicense) { + const gold = license.check(APP_ID, 'gold'); + isGoldPlus = gold.state === 'valid'; + + const enterprise = license.check(APP_ID, 'enterprise'); + isEnterprisePlus = enterprise.state === 'valid'; + + licenseId = license.uid; +} + +export async function setLicensingPluginStart(licensingPlugin: LicensingPluginStart) { + const license = await licensingPlugin.refresh(); + updateLicenseState(license); - licenseId = license.uid; - }); + licensingPluginStart = licensingPlugin; + licensingPluginStart.license$.subscribe(updateLicenseState); } export function notifyLicensedFeatureUsage(licensedFeature: LICENSED_FEATURES) { diff --git a/x-pack/plugins/maps/public/plugin.ts b/x-pack/plugins/maps/public/plugin.ts index 8bffea3ce5a87..b5340f4e31068 100644 --- a/x-pack/plugins/maps/public/plugin.ts +++ b/x-pack/plugins/maps/public/plugin.ts @@ -158,8 +158,8 @@ export class MapsPlugin }); } - public start(core: CoreStart, plugins: MapsPluginStartDependencies): MapsStartApi { - setLicensingPluginStart(plugins.licensing); + public async start(core: CoreStart, plugins: MapsPluginStartDependencies): Promise { + await setLicensingPluginStart(plugins.licensing); plugins.uiActions.addTriggerAction(VISUALIZE_GEO_FIELD_TRIGGER, visualizeGeoFieldAction); setStartServices(core, plugins); // unregisters the OSS alias From 455d7acf32a82f7ed2802b721db900f2c9f937d1 Mon Sep 17 00:00:00 2001 From: Thomas Neirynck Date: Tue, 12 Jan 2021 15:32:25 -0500 Subject: [PATCH 02/13] remove blocking behavior --- x-pack/plugins/maps/public/licensed_features.ts | 1 - x-pack/plugins/maps/public/plugin.ts | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/maps/public/licensed_features.ts b/x-pack/plugins/maps/public/licensed_features.ts index f16fcac900683..e39f8d672ae21 100644 --- a/x-pack/plugins/maps/public/licensed_features.ts +++ b/x-pack/plugins/maps/public/licensed_features.ts @@ -36,7 +36,6 @@ export const LICENCED_FEATURES_DETAILS: Record licenseId; diff --git a/x-pack/plugins/maps/public/plugin.ts b/x-pack/plugins/maps/public/plugin.ts index b5340f4e31068..8d9ea83e1cfd2 100644 --- a/x-pack/plugins/maps/public/plugin.ts +++ b/x-pack/plugins/maps/public/plugin.ts @@ -158,8 +158,8 @@ export class MapsPlugin }); } - public async start(core: CoreStart, plugins: MapsPluginStartDependencies): Promise { - await setLicensingPluginStart(plugins.licensing); + public start(core: CoreStart, plugins: MapsPluginStartDependencies): Promise { + setLicensingPluginStart(plugins.licensing); plugins.uiActions.addTriggerAction(VISUALIZE_GEO_FIELD_TRIGGER, visualizeGeoFieldAction); setStartServices(core, plugins); // unregisters the OSS alias From 37cfeb6d5aa37f0b4b0e43a2da83bbbbbe6abbf7 Mon Sep 17 00:00:00 2001 From: Thomas Neirynck Date: Wed, 13 Jan 2021 14:40:21 -0500 Subject: [PATCH 03/13] delay map availability until license-state is initialized --- x-pack/plugins/maps/public/licensed_features.ts | 10 ++++++++++ .../maps/public/routes/map_page/saved_map/saved_map.ts | 3 +++ 2 files changed, 13 insertions(+) diff --git a/x-pack/plugins/maps/public/licensed_features.ts b/x-pack/plugins/maps/public/licensed_features.ts index e39f8d672ae21..049087d5fbf1d 100644 --- a/x-pack/plugins/maps/public/licensed_features.ts +++ b/x-pack/plugins/maps/public/licensed_features.ts @@ -41,7 +41,15 @@ let isEnterprisePlus: boolean = false; export const getLicenseId = () => licenseId; export const getIsGoldPlus = () => isGoldPlus; +let initializeLicense: (value: unknown) => void; +const licenseInitialized = new Promise((resolve) => { + initializeLicense = resolve; +}); + export const getIsEnterprisePlus = () => isEnterprisePlus; +export const whenLicenseInitialized = async (): Promise => { + await licenseInitialized; +}; export function registerLicensedFeatures(licensingPlugin: LicensingPluginSetup) { for (const licensedFeature of Object.values(LICENSED_FEATURES)) { @@ -70,6 +78,8 @@ export async function setLicensingPluginStart(licensingPlugin: LicensingPluginSt licensingPluginStart = licensingPlugin; licensingPluginStart.license$.subscribe(updateLicenseState); + + initializeLicense(undefined); } export function notifyLicensedFeatureUsage(licensedFeature: LICENSED_FEATURES) { diff --git a/x-pack/plugins/maps/public/routes/map_page/saved_map/saved_map.ts b/x-pack/plugins/maps/public/routes/map_page/saved_map/saved_map.ts index 3530e3cc615ad..ae54228854483 100644 --- a/x-pack/plugins/maps/public/routes/map_page/saved_map/saved_map.ts +++ b/x-pack/plugins/maps/public/routes/map_page/saved_map/saved_map.ts @@ -45,6 +45,7 @@ import { copyPersistentState } from '../../../reducers/util'; import { getBreadcrumbs } from './get_breadcrumbs'; import { DEFAULT_IS_LAYER_TOC_OPEN } from '../../../reducers/ui'; import { createBasemapLayerDescriptor } from '../../../classes/layers/create_basemap_layer_descriptor'; +import { whenLicenseInitialized } from '../../../licensed_features'; export class SavedMap { private _attributes: MapSavedObjectAttributes | null = null; @@ -87,6 +88,8 @@ export class SavedMap { } async whenReady() { + await whenLicenseInitialized(); + if (!this._mapEmbeddableInput) { this._attributes = { title: '', From a64ad0d2c2f472cd0c00bbcd4ee301451eee3df6 Mon Sep 17 00:00:00 2001 From: Thomas Neirynck Date: Wed, 13 Jan 2021 17:46:15 -0500 Subject: [PATCH 04/13] implement bounds retrieval for file sources --- .../classes/sources/es_source/es_source.ts | 6 +++--- .../geojson_file_source/geojson_file_source.ts | 17 +++++++++++++++-- .../mvt_single_layer_vector_source.tsx | 4 ++-- .../sources/vector_source/vector_source.tsx | 6 +++--- 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/x-pack/plugins/maps/public/classes/sources/es_source/es_source.ts b/x-pack/plugins/maps/public/classes/sources/es_source/es_source.ts index 967131e900fc6..f4f79e899b0d8 100644 --- a/x-pack/plugins/maps/public/classes/sources/es_source/es_source.ts +++ b/x-pack/plugins/maps/public/classes/sources/es_source/es_source.ts @@ -7,7 +7,7 @@ import { i18n } from '@kbn/i18n'; import uuid from 'uuid/v4'; import { Filter, IFieldType, IndexPattern, ISearchSource } from 'src/plugins/data/public'; -import { AbstractVectorSource, BoundsFilters } from '../vector_source'; +import { AbstractVectorSource, ESGlobalFilters } from '../vector_source'; import { getAutocompleteService, getIndexPatternService, @@ -211,7 +211,7 @@ export class AbstractESSource extends AbstractVectorSource implements IESSource } async makeSearchSource( - searchFilters: VectorSourceRequestMeta | VectorJoinSourceRequestMeta | BoundsFilters, + searchFilters: VectorSourceRequestMeta | VectorJoinSourceRequestMeta | ESGlobalFilters, limit: number, initialSearchContext?: object ): Promise { @@ -264,7 +264,7 @@ export class AbstractESSource extends AbstractVectorSource implements IESSource } async getBoundsForFilters( - boundsFilters: BoundsFilters, + boundsFilters: ESGlobalFilters, registerCancelCallback: (callback: () => void) => void ): Promise { const searchSource = await this.makeSearchSource(boundsFilters, 0); diff --git a/x-pack/plugins/maps/public/classes/sources/geojson_file_source/geojson_file_source.ts b/x-pack/plugins/maps/public/classes/sources/geojson_file_source/geojson_file_source.ts index 6172405152739..a6ae38546daab 100644 --- a/x-pack/plugins/maps/public/classes/sources/geojson_file_source/geojson_file_source.ts +++ b/x-pack/plugins/maps/public/classes/sources/geojson_file_source/geojson_file_source.ts @@ -5,11 +5,12 @@ */ import { Feature, FeatureCollection } from 'geojson'; -import { AbstractVectorSource, GeoJsonWithMeta } from '../vector_source'; +import { AbstractVectorSource, ESGlobalFilters, GeoJsonWithMeta } from '../vector_source'; import { EMPTY_FEATURE_COLLECTION, SOURCE_TYPES } from '../../../../common/constants'; -import { GeojsonFileSourceDescriptor } from '../../../../common/descriptor_types'; +import { GeojsonFileSourceDescriptor, MapExtent } from '../../../../common/descriptor_types'; import { registerSource } from '../source_registry'; import { IField } from '../../fields/field'; +import { getFeatureCollectionBounds } from '../../util/get_feature_collection_bounds'; function getFeatureCollection(geoJson: Feature | FeatureCollection | null): FeatureCollection { if (!geoJson) { @@ -42,6 +43,18 @@ export class GeojsonFileSource extends AbstractVectorSource { }; } + isBoundsAware(): boolean { + return true; + } + + async getBoundsForFilters( + boundsFilters: ESGlobalFilters, + registerCancelCallback: (callback: () => void) => void + ): Promise { + const featureCollection = (this._descriptor as GeojsonFileSourceDescriptor).__featureCollection; + return getFeatureCollectionBounds(featureCollection, false); + } + async getGeoJsonWithMeta(): Promise { return { data: (this._descriptor as GeojsonFileSourceDescriptor).__featureCollection, diff --git a/x-pack/plugins/maps/public/classes/sources/mvt_single_layer_vector_source/mvt_single_layer_vector_source.tsx b/x-pack/plugins/maps/public/classes/sources/mvt_single_layer_vector_source/mvt_single_layer_vector_source.tsx index adc478c1f45d3..0fb739528d2a5 100644 --- a/x-pack/plugins/maps/public/classes/sources/mvt_single_layer_vector_source/mvt_single_layer_vector_source.tsx +++ b/x-pack/plugins/maps/public/classes/sources/mvt_single_layer_vector_source/mvt_single_layer_vector_source.tsx @@ -9,7 +9,7 @@ import uuid from 'uuid/v4'; import React from 'react'; import { GeoJsonProperties } from 'geojson'; import { AbstractSource, ImmutableSourceProperty, SourceEditorArgs } from '../source'; -import { BoundsFilters, GeoJsonWithMeta, ITiledSingleLayerVectorSource } from '../vector_source'; +import { ESGlobalFilters, GeoJsonWithMeta, ITiledSingleLayerVectorSource } from '../vector_source'; import { FIELD_ORIGIN, MAX_ZOOM, @@ -179,7 +179,7 @@ export class MVTSingleLayerVectorSource } async getBoundsForFilters( - boundsFilters: BoundsFilters, + boundsFilters: ESGlobalFilters, registerCancelCallback: (callback: () => void) => void ): Promise { return null; diff --git a/x-pack/plugins/maps/public/classes/sources/vector_source/vector_source.tsx b/x-pack/plugins/maps/public/classes/sources/vector_source/vector_source.tsx index 32db97708e397..6f73413067622 100644 --- a/x-pack/plugins/maps/public/classes/sources/vector_source/vector_source.tsx +++ b/x-pack/plugins/maps/public/classes/sources/vector_source/vector_source.tsx @@ -35,7 +35,7 @@ export interface GeoJsonWithMeta { meta?: GeoJsonFetchMeta; } -export interface BoundsFilters { +export interface ESGlobalFilters { applyGlobalQuery: boolean; applyGlobalTime: boolean; filters: Filter[]; @@ -47,7 +47,7 @@ export interface BoundsFilters { export interface IVectorSource extends ISource { getTooltipProperties(properties: GeoJsonProperties): Promise; getBoundsForFilters( - boundsFilters: BoundsFilters, + boundsFilters: ESGlobalFilters, registerCancelCallback: (callback: () => void) => void ): Promise; getGeoJsonWithMeta( @@ -147,7 +147,7 @@ export class AbstractVectorSource extends AbstractSource implements IVectorSourc } async getBoundsForFilters( - boundsFilters: BoundsFilters, + boundsFilters: ESGlobalFilters, registerCancelCallback: (callback: () => void) => void ): Promise { return null; From b9454e9d90d6bfbb320048ff1d05ce11560dac47 Mon Sep 17 00:00:00 2001 From: Thomas Neirynck Date: Thu, 14 Jan 2021 14:23:29 -0500 Subject: [PATCH 05/13] Revert "delay map availability until license-state is initialized" This reverts commit 37cfeb6d5aa37f0b4b0e43a2da83bbbbbe6abbf7. --- x-pack/plugins/maps/public/licensed_features.ts | 10 ---------- .../maps/public/routes/map_page/saved_map/saved_map.ts | 3 --- 2 files changed, 13 deletions(-) diff --git a/x-pack/plugins/maps/public/licensed_features.ts b/x-pack/plugins/maps/public/licensed_features.ts index 049087d5fbf1d..e39f8d672ae21 100644 --- a/x-pack/plugins/maps/public/licensed_features.ts +++ b/x-pack/plugins/maps/public/licensed_features.ts @@ -41,15 +41,7 @@ let isEnterprisePlus: boolean = false; export const getLicenseId = () => licenseId; export const getIsGoldPlus = () => isGoldPlus; -let initializeLicense: (value: unknown) => void; -const licenseInitialized = new Promise((resolve) => { - initializeLicense = resolve; -}); - export const getIsEnterprisePlus = () => isEnterprisePlus; -export const whenLicenseInitialized = async (): Promise => { - await licenseInitialized; -}; export function registerLicensedFeatures(licensingPlugin: LicensingPluginSetup) { for (const licensedFeature of Object.values(LICENSED_FEATURES)) { @@ -78,8 +70,6 @@ export async function setLicensingPluginStart(licensingPlugin: LicensingPluginSt licensingPluginStart = licensingPlugin; licensingPluginStart.license$.subscribe(updateLicenseState); - - initializeLicense(undefined); } export function notifyLicensedFeatureUsage(licensedFeature: LICENSED_FEATURES) { diff --git a/x-pack/plugins/maps/public/routes/map_page/saved_map/saved_map.ts b/x-pack/plugins/maps/public/routes/map_page/saved_map/saved_map.ts index ae54228854483..3530e3cc615ad 100644 --- a/x-pack/plugins/maps/public/routes/map_page/saved_map/saved_map.ts +++ b/x-pack/plugins/maps/public/routes/map_page/saved_map/saved_map.ts @@ -45,7 +45,6 @@ import { copyPersistentState } from '../../../reducers/util'; import { getBreadcrumbs } from './get_breadcrumbs'; import { DEFAULT_IS_LAYER_TOC_OPEN } from '../../../reducers/ui'; import { createBasemapLayerDescriptor } from '../../../classes/layers/create_basemap_layer_descriptor'; -import { whenLicenseInitialized } from '../../../licensed_features'; export class SavedMap { private _attributes: MapSavedObjectAttributes | null = null; @@ -88,8 +87,6 @@ export class SavedMap { } async whenReady() { - await whenLicenseInitialized(); - if (!this._mapEmbeddableInput) { this._attributes = { title: '', From fc47b82242c85765c9b3fa5db0d150cfd19210be Mon Sep 17 00:00:00 2001 From: Thomas Neirynck Date: Thu, 14 Jan 2021 14:23:44 -0500 Subject: [PATCH 06/13] Revert "remove blocking behavior" This reverts commit 455d7acf32a82f7ed2802b721db900f2c9f937d1. --- x-pack/plugins/maps/public/licensed_features.ts | 1 + x-pack/plugins/maps/public/plugin.ts | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/maps/public/licensed_features.ts b/x-pack/plugins/maps/public/licensed_features.ts index e39f8d672ae21..f16fcac900683 100644 --- a/x-pack/plugins/maps/public/licensed_features.ts +++ b/x-pack/plugins/maps/public/licensed_features.ts @@ -36,6 +36,7 @@ export const LICENCED_FEATURES_DETAILS: Record licenseId; diff --git a/x-pack/plugins/maps/public/plugin.ts b/x-pack/plugins/maps/public/plugin.ts index 8d9ea83e1cfd2..b5340f4e31068 100644 --- a/x-pack/plugins/maps/public/plugin.ts +++ b/x-pack/plugins/maps/public/plugin.ts @@ -158,8 +158,8 @@ export class MapsPlugin }); } - public start(core: CoreStart, plugins: MapsPluginStartDependencies): Promise { - setLicensingPluginStart(plugins.licensing); + public async start(core: CoreStart, plugins: MapsPluginStartDependencies): Promise { + await setLicensingPluginStart(plugins.licensing); plugins.uiActions.addTriggerAction(VISUALIZE_GEO_FIELD_TRIGGER, visualizeGeoFieldAction); setStartServices(core, plugins); // unregisters the OSS alias From 9ff82de851131b85c2888f2cbf40288e8c74e6ae Mon Sep 17 00:00:00 2001 From: Thomas Neirynck Date: Thu, 14 Jan 2021 14:23:55 -0500 Subject: [PATCH 07/13] Revert "init" This reverts commit fb23b203cbe9b9555685f0798ca6916b9ab3252b. --- .../plugins/maps/public/licensed_features.ts | 24 +++++++------------ x-pack/plugins/maps/public/plugin.ts | 4 ++-- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/x-pack/plugins/maps/public/licensed_features.ts b/x-pack/plugins/maps/public/licensed_features.ts index f16fcac900683..f709dd529e375 100644 --- a/x-pack/plugins/maps/public/licensed_features.ts +++ b/x-pack/plugins/maps/public/licensed_features.ts @@ -54,23 +54,17 @@ export function registerLicensedFeatures(licensingPlugin: LicensingPluginSetup) } let licensingPluginStart: LicensingPluginStart; +export function setLicensingPluginStart(licensingPlugin: LicensingPluginStart) { + licensingPluginStart = licensingPlugin; + licensingPluginStart.license$.subscribe((license: ILicense) => { + const gold = license.check(APP_ID, 'gold'); + isGoldPlus = gold.state === 'valid'; -function updateLicenseState(license: ILicense) { - const gold = license.check(APP_ID, 'gold'); - isGoldPlus = gold.state === 'valid'; - - const enterprise = license.check(APP_ID, 'enterprise'); - isEnterprisePlus = enterprise.state === 'valid'; - - licenseId = license.uid; -} - -export async function setLicensingPluginStart(licensingPlugin: LicensingPluginStart) { - const license = await licensingPlugin.refresh(); - updateLicenseState(license); + const enterprise = license.check(APP_ID, 'enterprise'); + isEnterprisePlus = enterprise.state === 'valid'; - licensingPluginStart = licensingPlugin; - licensingPluginStart.license$.subscribe(updateLicenseState); + licenseId = license.uid; + }); } export function notifyLicensedFeatureUsage(licensedFeature: LICENSED_FEATURES) { diff --git a/x-pack/plugins/maps/public/plugin.ts b/x-pack/plugins/maps/public/plugin.ts index b5340f4e31068..8bffea3ce5a87 100644 --- a/x-pack/plugins/maps/public/plugin.ts +++ b/x-pack/plugins/maps/public/plugin.ts @@ -158,8 +158,8 @@ export class MapsPlugin }); } - public async start(core: CoreStart, plugins: MapsPluginStartDependencies): Promise { - await setLicensingPluginStart(plugins.licensing); + public start(core: CoreStart, plugins: MapsPluginStartDependencies): MapsStartApi { + setLicensingPluginStart(plugins.licensing); plugins.uiActions.addTriggerAction(VISUALIZE_GEO_FIELD_TRIGGER, visualizeGeoFieldAction); setStartServices(core, plugins); // unregisters the OSS alias From 90e0db71440449d98fbcd62815fb68558d0a347b Mon Sep 17 00:00:00 2001 From: Thomas Neirynck Date: Wed, 20 Jan 2021 17:38:15 -0500 Subject: [PATCH 08/13] add fields implementation for geojson --- .../source_descriptor_types.ts | 6 ++ .../classes/fields/geojson_file_field.ts | 35 ++++++++++++ .../layers/file_upload_wizard/wizard.tsx | 4 +- .../geojson_file_source.ts | 57 ++++++++++++++++--- .../sources/geojson_file_source/index.ts | 2 +- .../maps/public/selectors/map_selectors.ts | 6 +- 6 files changed, 95 insertions(+), 15 deletions(-) create mode 100644 x-pack/plugins/maps/public/classes/fields/geojson_file_field.ts diff --git a/x-pack/plugins/maps/common/descriptor_types/source_descriptor_types.ts b/x-pack/plugins/maps/common/descriptor_types/source_descriptor_types.ts index 603e1d767e1c6..b849b42429cf6 100644 --- a/x-pack/plugins/maps/common/descriptor_types/source_descriptor_types.ts +++ b/x-pack/plugins/maps/common/descriptor_types/source_descriptor_types.ts @@ -156,7 +156,13 @@ export type TiledSingleLayerVectorSourceDescriptor = AbstractSourceDescriptor & tooltipProperties: string[]; }; +export type GeoJsonFileFieldDescriptor = { + name: string; + type: 'string' | 'number'; +}; + export type GeojsonFileSourceDescriptor = { + __fields?: GeoJsonFileFieldDescriptor[]; __featureCollection: FeatureCollection; name: string; type: string; diff --git a/x-pack/plugins/maps/public/classes/fields/geojson_file_field.ts b/x-pack/plugins/maps/public/classes/fields/geojson_file_field.ts new file mode 100644 index 0000000000000..38be25054e05a --- /dev/null +++ b/x-pack/plugins/maps/public/classes/fields/geojson_file_field.ts @@ -0,0 +1,35 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { FIELD_ORIGIN } from '../../../common/constants'; +import { IField, AbstractField } from './field'; +import { IVectorSource } from '../sources/vector_source'; +import { GeoJsonFileSource } from '../sources/geojson_file_source'; + +export class GeoJsonFileField extends AbstractField implements IField { + private readonly _source: GeoJsonFileSource; + + constructor({ + fieldName, + source, + origin, + }: { + fieldName: string; + source: GeoJsonFileSource; + origin: FIELD_ORIGIN; + }) { + super({ fieldName, origin }); + this._source = source; + } + + getSource(): IVectorSource { + return this._source; + } + + async getLabel(): Promise { + return this.getName(); + } +} diff --git a/x-pack/plugins/maps/public/classes/layers/file_upload_wizard/wizard.tsx b/x-pack/plugins/maps/public/classes/layers/file_upload_wizard/wizard.tsx index a0029c5c64e0b..9c6a56eed5680 100644 --- a/x-pack/plugins/maps/public/classes/layers/file_upload_wizard/wizard.tsx +++ b/x-pack/plugins/maps/public/classes/layers/file_upload_wizard/wizard.tsx @@ -14,7 +14,7 @@ import { SCALING_TYPES, } from '../../../../common/constants'; import { getFileUploadComponent } from '../../../kibana_services'; -import { GeojsonFileSource } from '../../sources/geojson_file_source'; +import { GeoJsonFileSource } from '../../sources/geojson_file_source'; import { VectorLayer } from '../../layers/vector_layer/vector_layer'; import { createDefaultLayerDescriptor } from '../../sources/es_search_source'; import { RenderWizardArguments } from '../../layers/layer_wizard_registry'; @@ -79,7 +79,7 @@ export class ClientFileCreateSourceEditor extends Component { + return field.name === fieldName; + }); + + if (!descriptor) { + throw new Error( + `Cannot find corresponding field ${fieldName} in __fields array ${JSON.stringify( + this._getFields() + )} ` + ); + } + return new GeoJsonFileField({ + fieldName: descriptor.name, + source: this, + origin: FIELD_ORIGIN.SOURCE, + }); + } + + async getFields(): Promise { + const fields = this._getFields(); + return fields.map((field: GeoJsonFileFieldDescriptor) => { + return new GeoJsonFileField({ + fieldName: field.name, + source: this, + origin: FIELD_ORIGIN.SOURCE, + }); + }); + } + isBoundsAware(): boolean { return true; } @@ -62,10 +105,6 @@ export class GeojsonFileSource extends AbstractVectorSource { }; } - createField({ fieldName }: { fieldName: string }): IField { - throw new Error('Not implemented'); - } - async getDisplayName() { return (this._descriptor as GeojsonFileSourceDescriptor).name; } @@ -76,6 +115,6 @@ export class GeojsonFileSource extends AbstractVectorSource { } registerSource({ - ConstructorFunction: GeojsonFileSource, + ConstructorFunction: GeoJsonFileSource, type: SOURCE_TYPES.GEOJSON_FILE, }); diff --git a/x-pack/plugins/maps/public/classes/sources/geojson_file_source/index.ts b/x-pack/plugins/maps/public/classes/sources/geojson_file_source/index.ts index cf0d15dcb747a..ef6806e0aa151 100644 --- a/x-pack/plugins/maps/public/classes/sources/geojson_file_source/index.ts +++ b/x-pack/plugins/maps/public/classes/sources/geojson_file_source/index.ts @@ -4,4 +4,4 @@ * you may not use this file except in compliance with the Elastic License. */ -export { GeojsonFileSource } from './geojson_file_source'; +export { GeoJsonFileSource } from './geojson_file_source'; diff --git a/x-pack/plugins/maps/public/selectors/map_selectors.ts b/x-pack/plugins/maps/public/selectors/map_selectors.ts index 7b72a3c979abe..5a3e6c4ad174e 100644 --- a/x-pack/plugins/maps/public/selectors/map_selectors.ts +++ b/x-pack/plugins/maps/public/selectors/map_selectors.ts @@ -22,7 +22,7 @@ import { TiledVectorLayer } from '../classes/layers/tiled_vector_layer/tiled_vec import { copyPersistentState, TRACKED_LAYER_DESCRIPTOR } from '../reducers/util'; import { InnerJoin } from '../classes/joins/inner_join'; import { getSourceByType } from '../classes/sources/source_registry'; -import { GeojsonFileSource } from '../classes/sources/geojson_file_source'; +import { GeoJsonFileSource } from '../classes/sources/geojson_file_source'; import { SOURCE_DATA_REQUEST_ID, STYLE_TYPE, @@ -241,7 +241,7 @@ export const getSpatialFiltersLayer = createSelector( type: 'FeatureCollection', features: extractFeaturesFromFilters(filters), }; - const geoJsonSourceDescriptor = GeojsonFileSource.createDescriptor( + const geoJsonSourceDescriptor = GeoJsonFileSource.createDescriptor( featureCollection, 'spatialFilters' ); @@ -272,7 +272,7 @@ export const getSpatialFiltersLayer = createSelector( }, }), }), - source: new GeojsonFileSource(geoJsonSourceDescriptor), + source: new GeoJsonFileSource(geoJsonSourceDescriptor), }); } ); From 9ef77929e2df5613256579b4c517d7845f4738b3 Mon Sep 17 00:00:00 2001 From: Thomas Neirynck Date: Mon, 25 Jan 2021 19:14:34 -0500 Subject: [PATCH 09/13] add datatype --- .../maps/public/classes/fields/geojson_file_field.ts | 8 ++++++++ .../sources/geojson_file_source/geojson_file_source.ts | 2 ++ 2 files changed, 10 insertions(+) diff --git a/x-pack/plugins/maps/public/classes/fields/geojson_file_field.ts b/x-pack/plugins/maps/public/classes/fields/geojson_file_field.ts index 38be25054e05a..ae42b09d491c5 100644 --- a/x-pack/plugins/maps/public/classes/fields/geojson_file_field.ts +++ b/x-pack/plugins/maps/public/classes/fields/geojson_file_field.ts @@ -11,18 +11,22 @@ import { GeoJsonFileSource } from '../sources/geojson_file_source'; export class GeoJsonFileField extends AbstractField implements IField { private readonly _source: GeoJsonFileSource; + private readonly _dataType: string; constructor({ fieldName, source, origin, + dataType, }: { fieldName: string; source: GeoJsonFileSource; origin: FIELD_ORIGIN; + dataType: string; }) { super({ fieldName, origin }); this._source = source; + this._dataType = dataType; } getSource(): IVectorSource { @@ -32,4 +36,8 @@ export class GeoJsonFileField extends AbstractField implements IField { async getLabel(): Promise { return this.getName(); } + + async getDataType(): Promise { + return this._dataType; + } } diff --git a/x-pack/plugins/maps/public/classes/sources/geojson_file_source/geojson_file_source.ts b/x-pack/plugins/maps/public/classes/sources/geojson_file_source/geojson_file_source.ts index 0b84d4a28861b..d0d69fbb5fb86 100644 --- a/x-pack/plugins/maps/public/classes/sources/geojson_file_source/geojson_file_source.ts +++ b/x-pack/plugins/maps/public/classes/sources/geojson_file_source/geojson_file_source.ts @@ -72,6 +72,7 @@ export class GeoJsonFileSource extends AbstractVectorSource { fieldName: descriptor.name, source: this, origin: FIELD_ORIGIN.SOURCE, + dataType: descriptor.type, }); } @@ -82,6 +83,7 @@ export class GeoJsonFileSource extends AbstractVectorSource { fieldName: field.name, source: this, origin: FIELD_ORIGIN.SOURCE, + dataType: field.type, }); }); } From 063c7a3c82b43d2ff033f6e2e52e89e659aba2ce Mon Sep 17 00:00:00 2001 From: Thomas Neirynck Date: Mon, 25 Jan 2021 19:44:20 -0500 Subject: [PATCH 10/13] unit tests --- .../layers/file_upload_wizard/wizard.tsx | 5 +- .../classes/sources/es_source/es_source.ts | 6 +- .../geojson_file_source/geojson_file.test.ts | 105 ++++++++++++++++++ .../geojson_file_source.ts | 24 ++-- .../mvt_single_layer_vector_source.tsx | 4 +- .../sources/vector_source/vector_source.tsx | 6 +- .../maps/public/routes/map_page/map_page.tsx | 3 +- .../routes/map_page/saved_map/saved_map.ts | 72 +++++++++++- 8 files changed, 204 insertions(+), 21 deletions(-) create mode 100644 x-pack/plugins/maps/public/classes/sources/geojson_file_source/geojson_file.test.ts diff --git a/x-pack/plugins/maps/public/classes/layers/file_upload_wizard/wizard.tsx b/x-pack/plugins/maps/public/classes/layers/file_upload_wizard/wizard.tsx index 9c6a56eed5680..3e755fda4d250 100644 --- a/x-pack/plugins/maps/public/classes/layers/file_upload_wizard/wizard.tsx +++ b/x-pack/plugins/maps/public/classes/layers/file_upload_wizard/wizard.tsx @@ -79,7 +79,10 @@ export class ClientFileCreateSourceEditor extends Component { @@ -264,7 +264,7 @@ export class AbstractESSource extends AbstractVectorSource implements IESSource } async getBoundsForFilters( - boundsFilters: ESGlobalFilters, + boundsFilters: BoundsFilters, registerCancelCallback: (callback: () => void) => void ): Promise { const searchSource = await this.makeSearchSource(boundsFilters, 0); diff --git a/x-pack/plugins/maps/public/classes/sources/geojson_file_source/geojson_file.test.ts b/x-pack/plugins/maps/public/classes/sources/geojson_file_source/geojson_file.test.ts new file mode 100644 index 0000000000000..69944acc4843e --- /dev/null +++ b/x-pack/plugins/maps/public/classes/sources/geojson_file_source/geojson_file.test.ts @@ -0,0 +1,105 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { GeoJsonFileSource } from './geojson_file_source'; +import { BoundsFilters } from '../vector_source'; +import { FIELD_ORIGIN } from '../../../../common/constants'; + +describe('GeoJsonFileSource', () => { + describe('getName', () => { + it('should get bounds from feature collection', async () => { + const geojsonFileSource = new GeoJsonFileSource({}); + expect(await geojsonFileSource.getDisplayName()).toBe('Features'); + }); + }); + describe('getBounds', () => { + it('should get null bounds', async () => { + const geojsonFileSource = new GeoJsonFileSource({}); + expect( + await geojsonFileSource.getBoundsForFilters(({} as unknown) as BoundsFilters, () => {}) + ).toEqual(null); + }); + + it('should get bounds from feature collection', async () => { + const geojsonFileSource = new GeoJsonFileSource({ + __featureCollection: { + type: 'FeatureCollection', + features: [ + { + type: 'Feature', + geometry: { + type: 'Point', + coordinates: [0, 1], + }, + properties: {}, + }, + { + type: 'Feature', + geometry: { + type: 'Point', + coordinates: [2, 3], + }, + properties: {}, + }, + ], + }, + }); + + expect(geojsonFileSource.isBoundsAware()).toBe(true); + expect( + await geojsonFileSource.getBoundsForFilters(({} as unknown) as BoundsFilters, () => {}) + ).toEqual({ + maxLat: 3, + maxLon: 2, + minLat: 1, + minLon: 0, + }); + }); + }); + + describe('getFields', () => { + it('should get fields from config', async () => { + const geojsonFileSource = new GeoJsonFileSource({ + __fields: [ + { + type: 'string', + name: 'foo', + }, + { + type: 'number', + name: 'bar', + }, + ], + }); + + const fields = await geojsonFileSource.getFields(); + + const actualFields = fields.map(async (field) => { + return { + dataType: await field.getDataType(), + origin: field.getOrigin(), + name: field.getName(), + source: field.getSource(), + }; + }); + + expect(await Promise.all(actualFields)).toEqual([ + { + dataType: 'string', + origin: FIELD_ORIGIN.SOURCE, + source: geojsonFileSource, + name: 'foo', + }, + { + dataType: 'number', + origin: FIELD_ORIGIN.SOURCE, + source: geojsonFileSource, + name: 'bar', + }, + ]); + }); + }); +}); diff --git a/x-pack/plugins/maps/public/classes/sources/geojson_file_source/geojson_file_source.ts b/x-pack/plugins/maps/public/classes/sources/geojson_file_source/geojson_file_source.ts index d0d69fbb5fb86..69d84dc65d382 100644 --- a/x-pack/plugins/maps/public/classes/sources/geojson_file_source/geojson_file_source.ts +++ b/x-pack/plugins/maps/public/classes/sources/geojson_file_source/geojson_file_source.ts @@ -5,7 +5,7 @@ */ import { Feature, FeatureCollection } from 'geojson'; -import { AbstractVectorSource, ESGlobalFilters, GeoJsonWithMeta } from '../vector_source'; +import { AbstractVectorSource, BoundsFilters, GeoJsonWithMeta } from '../vector_source'; import { EMPTY_FEATURE_COLLECTION, FIELD_ORIGIN, SOURCE_TYPES } from '../../../../common/constants'; import { GeoJsonFileFieldDescriptor, @@ -16,8 +16,11 @@ import { registerSource } from '../source_registry'; import { IField } from '../../fields/field'; import { getFeatureCollectionBounds } from '../../util/get_feature_collection_bounds'; import { GeoJsonFileField } from '../../fields/geojson_file_field'; +import { Adapters } from '../../../../../../../src/plugins/inspector/common/adapters'; -function getFeatureCollection(geoJson: Feature | FeatureCollection | null): FeatureCollection { +function getFeatureCollection( + geoJson: Feature | FeatureCollection | null | undefined +): FeatureCollection { if (!geoJson) { return EMPTY_FEATURE_COLLECTION; } @@ -38,18 +41,21 @@ function getFeatureCollection(geoJson: Feature | FeatureCollection | null): Feat export class GeoJsonFileSource extends AbstractVectorSource { static createDescriptor( - geoJson: Feature | FeatureCollection | null, - name: string, - fields?: GeoJsonFileFieldDescriptor[] + descriptor: Partial ): GeojsonFileSourceDescriptor { return { type: SOURCE_TYPES.GEOJSON_FILE, - __featureCollection: getFeatureCollection(geoJson), - __fields: fields || [], - name, + __featureCollection: getFeatureCollection(descriptor.__featureCollection), + __fields: descriptor.__fields || [], + name: descriptor.name || 'Features', }; } + constructor(descriptor: Partial, inspectorAdapters?: Adapters) { + const normalizedDescriptor = GeoJsonFileSource.createDescriptor(descriptor); + super(normalizedDescriptor, inspectorAdapters); + } + _getFields(): GeoJsonFileFieldDescriptor[] { const fields = (this._descriptor as GeojsonFileSourceDescriptor).__fields; return fields ? fields : []; @@ -93,7 +99,7 @@ export class GeoJsonFileSource extends AbstractVectorSource { } async getBoundsForFilters( - boundsFilters: ESGlobalFilters, + boundsFilters: BoundsFilters, registerCancelCallback: (callback: () => void) => void ): Promise { const featureCollection = (this._descriptor as GeojsonFileSourceDescriptor).__featureCollection; diff --git a/x-pack/plugins/maps/public/classes/sources/mvt_single_layer_vector_source/mvt_single_layer_vector_source.tsx b/x-pack/plugins/maps/public/classes/sources/mvt_single_layer_vector_source/mvt_single_layer_vector_source.tsx index 0fb739528d2a5..adc478c1f45d3 100644 --- a/x-pack/plugins/maps/public/classes/sources/mvt_single_layer_vector_source/mvt_single_layer_vector_source.tsx +++ b/x-pack/plugins/maps/public/classes/sources/mvt_single_layer_vector_source/mvt_single_layer_vector_source.tsx @@ -9,7 +9,7 @@ import uuid from 'uuid/v4'; import React from 'react'; import { GeoJsonProperties } from 'geojson'; import { AbstractSource, ImmutableSourceProperty, SourceEditorArgs } from '../source'; -import { ESGlobalFilters, GeoJsonWithMeta, ITiledSingleLayerVectorSource } from '../vector_source'; +import { BoundsFilters, GeoJsonWithMeta, ITiledSingleLayerVectorSource } from '../vector_source'; import { FIELD_ORIGIN, MAX_ZOOM, @@ -179,7 +179,7 @@ export class MVTSingleLayerVectorSource } async getBoundsForFilters( - boundsFilters: ESGlobalFilters, + boundsFilters: BoundsFilters, registerCancelCallback: (callback: () => void) => void ): Promise { return null; diff --git a/x-pack/plugins/maps/public/classes/sources/vector_source/vector_source.tsx b/x-pack/plugins/maps/public/classes/sources/vector_source/vector_source.tsx index 6f73413067622..32db97708e397 100644 --- a/x-pack/plugins/maps/public/classes/sources/vector_source/vector_source.tsx +++ b/x-pack/plugins/maps/public/classes/sources/vector_source/vector_source.tsx @@ -35,7 +35,7 @@ export interface GeoJsonWithMeta { meta?: GeoJsonFetchMeta; } -export interface ESGlobalFilters { +export interface BoundsFilters { applyGlobalQuery: boolean; applyGlobalTime: boolean; filters: Filter[]; @@ -47,7 +47,7 @@ export interface ESGlobalFilters { export interface IVectorSource extends ISource { getTooltipProperties(properties: GeoJsonProperties): Promise; getBoundsForFilters( - boundsFilters: ESGlobalFilters, + boundsFilters: BoundsFilters, registerCancelCallback: (callback: () => void) => void ): Promise; getGeoJsonWithMeta( @@ -147,7 +147,7 @@ export class AbstractVectorSource extends AbstractSource implements IVectorSourc } async getBoundsForFilters( - boundsFilters: ESGlobalFilters, + boundsFilters: BoundsFilters, registerCancelCallback: (callback: () => void) => void ): Promise { return null; diff --git a/x-pack/plugins/maps/public/routes/map_page/map_page.tsx b/x-pack/plugins/maps/public/routes/map_page/map_page.tsx index c8c9f620845ee..213d25bb6d80a 100644 --- a/x-pack/plugins/maps/public/routes/map_page/map_page.tsx +++ b/x-pack/plugins/maps/public/routes/map_page/map_page.tsx @@ -35,9 +35,10 @@ export class MapPage extends Component { constructor(props: Props) { super(props); + const layerList = getInitialLayersFromUrlParam(); this.state = { savedMap: new SavedMap({ - defaultLayers: getInitialLayersFromUrlParam(), + defaultLayers: layerList, mapEmbeddableInput: props.mapEmbeddableInput, embeddableId: props.embeddableId, originatingApp: props.originatingApp, diff --git a/x-pack/plugins/maps/public/routes/map_page/saved_map/saved_map.ts b/x-pack/plugins/maps/public/routes/map_page/saved_map/saved_map.ts index 27fd78980710f..eb192c2c2a173 100644 --- a/x-pack/plugins/maps/public/routes/map_page/saved_map/saved_map.ts +++ b/x-pack/plugins/maps/public/routes/map_page/saved_map/saved_map.ts @@ -8,7 +8,14 @@ import _ from 'lodash'; import { i18n } from '@kbn/i18n'; import { EmbeddableStateTransfer } from 'src/plugins/embeddable/public'; import { MapSavedObjectAttributes } from '../../../../common/map_saved_object_type'; -import { MAP_PATH, MAP_SAVED_OBJECT_TYPE } from '../../../../common/constants'; +import { + COLOR_MAP_TYPE, + FIELD_ORIGIN, + MAP_PATH, + MAP_SAVED_OBJECT_TYPE, + SOURCE_TYPES, + STYLE_TYPE, +} from '../../../../common/constants'; import { createMapStore, MapStore, MapStoreState } from '../../../reducers/store'; import { getTimeFilters, @@ -40,7 +47,7 @@ import { getSavedObjectsTagging, } from '../../../kibana_services'; import { goToSpecifiedPath } from '../../../render_app'; -import { LayerDescriptor } from '../../../../common/descriptor_types'; +import { LayerDescriptor, VectorLayerDescriptor } from '../../../../common/descriptor_types'; import { copyPersistentState } from '../../../reducers/util'; import { getBreadcrumbs } from './get_breadcrumbs'; import { DEFAULT_IS_LAYER_TOC_OPEN } from '../../../reducers/ui'; @@ -167,10 +174,71 @@ export class SavedMap { layerList.push(...this._defaultLayers); } } + const geojsonLayer: VectorLayerDescriptor = { + type: 'VECTOR', + id: 'foobar1', + style: { + properties: { + fillColor: { + type: STYLE_TYPE.DYNAMIC, + options: { + customColorRamp: [ + { + stop: 0, + color: '#FF0000', + }, + { + stop: 1, + color: '#00FF00', + }, + ], + field: { + name: 'foobarnumber', + origin: FIELD_ORIGIN.SOURCE, + }, + useCustomColorRamp: true, + }, + }, + }, + }, + sourceDescriptor: { + type: SOURCE_TYPES.GEOJSON_FILE, + __fields: [ + { + name: 'foobarnumber', + type: 'number', + }, + { + name: 'foobarstring', + type: 'string', + }, + ], + __featureCollection: { + type: 'FeatureCollection', + features: [ + { + type: 'Feature', + geometry: { + type: 'Point', + coordinates: [0, 0], + }, + properties: { + foobarnumber: 1, + foobarstring: 'foobar', + }, + }, + ], + }, + }, + }; + + layerList.push(geojsonLayer); + this._store.dispatch(replaceLayerList(layerList)); if (this._mapEmbeddableInput && this._mapEmbeddableInput.hiddenLayers !== undefined) { this._store.dispatch(setHiddenLayers(this._mapEmbeddableInput.hiddenLayers)); } + this._initialLayerListConfig = copyPersistentState(layerList); } From 1853d8ade67e1f9421f51543c6493caa3668c23e Mon Sep 17 00:00:00 2001 From: Thomas Neirynck Date: Mon, 25 Jan 2021 19:46:29 -0500 Subject: [PATCH 11/13] revert --- .../maps/public/routes/map_page/map_page.tsx | 3 +- .../routes/map_page/saved_map/saved_map.ts | 72 +------------------ 2 files changed, 3 insertions(+), 72 deletions(-) diff --git a/x-pack/plugins/maps/public/routes/map_page/map_page.tsx b/x-pack/plugins/maps/public/routes/map_page/map_page.tsx index 213d25bb6d80a..c8c9f620845ee 100644 --- a/x-pack/plugins/maps/public/routes/map_page/map_page.tsx +++ b/x-pack/plugins/maps/public/routes/map_page/map_page.tsx @@ -35,10 +35,9 @@ export class MapPage extends Component { constructor(props: Props) { super(props); - const layerList = getInitialLayersFromUrlParam(); this.state = { savedMap: new SavedMap({ - defaultLayers: layerList, + defaultLayers: getInitialLayersFromUrlParam(), mapEmbeddableInput: props.mapEmbeddableInput, embeddableId: props.embeddableId, originatingApp: props.originatingApp, diff --git a/x-pack/plugins/maps/public/routes/map_page/saved_map/saved_map.ts b/x-pack/plugins/maps/public/routes/map_page/saved_map/saved_map.ts index eb192c2c2a173..27fd78980710f 100644 --- a/x-pack/plugins/maps/public/routes/map_page/saved_map/saved_map.ts +++ b/x-pack/plugins/maps/public/routes/map_page/saved_map/saved_map.ts @@ -8,14 +8,7 @@ import _ from 'lodash'; import { i18n } from '@kbn/i18n'; import { EmbeddableStateTransfer } from 'src/plugins/embeddable/public'; import { MapSavedObjectAttributes } from '../../../../common/map_saved_object_type'; -import { - COLOR_MAP_TYPE, - FIELD_ORIGIN, - MAP_PATH, - MAP_SAVED_OBJECT_TYPE, - SOURCE_TYPES, - STYLE_TYPE, -} from '../../../../common/constants'; +import { MAP_PATH, MAP_SAVED_OBJECT_TYPE } from '../../../../common/constants'; import { createMapStore, MapStore, MapStoreState } from '../../../reducers/store'; import { getTimeFilters, @@ -47,7 +40,7 @@ import { getSavedObjectsTagging, } from '../../../kibana_services'; import { goToSpecifiedPath } from '../../../render_app'; -import { LayerDescriptor, VectorLayerDescriptor } from '../../../../common/descriptor_types'; +import { LayerDescriptor } from '../../../../common/descriptor_types'; import { copyPersistentState } from '../../../reducers/util'; import { getBreadcrumbs } from './get_breadcrumbs'; import { DEFAULT_IS_LAYER_TOC_OPEN } from '../../../reducers/ui'; @@ -174,71 +167,10 @@ export class SavedMap { layerList.push(...this._defaultLayers); } } - const geojsonLayer: VectorLayerDescriptor = { - type: 'VECTOR', - id: 'foobar1', - style: { - properties: { - fillColor: { - type: STYLE_TYPE.DYNAMIC, - options: { - customColorRamp: [ - { - stop: 0, - color: '#FF0000', - }, - { - stop: 1, - color: '#00FF00', - }, - ], - field: { - name: 'foobarnumber', - origin: FIELD_ORIGIN.SOURCE, - }, - useCustomColorRamp: true, - }, - }, - }, - }, - sourceDescriptor: { - type: SOURCE_TYPES.GEOJSON_FILE, - __fields: [ - { - name: 'foobarnumber', - type: 'number', - }, - { - name: 'foobarstring', - type: 'string', - }, - ], - __featureCollection: { - type: 'FeatureCollection', - features: [ - { - type: 'Feature', - geometry: { - type: 'Point', - coordinates: [0, 0], - }, - properties: { - foobarnumber: 1, - foobarstring: 'foobar', - }, - }, - ], - }, - }, - }; - - layerList.push(geojsonLayer); - this._store.dispatch(replaceLayerList(layerList)); if (this._mapEmbeddableInput && this._mapEmbeddableInput.hiddenLayers !== undefined) { this._store.dispatch(setHiddenLayers(this._mapEmbeddableInput.hiddenLayers)); } - this._initialLayerListConfig = copyPersistentState(layerList); } From 9f06d5bb44be33e4b9d0b432c7c43dff4af19f04 Mon Sep 17 00:00:00 2001 From: Thomas Neirynck Date: Mon, 25 Jan 2021 19:52:36 -0500 Subject: [PATCH 12/13] fix typos --- .../public/classes/layers/file_upload_wizard/wizard.tsx | 2 +- x-pack/plugins/maps/public/selectors/map_selectors.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/x-pack/plugins/maps/public/classes/layers/file_upload_wizard/wizard.tsx b/x-pack/plugins/maps/public/classes/layers/file_upload_wizard/wizard.tsx index 3e755fda4d250..68fd25ce9e7ae 100644 --- a/x-pack/plugins/maps/public/classes/layers/file_upload_wizard/wizard.tsx +++ b/x-pack/plugins/maps/public/classes/layers/file_upload_wizard/wizard.tsx @@ -80,7 +80,7 @@ export class ClientFileCreateSourceEditor extends Component Date: Tue, 26 Jan 2021 10:40:44 -0500 Subject: [PATCH 13/13] fix test name --- .../classes/sources/geojson_file_source/geojson_file.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/maps/public/classes/sources/geojson_file_source/geojson_file.test.ts b/x-pack/plugins/maps/public/classes/sources/geojson_file_source/geojson_file.test.ts index 69944acc4843e..cb31a838ef5dd 100644 --- a/x-pack/plugins/maps/public/classes/sources/geojson_file_source/geojson_file.test.ts +++ b/x-pack/plugins/maps/public/classes/sources/geojson_file_source/geojson_file.test.ts @@ -10,7 +10,7 @@ import { FIELD_ORIGIN } from '../../../../common/constants'; describe('GeoJsonFileSource', () => { describe('getName', () => { - it('should get bounds from feature collection', async () => { + it('should get default display name', async () => { const geojsonFileSource = new GeoJsonFileSource({}); expect(await geojsonFileSource.getDisplayName()).toBe('Features'); });