Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.x] Fix TMS not loaded in legacy maps (#73570) #74307

Merged
merged 1 commit into from
Aug 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions src/plugins/maps_legacy/public/map/service_settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export class ServiceSettings {
constructor(mapConfig, tilemapsConfig) {
this._mapConfig = mapConfig;
this._tilemapsConfig = tilemapsConfig;
this._hasTmsConfigured = typeof tilemapsConfig.url === 'string' && tilemapsConfig.url !== '';

this._showZoomMessage = true;
this._emsClient = new EMSClient({
Expand All @@ -53,13 +54,10 @@ export class ServiceSettings {
linkify: true,
});

// TMS attribution
const attributionFromConfig = _.escape(
markdownIt.render(this._tilemapsConfig.deprecated.config.options.attribution || '')
);
// TMS Options
this.tmsOptionsFromConfig = _.assign({}, this._tilemapsConfig.deprecated.config.options, {
attribution: attributionFromConfig,
this.tmsOptionsFromConfig = _.assign({}, this._tilemapsConfig.options, {
attribution: _.escape(markdownIt.render(this._tilemapsConfig.options.attribution || '')),
url: this._tilemapsConfig.url,
});
}

Expand Down Expand Up @@ -122,7 +120,7 @@ export class ServiceSettings {
*/
async getTMSServices() {
let allServices = [];
if (this._tilemapsConfig.deprecated.isOverridden) {
if (this._hasTmsConfigured) {
//use tilemap.* settings from yml
const tmsService = _.cloneDeep(this.tmsOptionsFromConfig);
tmsService.id = TMS_IN_YML_ID;
Expand Down Expand Up @@ -210,14 +208,12 @@ export class ServiceSettings {
if (tmsServiceConfig.origin === ORIGIN.EMS) {
return this._getAttributesForEMSTMSLayer(isDesaturated, isDarkMode);
} else if (tmsServiceConfig.origin === ORIGIN.KIBANA_YML) {
const config = this._tilemapsConfig.deprecated.config;
const attrs = _.pick(config, ['url', 'minzoom', 'maxzoom', 'attribution']);
const attrs = _.pick(this._tilemapsConfig, ['url', 'minzoom', 'maxzoom', 'attribution']);
return { ...attrs, ...{ origin: ORIGIN.KIBANA_YML } };
} else {
//this is an older config. need to resolve this dynamically.
if (tmsServiceConfig.id === TMS_IN_YML_ID) {
const config = this._tilemapsConfig.deprecated.config;
const attrs = _.pick(config, ['url', 'minzoom', 'maxzoom', 'attribution']);
const attrs = _.pick(this._tilemapsConfig, ['url', 'minzoom', 'maxzoom', 'attribution']);
return { ...attrs, ...{ origin: ORIGIN.KIBANA_YML } };
} else {
//assume ems
Expand Down
24 changes: 5 additions & 19 deletions src/plugins/maps_legacy/public/map/service_settings.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,7 @@ describe('service_settings (FKA tile_map test)', function () {
};

const defaultTilemapConfig = {
deprecated: {
config: {
options: {},
},
},
options: {},
};

function makeServiceSettings(mapConfigOptions = {}, tilemapOptions = {}) {
Expand Down Expand Up @@ -160,13 +156,8 @@ describe('service_settings (FKA tile_map test)', function () {
serviceSettings = makeServiceSettings(
{},
{
deprecated: {
isOverridden: true,
config: {
url: 'https://a.tile.openstreetmap.org/{z}/{x}/{y}.png',
options: { minZoom: 0, maxZoom: 20 },
},
},
url: 'https://a.tile.openstreetmap.org/{z}/{x}/{y}.png',
options: { minZoom: 0, maxZoom: 20 },
}
);

Expand Down Expand Up @@ -251,13 +242,8 @@ describe('service_settings (FKA tile_map test)', function () {
includeElasticMapsService: false,
},
{
deprecated: {
isOverridden: true,
config: {
url: 'https://a.tile.openstreetmap.org/{z}/{x}/{y}.png',
options: { minZoom: 0, maxZoom: 20 },
},
},
url: 'https://a.tile.openstreetmap.org/{z}/{x}/{y}.png',
options: { minZoom: 0, maxZoom: 20 },
}
);
const tilemapServices = await serviceSettings.getTMSServices();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,8 @@ describe('RegionMapsVisualizationTests', function () {
emsLandingPageUrl: '',
};
const tilemapsConfig = {
deprecated: {
config: {
options: {
attribution: '123',
},
},
options: {
attribution: '123',
},
};
const serviceSettings = new ServiceSettings(mapConfig, tilemapsConfig);
Expand Down
9 changes: 0 additions & 9 deletions src/plugins/tile_map/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,6 @@ import { schema, TypeOf } from '@kbn/config-schema';

export const configSchema = schema.object({
url: schema.maybe(schema.string()),
deprecated: schema.any({
defaultValue: {
config: {
options: {
attribution: '',
},
},
},
}),
options: schema.object({
attribution: schema.string({ defaultValue: '' }),
minZoom: schema.number({ defaultValue: 0, min: 0 }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,8 @@ describe('CoordinateMapsVisualizationTest', function () {
emsLandingPageUrl: '',
};
const tilemapsConfig = {
deprecated: {
config: {
options: {
attribution: '123',
},
},
options: {
attribution: '123',
},
};

Expand Down
1 change: 0 additions & 1 deletion src/plugins/tile_map/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { configSchema, ConfigSchema } from '../config';
export const config: PluginConfigDescriptor<ConfigSchema> = {
exposeToBrowser: {
url: true,
deprecated: true,
options: true,
},
schema: configSchema,
Expand Down