diff --git a/src/plugins/links/public/actions/compatibility_check.ts b/src/plugins/links/public/actions/compatibility_check.ts new file mode 100644 index 0000000000000..986c91368abfa --- /dev/null +++ b/src/plugins/links/public/actions/compatibility_check.ts @@ -0,0 +1,16 @@ +/* + * 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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { apiIsPresentationContainer, PresentationContainer } from '@kbn/presentation-containers'; +import { EmbeddableApiContext } from '@kbn/presentation-publishing'; + +export const compatibilityCheck = ( + api: EmbeddableApiContext['embeddable'] +): api is PresentationContainer => { + return apiIsPresentationContainer(api); +}; diff --git a/src/plugins/links/public/actions/create_links_panel_action.ts b/src/plugins/links/public/actions/create_links_panel_action.ts index eb8f2c11d8682..02d157055f758 100644 --- a/src/plugins/links/public/actions/create_links_panel_action.ts +++ b/src/plugins/links/public/actions/create_links_panel_action.ts @@ -6,7 +6,6 @@ * Side Public License, v 1. */ -import { apiIsPresentationContainer } from '@kbn/presentation-containers'; import { EmbeddableApiContext } from '@kbn/presentation-publishing'; import { ADD_PANEL_TRIGGER, IncompatibleActionError } from '@kbn/ui-actions-plugin/public'; import { COMMON_EMBEDDABLE_GROUPING } from '@kbn/embeddable-plugin/public'; @@ -21,12 +20,12 @@ export const registerCreateLinksPanelAction = () => { getIconType: () => APP_ICON, order: 10, isCompatible: async ({ embeddable }) => { - return apiIsPresentationContainer(embeddable); + const { compatibilityCheck } = await import('./compatibility_check'); + return compatibilityCheck(embeddable); }, execute: async ({ embeddable }) => { - if (!apiIsPresentationContainer(embeddable)) { - throw new IncompatibleActionError(); - } + const { compatibilityCheck } = await import('./compatibility_check'); + if (!compatibilityCheck(embeddable)) throw new IncompatibleActionError(); const { openEditorFlyout } = await import('../editor/open_editor_flyout'); const runtimeState = await openEditorFlyout({ parentDashboard: embeddable,