Skip to content

Commit

Permalink
[BUG] show region blocked warning config not respected (#2042)
Browse files Browse the repository at this point in the history
The configuration wasn't passed down to the options that was
expecting it to be available for the plugin to run the conditional
logic.

Value was undefined for region map. Also, cleaned up the vega map
view code.

Issue:

#2041

Signed-off-by: Kawika Avilla <[email protected]>
  • Loading branch information
kavilla authored Aug 2, 2022
1 parent 28fd642 commit 5fb4143
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,13 @@ export function BaseMapsVisualizationProvider() {
isDarkMode
);
const showZoomMessage = serviceSettings.shouldShowZoomMessage(tmsLayer);
const showRegionBlockedWarning = serviceSettings.shouldShowRegionBlockedWarning();
const options = { ...tmsLayer };
delete options.id;
delete options.subdomains;
this._opensearchDashboardsMap.setBaseLayer({
baseLayerType: 'tms',
options: { ...options, showZoomMessage, ...meta },
options: { ...options, showZoomMessage, showRegionBlockedWarning, ...meta },
});
}

Expand Down
5 changes: 5 additions & 0 deletions src/plugins/maps_legacy/public/map/service_settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export class ServiceSettings {
this._hasTmsConfigured = typeof tilemapsConfig.url === 'string' && tilemapsConfig.url !== '';

this._showZoomMessage = true;
this._showRegionBlockedWarning = this._mapConfig.showRegionBlockedWarning;
this._emsClient = null;
this._opensearchMapsClient = new OpenSearchMapsClient({
language: i18n.getLocale(),
Expand Down Expand Up @@ -88,6 +89,10 @@ export class ServiceSettings {
});
}

shouldShowRegionBlockedWarning() {
return this._showRegionBlockedWarning;
}

shouldShowZoomMessage({ origin }) {
return origin === ORIGIN.EMS && this._showZoomMessage;
}
Expand Down
1 change: 1 addition & 0 deletions src/plugins/vis_type_vega/public/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@ export const [getMapsLegacyConfig, setMapsLegacyConfig] = createGetterSetter<Map

export const getEnableExternalUrls = () => getInjectedVars().enableExternalUrls;
export const getEmsTileLayerId = () => getMapsLegacyConfig().emsTileLayerId;
export const getShowRegionBlockedWarning = () => getMapsLegacyConfig().showRegionBlockedWarning;
4 changes: 2 additions & 2 deletions src/plugins/vis_type_vega/public/vega_view/vega_map_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { i18n } from '@osd/i18n';
import { vega } from '../lib/vega';
import { VegaBaseView } from './vega_base_view';
import { VegaMapLayer } from './vega_map_layer';
import { getEmsTileLayerId, getUISettings } from '../services';
import { getEmsTileLayerId, getShowRegionBlockedWarning, getUISettings } from '../services';
import { lazyLoadMapsLegacyModules } from '../../../maps_legacy/public';

export class VegaMapView extends VegaBaseView {
Expand All @@ -58,7 +58,7 @@ export class VegaMapView extends VegaBaseView {
baseMapOpts = {
...baseMapOpts,
...(await this._serviceSettings.getAttributesForTMSLayer(baseMapOpts, true, isDarkMode)),
showRegionBlockedWarning: this._serviceSettings._mapConfig.showRegionBlockedWarning,
showRegionBlockedWarning: getShowRegionBlockedWarning(),
};
if (!baseMapOpts) {
this.onWarn(
Expand Down

0 comments on commit 5fb4143

Please sign in to comment.