[Maps] Enable all zoom levels for all users (#96093)

This commit is contained in:
Thomas Neirynck 2021-04-05 12:04:20 -04:00 committed by GitHub
parent 95e45ddebc
commit 8e11e2598e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 12 additions and 346 deletions

1
.github/CODEOWNERS vendored
View file

@ -146,7 +146,6 @@
/x-pack/test/visual_regression/tests/maps/index.js @elastic/kibana-gis
#CC# /src/plugins/maps_legacy/ @elastic/kibana-gis
#CC# /x-pack/plugins/file_upload @elastic/kibana-gis
#CC# /x-pack/plugins/maps_legacy_licensing @elastic/kibana-gis
/src/plugins/tile_map/ @elastic/kibana-gis
/src/plugins/region_map/ @elastic/kibana-gis

View file

@ -452,10 +452,6 @@ using the CURL scripts in the scripts folder.
|Visualize geo data from Elasticsearch or 3rd party geo-services.
|{kib-repo}blob/{branch}/x-pack/plugins/maps_legacy_licensing/README.md[mapsLegacyLicensing]
|This plugin provides access to the detailed tile map services from Elastic.
|{kib-repo}blob/{branch}/x-pack/plugins/ml/readme.md[ml]
|This plugin provides access to the machine learning features provided by
Elastic.

View file

@ -51,7 +51,6 @@ pageLoadAssetSize:
management: 46112
maps: 80000
mapsLegacy: 87859
mapsLegacyLicensing: 20214
ml: 82187
monitoring: 80000
navigation: 37269

View file

@ -103,43 +103,8 @@ describe('service_settings (FKA tile_map test)', function () {
expect(tmsService.attribution.includes('OpenStreetMap')).toEqual(true);
});
describe('modify - url', function () {
let tilemapServices;
describe('tms mods', function () {
let serviceSettings;
async function assertQuery(expected) {
const attrs = await serviceSettings.getAttributesForTMSLayer(tilemapServices[0]);
const urlObject = url.parse(attrs.url, true);
Object.keys(expected).forEach((key) => {
expect(urlObject.query[key]).toEqual(expected[key]);
});
}
it('accepts an object', async () => {
serviceSettings = makeServiceSettings();
serviceSettings.setQueryParams({ foo: 'bar' });
tilemapServices = await serviceSettings.getTMSServices();
await assertQuery({ foo: 'bar' });
});
it('merged additions with previous values', async () => {
// ensure that changes are always additive
serviceSettings = makeServiceSettings();
serviceSettings.setQueryParams({ foo: 'bar' });
serviceSettings.setQueryParams({ bar: 'stool' });
tilemapServices = await serviceSettings.getTMSServices();
await assertQuery({ foo: 'bar', bar: 'stool' });
});
it('overwrites conflicting previous values', async () => {
serviceSettings = makeServiceSettings();
// ensure that conflicts are overwritten
serviceSettings.setQueryParams({ foo: 'bar' });
serviceSettings.setQueryParams({ bar: 'stool' });
serviceSettings.setQueryParams({ foo: 'tstool' });
tilemapServices = await serviceSettings.getTMSServices();
await assertQuery({ foo: 'tstool', bar: 'stool' });
});
it('should merge in tilemap url', async () => {
serviceSettings = makeServiceSettings(
@ -161,7 +126,7 @@ describe('service_settings (FKA tile_map test)', function () {
id: 'road_map',
name: 'Road Map - Bright',
url:
'https://tiles.foobar/raster/styles/osm-bright/{z}/{x}/{y}.png?elastic_tile_service_tos=agree&my_app_name=kibana&my_app_version=1.2.3',
'https://tiles.foobar/raster/styles/osm-bright/{z}/{x}/{y}.png?elastic_tile_service_tos=agree&my_app_name=kibana&my_app_version=1.2.3&license=sspl',
minZoom: 0,
maxZoom: 10,
attribution:
@ -208,19 +173,19 @@ describe('service_settings (FKA tile_map test)', function () {
);
expect(desaturationFalse.url).toEqual(
'https://tiles.foobar/raster/styles/osm-bright/{z}/{x}/{y}.png?elastic_tile_service_tos=agree&my_app_name=kibana&my_app_version=1.2.3'
'https://tiles.foobar/raster/styles/osm-bright/{z}/{x}/{y}.png?elastic_tile_service_tos=agree&my_app_name=kibana&my_app_version=1.2.3&license=sspl'
);
expect(desaturationFalse.maxZoom).toEqual(10);
expect(desaturationTrue.url).toEqual(
'https://tiles.foobar/raster/styles/osm-bright-desaturated/{z}/{x}/{y}.png?elastic_tile_service_tos=agree&my_app_name=kibana&my_app_version=1.2.3'
'https://tiles.foobar/raster/styles/osm-bright-desaturated/{z}/{x}/{y}.png?elastic_tile_service_tos=agree&my_app_name=kibana&my_app_version=1.2.3&license=sspl'
);
expect(desaturationTrue.maxZoom).toEqual(18);
expect(darkThemeDesaturationFalse.url).toEqual(
'https://tiles.foobar/raster/styles/dark-matter/{z}/{x}/{y}.png?elastic_tile_service_tos=agree&my_app_name=kibana&my_app_version=1.2.3'
'https://tiles.foobar/raster/styles/dark-matter/{z}/{x}/{y}.png?elastic_tile_service_tos=agree&my_app_name=kibana&my_app_version=1.2.3&license=sspl'
);
expect(darkThemeDesaturationFalse.maxZoom).toEqual(22);
expect(darkThemeDesaturationTrue.url).toEqual(
'https://tiles.foobar/raster/styles/dark-matter/{z}/{x}/{y}.png?elastic_tile_service_tos=agree&my_app_name=kibana&my_app_version=1.2.3'
'https://tiles.foobar/raster/styles/dark-matter/{z}/{x}/{y}.png?elastic_tile_service_tos=agree&my_app_name=kibana&my_app_version=1.2.3&license=sspl'
);
expect(darkThemeDesaturationTrue.maxZoom).toEqual(22);
});
@ -264,14 +229,13 @@ describe('service_settings (FKA tile_map test)', function () {
describe('File layers', function () {
it('should load manifest (all props)', async function () {
const serviceSettings = makeServiceSettings();
serviceSettings.setQueryParams({ foo: 'bar' });
const fileLayers = await serviceSettings.getFileLayers();
expect(fileLayers.length).toEqual(19);
const assertions = fileLayers.map(async function (fileLayer) {
expect(fileLayer.origin).toEqual(ORIGIN.EMS);
const fileUrl = await serviceSettings.getUrlForRegionLayer(fileLayer);
const urlObject = url.parse(fileUrl, true);
Object.keys({ foo: 'bar', elastic_tile_service_tos: 'agree' }).forEach((key) => {
Object.keys({ elastic_tile_service_tos: 'agree' }).forEach((key) => {
expect(typeof urlObject.query[key]).toEqual('string');
});
});

View file

@ -22,7 +22,6 @@ export class ServiceSettings implements IServiceSettings {
private readonly _mapConfig: MapsEmsConfig;
private readonly _tilemapsConfig: TileMapConfig;
private readonly _hasTmsConfigured: boolean;
private _showZoomMessage: boolean;
private readonly _emsClient: EMSClient;
private readonly tmsOptionsFromConfig: any;
@ -31,7 +30,6 @@ export class ServiceSettings implements IServiceSettings {
this._tilemapsConfig = tilemapsConfig;
this._hasTmsConfigured = typeof tilemapsConfig.url === 'string' && tilemapsConfig.url !== '';
this._showZoomMessage = true;
this._emsClient = new EMSClient({
language: i18n.getLocale(),
appVersion: getKibanaVersion(),
@ -45,6 +43,9 @@ export class ServiceSettings implements IServiceSettings {
return fetch(...args);
},
});
// any kibana user, regardless of distribution, should get all zoom levels
// use `sspl` license to indicate this
this._emsClient.addQueryParams({ license: 'sspl' });
const markdownIt = new MarkdownIt({
html: false,
@ -58,18 +59,6 @@ export class ServiceSettings implements IServiceSettings {
});
}
shouldShowZoomMessage({ origin }: { origin: string }): boolean {
return origin === ORIGIN.EMS && this._showZoomMessage;
}
enableZoomMessage(): void {
this._showZoomMessage = true;
}
disableZoomMessage(): void {
this._showZoomMessage = false;
}
__debugStubManifestCalls(manifestRetrieval: () => Promise<unknown>): { removeStub: () => void } {
const oldGetManifest = this._emsClient.getManifest;

View file

@ -46,8 +46,6 @@ export interface IServiceSettings {
getFileLayers(): Promise<FileLayer[]>;
getUrlForRegionLayer(layer: FileLayer): Promise<string | undefined>;
setQueryParams(params: { [p: string]: string }): void;
enableZoomMessage(): void;
disableZoomMessage(): void;
getAttributesForTMSLayer(
tmsServiceConfig: TmsLayer,
isDesaturated: boolean,

View file

@ -5,5 +5,5 @@
"ui": true,
"server": true,
"requiredPlugins": ["mapsEms"],
"requiredBundles": ["kibanaReact", "visDefaultEditor", "mapsEms"]
"requiredBundles": ["visDefaultEditor", "mapsEms"]
}

View file

@ -193,13 +193,12 @@ export function BaseMapsVisualizationProvider() {
isDesaturated,
isDarkMode
);
const showZoomMessage = serviceSettings.shouldShowZoomMessage(tmsLayer);
const options = { ...tmsLayer };
delete options.id;
delete options.subdomains;
this._kibanaMap.setBaseLayer({
baseLayerType: 'tms',
options: { ...options, showZoomMessage, ...meta },
options: { ...options, ...meta },
});
}

View file

@ -7,13 +7,11 @@
*/
import { EventEmitter } from 'events';
import { createZoomWarningMsg } from './map_messages';
import $ from 'jquery';
import { get, isEqual, escape } from 'lodash';
import { zoomToPrecision } from './zoom_to_precision';
import { i18n } from '@kbn/i18n';
import { ORIGIN } from '../../../maps_ems/common';
import { getToasts } from '../kibana_services';
import { L } from '../leaflet';
function makeFitControl(fitContainer, kibanaMap) {
@ -479,22 +477,6 @@ export class KibanaMap extends EventEmitter {
this._updateLegend();
}
_addMaxZoomMessage = (layer) => {
const zoomWarningMsg = createZoomWarningMsg(
getToasts(),
this.getZoomLevel,
this.getMaxZoomLevel
);
this._leafletMap.on('zoomend', zoomWarningMsg);
this._containerNode.setAttribute('data-test-subj', 'zoomWarningEnabled');
layer.on('remove', () => {
this._leafletMap.off('zoomend', zoomWarningMsg);
this._containerNode.removeAttribute('data-test-subj');
});
};
setLegendPosition(position) {
if (this._legendPosition === position) {
if (!this._leafletLegendControl) {
@ -572,11 +554,6 @@ export class KibanaMap extends EventEmitter {
});
this._leafletBaseLayer = baseLayer;
if (settings.options.showZoomMessage) {
baseLayer.on('add', () => {
this._addMaxZoomMessage(baseLayer);
});
}
this._leafletBaseLayer.addTo(this._leafletMap);
this._leafletBaseLayer.bringToBack();
if (settings.options.minZoom > this._leafletMap.getZoom()) {

View file

@ -1,105 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import React from 'react';
import { FormattedMessage } from '@kbn/i18n/react';
import { EuiSpacer, EuiButtonEmpty } from '@elastic/eui';
import { toMountPoint } from '../../../kibana_react/public';
export const createZoomWarningMsg = (function () {
let disableZoomMsg = false;
const setZoomMsg = (boolDisableMsg) => (disableZoomMsg = boolDisableMsg);
class ZoomWarning extends React.Component {
constructor(props) {
super(props);
this.state = {
disabled: false,
};
}
render() {
return (
<div>
<p>
<FormattedMessage
id="maps_legacy.kibanaMap.zoomWarning"
defaultMessage="You've reached the maximum number of zoom
levels. To zoom all the way in, upgrade to the
{defaultDistribution} of Elasticsearch and Kibana. You'll get
access to additional zoom levels for free through the {ems}.
Or, you can configure your own map server. Please go to
{ wms } or { configSettings} for more information."
values={{
defaultDistribution: (
<a target="_blank" href="https://www.elastic.co/downloads/kibana">
{`default distribution `}
</a>
),
ems: (
<a target="_blank" href="https://www.elastic.co/elastic-maps-service">
{`Elastic Maps Service`}
</a>
),
wms: (
<a
target="_blank"
href="https://www.elastic.co/guide/en/kibana/current/tilemap.html"
>
{`Custom WMS Configuration`}
</a>
),
configSettings: (
<a
target="_blank"
href="https://www.elastic.co/guide/en/kibana/current/settings.html"
>
{`Custom TMS Using Config Settings`}
</a>
),
}}
/>
</p>
<EuiSpacer size="xs" />
<EuiButtonEmpty
size="s"
flush="left"
isDisabled={this.state.disabled}
onClick={() => {
this.setState(
{
disabled: true,
},
() => this.props.onChange(this.state.disabled)
);
}}
data-test-subj="suppressZoomWarnings"
>
{`Don't show again`}
</EuiButtonEmpty>
</div>
);
}
}
const zoomToast = {
title: 'No additional zoom levels',
text: toMountPoint(<ZoomWarning onChange={setZoomMsg} />),
'data-test-subj': 'maxZoomWarning',
};
return (toastService, getZoomLevel, getMaxZoomLevel) => {
return () => {
const zoomLevel = getZoomLevel();
const maxMapZoom = getMaxZoomLevel();
if (!disableZoomMsg && zoomLevel === maxMapZoom) {
toastService.addDanger(zoomToast);
}
};
};
})();

View file

@ -15,7 +15,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const retry = getService('retry');
const inspector = getService('inspector');
const filterBar = getService('filterBar');
const testSubjects = getService('testSubjects');
const browser = getService('browser');
const PageObjects = getPageObjects([
'common',
@ -221,63 +220,5 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});
});
});
describe('zoom warning behavior', function describeIndexTests() {
// Zoom warning is only applicable to OSS
this.tags(['skipCloud', 'skipFirefox']);
const waitForLoading = false;
let zoomWarningEnabled;
let last = false;
const toastDefaultLife = 6000;
before(async function () {
await browser.setWindowSize(1280, 1000);
log.debug('navigateToApp visualize');
await PageObjects.visualize.navigateToNewAggBasedVisualization();
log.debug('clickTileMap');
await PageObjects.visualize.clickTileMap();
await PageObjects.visualize.clickNewSearch();
zoomWarningEnabled = await testSubjects.exists('zoomWarningEnabled');
log.debug(`Zoom warning enabled: ${zoomWarningEnabled}`);
const zoomLevel = 9;
for (let i = 0; i < zoomLevel; i++) {
await PageObjects.tileMap.clickMapZoomIn();
}
});
beforeEach(async function () {
await PageObjects.tileMap.clickMapZoomIn(waitForLoading);
});
afterEach(async function () {
if (!last) {
await PageObjects.common.sleep(toastDefaultLife);
await PageObjects.tileMap.clickMapZoomOut(waitForLoading);
}
});
it('should show warning at zoom 10', async () => {
await testSubjects.existOrFail('maxZoomWarning');
});
it('should continue providing zoom warning if left alone', async () => {
await testSubjects.existOrFail('maxZoomWarning');
});
it('should suppress zoom warning if suppress warnings button clicked', async () => {
last = true;
await PageObjects.visChart.waitForVisualization();
await testSubjects.click('suppressZoomWarnings');
await PageObjects.tileMap.clickMapZoomOut(waitForLoading);
await testSubjects.waitForDeleted('suppressZoomWarnings');
await PageObjects.tileMap.clickMapZoomIn(waitForLoading);
await testSubjects.missingOrFail('maxZoomWarning');
});
});
});
}

View file

@ -181,7 +181,6 @@
{ "path": "./x-pack/plugins/license_management/tsconfig.json" },
{ "path": "./x-pack/plugins/licensing/tsconfig.json" },
{ "path": "./x-pack/plugins/logstash/tsconfig.json" },
{ "path": "./x-pack/plugins/maps_legacy_licensing/tsconfig.json" },
{ "path": "./x-pack/plugins/maps/tsconfig.json" },
{ "path": "./x-pack/plugins/ml/tsconfig.json" },
{ "path": "./x-pack/plugins/monitoring/tsconfig.json" },

View file

@ -85,7 +85,6 @@
{ "path": "./x-pack/plugins/license_management/tsconfig.json" },
{ "path": "./x-pack/plugins/licensing/tsconfig.json" },
{ "path": "./x-pack/plugins/logstash/tsconfig.json" },
{ "path": "./x-pack/plugins/maps_legacy_licensing/tsconfig.json" },
{ "path": "./x-pack/plugins/maps/tsconfig.json" },
{ "path": "./x-pack/plugins/ml/tsconfig.json" },
{ "path": "./x-pack/plugins/monitoring/tsconfig.json" },

View file

@ -1,4 +0,0 @@
# Tile Map Plugin
This plugin provides access to the detailed tile map services from Elastic.

View file

@ -1,8 +0,0 @@
{
"id": "mapsLegacyLicensing",
"version": "8.0.0",
"kibanaVersion": "kibana",
"server": false,
"ui": true,
"requiredPlugins": ["licensing", "mapsEms"]
}

View file

@ -1,12 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { MapsLegacyLicensing } from './plugin';
export function plugin() {
return new MapsLegacyLicensing();
}

View file

@ -1,48 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { CoreSetup, CoreStart, Plugin } from 'kibana/public';
import { LicensingPluginSetup, ILicense } from '../../licensing/public';
import { IServiceSettings, MapsEmsPluginSetup } from '../../../../src/plugins/maps_ems/public';
/**
* These are the interfaces with your public contracts. You should export these
* for other plugins to use in _their_ `SetupDeps`/`StartDeps` interfaces.
* @public
*/
export interface MapsLegacyLicensingSetupDependencies {
licensing: LicensingPluginSetup;
mapsEms: MapsEmsPluginSetup;
}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface MapsLegacyLicensingStartDependencies {}
export type MapsLegacyLicensingSetup = ReturnType<MapsLegacyLicensing['setup']>;
export type MapsLegacyLicensingStart = ReturnType<MapsLegacyLicensing['start']>;
export class MapsLegacyLicensing
implements Plugin<MapsLegacyLicensingSetup, MapsLegacyLicensingStart> {
public setup(core: CoreSetup, plugins: MapsLegacyLicensingSetupDependencies) {
const { licensing, mapsEms } = plugins;
if (licensing) {
licensing.license$.subscribe(async (license: ILicense) => {
const serviceSettings: IServiceSettings = await mapsEms.getServiceSettings();
const { uid, isActive } = license;
if (isActive && license.hasAtLeast('basic')) {
serviceSettings.setQueryParams({ license: uid || '' });
serviceSettings.disableZoomMessage();
} else {
serviceSettings.setQueryParams({ license: '' });
serviceSettings.enableZoomMessage();
}
});
}
}
public start(core: CoreStart, plugins: MapsLegacyLicensingStartDependencies) {}
}

View file

@ -1,15 +0,0 @@
{
"extends": "../../../tsconfig.project.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
"emitDeclarationOnly": true,
"declaration": true,
"declarationMap": true
},
"include": ["public/**/*"],
"references": [
{ "path": "../licensing/tsconfig.json" },
{ "path": "../../../src/plugins/maps_ems/tsconfig.json" }
]
}

View file

@ -3080,7 +3080,6 @@
"maps_legacy.baseMapsVisualization.childShouldImplementMethodErrorMessage": "子はdata-updateに対応できるようこのメソッドを導入する必要があります",
"maps_legacy.defaultDistributionMessage": "Mapsを入手するには、ElasticsearchとKibanaの{defaultDistribution}にアップグレードしてください。",
"maps_legacy.kibanaMap.leaflet.fitDataBoundsAriaLabel": "データバウンドを合わせる",
"maps_legacy.kibanaMap.zoomWarning": "ズームレベルが最大に達しました。完全にズームインするには、ElasticsearchとKibanaの{defaultDistribution}にアップグレードしてください。{ems}ではより多くのズームレベルを無料で利用できます。または、独自のマップサーバーを構成できます。詳細は、{ wms }または{ configSettings}をご覧ください。",
"maps_legacy.legacyMapDeprecationMessage": "Mapsを使用すると、複数のレイヤーとインデックスを追加する、個別のドキュメントをプロットする、データ値から特徴を表現する、ヒートマップ、グリッド、クラスターを追加するなど、さまざまなことが可能です。{getMapsMessage}",
"maps_legacy.legacyMapDeprecationTitle": "{label}は8.0でMapsに移行されます。",
"maps_legacy.openInMapsButtonLabel": "Mapsで表示",

View file

@ -3101,7 +3101,6 @@
"maps_legacy.baseMapsVisualization.childShouldImplementMethodErrorMessage": "子对象应实现此方法以响应数据更新",
"maps_legacy.defaultDistributionMessage": "要获取 Maps请升级到 {defaultDistribution} 版的 Elasticsearch 和 Kibana。",
"maps_legacy.kibanaMap.leaflet.fitDataBoundsAriaLabel": "适应数据边界",
"maps_legacy.kibanaMap.zoomWarning": "已达到缩放级别数目上限。要一直放大,请升级到 Elasticsearch 和 Kibana 的{defaultDistribution}。您可以通过 {ems} 免费使用其他缩放级别。或者,您可以配置自己的地图服务器。请前往 { wms } 或 { configSettings} 以获取详细信息。",
"maps_legacy.legacyMapDeprecationMessage": "使用 Maps可以添加多个图层和索引绘制单个文档使用数据值表示特征添加热图、网格和集群等等。{getMapsMessage}",
"maps_legacy.legacyMapDeprecationTitle": "在 8.0 中,{label} 将迁移到 Maps。",
"maps_legacy.openInMapsButtonLabel": "在 Maps 中查看",