From 24f463f84c5f8798f6e3c8544801c9adfcda8c04 Mon Sep 17 00:00:00 2001 From: Thomas Neirynck Date: Tue, 15 Dec 2020 16:50:26 -0500 Subject: [PATCH] [Maps] Track enterprise use of on-prem EMS (#85885) --- x-pack/plugins/maps/common/ems_settings.test.ts | 10 +++++----- x-pack/plugins/maps/common/ems_settings.ts | 4 ---- .../layers/vector_tile_layer/vector_tile_layer.js | 6 +++++- .../sources/ems_file_source/ems_file_source.tsx | 6 ++++++ .../classes/sources/ems_tms_source/ems_tms_source.js | 6 ++++++ x-pack/plugins/maps/public/licensed_features.ts | 5 +++++ 6 files changed, 27 insertions(+), 10 deletions(-) diff --git a/x-pack/plugins/maps/common/ems_settings.test.ts b/x-pack/plugins/maps/common/ems_settings.test.ts index 69ae7069129c..280b68c9bf54 100644 --- a/x-pack/plugins/maps/common/ems_settings.test.ts +++ b/x-pack/plugins/maps/common/ems_settings.test.ts @@ -30,7 +30,7 @@ describe('EMSSettings', () => { test('should validate defaults', () => { const emsSettings = new EMSSettings(mockConfig, IS_ENTERPRISE_PLUS); expect(emsSettings.isEMSEnabled()).toBe(true); - expect(emsSettings.isOnPrem()).toBe(false); + expect(emsSettings.isEMSUrlSet()).toBe(false); }); test('should validate if on-prem is turned on', () => { @@ -44,7 +44,7 @@ describe('EMSSettings', () => { IS_ENTERPRISE_PLUS ); expect(emsSettings.isEMSEnabled()).toBe(true); - expect(emsSettings.isOnPrem()).toBe(true); + expect(emsSettings.isEMSUrlSet()).toBe(true); }); test('should not validate if ems turned off', () => { @@ -58,7 +58,7 @@ describe('EMSSettings', () => { IS_ENTERPRISE_PLUS ); expect(emsSettings.isEMSEnabled()).toBe(false); - expect(emsSettings.isOnPrem()).toBe(false); + expect(emsSettings.isEMSUrlSet()).toBe(false); }); test('should work if ems is turned off, but on-prem is turned on', () => { @@ -73,7 +73,7 @@ describe('EMSSettings', () => { IS_ENTERPRISE_PLUS ); expect(emsSettings.isEMSEnabled()).toBe(true); - expect(emsSettings.isOnPrem()).toBe(true); + expect(emsSettings.isEMSUrlSet()).toBe(true); }); describe('when license is turned off', () => { @@ -88,7 +88,7 @@ describe('EMSSettings', () => { () => false ); expect(emsSettings.isEMSEnabled()).toBe(false); - expect(emsSettings.isOnPrem()).toBe(true); + expect(emsSettings.isEMSUrlSet()).toBe(true); }); }); }); diff --git a/x-pack/plugins/maps/common/ems_settings.ts b/x-pack/plugins/maps/common/ems_settings.ts index 9c6d1cfe88b5..10180b3c4099 100644 --- a/x-pack/plugins/maps/common/ems_settings.ts +++ b/x-pack/plugins/maps/common/ems_settings.ts @@ -39,10 +39,6 @@ export class EMSSettings { return this._config.emsUrl!.replace(/\/$/, ''); } - isOnPrem(): boolean { - return this.isEMSUrlSet(); - } - isIncludeElasticMapsService() { return !!this._config.includeElasticMapsService; } diff --git a/x-pack/plugins/maps/public/classes/layers/vector_tile_layer/vector_tile_layer.js b/x-pack/plugins/maps/public/classes/layers/vector_tile_layer/vector_tile_layer.js index dc3ace69e5a6..ae98455bb2d0 100644 --- a/x-pack/plugins/maps/public/classes/layers/vector_tile_layer/vector_tile_layer.js +++ b/x-pack/plugins/maps/public/classes/layers/vector_tile_layer/vector_tile_layer.js @@ -11,7 +11,7 @@ import { isRetina } from '../../../meta'; import { addSpriteSheetToMapFromImageData, loadSpriteSheetImageData, -} from '../../../connected_components/mb_map/utils'; //todo move this implementation +} from '../../../connected_components/mb_map/utils'; const MB_STYLE_TYPE_TO_OPACITY = { fill: ['fill-opacity'], @@ -285,4 +285,8 @@ export class VectorTileLayer extends TileLayer { supportsLabelsOnTop() { return true; } + + async getLicensedFeatures() { + return this._source.getLicensedFeatures(); + } } diff --git a/x-pack/plugins/maps/public/classes/sources/ems_file_source/ems_file_source.tsx b/x-pack/plugins/maps/public/classes/sources/ems_file_source/ems_file_source.tsx index 36b965b08eb9..7f1040a38a3e 100644 --- a/x-pack/plugins/maps/public/classes/sources/ems_file_source/ems_file_source.tsx +++ b/x-pack/plugins/maps/public/classes/sources/ems_file_source/ems_file_source.tsx @@ -27,6 +27,7 @@ import { EMSFileSourceDescriptor } from '../../../../common/descriptor_types'; import { ITooltipProperty } from '../../tooltips/tooltip_property'; import { getEMSSettings } from '../../../kibana_services'; import { getEmsUnavailableMessage } from '../../../components/ems_unavailable_message'; +import { LICENSED_FEATURES } from '../../../licensed_features'; function getErrorInfo(fileId: string) { return i18n.translate('xpack.maps.source.emsFile.unableToFindFileIdErrorMessage', { @@ -213,6 +214,11 @@ export class EMSFileSource extends AbstractVectorSource implements IEmsFileSourc async getSupportedShapeTypes(): Promise { return [VECTOR_SHAPE_TYPE.POLYGON]; } + + async getLicensedFeatures(): Promise { + const emsSettings = getEMSSettings(); + return emsSettings.isEMSUrlSet() ? [LICENSED_FEATURES.ON_PREM_EMS] : []; + } } registerSource({ diff --git a/x-pack/plugins/maps/public/classes/sources/ems_tms_source/ems_tms_source.js b/x-pack/plugins/maps/public/classes/sources/ems_tms_source/ems_tms_source.js index f933887c6a4c..a552b8ef6804 100644 --- a/x-pack/plugins/maps/public/classes/sources/ems_tms_source/ems_tms_source.js +++ b/x-pack/plugins/maps/public/classes/sources/ems_tms_source/ems_tms_source.js @@ -14,6 +14,7 @@ import { SOURCE_TYPES } from '../../../../common/constants'; import { getEmsTileLayerId, getIsDarkMode, getEMSSettings } from '../../../kibana_services'; import { registerSource } from '../source_registry'; import { getEmsUnavailableMessage } from '../../../components/ems_unavailable_message'; +import { LICENSED_FEATURES } from '../../../licensed_features'; function getErrorInfo(emsTileLayerId) { return i18n.translate('xpack.maps.source.emsTile.unableToFindTileIdErrorMessage', { @@ -147,6 +148,11 @@ export class EMSTMSSource extends AbstractTMSSource { const emsTileLayerId = getEmsTileLayerId(); return getIsDarkMode() ? emsTileLayerId.dark : emsTileLayerId.bright; } + + async getLicensedFeatures() { + const emsSettings = getEMSSettings(); + return emsSettings.isEMSUrlSet() ? [LICENSED_FEATURES.ON_PREM_EMS] : []; + } } registerSource({ diff --git a/x-pack/plugins/maps/public/licensed_features.ts b/x-pack/plugins/maps/public/licensed_features.ts index facbd631fee3..f709dd529e37 100644 --- a/x-pack/plugins/maps/public/licensed_features.ts +++ b/x-pack/plugins/maps/public/licensed_features.ts @@ -11,6 +11,7 @@ import { APP_ID } from '../common/constants'; export enum LICENSED_FEATURES { GEO_LINE_AGG = 'GEO_LINE_AGG', GEO_SHAPE_AGGS_GEO_TILE = 'GEO_SHAPE_AGGS_GEO_TILE', + ON_PREM_EMS = 'ON_PREM_EMS', } export interface LicensedFeatureDetail { @@ -27,6 +28,10 @@ export const LICENCED_FEATURES_DETAILS: Record