Skip to content

Commit

Permalink
Remove deprecated refs from service settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Caldwell committed Jul 28, 2020
1 parent 2ea2f10 commit f1490c9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
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
6 changes: 1 addition & 5 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

0 comments on commit f1490c9

Please sign in to comment.