diff --git a/examples/embeddable_examples/public/plugin.ts b/examples/embeddable_examples/public/plugin.ts index 37f4b17435bc1..06473cd11388b 100644 --- a/examples/embeddable_examples/public/plugin.ts +++ b/examples/embeddable_examples/public/plugin.ts @@ -22,8 +22,7 @@ import { ContentManagementPublicStart, } from '@kbn/content-management-plugin/public'; import { setupApp } from './app/setup_app'; -import { DATA_TABLE_ID } from './react_embeddables/data_table/constants'; -import { registerCreateDataTableAction } from './react_embeddables/data_table/create_data_table_action'; +import { ADD_DATA_TABLE_ACTION_ID, DATA_TABLE_ID } from './react_embeddables/data_table/constants'; import { ADD_EUI_MARKDOWN_ACTION_ID, EUI_MARKDOWN_ID, @@ -117,7 +116,12 @@ export class EmbeddableExamplesPlugin implements Plugin { + const { createDataTableAction } = await import( + './react_embeddables/data_table/create_data_table_action' + ); + return createDataTableAction; + }); registerCreateSavedBookAction(deps.uiActions, core); } diff --git a/examples/embeddable_examples/public/react_embeddables/data_table/create_data_table_action.ts b/examples/embeddable_examples/public/react_embeddables/data_table/create_data_table_action.ts index ac52d4bf354b2..bbeba2224c5b1 100644 --- a/examples/embeddable_examples/public/react_embeddables/data_table/create_data_table_action.ts +++ b/examples/embeddable_examples/public/react_embeddables/data_table/create_data_table_action.ts @@ -12,8 +12,6 @@ import { apiIsPresentationContainer } from '@kbn/presentation-containers'; import { EmbeddableApiContext } from '@kbn/presentation-publishing'; import { IncompatibleActionError, - UiActionsStart, - ADD_PANEL_TRIGGER, } from '@kbn/ui-actions-plugin/public'; import { embeddableExamplesGrouping } from '../embeddable_examples_grouping'; import { ADD_DATA_TABLE_ACTION_ID, DATA_TABLE_ID } from './constants'; @@ -22,15 +20,15 @@ import { ADD_DATA_TABLE_ACTION_ID, DATA_TABLE_ID } from './constants'; // Create and register an action which allows this embeddable to be created from // the dashboard toolbar context menu. // ----------------------------------------------------------------------------- -export const registerCreateDataTableAction = (uiActions: UiActionsStart) => { - uiActions.registerAction({ + +export const createDataTableAction = { id: ADD_DATA_TABLE_ACTION_ID, grouping: [embeddableExamplesGrouping], getIconType: () => 'tableDensityNormal', - isCompatible: async ({ embeddable }) => { + isCompatible: async ({ embeddable }: EmbeddableApiContext) => { return apiIsPresentationContainer(embeddable); }, - execute: async ({ embeddable }) => { + execute: async ({ embeddable }: EmbeddableApiContext) => { if (!apiIsPresentationContainer(embeddable)) throw new IncompatibleActionError(); embeddable.addNewPanel( { @@ -43,6 +41,4 @@ export const registerCreateDataTableAction = (uiActions: UiActionsStart) => { i18n.translate('embeddableExamples.dataTable.ariaLabel', { defaultMessage: 'Data table', }), - }); - uiActions.attachAction(ADD_PANEL_TRIGGER, ADD_DATA_TABLE_ACTION_ID); -}; + }