diff --git a/x-pack/plugins/maps/public/legacy_visualizations/is_legacy_map.ts b/x-pack/plugins/maps/public/legacy_visualizations/is_legacy_map.ts index 9f13091e7b7ef..46f7b9cf27be5 100644 --- a/x-pack/plugins/maps/public/legacy_visualizations/is_legacy_map.ts +++ b/x-pack/plugins/maps/public/legacy_visualizations/is_legacy_map.ts @@ -5,10 +5,8 @@ * 2.0. */ -import type { HasType } from '@kbn/presentation-publishing'; import { Embeddable } from '@kbn/embeddable-plugin/public'; import type { HasVisualizeConfig, VisualizeEmbeddable } from '@kbn/visualizations-plugin/public'; -import { apiHasVisualizeConfig } from '@kbn/visualizations-plugin/public'; export function isLegacyMap(embeddable: Embeddable) { return ( @@ -18,11 +16,6 @@ export function isLegacyMap(embeddable: Embeddable) { ); } -type LegacyMapApi = HasType & Partial; - -export function isLegacyMapApi(api: LegacyMapApi) { - if (!apiHasVisualizeConfig(api)) { - return false; - } +export function isLegacyMapApi(api: HasVisualizeConfig) { return ['region_map', 'tile_map'].includes(api.getVis().type?.name); } diff --git a/x-pack/plugins/maps/public/trigger_actions/filter_by_map_extent/action.ts b/x-pack/plugins/maps/public/trigger_actions/filter_by_map_extent/action.ts index b45d999f4c53a..a368dc65b26fe 100644 --- a/x-pack/plugins/maps/public/trigger_actions/filter_by_map_extent/action.ts +++ b/x-pack/plugins/maps/public/trigger_actions/filter_by_map_extent/action.ts @@ -8,6 +8,7 @@ import { i18n } from '@kbn/i18n'; import { type EmbeddableApiContext, apiHasType, apiIsOfType } from '@kbn/presentation-publishing'; import { createAction } from '@kbn/ui-actions-plugin/public'; +import { apiHasVisualizeConfig } from '@kbn/visualizations-plugin/public'; import { type FilterByMapExtentActionApi } from './types'; import { MAP_SAVED_OBJECT_TYPE } from '../../../common/constants'; import { isLegacyMapApi } from '../../legacy_visualizations/is_legacy_map'; @@ -52,10 +53,11 @@ export const filterByMapExtentAction = createAction({ return 'filter'; }, isCompatible: async ({ embeddable }: EmbeddableApiContext) => { - if (!isApiCompatible(embeddable)) return false; - return embeddable.disableTriggers - ? false - : apiIsOfType(embeddable, MAP_SAVED_OBJECT_TYPE) || isLegacyMapApi(embeddable); + if (!isApiCompatible(embeddable) || embeddable.disableTriggers) return false; + return ( + apiIsOfType(embeddable, MAP_SAVED_OBJECT_TYPE) || + (apiHasVisualizeConfig(embeddable) && isLegacyMapApi(embeddable)) + ); }, execute: async ({ embeddable }: EmbeddableApiContext) => { const { openModal } = await import('./modal'); diff --git a/x-pack/plugins/maps/public/trigger_actions/synchronize_movement/is_compatible.ts b/x-pack/plugins/maps/public/trigger_actions/synchronize_movement/is_compatible.ts index b8adf9d8c13e6..bd31feb04f00e 100644 --- a/x-pack/plugins/maps/public/trigger_actions/synchronize_movement/is_compatible.ts +++ b/x-pack/plugins/maps/public/trigger_actions/synchronize_movement/is_compatible.ts @@ -6,7 +6,8 @@ */ import { apiIsOfType } from '@kbn/presentation-publishing'; -import { type HasLensConfig, apiHasLensConfig } from '@kbn/lens-plugin/public'; +import { apiHasVisualizeConfig } from '@kbn/visualizations-plugin/public'; +import { apiHasLensConfig } from '@kbn/lens-plugin/public'; import { MAP_SAVED_OBJECT_TYPE } from '../../../common/constants'; import { isLegacyMapApi } from '../../legacy_visualizations/is_legacy_map'; import { mapEmbeddablesSingleton } from '../../embeddable/map_embeddables_singleton'; @@ -16,14 +17,9 @@ export function isCompatible(api: SynchronizeMovementActionApi) { if (!mapEmbeddablesSingleton.hasMultipleMaps()) { return false; } - - if (apiHasLensConfig(api) && (api as HasLensConfig).getSavedVis()?.visualizationType === 'lnsChoropleth') { - return true; - } - - if (isLegacyMapApi(api)) { - return true; - } - - return apiIsOfType(api, MAP_SAVED_OBJECT_TYPE); + return ( + apiIsOfType(api, MAP_SAVED_OBJECT_TYPE) || + (apiHasLensConfig(api) && api.getSavedVis()?.visualizationType === 'lnsChoropleth') || + (apiHasVisualizeConfig(api) && isLegacyMapApi(api)) + ); } diff --git a/x-pack/plugins/maps/public/trigger_actions/synchronize_movement/types.ts b/x-pack/plugins/maps/public/trigger_actions/synchronize_movement/types.ts index 2e3ea9862c735..4b9e48e19c2d0 100644 --- a/x-pack/plugins/maps/public/trigger_actions/synchronize_movement/types.ts +++ b/x-pack/plugins/maps/public/trigger_actions/synchronize_movement/types.ts @@ -9,5 +9,6 @@ import type { HasType } from '@kbn/presentation-publishing'; import type { HasLensConfig } from '@kbn/lens-plugin/public'; import type { HasVisualizeConfig } from '@kbn/visualizations-plugin/public'; -export type SynchronizeMovementActionApi = HasType<'lens' | 'visualization' | 'map'> & - Partial; +export type SynchronizeMovementActionApi = + | HasType<'map' | 'visualization' | 'lens'> + | Partial;