From 79dfd64cb098067470ef277bd59c67fcca3f29d4 Mon Sep 17 00:00:00 2001 From: Zuocheng Ding Date: Fri, 10 Dec 2021 20:06:34 +0000 Subject: [PATCH] [Map] Remove hardcoded AWS paths Clean up temp aws paths in code base. Add a configurable flag `showRegionBlockedWarning` into map plugin level config file. Signed-off-by: Zuocheng Ding --- config/opensearch_dashboards.yml | 6 +++++- src/legacy/server/config/schema.js | 1 + src/plugins/maps_legacy/config.ts | 1 + .../maps_legacy/public/map/opensearch_dashboards_map.js | 2 +- src/plugins/maps_legacy/server/index.ts | 1 + src/plugins/region_map/public/choropleth_layer.js | 6 +----- src/plugins/vis_type_vega/public/vega_view/vega_map_view.js | 1 + 7 files changed, 11 insertions(+), 7 deletions(-) diff --git a/config/opensearch_dashboards.yml b/config/opensearch_dashboards.yml index 143dac3c175e..26c11904fa9a 100644 --- a/config/opensearch_dashboards.yml +++ b/config/opensearch_dashboards.yml @@ -160,4 +160,8 @@ # defaultUrl: "" # darkModeUrl: "" # faviconUrl: "" - # applicationTitle: "" \ No newline at end of file + # applicationTitle: "" + +# Set the value of this setting to true to capture region blocked warnings and errors +# for your map rendering services. +# map.showRegionBlockedWarning: false \ No newline at end of file diff --git a/src/legacy/server/config/schema.js b/src/legacy/server/config/schema.js index 544b9bc9ec64..6c59761c9295 100644 --- a/src/legacy/server/config/schema.js +++ b/src/legacy/server/config/schema.js @@ -156,6 +156,7 @@ export default () => map: Joi.object({ includeOpenSearchMapsService: Joi.boolean().default(true), proxyOpenSearchMapsServiceInMaps: Joi.boolean().default(false), + showRegionBlockedWarning: Joi.boolean().default(false), tilemap: Joi.object({ url: Joi.string(), options: Joi.object({ diff --git a/src/plugins/maps_legacy/config.ts b/src/plugins/maps_legacy/config.ts index 305074c7419a..bacd342896b5 100644 --- a/src/plugins/maps_legacy/config.ts +++ b/src/plugins/maps_legacy/config.ts @@ -37,6 +37,7 @@ import { configSchema as regionmapSchema } from '../region_map/config'; export const configSchema = schema.object({ includeOpenSearchMapsService: schema.boolean({ defaultValue: true }), proxyOpenSearchMapsServiceInMaps: schema.boolean({ defaultValue: false }), + showRegionBlockedWarning: schema.boolean({ defaultValue: false }), tilemap: tilemapSchema, regionmap: regionmapSchema, manifestServiceUrl: schema.string({ defaultValue: '' }), diff --git a/src/plugins/maps_legacy/public/map/opensearch_dashboards_map.js b/src/plugins/maps_legacy/public/map/opensearch_dashboards_map.js index c2c94e8bfa5d..0824c9c62c14 100644 --- a/src/plugins/maps_legacy/public/map/opensearch_dashboards_map.js +++ b/src/plugins/maps_legacy/public/map/opensearch_dashboards_map.js @@ -611,7 +611,7 @@ export class OpenSearchDashboardsMap extends EventEmitter { this.emit('baseLayer:loading'); }); baseLayer.on('tileerror', () => { - if (baseLayer._url.includes('search-services.aws.a2z.com')) { + if (settings.options.showRegionBlockedWarning) { createRegionBlockedWarning(); } }); diff --git a/src/plugins/maps_legacy/server/index.ts b/src/plugins/maps_legacy/server/index.ts index 404beeb6d32b..6c9b06e491c5 100644 --- a/src/plugins/maps_legacy/server/index.ts +++ b/src/plugins/maps_legacy/server/index.ts @@ -40,6 +40,7 @@ export const config: PluginConfigDescriptor = { exposeToBrowser: { includeOpenSearchMapsService: true, proxyOpenSearchMapsServiceInMaps: true, + showRegionBlockedWarning: true, tilemap: true, regionmap: true, manifestServiceUrl: true, diff --git a/src/plugins/region_map/public/choropleth_layer.js b/src/plugins/region_map/public/choropleth_layer.js index c6b15eeb7bb4..ee747745d8cb 100644 --- a/src/plugins/region_map/public/choropleth_layer.js +++ b/src/plugins/region_map/public/choropleth_layer.js @@ -193,16 +193,12 @@ Make sure the file exists at that location.", values: { name: name }, } ); - } else if (e.config.url.includes('aws.a2z.com')) { - // AES Region Maps will throw CORS exception when accessed from Embargo Regions. - // OPTIONS will fail before GET. Thus CORS error. - errorMessage = 'The vector map ' + name + ' is not available.'; } else { errorMessage = i18n.translate( 'regionMap.choroplethLayer.downloadingVectorDataErrorMessage', { defaultMessage: - 'Cannot download {name} file. Please ensure the \ + 'The vector map {name} is not available. Please ensure the \ CORS configuration of the server permits requests from the OpenSearch Dashboards application on this host.', values: { name: name }, } diff --git a/src/plugins/vis_type_vega/public/vega_view/vega_map_view.js b/src/plugins/vis_type_vega/public/vega_view/vega_map_view.js index 51518b4d9f7e..d300d5246736 100644 --- a/src/plugins/vis_type_vega/public/vega_view/vega_map_view.js +++ b/src/plugins/vis_type_vega/public/vega_view/vega_map_view.js @@ -60,6 +60,7 @@ export class VegaMapView extends VegaBaseView { baseMapOpts = { ...baseMapOpts, ...(await this._serviceSettings.getAttributesForTMSLayer(baseMapOpts, true, isDarkMode)), + showRegionBlockedWarning: this._serviceSettings._mapConfig.showRegionBlockedWarning, }; if (!baseMapOpts) { this.onWarn(