[Maps] fix legacy tile_map and region_map visualizations do not display title in Map embeddable action modals (#139054)

* [Maps] fix legacy tile_map and region_map visualizations do not display title in Map embeddable action modals

* pass title to embeddable

* eslint

* tslint

* clean up
This commit is contained in:
Nathan Reese 2022-08-18 15:54:39 -06:00 committed by GitHub
parent 3de69b6b89
commit 7be8ae67f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 37 additions and 2 deletions

View file

@ -192,6 +192,10 @@ export class VisualizeEmbeddable
return this.vis.description;
}
public getVis() {
return this.vis;
}
/**
* Gets the Visualize embeddable's local filters
* @returns Local/panel-level array of filters for Visualize embeddable

View file

@ -37,6 +37,7 @@ export type { Vis, SerializedVis, SerializedVisData, VisData } from './vis';
export type VisualizeEmbeddableFactoryContract = PublicContract<VisualizeEmbeddableFactory>;
export type VisualizeEmbeddableContract = PublicContract<VisualizeEmbeddable>;
export type { VisualizeInput } from './embeddable';
export type { VisualizeEmbeddable } from './embeddable';
export type { SchemaConfig } from './vis_schemas';
export { updateOldState } from './legacy/vis_update_state';
export type { PersistedState } from './persisted_state';

View file

@ -16,6 +16,7 @@ import type { LazyLoadedMapModules } from '../lazy_load_bundle';
import { lazyLoadMapModules } from '../lazy_load_bundle';
interface Props {
title: string;
filters?: Filter[];
query?: Query;
timeRange?: TimeRange;
@ -81,7 +82,7 @@ export class MapComponent extends Component<Props, State> {
{
id: uuid(),
attributes: {
title: '',
title: this.props.title,
layerListJSON: JSON.stringify([
mapModules.createBasemapLayerDescriptor(),
...this.props.getLayerDescriptors({

View file

@ -7,3 +7,4 @@
export { createRegionMapFn, regionMapRenderer, regionMapVisType } from './region_map';
export { createTileMapFn, tileMapRenderer, tileMapVisType } from './tile_map';
export { isLegacyMap } from './is_legacy_map';

View file

@ -0,0 +1,17 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { Embeddable } from '@kbn/embeddable-plugin/public';
import type { VisualizeEmbeddable } from '@kbn/visualizations-plugin/public';
export function isLegacyMap(embeddable: Embeddable) {
return (
embeddable.type === 'visualization' &&
typeof (embeddable as VisualizeEmbeddable).getVis === 'function' &&
['region_map', 'tile_map'].includes((embeddable as VisualizeEmbeddable).getVis()?.type?.name)
);
}

View file

@ -36,6 +36,7 @@ function RegionMapVisualization(props: Props) {
}
return (
<MapComponent
title={props.visConfig.layerDescriptorParams.label}
filters={props.filters}
query={props.query}
timeRange={props.timeRange}

View file

@ -36,6 +36,7 @@ function TileMapVisualization(props: Props) {
}
return (
<MapComponent
title={props.visConfig.layerDescriptorParams.label}
filters={props.filters}
query={props.query}
timeRange={props.timeRange}

View file

@ -10,6 +10,7 @@ import { i18n } from '@kbn/i18n';
import { Embeddable, EmbeddableInput } from '@kbn/embeddable-plugin/public';
import { createReactOverlays } from '@kbn/kibana-react-plugin/public';
import { createAction } from '@kbn/ui-actions-plugin/public';
import { isLegacyMap } from '../legacy_visualizations';
import { MAP_SAVED_OBJECT_TYPE } from '../../common/constants';
import { getCore } from '../kibana_services';
@ -58,7 +59,10 @@ export const filterByMapExtentAction = createAction<FilterByMapExtentActionConte
return 'filter';
},
isCompatible: async ({ embeddable }: FilterByMapExtentActionContext) => {
return embeddable.type === MAP_SAVED_OBJECT_TYPE && !embeddable.getInput().disableTriggers;
return (
(embeddable.type === MAP_SAVED_OBJECT_TYPE || isLegacyMap(embeddable)) &&
!embeddable.getInput().disableTriggers
);
},
execute: async (context: FilterByMapExtentActionContext) => {
const { FilterByMapExtentModal } = await import('./filter_by_map_extent_modal');

View file

@ -11,6 +11,7 @@ import { createReactOverlays } from '@kbn/kibana-react-plugin/public';
import { Embeddable, EmbeddableInput } from '@kbn/embeddable-plugin/public';
import { createAction } from '@kbn/ui-actions-plugin/public';
import type { Embeddable as LensEmbeddable } from '@kbn/lens-plugin/public';
import { isLegacyMap } from '../legacy_visualizations';
import { MAP_SAVED_OBJECT_TYPE } from '../../common/constants';
import { getCore } from '../kibana_services';
@ -52,6 +53,10 @@ export const synchronizeMovementAction = createAction<SynchronizeMovementActionC
return true;
}
if (isLegacyMap(embeddable)) {
return true;
}
return embeddable.type === MAP_SAVED_OBJECT_TYPE;
},
execute: async ({ embeddable }: SynchronizeMovementActionContext) => {