mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[Maps] do not display EMS or kibana layer wizards when not configured (#64554)
* [Maps] do not display EMS or kibana layer wizards when not configured * default tilemap to empty object instead of array * fix typo Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
parent
02ba5fcb13
commit
d6f0c785d9
7 changed files with 33 additions and 5 deletions
|
@ -54,7 +54,7 @@ export function maps(kibana) {
|
|||
emsLandingPageUrl: mapConfig.emsLandingPageUrl,
|
||||
kbnPkgVersion: serverConfig.get('pkg.version'),
|
||||
regionmapLayers: _.get(mapConfig, 'regionmap.layers', []),
|
||||
tilemap: _.get(mapConfig, 'tilemap', []),
|
||||
tilemap: _.get(mapConfig, 'tilemap', {}),
|
||||
};
|
||||
},
|
||||
styleSheetPaths: `${__dirname}/public/index.scss`,
|
||||
|
|
|
@ -20,6 +20,7 @@ export type RenderWizardArguments = {
|
|||
};
|
||||
|
||||
export type LayerWizard = {
|
||||
checkVisibility?: () => boolean;
|
||||
description: string;
|
||||
icon: string;
|
||||
isIndexingSource?: boolean;
|
||||
|
@ -34,5 +35,7 @@ export function registerLayerWizard(layerWizard: LayerWizard) {
|
|||
}
|
||||
|
||||
export function getLayerWizards(): LayerWizard[] {
|
||||
return [...registry];
|
||||
return registry.filter(layerWizard => {
|
||||
return layerWizard.checkVisibility ? layerWizard.checkVisibility() : true;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -12,8 +12,13 @@ import { LayerWizard, RenderWizardArguments } from '../../layer_wizard_registry'
|
|||
import { EMSFileCreateSourceEditor } from './create_source_editor';
|
||||
// @ts-ignore
|
||||
import { EMSFileSource, sourceTitle } from './ems_file_source';
|
||||
// @ts-ignore
|
||||
import { isEmsEnabled } from '../../../meta';
|
||||
|
||||
export const emsBoundariesLayerWizardConfig: LayerWizard = {
|
||||
checkVisibility: () => {
|
||||
return isEmsEnabled();
|
||||
},
|
||||
description: i18n.translate('xpack.maps.source.emsFileDescription', {
|
||||
defaultMessage: 'Administrative boundaries from Elastic Maps Service',
|
||||
}),
|
||||
|
|
|
@ -12,8 +12,13 @@ import { EMSTMSSource, sourceTitle } from './ems_tms_source';
|
|||
import { VectorTileLayer } from '../../vector_tile_layer';
|
||||
// @ts-ignore
|
||||
import { TileServiceSelect } from './tile_service_select';
|
||||
// @ts-ignore
|
||||
import { isEmsEnabled } from '../../../meta';
|
||||
|
||||
export const emsBaseMapLayerWizardConfig: LayerWizard = {
|
||||
checkVisibility: () => {
|
||||
return isEmsEnabled();
|
||||
},
|
||||
description: i18n.translate('xpack.maps.source.emsTileDescription', {
|
||||
defaultMessage: 'Tile map service from Elastic Maps Service',
|
||||
}),
|
||||
|
|
|
@ -12,8 +12,14 @@ import { KibanaRegionmapSource, sourceTitle } from './kibana_regionmap_source';
|
|||
import { VectorLayer } from '../../vector_layer';
|
||||
// @ts-ignore
|
||||
import { CreateSourceEditor } from './create_source_editor';
|
||||
// @ts-ignore
|
||||
import { getKibanaRegionList } from '../../../meta';
|
||||
|
||||
export const kibanaRegionMapLayerWizardConfig: LayerWizard = {
|
||||
checkVisibility: () => {
|
||||
const regions = getKibanaRegionList();
|
||||
return regions.length;
|
||||
},
|
||||
description: i18n.translate('xpack.maps.source.kbnRegionMapDescription', {
|
||||
defaultMessage: 'Vector data from hosted GeoJSON configured in kibana.yml',
|
||||
}),
|
||||
|
|
|
@ -12,8 +12,14 @@ import { CreateSourceEditor } from './create_source_editor';
|
|||
// @ts-ignore
|
||||
import { KibanaTilemapSource, sourceTitle } from './kibana_tilemap_source';
|
||||
import { TileLayer } from '../../tile_layer';
|
||||
// @ts-ignore
|
||||
import { getKibanaTileMap } from '../../../meta';
|
||||
|
||||
export const kibanaBasemapLayerWizardConfig: LayerWizard = {
|
||||
checkVisibility: () => {
|
||||
const tilemap = getKibanaTileMap();
|
||||
return !!tilemap.url;
|
||||
},
|
||||
description: i18n.translate('xpack.maps.source.kbnTMSDescription', {
|
||||
defaultMessage: 'Tile map service configured in kibana.yml',
|
||||
}),
|
||||
|
|
|
@ -36,12 +36,15 @@ function fetchFunction(...args) {
|
|||
return fetch(...args);
|
||||
}
|
||||
|
||||
export function isEmsEnabled() {
|
||||
return getInjectedVarFunc()('isEmsEnabled', true);
|
||||
}
|
||||
|
||||
let emsClient = null;
|
||||
let latestLicenseId = null;
|
||||
export function getEMSClient() {
|
||||
if (!emsClient) {
|
||||
const isEmsEnabled = getInjectedVarFunc()('isEmsEnabled', true);
|
||||
if (isEmsEnabled) {
|
||||
if (isEmsEnabled()) {
|
||||
const proxyElasticMapsServiceInMaps = getInjectedVarFunc()(
|
||||
'proxyElasticMapsServiceInMaps',
|
||||
false
|
||||
|
@ -86,7 +89,7 @@ export function getEMSClient() {
|
|||
}
|
||||
|
||||
export function getGlyphUrl() {
|
||||
if (!getInjectedVarFunc()('isEmsEnabled', true)) {
|
||||
if (!isEmsEnabled()) {
|
||||
return '';
|
||||
}
|
||||
return getInjectedVarFunc()('proxyElasticMapsServiceInMaps', false)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue