[Maps] Track enterprise use of on-prem EMS (#85885)

This commit is contained in:
Thomas Neirynck 2020-12-15 16:50:26 -05:00 committed by GitHub
parent 85dae266eb
commit 24f463f84c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 27 additions and 10 deletions

View file

@ -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);
});
});
});

View file

@ -39,10 +39,6 @@ export class EMSSettings {
return this._config.emsUrl!.replace(/\/$/, '');
}
isOnPrem(): boolean {
return this.isEMSUrlSet();
}
isIncludeElasticMapsService() {
return !!this._config.includeElasticMapsService;
}

View file

@ -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();
}
}

View file

@ -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<VECTOR_SHAPE_TYPE[]> {
return [VECTOR_SHAPE_TYPE.POLYGON];
}
async getLicensedFeatures(): Promise<LICENSED_FEATURES[]> {
const emsSettings = getEMSSettings();
return emsSettings.isEMSUrlSet() ? [LICENSED_FEATURES.ON_PREM_EMS] : [];
}
}
registerSource({

View file

@ -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({

View file

@ -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<LICENSED_FEATURES, LicensedFeatur
name: 'geo_tile aggregation on geo_shape field-type',
license: 'gold',
},
[LICENSED_FEATURES.ON_PREM_EMS]: {
name: 'layer from local Elastic Maps Server',
license: 'enterprise',
},
};
let licenseId: string | undefined;