From 0af81310b6c4ce72a628fe08542c9b2f59113cb3 Mon Sep 17 00:00:00 2001 From: Josh Dover Date: Tue, 5 Jan 2021 02:11:05 -0700 Subject: [PATCH] Remove dynamic mapped types from UiActions (#87075) * Remove dynamic mapped types from UiActions * Remove import between data <-> embeddables * remove outdated comments, export action types from discover_enhanced * fix notice.txt Co-authored-by: restrry --- ...ns-embeddable-public.contextmenutrigger.md | 2 +- ...ble-public.embeddable.supportedtriggers.md | 4 +- ...le-public.iembeddable.supportedtriggers.md | 4 +- ...ins-embeddable-public.panelbadgetrigger.md | 2 +- ...eddable-public.panelnotificationtrigger.md | 2 +- ...plugin-plugins-ui_actions-public.action.md | 4 +- ...n-plugins-ui_actions-public.action.type.md | 2 +- ...-plugins-ui_actions-public.actionbytype.md | 11 -- ..._actions-public.actioncontextmapping.__.md | 11 -- ...oncontextmapping.action_visualize_field.md | 11 -- ...ntextmapping.action_visualize_geo_field.md | 11 -- ...textmapping.action_visualize_lens_field.md | 11 -- ...-ui_actions-public.actioncontextmapping.md | 21 ---- ...i_actions-public.actiondefinitionbytype.md | 11 -- ...i_actions-public.actionexecutioncontext.md | 2 +- ...in-plugins-ui_actions-public.actiontype.md | 11 -- ...-plugins-ui_actions-public.createaction.md | 6 +- ...kibana-plugin-plugins-ui_actions-public.md | 7 -- ...ugins-ui_actions-public.rowclicktrigger.md | 2 +- ...in-plugins-ui_actions-public.trigger.id.md | 2 +- ...lugin-plugins-ui_actions-public.trigger.md | 4 +- ...lugins-ui_actions-public.triggercontext.md | 11 -- ...actions-public.triggercontextmapping.__.md | 11 -- ...ui_actions-public.triggercontextmapping.md | 21 ---- ...triggercontextmapping.row_click_trigger.md | 11 -- ...rcontextmapping.visualize_field_trigger.md | 11 -- ...textmapping.visualize_geo_field_trigger.md | 11 -- ...gin-plugins-ui_actions-public.triggerid.md | 11 -- ...ctions-public.uiactionsactiondefinition.md | 4 +- ...s-public.uiactionsactiondefinition.type.md | 2 +- ...-ui_actions-public.uiactionspresentable.md | 2 +- ...ons-public.uiactionspresentablegrouping.md | 2 +- ...ublic.uiactionsservice.addtriggeraction.md | 2 +- ...ns-public.uiactionsservice.attachaction.md | 2 +- ...ns-public.uiactionsservice.detachaction.md | 2 +- ....uiactionsservice.executetriggeractions.md | 2 +- ...tions-public.uiactionsservice.getaction.md | 2 +- ...ions-public.uiactionsservice.gettrigger.md | 2 +- ...blic.uiactionsservice.gettriggeractions.md | 2 +- ...ionsservice.gettriggercompatibleactions.md | 2 +- ...gins-ui_actions-public.uiactionsservice.md | 18 +-- ...-public.uiactionsservice.registeraction.md | 2 +- ...ui_actions-public.visualizefieldtrigger.md | 2 +- ...actions-public.visualizegeofieldtrigger.md | 2 +- .../book/add_book_to_library_action.tsx | 1 + .../public/book/edit_book_action.tsx | 1 + .../book/unlink_book_from_library_action.tsx | 1 + examples/embeddable_examples/public/plugin.ts | 22 +--- .../public/hello_world_action.tsx | 1 + examples/ui_action_examples/public/plugin.ts | 14 +-- .../public/actions/actions.tsx | 18 ++- examples/ui_actions_explorer/public/app.tsx | 2 +- .../ui_actions_explorer/public/plugin.tsx | 26 ----- .../actions/add_to_library_action.tsx | 4 +- .../actions/clone_panel_action.tsx | 4 +- .../actions/expand_panel_action.tsx | 4 +- .../application/actions/export_csv_action.tsx | 4 +- .../actions/library_notification_action.tsx | 4 +- .../actions/replace_panel_action.tsx | 4 +- .../actions/unlink_from_library_action.tsx | 4 +- src/plugins/dashboard/public/plugin.tsx | 30 +---- .../dashboard/public/services/ui_actions.ts | 2 +- .../public/actions/apply_filter_action.ts | 6 +- .../create_filters_from_range_select.test.ts | 8 +- .../public/actions/select_range_action.ts | 6 +- .../data/public/actions/value_click_action.ts | 6 +- src/plugins/data/public/plugin.ts | 22 +--- .../public/triggers/apply_filter_trigger.ts | 2 +- .../components/data_table.tsx | 6 +- src/plugins/embeddable/public/bootstrap.ts | 31 ------ .../public/lib/embeddables/embeddable.tsx | 3 +- .../public/lib/embeddables/i_embeddable.ts | 3 +- .../lib/panel/embeddable_panel.test.tsx | 6 +- .../test_samples/actions/edit_mode_action.ts | 9 +- .../test_samples/actions/say_hello_action.tsx | 8 +- .../actions/send_message_action.tsx | 9 +- .../embeddables/contact_card/contact_card.tsx | 7 -- .../public/lib/triggers/triggers.ts | 10 +- src/plugins/embeddable/public/public.api.md | 12 +- .../ui_actions/public/actions/action.test.ts | 14 +-- .../ui_actions/public/actions/action.ts | 19 +--- .../public/actions/action_internal.ts | 3 +- .../public/actions/create_action.ts | 19 +--- .../build_eui_context_menu_panels.test.ts | 1 + .../build_eui_context_menu_panels.tsx | 3 +- src/plugins/ui_actions/public/index.ts | 12 +- src/plugins/ui_actions/public/mocks.ts | 3 +- src/plugins/ui_actions/public/public.api.md | 104 ++++-------------- .../service/ui_actions_execution_service.ts | 7 +- .../public/service/ui_actions_service.test.ts | 40 +++---- .../public/service/ui_actions_service.ts | 50 +++------ .../tests/execute_trigger_actions.test.ts | 43 +++----- .../public/tests/get_trigger_actions.test.ts | 17 ++- .../get_trigger_compatible_actions.test.ts | 29 ++--- .../tests/test_samples/hello_world_action.tsx | 14 +-- .../public/triggers/default_trigger.ts | 2 +- .../public/triggers/row_click_trigger.ts | 2 +- .../ui_actions/public/triggers/trigger.ts | 8 +- .../public/triggers/trigger_contract.ts | 9 +- .../public/triggers/trigger_internal.ts | 9 +- .../triggers/visualize_field_trigger.ts | 2 +- .../triggers/visualize_geo_field_trigger.ts | 2 +- src/plugins/ui_actions/public/types.ts | 32 +----- .../ui_actions/public/util/presentable.ts | 6 +- .../public/embeddable/visualize_embeddable.ts | 3 +- .../visualizations/public/vis_types/types.ts | 3 +- .../vis_types/vis_type_alias_registry.ts | 5 +- .../public/actions/visualize_field_action.ts | 2 +- .../public/sample_panel_action.tsx | 9 +- .../public/sample_panel_link.ts | 9 +- .../app1_hello_world_drilldown.tsx | 2 +- .../app1_to_dashboard_drilldown.ts | 5 +- .../app2_to_dashboard_drilldown.ts | 5 +- .../dashboard_hello_world_drilldown/index.tsx | 5 +- .../index.tsx | 4 +- .../drilldown.tsx | 7 +- .../public/triggers/sample_app1_trigger.ts | 8 +- .../public/triggers/sample_app2_trigger.ts | 8 +- .../abstract_dashboard_drilldown.tsx | 21 ++-- .../abstract_dashboard_drilldown/types.ts | 3 +- .../drilldowns/actions/drilldown_shared.ts | 3 +- .../flyout_create_drilldown.test.tsx | 10 +- .../flyout_create_drilldown.tsx | 4 +- .../flyout_edit_drilldown.tsx | 4 +- .../flyout_edit_drilldown/menu_item.test.tsx | 1 + .../flyout_edit_drilldown/menu_item.tsx | 5 +- .../drilldowns/actions/test_helpers.ts | 10 +- .../dashboard_drilldowns_services.ts | 15 +-- ...embeddable_to_dashboard_drilldown.test.tsx | 3 +- .../embeddable_to_dashboard_drilldown.tsx | 10 +- .../plugins/discover_enhanced/public/index.ts | 6 +- .../discover_enhanced/public/plugin.ts | 16 +-- .../public/lib/url_drilldown.tsx | 4 +- .../embeddable_enhanced/public/plugin.ts | 10 +- .../workspace_panel/workspace_panel.test.tsx | 6 +- .../visualize_field_actions.ts | 2 +- x-pack/plugins/lens/public/types.ts | 15 +-- .../maps/public/embeddable/map_embeddable.tsx | 7 +- .../public/trigger_actions/trigger_utils.ts | 1 - .../visualize_geo_field_action.ts | 3 +- .../embeddable_swim_lane_container.test.tsx | 5 +- .../apply_influencer_filters_action.tsx | 10 +- .../ui_actions/apply_time_range_action.tsx | 10 +- .../ui_actions/clear_selection_action.tsx | 10 +- .../ui_actions/edit_swimlane_panel_action.tsx | 10 +- x-pack/plugins/ml/public/ui_actions/index.ts | 41 +------ .../open_in_anomaly_explorer_action.tsx | 10 +- .../plugins/ml/public/ui_actions/triggers.ts | 2 +- .../action_wizard/action_wizard.tsx | 26 ++--- .../components/action_wizard/test_data.tsx | 9 +- .../public/custom_time_range_action.tsx | 7 +- .../public/custom_time_range_badge.tsx | 4 +- .../connected_flyout_manage_drilldowns.tsx | 12 +- .../test_data.ts | 8 +- .../flyout_drilldown_wizard.stories.tsx | 10 +- .../flyout_drilldown_wizard.tsx | 12 +- .../form_drilldown_wizard.stories.tsx | 8 +- .../form_drilldown_wizard.test.tsx | 8 +- .../form_drilldown_wizard.tsx | 8 +- .../public/drilldowns/drilldown_definition.ts | 31 +----- .../hooks/use_drilldown_state_manager.tsx | 5 +- .../public/dynamic_actions/action_factory.ts | 28 ++--- .../action_factory_definition.ts | 13 +-- .../dynamic_actions/dynamic_action_manager.ts | 13 +-- .../public/dynamic_actions/types.ts | 5 +- .../ui_actions_enhanced/public/plugin.ts | 27 +---- .../ui_actions_service_enhancements.ts | 38 ++----- 167 files changed, 483 insertions(+), 1149 deletions(-) delete mode 100644 docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.actionbytype.md delete mode 100644 docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.actioncontextmapping.__.md delete mode 100644 docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.actioncontextmapping.action_visualize_field.md delete mode 100644 docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.actioncontextmapping.action_visualize_geo_field.md delete mode 100644 docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.actioncontextmapping.action_visualize_lens_field.md delete mode 100644 docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.actioncontextmapping.md delete mode 100644 docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.actiondefinitionbytype.md delete mode 100644 docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.actiontype.md delete mode 100644 docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.triggercontext.md delete mode 100644 docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.triggercontextmapping.__.md delete mode 100644 docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.triggercontextmapping.md delete mode 100644 docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.triggercontextmapping.row_click_trigger.md delete mode 100644 docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.triggercontextmapping.visualize_field_trigger.md delete mode 100644 docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.triggercontextmapping.visualize_geo_field_trigger.md delete mode 100644 docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.triggerid.md diff --git a/docs/development/plugins/embeddable/public/kibana-plugin-plugins-embeddable-public.contextmenutrigger.md b/docs/development/plugins/embeddable/public/kibana-plugin-plugins-embeddable-public.contextmenutrigger.md index 0a88e1e0a2ea8..eec1e9ac7e3fb 100644 --- a/docs/development/plugins/embeddable/public/kibana-plugin-plugins-embeddable-public.contextmenutrigger.md +++ b/docs/development/plugins/embeddable/public/kibana-plugin-plugins-embeddable-public.contextmenutrigger.md @@ -7,5 +7,5 @@ Signature: ```typescript -contextMenuTrigger: Trigger<'CONTEXT_MENU_TRIGGER'> +contextMenuTrigger: Trigger ``` diff --git a/docs/development/plugins/embeddable/public/kibana-plugin-plugins-embeddable-public.embeddable.supportedtriggers.md b/docs/development/plugins/embeddable/public/kibana-plugin-plugins-embeddable-public.embeddable.supportedtriggers.md index 16676bc732b1c..8a5efe60ba411 100644 --- a/docs/development/plugins/embeddable/public/kibana-plugin-plugins-embeddable-public.embeddable.supportedtriggers.md +++ b/docs/development/plugins/embeddable/public/kibana-plugin-plugins-embeddable-public.embeddable.supportedtriggers.md @@ -7,9 +7,9 @@ Signature: ```typescript -supportedTriggers(): Array; +supportedTriggers(): string[]; ``` Returns: -`Array` +`string[]` diff --git a/docs/development/plugins/embeddable/public/kibana-plugin-plugins-embeddable-public.iembeddable.supportedtriggers.md b/docs/development/plugins/embeddable/public/kibana-plugin-plugins-embeddable-public.iembeddable.supportedtriggers.md index 5480f3b246648..bb560c11bf440 100644 --- a/docs/development/plugins/embeddable/public/kibana-plugin-plugins-embeddable-public.iembeddable.supportedtriggers.md +++ b/docs/development/plugins/embeddable/public/kibana-plugin-plugins-embeddable-public.iembeddable.supportedtriggers.md @@ -9,9 +9,9 @@ List of triggers that this embeddable will execute. Signature: ```typescript -supportedTriggers(): Array; +supportedTriggers(): string[]; ``` Returns: -`Array` +`string[]` diff --git a/docs/development/plugins/embeddable/public/kibana-plugin-plugins-embeddable-public.panelbadgetrigger.md b/docs/development/plugins/embeddable/public/kibana-plugin-plugins-embeddable-public.panelbadgetrigger.md index f6113c93a1c66..feacd0152d384 100644 --- a/docs/development/plugins/embeddable/public/kibana-plugin-plugins-embeddable-public.panelbadgetrigger.md +++ b/docs/development/plugins/embeddable/public/kibana-plugin-plugins-embeddable-public.panelbadgetrigger.md @@ -7,5 +7,5 @@ Signature: ```typescript -panelBadgeTrigger: Trigger<'PANEL_BADGE_TRIGGER'> +panelBadgeTrigger: Trigger ``` diff --git a/docs/development/plugins/embeddable/public/kibana-plugin-plugins-embeddable-public.panelnotificationtrigger.md b/docs/development/plugins/embeddable/public/kibana-plugin-plugins-embeddable-public.panelnotificationtrigger.md index df606c11f64ce..c831df19d2959 100644 --- a/docs/development/plugins/embeddable/public/kibana-plugin-plugins-embeddable-public.panelnotificationtrigger.md +++ b/docs/development/plugins/embeddable/public/kibana-plugin-plugins-embeddable-public.panelnotificationtrigger.md @@ -7,5 +7,5 @@ Signature: ```typescript -panelNotificationTrigger: Trigger<'PANEL_NOTIFICATION_TRIGGER'> +panelNotificationTrigger: Trigger ``` diff --git a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.action.md b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.action.md index 19af63a679de8..d8e527debcc4e 100644 --- a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.action.md +++ b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.action.md @@ -7,7 +7,7 @@ Signature: ```typescript -export interface Action extends Partial>> +export interface Action extends Partial>> ``` ## Properties @@ -17,7 +17,7 @@ export interface Action extend | [id](./kibana-plugin-plugins-ui_actions-public.action.id.md) | string | A unique identifier for this action instance. | | [MenuItem](./kibana-plugin-plugins-ui_actions-public.action.menuitem.md) | UiComponent<{
context: ActionExecutionContext<Context>;
}> | UiComponent to render when displaying this action as a context menu item. If not provided, getDisplayName will be used instead. | | [order](./kibana-plugin-plugins-ui_actions-public.action.order.md) | number | Determined the order when there is more than one action matched to a trigger. Higher numbers are displayed first. | -| [type](./kibana-plugin-plugins-ui_actions-public.action.type.md) | T | The action type is what determines the context shape. | +| [type](./kibana-plugin-plugins-ui_actions-public.action.type.md) | string | The action type is what determines the context shape. | ## Methods diff --git a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.action.type.md b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.action.type.md index c423df9d1324c..6905f3deb441d 100644 --- a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.action.type.md +++ b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.action.type.md @@ -9,5 +9,5 @@ The action type is what determines the context shape. Signature: ```typescript -readonly type: T; +readonly type: string; ``` diff --git a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.actionbytype.md b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.actionbytype.md deleted file mode 100644 index 3ceb96adadb1a..0000000000000 --- a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.actionbytype.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-ui\_actions-public](./kibana-plugin-plugins-ui_actions-public.md) > [ActionByType](./kibana-plugin-plugins-ui_actions-public.actionbytype.md) - -## ActionByType type - -Signature: - -```typescript -export declare type ActionByType = Action; -``` diff --git a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.actioncontextmapping.__.md b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.actioncontextmapping.__.md deleted file mode 100644 index eb7b1e5954ed2..0000000000000 --- a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.actioncontextmapping.__.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-ui\_actions-public](./kibana-plugin-plugins-ui_actions-public.md) > [ActionContextMapping](./kibana-plugin-plugins-ui_actions-public.actioncontextmapping.md) > [""](./kibana-plugin-plugins-ui_actions-public.actioncontextmapping.__.md) - -## ActionContextMapping."" property - -Signature: - -```typescript -[DEFAULT_ACTION]: BaseContext; -``` diff --git a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.actioncontextmapping.action_visualize_field.md b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.actioncontextmapping.action_visualize_field.md deleted file mode 100644 index eb0547bbf8261..0000000000000 --- a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.actioncontextmapping.action_visualize_field.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-ui\_actions-public](./kibana-plugin-plugins-ui_actions-public.md) > [ActionContextMapping](./kibana-plugin-plugins-ui_actions-public.actioncontextmapping.md) > [ACTION\_VISUALIZE\_FIELD](./kibana-plugin-plugins-ui_actions-public.actioncontextmapping.action_visualize_field.md) - -## ActionContextMapping.ACTION\_VISUALIZE\_FIELD property - -Signature: - -```typescript -[ACTION_VISUALIZE_FIELD]: VisualizeFieldContext; -``` diff --git a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.actioncontextmapping.action_visualize_geo_field.md b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.actioncontextmapping.action_visualize_geo_field.md deleted file mode 100644 index b44ed75106423..0000000000000 --- a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.actioncontextmapping.action_visualize_geo_field.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-ui\_actions-public](./kibana-plugin-plugins-ui_actions-public.md) > [ActionContextMapping](./kibana-plugin-plugins-ui_actions-public.actioncontextmapping.md) > [ACTION\_VISUALIZE\_GEO\_FIELD](./kibana-plugin-plugins-ui_actions-public.actioncontextmapping.action_visualize_geo_field.md) - -## ActionContextMapping.ACTION\_VISUALIZE\_GEO\_FIELD property - -Signature: - -```typescript -[ACTION_VISUALIZE_GEO_FIELD]: VisualizeFieldContext; -``` diff --git a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.actioncontextmapping.action_visualize_lens_field.md b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.actioncontextmapping.action_visualize_lens_field.md deleted file mode 100644 index 96370a07806d3..0000000000000 --- a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.actioncontextmapping.action_visualize_lens_field.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-ui\_actions-public](./kibana-plugin-plugins-ui_actions-public.md) > [ActionContextMapping](./kibana-plugin-plugins-ui_actions-public.actioncontextmapping.md) > [ACTION\_VISUALIZE\_LENS\_FIELD](./kibana-plugin-plugins-ui_actions-public.actioncontextmapping.action_visualize_lens_field.md) - -## ActionContextMapping.ACTION\_VISUALIZE\_LENS\_FIELD property - -Signature: - -```typescript -[ACTION_VISUALIZE_LENS_FIELD]: VisualizeFieldContext; -``` diff --git a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.actioncontextmapping.md b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.actioncontextmapping.md deleted file mode 100644 index f83632dea0aa9..0000000000000 --- a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.actioncontextmapping.md +++ /dev/null @@ -1,21 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-ui\_actions-public](./kibana-plugin-plugins-ui_actions-public.md) > [ActionContextMapping](./kibana-plugin-plugins-ui_actions-public.actioncontextmapping.md) - -## ActionContextMapping interface - -Signature: - -```typescript -export interface ActionContextMapping -``` - -## Properties - -| Property | Type | Description | -| --- | --- | --- | -| [""](./kibana-plugin-plugins-ui_actions-public.actioncontextmapping.__.md) | BaseContext | | -| [ACTION\_VISUALIZE\_FIELD](./kibana-plugin-plugins-ui_actions-public.actioncontextmapping.action_visualize_field.md) | VisualizeFieldContext | | -| [ACTION\_VISUALIZE\_GEO\_FIELD](./kibana-plugin-plugins-ui_actions-public.actioncontextmapping.action_visualize_geo_field.md) | VisualizeFieldContext | | -| [ACTION\_VISUALIZE\_LENS\_FIELD](./kibana-plugin-plugins-ui_actions-public.actioncontextmapping.action_visualize_lens_field.md) | VisualizeFieldContext | | - diff --git a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.actiondefinitionbytype.md b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.actiondefinitionbytype.md deleted file mode 100644 index ba4dc39088fe4..0000000000000 --- a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.actiondefinitionbytype.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-ui\_actions-public](./kibana-plugin-plugins-ui_actions-public.md) > [ActionDefinitionByType](./kibana-plugin-plugins-ui_actions-public.actiondefinitionbytype.md) - -## ActionDefinitionByType type - -Signature: - -```typescript -export declare type ActionDefinitionByType = ActionDefinition; -``` diff --git a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.actionexecutioncontext.md b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.actionexecutioncontext.md index 3271d86779959..d6f754a1ba458 100644 --- a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.actionexecutioncontext.md +++ b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.actionexecutioncontext.md @@ -9,5 +9,5 @@ Action methods are executed with Context from trigger + [ActionExecutionMeta](./ Signature: ```typescript -export declare type ActionExecutionContext = Context & ActionExecutionMeta; +export declare type ActionExecutionContext = Context & ActionExecutionMeta; ``` diff --git a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.actiontype.md b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.actiontype.md deleted file mode 100644 index 4916585531004..0000000000000 --- a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.actiontype.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-ui\_actions-public](./kibana-plugin-plugins-ui_actions-public.md) > [ActionType](./kibana-plugin-plugins-ui_actions-public.actiontype.md) - -## ActionType type - -Signature: - -```typescript -export declare type ActionType = keyof ActionContextMapping; -``` diff --git a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.createaction.md b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.createaction.md index 04ab36c2e3f58..8bb9094a1d8bf 100644 --- a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.createaction.md +++ b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.createaction.md @@ -7,16 +7,16 @@ Signature: ```typescript -export declare function createAction(action: ActionDefinitionByType): ActionByType; +export declare function createAction(action: ActionDefinition): Action; ``` ## Parameters | Parameter | Type | Description | | --- | --- | --- | -| action | ActionDefinitionByType<T> | | +| action | ActionDefinition<Context> | | Returns: -`ActionByType` +`Action` diff --git a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.md b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.md index 76e347bddd168..9f009d1617cc8 100644 --- a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.md +++ b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.md @@ -24,11 +24,9 @@ | Interface | Description | | --- | --- | | [Action](./kibana-plugin-plugins-ui_actions-public.action.md) | | -| [ActionContextMapping](./kibana-plugin-plugins-ui_actions-public.actioncontextmapping.md) | | | [ActionExecutionMeta](./kibana-plugin-plugins-ui_actions-public.actionexecutionmeta.md) | During action execution we can provide additional information, for example, trigger, that caused the action execution | | [RowClickContext](./kibana-plugin-plugins-ui_actions-public.rowclickcontext.md) | | | [Trigger](./kibana-plugin-plugins-ui_actions-public.trigger.md) | This is a convenience interface used to register a \*trigger\*.Trigger specifies a named anchor to which Action can be attached. When Trigger is being \*called\* it creates a Context object and passes it to the execute method of an Action.More than one action can be attached to a single trigger, in which case when trigger is \*called\* it first displays a context menu for user to pick a single action to execute. | -| [TriggerContextMapping](./kibana-plugin-plugins-ui_actions-public.triggercontextmapping.md) | | | [UiActionsActionDefinition](./kibana-plugin-plugins-ui_actions-public.uiactionsactiondefinition.md) | A convenience interface used to register an action. | | [UiActionsPresentable](./kibana-plugin-plugins-ui_actions-public.uiactionspresentable.md) | Represents something that can be displayed to user in UI. | | [UiActionsServiceParams](./kibana-plugin-plugins-ui_actions-public.uiactionsserviceparams.md) | | @@ -52,12 +50,7 @@ | Type Alias | Description | | --- | --- | -| [ActionByType](./kibana-plugin-plugins-ui_actions-public.actionbytype.md) | | -| [ActionDefinitionByType](./kibana-plugin-plugins-ui_actions-public.actiondefinitionbytype.md) | | | [ActionExecutionContext](./kibana-plugin-plugins-ui_actions-public.actionexecutioncontext.md) | Action methods are executed with Context from trigger + [ActionExecutionMeta](./kibana-plugin-plugins-ui_actions-public.actionexecutionmeta.md) | -| [ActionType](./kibana-plugin-plugins-ui_actions-public.actiontype.md) | | -| [TriggerContext](./kibana-plugin-plugins-ui_actions-public.triggercontext.md) | | -| [TriggerId](./kibana-plugin-plugins-ui_actions-public.triggerid.md) | | | [UiActionsPresentableGrouping](./kibana-plugin-plugins-ui_actions-public.uiactionspresentablegrouping.md) | | | [UiActionsSetup](./kibana-plugin-plugins-ui_actions-public.uiactionssetup.md) | | | [UiActionsStart](./kibana-plugin-plugins-ui_actions-public.uiactionsstart.md) | | diff --git a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.rowclicktrigger.md b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.rowclicktrigger.md index aa1097d8c0864..f05138296e6e8 100644 --- a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.rowclicktrigger.md +++ b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.rowclicktrigger.md @@ -7,5 +7,5 @@ Signature: ```typescript -rowClickTrigger: Trigger<'ROW_CLICK_TRIGGER'> +rowClickTrigger: Trigger ``` diff --git a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.trigger.id.md b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.trigger.id.md index 5603c852ad39d..5bf868720cdec 100644 --- a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.trigger.id.md +++ b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.trigger.id.md @@ -9,5 +9,5 @@ Unique name of the trigger as identified in `ui_actions` plugin trigger registry Signature: ```typescript -id: ID; +id: string; ``` diff --git a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.trigger.md b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.trigger.md index ed76cfea97684..d829d7b87c177 100644 --- a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.trigger.md +++ b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.trigger.md @@ -13,7 +13,7 @@ More than one action can be attached to a single trigger, in which case when tri Signature: ```typescript -export interface Trigger +export interface Trigger ``` ## Properties @@ -21,6 +21,6 @@ export interface Trigger | Property | Type | Description | | --- | --- | --- | | [description](./kibana-plugin-plugins-ui_actions-public.trigger.description.md) | string | A longer user friendly description of the trigger. | -| [id](./kibana-plugin-plugins-ui_actions-public.trigger.id.md) | ID | Unique name of the trigger as identified in ui_actions plugin trigger registry. | +| [id](./kibana-plugin-plugins-ui_actions-public.trigger.id.md) | string | Unique name of the trigger as identified in ui_actions plugin trigger registry. | | [title](./kibana-plugin-plugins-ui_actions-public.trigger.title.md) | string | User friendly name of the trigger. | diff --git a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.triggercontext.md b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.triggercontext.md deleted file mode 100644 index 4ce95d27ecffa..0000000000000 --- a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.triggercontext.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-ui\_actions-public](./kibana-plugin-plugins-ui_actions-public.md) > [TriggerContext](./kibana-plugin-plugins-ui_actions-public.triggercontext.md) - -## TriggerContext type - -Signature: - -```typescript -export declare type TriggerContext = T extends TriggerId ? TriggerContextMapping[T] : never; -``` diff --git a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.triggercontextmapping.__.md b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.triggercontextmapping.__.md deleted file mode 100644 index 17ad926f8ee82..0000000000000 --- a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.triggercontextmapping.__.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-ui\_actions-public](./kibana-plugin-plugins-ui_actions-public.md) > [TriggerContextMapping](./kibana-plugin-plugins-ui_actions-public.triggercontextmapping.md) > [""](./kibana-plugin-plugins-ui_actions-public.triggercontextmapping.__.md) - -## TriggerContextMapping."" property - -Signature: - -```typescript -[DEFAULT_TRIGGER]: TriggerContext; -``` diff --git a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.triggercontextmapping.md b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.triggercontextmapping.md deleted file mode 100644 index da7a7a8bfe645..0000000000000 --- a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.triggercontextmapping.md +++ /dev/null @@ -1,21 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-ui\_actions-public](./kibana-plugin-plugins-ui_actions-public.md) > [TriggerContextMapping](./kibana-plugin-plugins-ui_actions-public.triggercontextmapping.md) - -## TriggerContextMapping interface - -Signature: - -```typescript -export interface TriggerContextMapping -``` - -## Properties - -| Property | Type | Description | -| --- | --- | --- | -| [""](./kibana-plugin-plugins-ui_actions-public.triggercontextmapping.__.md) | TriggerContext | | -| [ROW\_CLICK\_TRIGGER](./kibana-plugin-plugins-ui_actions-public.triggercontextmapping.row_click_trigger.md) | RowClickContext | | -| [VISUALIZE\_FIELD\_TRIGGER](./kibana-plugin-plugins-ui_actions-public.triggercontextmapping.visualize_field_trigger.md) | VisualizeFieldContext | | -| [VISUALIZE\_GEO\_FIELD\_TRIGGER](./kibana-plugin-plugins-ui_actions-public.triggercontextmapping.visualize_geo_field_trigger.md) | VisualizeFieldContext | | - diff --git a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.triggercontextmapping.row_click_trigger.md b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.triggercontextmapping.row_click_trigger.md deleted file mode 100644 index cf253df337378..0000000000000 --- a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.triggercontextmapping.row_click_trigger.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-ui\_actions-public](./kibana-plugin-plugins-ui_actions-public.md) > [TriggerContextMapping](./kibana-plugin-plugins-ui_actions-public.triggercontextmapping.md) > [ROW\_CLICK\_TRIGGER](./kibana-plugin-plugins-ui_actions-public.triggercontextmapping.row_click_trigger.md) - -## TriggerContextMapping.ROW\_CLICK\_TRIGGER property - -Signature: - -```typescript -[ROW_CLICK_TRIGGER]: RowClickContext; -``` diff --git a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.triggercontextmapping.visualize_field_trigger.md b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.triggercontextmapping.visualize_field_trigger.md deleted file mode 100644 index feaaffac8a234..0000000000000 --- a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.triggercontextmapping.visualize_field_trigger.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-ui\_actions-public](./kibana-plugin-plugins-ui_actions-public.md) > [TriggerContextMapping](./kibana-plugin-plugins-ui_actions-public.triggercontextmapping.md) > [VISUALIZE\_FIELD\_TRIGGER](./kibana-plugin-plugins-ui_actions-public.triggercontextmapping.visualize_field_trigger.md) - -## TriggerContextMapping.VISUALIZE\_FIELD\_TRIGGER property - -Signature: - -```typescript -[VISUALIZE_FIELD_TRIGGER]: VisualizeFieldContext; -``` diff --git a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.triggercontextmapping.visualize_geo_field_trigger.md b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.triggercontextmapping.visualize_geo_field_trigger.md deleted file mode 100644 index 023490a2ae027..0000000000000 --- a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.triggercontextmapping.visualize_geo_field_trigger.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-ui\_actions-public](./kibana-plugin-plugins-ui_actions-public.md) > [TriggerContextMapping](./kibana-plugin-plugins-ui_actions-public.triggercontextmapping.md) > [VISUALIZE\_GEO\_FIELD\_TRIGGER](./kibana-plugin-plugins-ui_actions-public.triggercontextmapping.visualize_geo_field_trigger.md) - -## TriggerContextMapping.VISUALIZE\_GEO\_FIELD\_TRIGGER property - -Signature: - -```typescript -[VISUALIZE_GEO_FIELD_TRIGGER]: VisualizeFieldContext; -``` diff --git a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.triggerid.md b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.triggerid.md deleted file mode 100644 index 6e5a234e286f9..0000000000000 --- a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.triggerid.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-ui\_actions-public](./kibana-plugin-plugins-ui_actions-public.md) > [TriggerId](./kibana-plugin-plugins-ui_actions-public.triggerid.md) - -## TriggerId type - -Signature: - -```typescript -export declare type TriggerId = keyof TriggerContextMapping; -``` diff --git a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionsactiondefinition.md b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionsactiondefinition.md index 7c873715795e9..a4de28ff4d1af 100644 --- a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionsactiondefinition.md +++ b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionsactiondefinition.md @@ -9,7 +9,7 @@ A convenience interface used to register an action. Signature: ```typescript -export interface ActionDefinition extends Partial>> +export interface ActionDefinition extends Partial>> ``` ## Properties @@ -17,7 +17,7 @@ export interface ActionDefinition extends Part | Property | Type | Description | | --- | --- | --- | | [id](./kibana-plugin-plugins-ui_actions-public.uiactionsactiondefinition.id.md) | string | ID of the action that uniquely identifies this action in the actions registry. | -| [type](./kibana-plugin-plugins-ui_actions-public.uiactionsactiondefinition.type.md) | ActionType | ID of the factory for this action. Used to construct dynamic actions. | +| [type](./kibana-plugin-plugins-ui_actions-public.uiactionsactiondefinition.type.md) | string | ID of the factory for this action. Used to construct dynamic actions. | ## Methods diff --git a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionsactiondefinition.type.md b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionsactiondefinition.type.md index 125f834e9036e..c2cc8b41568ce 100644 --- a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionsactiondefinition.type.md +++ b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionsactiondefinition.type.md @@ -9,5 +9,5 @@ ID of the factory for this action. Used to construct dynamic actions. Signature: ```typescript -readonly type?: ActionType; +readonly type?: string; ``` diff --git a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionspresentable.md b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionspresentable.md index 03fa7fb6e447e..659ea999b9f8e 100644 --- a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionspresentable.md +++ b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionspresentable.md @@ -9,7 +9,7 @@ Represents something that can be displayed to user in UI. Signature: ```typescript -export interface Presentable +export interface Presentable ``` ## Properties diff --git a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionspresentablegrouping.md b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionspresentablegrouping.md index a61ff65e39c69..2fb6c3e187d3d 100644 --- a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionspresentablegrouping.md +++ b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionspresentablegrouping.md @@ -7,5 +7,5 @@ Signature: ```typescript -export declare type PresentableGrouping = Array>; +export declare type PresentableGrouping = Array>; ``` diff --git a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionsservice.addtriggeraction.md b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionsservice.addtriggeraction.md index f29d487d774e0..30272cdcdc7f8 100644 --- a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionsservice.addtriggeraction.md +++ b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionsservice.addtriggeraction.md @@ -11,5 +11,5 @@ Signature: ```typescript -readonly addTriggerAction: (triggerId: T, action: ActionDefinition | Action) => void; +readonly addTriggerAction: (triggerId: string, action: ActionDefinition) => void; ``` diff --git a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionsservice.attachaction.md b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionsservice.attachaction.md index 1ebb30c49c0b3..fd17c76b0ee9f 100644 --- a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionsservice.attachaction.md +++ b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionsservice.attachaction.md @@ -7,5 +7,5 @@ Signature: ```typescript -readonly attachAction: (triggerId: T, actionId: string) => void; +readonly attachAction: (triggerId: string, actionId: string) => void; ``` diff --git a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionsservice.detachaction.md b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionsservice.detachaction.md index a6ff2489c6f0e..bf9c589e59f60 100644 --- a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionsservice.detachaction.md +++ b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionsservice.detachaction.md @@ -7,5 +7,5 @@ Signature: ```typescript -readonly detachAction: (triggerId: TriggerId, actionId: string) => void; +readonly detachAction: (triggerId: string, actionId: string) => void; ``` diff --git a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionsservice.executetriggeractions.md b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionsservice.executetriggeractions.md index b20f08520c43d..fb1a1ef14d315 100644 --- a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionsservice.executetriggeractions.md +++ b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionsservice.executetriggeractions.md @@ -12,5 +12,5 @@ Signature: ```typescript -readonly executeTriggerActions: (triggerId: T, context: TriggerContext) => Promise; +readonly executeTriggerActions: (triggerId: string, context: object) => Promise; ``` diff --git a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionsservice.getaction.md b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionsservice.getaction.md index 300c46a47c47f..32a4fcf8e6f89 100644 --- a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionsservice.getaction.md +++ b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionsservice.getaction.md @@ -7,5 +7,5 @@ Signature: ```typescript -readonly getAction: >(id: string) => Action, "" | "ACTION_VISUALIZE_FIELD" | "ACTION_VISUALIZE_GEO_FIELD" | "ACTION_VISUALIZE_LENS_FIELD" | "ACTION_GLOBAL_APPLY_FILTER" | "ACTION_SELECT_RANGE" | "ACTION_VALUE_CLICK" | "ACTION_CUSTOMIZE_PANEL" | "ACTION_ADD_PANEL" | "openInspector" | "deletePanel" | "editPanel">; +readonly getAction: >(id: string) => Action>; ``` diff --git a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionsservice.gettrigger.md b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionsservice.gettrigger.md index 95b737a8d6cae..b8f59e943f38e 100644 --- a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionsservice.gettrigger.md +++ b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionsservice.gettrigger.md @@ -7,5 +7,5 @@ Signature: ```typescript -readonly getTrigger: (triggerId: T) => TriggerContract; +readonly getTrigger: (triggerId: string) => TriggerContract; ``` diff --git a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionsservice.gettriggeractions.md b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionsservice.gettriggeractions.md index 27c1b1eb48f16..c7c0eac755aec 100644 --- a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionsservice.gettriggeractions.md +++ b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionsservice.gettriggeractions.md @@ -7,5 +7,5 @@ Signature: ```typescript -readonly getTriggerActions: (triggerId: T) => Action[]; +readonly getTriggerActions: (triggerId: string) => Action[]; ``` diff --git a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionsservice.gettriggercompatibleactions.md b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionsservice.gettriggercompatibleactions.md index edb7d2d3a1551..9e3e38a6ac43d 100644 --- a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionsservice.gettriggercompatibleactions.md +++ b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionsservice.gettriggercompatibleactions.md @@ -7,5 +7,5 @@ Signature: ```typescript -readonly getTriggerCompatibleActions: (triggerId: T, context: TriggerContextMapping[T]) => Promise[]>; +readonly getTriggerCompatibleActions: (triggerId: string, context: object) => Promise; ``` diff --git a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionsservice.md b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionsservice.md index 4fe8431770dea..fced0bbc3cde2 100644 --- a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionsservice.md +++ b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionsservice.md @@ -21,19 +21,19 @@ export declare class UiActionsService | Property | Modifiers | Type | Description | | --- | --- | --- | --- | | [actions](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.actions.md) | | ActionRegistry | | -| [addTriggerAction](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.addtriggeraction.md) | | <T extends "" | "ROW_CLICK_TRIGGER" | "VISUALIZE_FIELD_TRIGGER" | "VISUALIZE_GEO_FIELD_TRIGGER" | "FILTER_TRIGGER" | "CONTEXT_MENU_TRIGGER" | "PANEL_BADGE_TRIGGER" | "PANEL_NOTIFICATION_TRIGGER" | "SELECT_RANGE_TRIGGER" | "VALUE_CLICK_TRIGGER">(triggerId: T, action: ActionDefinition<TriggerContextMapping[T]> | Action<TriggerContextMapping[T], "" | "ACTION_VISUALIZE_FIELD" | "ACTION_VISUALIZE_GEO_FIELD" | "ACTION_VISUALIZE_LENS_FIELD" | "ACTION_GLOBAL_APPLY_FILTER" | "ACTION_SELECT_RANGE" | "ACTION_VALUE_CLICK" | "ACTION_CUSTOMIZE_PANEL" | "ACTION_ADD_PANEL" | "openInspector" | "deletePanel" | "editPanel">) => void | addTriggerAction is similar to attachAction as it attaches action to a trigger, but it also registers the action, if it has not been registered, yet.addTriggerAction also infers better typing of the action argument. | -| [attachAction](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.attachaction.md) | | <T extends "" | "ROW_CLICK_TRIGGER" | "VISUALIZE_FIELD_TRIGGER" | "VISUALIZE_GEO_FIELD_TRIGGER" | "FILTER_TRIGGER" | "CONTEXT_MENU_TRIGGER" | "PANEL_BADGE_TRIGGER" | "PANEL_NOTIFICATION_TRIGGER" | "SELECT_RANGE_TRIGGER" | "VALUE_CLICK_TRIGGER">(triggerId: T, actionId: string) => void | | +| [addTriggerAction](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.addtriggeraction.md) | | (triggerId: string, action: ActionDefinition) => void | addTriggerAction is similar to attachAction as it attaches action to a trigger, but it also registers the action, if it has not been registered, yet.addTriggerAction also infers better typing of the action argument. | +| [attachAction](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.attachaction.md) | | (triggerId: string, actionId: string) => void | | | [clear](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.clear.md) | | () => void | Removes all registered triggers and actions. | -| [detachAction](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.detachaction.md) | | (triggerId: TriggerId, actionId: string) => void | | -| [executeTriggerActions](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.executetriggeractions.md) | | <T extends "" | "ROW_CLICK_TRIGGER" | "VISUALIZE_FIELD_TRIGGER" | "VISUALIZE_GEO_FIELD_TRIGGER" | "FILTER_TRIGGER" | "CONTEXT_MENU_TRIGGER" | "PANEL_BADGE_TRIGGER" | "PANEL_NOTIFICATION_TRIGGER" | "SELECT_RANGE_TRIGGER" | "VALUE_CLICK_TRIGGER">(triggerId: T, context: TriggerContext<T>) => Promise<void> | | +| [detachAction](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.detachaction.md) | | (triggerId: string, actionId: string) => void | | +| [executeTriggerActions](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.executetriggeractions.md) | | (triggerId: string, context: object) => Promise<void> | | | [executionService](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.executionservice.md) | | UiActionsExecutionService | | | [fork](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.fork.md) | | () => UiActionsService | "Fork" a separate instance of UiActionsService that inherits all existing triggers and actions, but going forward all new triggers and actions added to this instance of UiActionsService are only available within this instance. | -| [getAction](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.getaction.md) | | <T extends ActionDefinition<{}>>(id: string) => Action<ActionContext<T>, "" | "ACTION_VISUALIZE_FIELD" | "ACTION_VISUALIZE_GEO_FIELD" | "ACTION_VISUALIZE_LENS_FIELD" | "ACTION_GLOBAL_APPLY_FILTER" | "ACTION_SELECT_RANGE" | "ACTION_VALUE_CLICK" | "ACTION_CUSTOMIZE_PANEL" | "ACTION_ADD_PANEL" | "openInspector" | "deletePanel" | "editPanel"> | | -| [getTrigger](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.gettrigger.md) | | <T extends "" | "ROW_CLICK_TRIGGER" | "VISUALIZE_FIELD_TRIGGER" | "VISUALIZE_GEO_FIELD_TRIGGER" | "FILTER_TRIGGER" | "CONTEXT_MENU_TRIGGER" | "PANEL_BADGE_TRIGGER" | "PANEL_NOTIFICATION_TRIGGER" | "SELECT_RANGE_TRIGGER" | "VALUE_CLICK_TRIGGER">(triggerId: T) => TriggerContract<T> | | -| [getTriggerActions](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.gettriggeractions.md) | | <T extends "" | "ROW_CLICK_TRIGGER" | "VISUALIZE_FIELD_TRIGGER" | "VISUALIZE_GEO_FIELD_TRIGGER" | "FILTER_TRIGGER" | "CONTEXT_MENU_TRIGGER" | "PANEL_BADGE_TRIGGER" | "PANEL_NOTIFICATION_TRIGGER" | "SELECT_RANGE_TRIGGER" | "VALUE_CLICK_TRIGGER">(triggerId: T) => Action<TriggerContextMapping[T], "" | "ACTION_VISUALIZE_FIELD" | "ACTION_VISUALIZE_GEO_FIELD" | "ACTION_VISUALIZE_LENS_FIELD" | "ACTION_GLOBAL_APPLY_FILTER" | "ACTION_SELECT_RANGE" | "ACTION_VALUE_CLICK" | "ACTION_CUSTOMIZE_PANEL" | "ACTION_ADD_PANEL" | "openInspector" | "deletePanel" | "editPanel">[] | | -| [getTriggerCompatibleActions](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.gettriggercompatibleactions.md) | | <T extends "" | "ROW_CLICK_TRIGGER" | "VISUALIZE_FIELD_TRIGGER" | "VISUALIZE_GEO_FIELD_TRIGGER" | "FILTER_TRIGGER" | "CONTEXT_MENU_TRIGGER" | "PANEL_BADGE_TRIGGER" | "PANEL_NOTIFICATION_TRIGGER" | "SELECT_RANGE_TRIGGER" | "VALUE_CLICK_TRIGGER">(triggerId: T, context: TriggerContextMapping[T]) => Promise<Action<TriggerContextMapping[T], "" | "ACTION_VISUALIZE_FIELD" | "ACTION_VISUALIZE_GEO_FIELD" | "ACTION_VISUALIZE_LENS_FIELD" | "ACTION_GLOBAL_APPLY_FILTER" | "ACTION_SELECT_RANGE" | "ACTION_VALUE_CLICK" | "ACTION_CUSTOMIZE_PANEL" | "ACTION_ADD_PANEL" | "openInspector" | "deletePanel" | "editPanel">[]> | | +| [getAction](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.getaction.md) | | <T extends ActionDefinition<object>>(id: string) => Action<ActionContext<T>> | | +| [getTrigger](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.gettrigger.md) | | (triggerId: string) => TriggerContract | | +| [getTriggerActions](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.gettriggeractions.md) | | (triggerId: string) => Action[] | | +| [getTriggerCompatibleActions](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.gettriggercompatibleactions.md) | | (triggerId: string, context: object) => Promise<Action[]> | | | [hasAction](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.hasaction.md) | | (actionId: string) => boolean | | -| [registerAction](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.registeraction.md) | | <A extends ActionDefinition<{}>>(definition: A) => Action<ActionContext<A>, "" | "ACTION_VISUALIZE_FIELD" | "ACTION_VISUALIZE_GEO_FIELD" | "ACTION_VISUALIZE_LENS_FIELD" | "ACTION_GLOBAL_APPLY_FILTER" | "ACTION_SELECT_RANGE" | "ACTION_VALUE_CLICK" | "ACTION_CUSTOMIZE_PANEL" | "ACTION_ADD_PANEL" | "openInspector" | "deletePanel" | "editPanel"> | | +| [registerAction](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.registeraction.md) | | <A extends ActionDefinition<object>>(definition: A) => Action<ActionContext<A>> | | | [registerTrigger](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.registertrigger.md) | | (trigger: Trigger) => void | | | [triggers](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.triggers.md) | | TriggerRegistry | | | [triggerToActions](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.triggertoactions.md) | | TriggerToActionsRegistry | | diff --git a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionsservice.registeraction.md b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionsservice.registeraction.md index dee5f75f7c074..75289e8f32351 100644 --- a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionsservice.registeraction.md +++ b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.uiactionsservice.registeraction.md @@ -7,5 +7,5 @@ Signature: ```typescript -readonly registerAction: >(definition: A) => Action, "" | "ACTION_VISUALIZE_FIELD" | "ACTION_VISUALIZE_GEO_FIELD" | "ACTION_VISUALIZE_LENS_FIELD" | "ACTION_GLOBAL_APPLY_FILTER" | "ACTION_SELECT_RANGE" | "ACTION_VALUE_CLICK" | "ACTION_CUSTOMIZE_PANEL" | "ACTION_ADD_PANEL" | "openInspector" | "deletePanel" | "editPanel">; +readonly registerAction: >(definition: A) => Action>; ``` diff --git a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.visualizefieldtrigger.md b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.visualizefieldtrigger.md index 15510bd3eb4a3..eb62d36df84d8 100644 --- a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.visualizefieldtrigger.md +++ b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.visualizefieldtrigger.md @@ -7,5 +7,5 @@ Signature: ```typescript -visualizeFieldTrigger: Trigger<'VISUALIZE_FIELD_TRIGGER'> +visualizeFieldTrigger: Trigger ``` diff --git a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.visualizegeofieldtrigger.md b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.visualizegeofieldtrigger.md index faec6a69b71f9..c547c33aaccbf 100644 --- a/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.visualizegeofieldtrigger.md +++ b/docs/development/plugins/ui_actions/public/kibana-plugin-plugins-ui_actions-public.visualizegeofieldtrigger.md @@ -7,5 +7,5 @@ Signature: ```typescript -visualizeGeoFieldTrigger: Trigger<'VISUALIZE_GEO_FIELD_TRIGGER'> +visualizeGeoFieldTrigger: Trigger ``` diff --git a/examples/embeddable_examples/public/book/add_book_to_library_action.tsx b/examples/embeddable_examples/public/book/add_book_to_library_action.tsx index 4ae3a545df0d0..b36635feb3dcc 100644 --- a/examples/embeddable_examples/public/book/add_book_to_library_action.tsx +++ b/examples/embeddable_examples/public/book/add_book_to_library_action.tsx @@ -35,6 +35,7 @@ export const createAddBookToLibraryAction = () => i18n.translate('embeddableExamples.book.addToLibrary', { defaultMessage: 'Add Book To Library', }), + id: ACTION_ADD_BOOK_TO_LIBRARY, type: ACTION_ADD_BOOK_TO_LIBRARY, order: 100, getIconType: () => 'folderCheck', diff --git a/examples/embeddable_examples/public/book/edit_book_action.tsx b/examples/embeddable_examples/public/book/edit_book_action.tsx index 877e50560000e..6fa5ff15716a6 100644 --- a/examples/embeddable_examples/public/book/edit_book_action.tsx +++ b/examples/embeddable_examples/public/book/edit_book_action.tsx @@ -53,6 +53,7 @@ export const createEditBookAction = (getStartServices: () => Promise i18n.translate('embeddableExamples.book.edit', { defaultMessage: 'Edit Book' }), + id: ACTION_EDIT_BOOK, type: ACTION_EDIT_BOOK, order: 100, getIconType: () => 'documents', diff --git a/examples/embeddable_examples/public/book/unlink_book_from_library_action.tsx b/examples/embeddable_examples/public/book/unlink_book_from_library_action.tsx index ebab2c483c625..54857010a1468 100644 --- a/examples/embeddable_examples/public/book/unlink_book_from_library_action.tsx +++ b/examples/embeddable_examples/public/book/unlink_book_from_library_action.tsx @@ -35,6 +35,7 @@ export const createUnlinkBookFromLibraryAction = () => i18n.translate('embeddableExamples.book.unlinkFromLibrary', { defaultMessage: 'Unlink Book from Library Item', }), + id: ACTION_UNLINK_BOOK_FROM_LIBRARY, type: ACTION_UNLINK_BOOK_FROM_LIBRARY, order: 100, getIconType: () => 'folderExclamation', diff --git a/examples/embeddable_examples/public/plugin.ts b/examples/embeddable_examples/public/plugin.ts index 9b9770e40611e..8e8f2ddfe2128 100644 --- a/examples/embeddable_examples/public/plugin.ts +++ b/examples/embeddable_examples/public/plugin.ts @@ -51,21 +51,15 @@ import { TodoRefEmbeddableFactory, TodoRefEmbeddableFactoryDefinition, } from './todo/todo_ref_embeddable_factory'; -import { ACTION_EDIT_BOOK, createEditBookAction } from './book/edit_book_action'; -import { BookEmbeddable, BOOK_EMBEDDABLE } from './book/book_embeddable'; +import { createEditBookAction } from './book/edit_book_action'; +import { BOOK_EMBEDDABLE } from './book/book_embeddable'; import { BookEmbeddableFactory, BookEmbeddableFactoryDefinition, } from './book/book_embeddable_factory'; import { UiActionsStart } from '../../../src/plugins/ui_actions/public'; -import { - ACTION_ADD_BOOK_TO_LIBRARY, - createAddBookToLibraryAction, -} from './book/add_book_to_library_action'; -import { - ACTION_UNLINK_BOOK_FROM_LIBRARY, - createUnlinkBookFromLibraryAction, -} from './book/unlink_book_from_library_action'; +import { createAddBookToLibraryAction } from './book/add_book_to_library_action'; +import { createUnlinkBookFromLibraryAction } from './book/unlink_book_from_library_action'; export interface EmbeddableExamplesSetupDependencies { embeddable: EmbeddableSetup; @@ -92,14 +86,6 @@ export interface EmbeddableExamplesStart { factories: ExampleEmbeddableFactories; } -declare module '../../../src/plugins/ui_actions/public' { - export interface ActionContextMapping { - [ACTION_EDIT_BOOK]: { embeddable: BookEmbeddable }; - [ACTION_ADD_BOOK_TO_LIBRARY]: { embeddable: BookEmbeddable }; - [ACTION_UNLINK_BOOK_FROM_LIBRARY]: { embeddable: BookEmbeddable }; - } -} - export class EmbeddableExamplesPlugin implements Plugin< diff --git a/examples/ui_action_examples/public/hello_world_action.tsx b/examples/ui_action_examples/public/hello_world_action.tsx index da20f40464516..54e3fbe10095c 100644 --- a/examples/ui_action_examples/public/hello_world_action.tsx +++ b/examples/ui_action_examples/public/hello_world_action.tsx @@ -30,6 +30,7 @@ interface StartServices { export const createHelloWorldAction = (getStartServices: () => Promise) => createAction({ + id: ACTION_HELLO_WORLD, type: ACTION_HELLO_WORLD, getDisplayName: () => 'Hello World!', execute: async () => { diff --git a/examples/ui_action_examples/public/plugin.ts b/examples/ui_action_examples/public/plugin.ts index 3a9f673261e33..1d896d3305661 100644 --- a/examples/ui_action_examples/public/plugin.ts +++ b/examples/ui_action_examples/public/plugin.ts @@ -19,8 +19,8 @@ import { Plugin, CoreSetup, CoreStart } from '../../../src/core/public'; import { UiActionsSetup, UiActionsStart } from '../../../src/plugins/ui_actions/public'; -import { createHelloWorldAction, ACTION_HELLO_WORLD } from './hello_world_action'; -import { helloWorldTrigger, HELLO_WORLD_TRIGGER_ID } from './hello_world_trigger'; +import { createHelloWorldAction } from './hello_world_action'; +import { helloWorldTrigger } from './hello_world_trigger'; export interface UiActionExamplesSetupDependencies { uiActions: UiActionsSetup; @@ -30,16 +30,6 @@ export interface UiActionExamplesStartDependencies { uiActions: UiActionsStart; } -declare module '../../../src/plugins/ui_actions/public' { - export interface TriggerContextMapping { - [HELLO_WORLD_TRIGGER_ID]: {}; - } - - export interface ActionContextMapping { - [ACTION_HELLO_WORLD]: {}; - } -} - export class UiActionExamplesPlugin implements Plugin { diff --git a/examples/ui_actions_explorer/public/actions/actions.tsx b/examples/ui_actions_explorer/public/actions/actions.tsx index 777bcd9c18119..1d9987ad73a26 100644 --- a/examples/ui_actions_explorer/public/actions/actions.tsx +++ b/examples/ui_actions_explorer/public/actions/actions.tsx @@ -38,7 +38,8 @@ export const ACTION_EDIT_USER = 'ACTION_EDIT_USER'; export const ACTION_TRIGGER_PHONE_USER = 'ACTION_TRIGGER_PHONE_USER'; export const ACTION_SHOWCASE_PLUGGABILITY = 'ACTION_SHOWCASE_PLUGGABILITY'; -export const showcasePluggability = createAction({ +export const showcasePluggability = createAction({ + id: ACTION_SHOWCASE_PLUGGABILITY, type: ACTION_SHOWCASE_PLUGGABILITY, getDisplayName: () => 'This is pluggable! Any plugin can inject their actions here.', execute: async (context: ActionExecutionContext) => @@ -49,13 +50,15 @@ export interface PhoneContext { phone: string; } -export const makePhoneCallAction = createAction({ +export const makePhoneCallAction = createAction({ + id: ACTION_CALL_PHONE_NUMBER, type: ACTION_CALL_PHONE_NUMBER, getDisplayName: () => 'Call phone number', execute: async (context) => alert(`Pretend calling ${context.phone}...`), }); -export const lookUpWeatherAction = createAction({ +export const lookUpWeatherAction = createAction({ + id: ACTION_TRAVEL_GUIDE, type: ACTION_TRAVEL_GUIDE, getIconType: () => 'popout', getDisplayName: () => 'View travel guide', @@ -68,7 +71,8 @@ export interface CountryContext { country: string; } -export const viewInMapsAction = createAction({ +export const viewInMapsAction = createAction({ + id: ACTION_VIEW_IN_MAPS, type: ACTION_VIEW_IN_MAPS, getIconType: () => 'popout', getDisplayName: () => 'View in maps', @@ -109,7 +113,8 @@ function EditUserModal({ } export const createEditUserAction = (getOpenModal: () => Promise) => - createAction({ + createAction({ + id: ACTION_EDIT_USER, type: ACTION_EDIT_USER, getIconType: () => 'pencil', getDisplayName: () => 'Edit user', @@ -126,7 +131,8 @@ export interface UserContext { } export const createTriggerPhoneTriggerAction = (getUiActionsApi: () => Promise) => - createAction({ + createAction({ + id: ACTION_TRIGGER_PHONE_USER, type: ACTION_TRIGGER_PHONE_USER, getDisplayName: () => 'Call phone number', shouldAutoExecute: async () => true, diff --git a/examples/ui_actions_explorer/public/app.tsx b/examples/ui_actions_explorer/public/app.tsx index bc8bdee75047d..38fc4e22b284f 100644 --- a/examples/ui_actions_explorer/public/app.tsx +++ b/examples/ui_actions_explorer/public/app.tsx @@ -77,7 +77,7 @@ const ActionsExplorer = ({ uiActionsApi, openModal }: Props) => { { - const dynamicAction = createAction({ + const dynamicAction = createAction({ id: `${ACTION_HELLO_WORLD}-${name}`, type: ACTION_HELLO_WORLD, getDisplayName: () => `Say hello to ${name}`, diff --git a/examples/ui_actions_explorer/public/plugin.tsx b/examples/ui_actions_explorer/public/plugin.tsx index b28e5e7a9f692..757a2f1dfa865 100644 --- a/examples/ui_actions_explorer/public/plugin.tsx +++ b/examples/ui_actions_explorer/public/plugin.tsx @@ -28,15 +28,6 @@ import { createEditUserAction, makePhoneCallAction, showcasePluggability, - UserContext, - CountryContext, - PhoneContext, - ACTION_EDIT_USER, - ACTION_SHOWCASE_PLUGGABILITY, - ACTION_CALL_PHONE_NUMBER, - ACTION_TRAVEL_GUIDE, - ACTION_VIEW_IN_MAPS, - ACTION_TRIGGER_PHONE_USER, createTriggerPhoneTriggerAction, } from './actions/actions'; import { DeveloperExamplesSetup } from '../../developer_examples/public'; @@ -51,23 +42,6 @@ interface SetupDeps { developerExamples: DeveloperExamplesSetup; } -declare module '../../../src/plugins/ui_actions/public' { - export interface TriggerContextMapping { - [USER_TRIGGER]: UserContext; - [COUNTRY_TRIGGER]: CountryContext; - [PHONE_TRIGGER]: PhoneContext; - } - - export interface ActionContextMapping { - [ACTION_EDIT_USER]: UserContext; - [ACTION_SHOWCASE_PLUGGABILITY]: {}; - [ACTION_CALL_PHONE_NUMBER]: PhoneContext; - [ACTION_TRAVEL_GUIDE]: CountryContext; - [ACTION_VIEW_IN_MAPS]: CountryContext; - [ACTION_TRIGGER_PHONE_USER]: UserContext; - } -} - export class UiActionsExplorerPlugin implements Plugin { public setup(core: CoreSetup, deps: SetupDeps) { deps.uiActions.registerTrigger({ diff --git a/src/plugins/dashboard/public/application/actions/add_to_library_action.tsx b/src/plugins/dashboard/public/application/actions/add_to_library_action.tsx index 880d40cc3c612..e0d59ef2a17b6 100644 --- a/src/plugins/dashboard/public/application/actions/add_to_library_action.tsx +++ b/src/plugins/dashboard/public/application/actions/add_to_library_action.tsx @@ -19,7 +19,7 @@ import _ from 'lodash'; -import { ActionByType, IncompatibleActionError } from '../../services/ui_actions'; +import { Action, IncompatibleActionError } from '../../services/ui_actions'; import { ViewMode, PanelState, @@ -39,7 +39,7 @@ export interface AddToLibraryActionContext { embeddable: IEmbeddable; } -export class AddToLibraryAction implements ActionByType { +export class AddToLibraryAction implements Action { public readonly type = ACTION_ADD_TO_LIBRARY; public readonly id = ACTION_ADD_TO_LIBRARY; public order = 15; diff --git a/src/plugins/dashboard/public/application/actions/clone_panel_action.tsx b/src/plugins/dashboard/public/application/actions/clone_panel_action.tsx index d27e2d6dce651..e59cefed598e8 100644 --- a/src/plugins/dashboard/public/application/actions/clone_panel_action.tsx +++ b/src/plugins/dashboard/public/application/actions/clone_panel_action.tsx @@ -21,7 +21,7 @@ import _ from 'lodash'; import uuid from 'uuid'; import { CoreStart } from 'src/core/public'; -import { ActionByType, IncompatibleActionError } from '../../services/ui_actions'; +import { Action, IncompatibleActionError } from '../../services/ui_actions'; import { SavedObject } from '../../services/saved_objects'; import { ViewMode, @@ -45,7 +45,7 @@ export interface ClonePanelActionContext { embeddable: IEmbeddable; } -export class ClonePanelAction implements ActionByType { +export class ClonePanelAction implements Action { public readonly type = ACTION_CLONE_PANEL; public readonly id = ACTION_CLONE_PANEL; public order = 45; diff --git a/src/plugins/dashboard/public/application/actions/expand_panel_action.tsx b/src/plugins/dashboard/public/application/actions/expand_panel_action.tsx index fe14ce13d44bc..3336f8dc5915c 100644 --- a/src/plugins/dashboard/public/application/actions/expand_panel_action.tsx +++ b/src/plugins/dashboard/public/application/actions/expand_panel_action.tsx @@ -19,7 +19,7 @@ import { dashboardExpandPanelAction } from '../../dashboard_strings'; import { IEmbeddable } from '../../services/embeddable'; -import { ActionByType, IncompatibleActionError } from '../../services/ui_actions'; +import { Action, IncompatibleActionError } from '../../services/ui_actions'; import { DASHBOARD_CONTAINER_TYPE, DashboardContainer, @@ -46,7 +46,7 @@ export interface ExpandPanelActionContext { embeddable: IEmbeddable; } -export class ExpandPanelAction implements ActionByType { +export class ExpandPanelAction implements Action { public readonly type = ACTION_EXPAND_PANEL; public readonly id = ACTION_EXPAND_PANEL; public order = 7; diff --git a/src/plugins/dashboard/public/application/actions/export_csv_action.tsx b/src/plugins/dashboard/public/application/actions/export_csv_action.tsx index a31ecbea88bab..1048ce2189744 100644 --- a/src/plugins/dashboard/public/application/actions/export_csv_action.tsx +++ b/src/plugins/dashboard/public/application/actions/export_csv_action.tsx @@ -24,7 +24,7 @@ import { FormatFactory } from '../../../../data/common/field_formats/utils'; import { DataPublicPluginStart, exporters } from '../../services/data'; import { downloadMultipleAs } from '../../services/share'; import { Adapters, IEmbeddable } from '../../services/embeddable'; -import { ActionByType } from '../../services/ui_actions'; +import { Action } from '../../services/ui_actions'; import { dashboardExportCsvAction } from '../../dashboard_strings'; export const ACTION_EXPORT_CSV = 'ACTION_EXPORT_CSV'; @@ -44,7 +44,7 @@ export interface ExportContext { * This is "Export CSV" action which appears in the context * menu of a dashboard panel. */ -export class ExportCSVAction implements ActionByType { +export class ExportCSVAction implements Action { public readonly id = ACTION_EXPORT_CSV; public readonly type = ACTION_EXPORT_CSV; diff --git a/src/plugins/dashboard/public/application/actions/library_notification_action.tsx b/src/plugins/dashboard/public/application/actions/library_notification_action.tsx index 13ccb279df821..a6d718846b9fe 100644 --- a/src/plugins/dashboard/public/application/actions/library_notification_action.tsx +++ b/src/plugins/dashboard/public/application/actions/library_notification_action.tsx @@ -19,7 +19,7 @@ import React from 'react'; -import { ActionByType, IncompatibleActionError } from '../../services/ui_actions'; +import { Action, IncompatibleActionError } from '../../services/ui_actions'; import { reactToUiComponent } from '../../services/kibana_react'; import { IEmbeddable, @@ -38,7 +38,7 @@ export interface LibraryNotificationActionContext { embeddable: IEmbeddable; } -export class LibraryNotificationAction implements ActionByType { +export class LibraryNotificationAction implements Action { public readonly id = ACTION_LIBRARY_NOTIFICATION; public readonly type = ACTION_LIBRARY_NOTIFICATION; public readonly order = 1; diff --git a/src/plugins/dashboard/public/application/actions/replace_panel_action.tsx b/src/plugins/dashboard/public/application/actions/replace_panel_action.tsx index 553a0b9770d01..909b758c511a9 100644 --- a/src/plugins/dashboard/public/application/actions/replace_panel_action.tsx +++ b/src/plugins/dashboard/public/application/actions/replace_panel_action.tsx @@ -20,7 +20,7 @@ import { CoreStart } from 'src/core/public'; import { IEmbeddable, ViewMode, EmbeddableStart } from '../../services/embeddable'; import { DASHBOARD_CONTAINER_TYPE, DashboardContainer } from '../embeddable'; -import { ActionByType, IncompatibleActionError } from '../../services/ui_actions'; +import { Action, IncompatibleActionError } from '../../services/ui_actions'; import { openReplacePanelFlyout } from './open_replace_panel_flyout'; import { dashboardReplacePanelAction } from '../../dashboard_strings'; @@ -34,7 +34,7 @@ export interface ReplacePanelActionContext { embeddable: IEmbeddable; } -export class ReplacePanelAction implements ActionByType { +export class ReplacePanelAction implements Action { public readonly type = ACTION_REPLACE_PANEL; public readonly id = ACTION_REPLACE_PANEL; public order = 3; diff --git a/src/plugins/dashboard/public/application/actions/unlink_from_library_action.tsx b/src/plugins/dashboard/public/application/actions/unlink_from_library_action.tsx index 93ceb72624259..901367b6af833 100644 --- a/src/plugins/dashboard/public/application/actions/unlink_from_library_action.tsx +++ b/src/plugins/dashboard/public/application/actions/unlink_from_library_action.tsx @@ -18,7 +18,7 @@ */ import _ from 'lodash'; -import { ActionByType, IncompatibleActionError } from '../../services/ui_actions'; +import { Action, IncompatibleActionError } from '../../services/ui_actions'; import { ViewMode, PanelState, @@ -38,7 +38,7 @@ export interface UnlinkFromLibraryActionContext { embeddable: IEmbeddable; } -export class UnlinkFromLibraryAction implements ActionByType { +export class UnlinkFromLibraryAction implements Action { public readonly type = ACTION_UNLINK_FROM_LIBRARY; public readonly id = ACTION_UNLINK_FROM_LIBRARY; public order = 15; diff --git a/src/plugins/dashboard/public/plugin.tsx b/src/plugins/dashboard/public/plugin.tsx index 4dff423098c5a..166f4eaf39997 100644 --- a/src/plugins/dashboard/public/plugin.tsx +++ b/src/plugins/dashboard/public/plugin.tsx @@ -62,27 +62,15 @@ import { } from './services/kibana_react'; import { - ACTION_CLONE_PANEL, - ACTION_EXPAND_PANEL, - ACTION_REPLACE_PANEL, ClonePanelAction, - ClonePanelActionContext, createDashboardContainerByValueRenderer, DASHBOARD_CONTAINER_TYPE, DashboardContainerFactory, DashboardContainerFactoryDefinition, ExpandPanelAction, - ExpandPanelActionContext, ReplacePanelAction, - ReplacePanelActionContext, - ACTION_UNLINK_FROM_LIBRARY, - UnlinkFromLibraryActionContext, UnlinkFromLibraryAction, - ACTION_ADD_TO_LIBRARY, - AddToLibraryActionContext, AddToLibraryAction, - ACTION_LIBRARY_NOTIFICATION, - LibraryNotificationActionContext, LibraryNotificationAction, } from './application'; import { @@ -94,11 +82,7 @@ import { createSavedDashboardLoader } from './saved_dashboards'; import { DashboardConstants } from './dashboard_constants'; import { PlaceholderEmbeddableFactory } from './application/embeddable/placeholder'; import { UrlGeneratorState } from '../../share/public'; -import { - ACTION_EXPORT_CSV, - ExportContext, - ExportCSVAction, -} from './application/actions/export_csv_action'; +import { ExportCSVAction } from './application/actions/export_csv_action'; import { dashboardFeatureCatalog } from './dashboard_strings'; declare module '../../share/public' { @@ -147,18 +131,6 @@ export interface DashboardStart { DashboardContainerByValueRenderer: ReturnType; } -declare module '../../../plugins/ui_actions/public' { - export interface ActionContextMapping { - [ACTION_EXPAND_PANEL]: ExpandPanelActionContext; - [ACTION_REPLACE_PANEL]: ReplacePanelActionContext; - [ACTION_CLONE_PANEL]: ClonePanelActionContext; - [ACTION_ADD_TO_LIBRARY]: AddToLibraryActionContext; - [ACTION_UNLINK_FROM_LIBRARY]: UnlinkFromLibraryActionContext; - [ACTION_LIBRARY_NOTIFICATION]: LibraryNotificationActionContext; - [ACTION_EXPORT_CSV]: ExportContext; - } -} - export class DashboardPlugin implements Plugin { diff --git a/src/plugins/dashboard/public/services/ui_actions.ts b/src/plugins/dashboard/public/services/ui_actions.ts index 4c9ac590191f6..81bdad35d464c 100644 --- a/src/plugins/dashboard/public/services/ui_actions.ts +++ b/src/plugins/dashboard/public/services/ui_actions.ts @@ -18,7 +18,7 @@ */ export { - ActionByType, + Action, IncompatibleActionError, UiActionsSetup, UiActionsStart, diff --git a/src/plugins/data/public/actions/apply_filter_action.ts b/src/plugins/data/public/actions/apply_filter_action.ts index 84ce5b0382624..909d6e97c221c 100644 --- a/src/plugins/data/public/actions/apply_filter_action.ts +++ b/src/plugins/data/public/actions/apply_filter_action.ts @@ -19,7 +19,7 @@ import { i18n } from '@kbn/i18n'; import { toMountPoint } from '../../../kibana_react/public'; -import { ActionByType, createAction, IncompatibleActionError } from '../../../ui_actions/public'; +import { Action, createAction, IncompatibleActionError } from '../../../ui_actions/public'; import { getOverlays, getIndexPatterns } from '../services'; import { applyFiltersPopover } from '../ui/apply_filters'; import { Filter, FilterManager, TimefilterContract, esFilters } from '..'; @@ -41,8 +41,8 @@ async function isCompatible(context: ApplyGlobalFilterActionContext) { export function createFilterAction( filterManager: FilterManager, timeFilter: TimefilterContract -): ActionByType { - return createAction({ +): Action { + return createAction({ type: ACTION_GLOBAL_APPLY_FILTER, id: ACTION_GLOBAL_APPLY_FILTER, order: 100, diff --git a/src/plugins/data/public/actions/filters/create_filters_from_range_select.test.ts b/src/plugins/data/public/actions/filters/create_filters_from_range_select.test.ts index 6dcfa4d02bcb2..9830bf5b7ba83 100644 --- a/src/plugins/data/public/actions/filters/create_filters_from_range_select.test.ts +++ b/src/plugins/data/public/actions/filters/create_filters_from_range_select.test.ts @@ -29,12 +29,16 @@ import { } from '../../../public'; import { dataPluginMock } from '../../../public/mocks'; import { setIndexPatterns, setSearchService } from '../../../public/services'; -import { TriggerContextMapping } from '../../../../ui_actions/public'; describe('brushEvent', () => { const DAY_IN_MS = 24 * 60 * 60 * 1000; const JAN_01_2014 = 1388559600000; - let baseEvent: TriggerContextMapping['SELECT_RANGE_TRIGGER']['data']; + let baseEvent: { + table: any; + column: number; + range: number[]; + timeFieldName?: string; + }; const mockField = { name: 'time', diff --git a/src/plugins/data/public/actions/select_range_action.ts b/src/plugins/data/public/actions/select_range_action.ts index 3b84523d782f6..c6d234665c05e 100644 --- a/src/plugins/data/public/actions/select_range_action.ts +++ b/src/plugins/data/public/actions/select_range_action.ts @@ -18,7 +18,7 @@ */ import { Datatable } from 'src/plugins/expressions/public'; -import { ActionByType, createAction, UiActionsStart } from '../../../../plugins/ui_actions/public'; +import { Action, createAction, UiActionsStart } from '../../../../plugins/ui_actions/public'; import { APPLY_FILTER_TRIGGER } from '../triggers'; import { createFiltersFromRangeSelectAction } from './filters/create_filters_from_range_select'; @@ -38,8 +38,8 @@ export const ACTION_SELECT_RANGE = 'ACTION_SELECT_RANGE'; export function createSelectRangeAction( getStartServices: () => { uiActions: UiActionsStart } -): ActionByType { - return createAction({ +): Action { + return createAction({ type: ACTION_SELECT_RANGE, id: ACTION_SELECT_RANGE, shouldAutoExecute: async () => true, diff --git a/src/plugins/data/public/actions/value_click_action.ts b/src/plugins/data/public/actions/value_click_action.ts index 8f207e94e8fbe..41c2943a6a5bb 100644 --- a/src/plugins/data/public/actions/value_click_action.ts +++ b/src/plugins/data/public/actions/value_click_action.ts @@ -18,7 +18,7 @@ */ import { Datatable } from 'src/plugins/expressions/public'; -import { ActionByType, createAction, UiActionsStart } from '../../../../plugins/ui_actions/public'; +import { Action, createAction, UiActionsStart } from '../../../../plugins/ui_actions/public'; import { APPLY_FILTER_TRIGGER } from '../triggers'; import { createFiltersFromValueClickAction } from './filters/create_filters_from_value_click'; import type { Filter } from '../../common/es_query/filters'; @@ -44,8 +44,8 @@ export interface ValueClickContext { export function createValueClickAction( getStartServices: () => { uiActions: UiActionsStart } -): ActionByType { - return createAction({ +): Action { + return createAction({ type: ACTION_VALUE_CLICK, id: ACTION_VALUE_CLICK, shouldAutoExecute: async () => true, diff --git a/src/plugins/data/public/plugin.ts b/src/plugins/data/public/plugin.ts index c60a1efabf987..43abe84950fdb 100644 --- a/src/plugins/data/public/plugin.ts +++ b/src/plugins/data/public/plugin.ts @@ -53,11 +53,6 @@ import { createFilterAction, createFiltersFromValueClickAction, createFiltersFromRangeSelectAction, - ApplyGlobalFilterActionContext, - ACTION_SELECT_RANGE, - ACTION_VALUE_CLICK, - SelectRangeActionContext, - ValueClickActionContext, createValueClickAction, createSelectRangeAction, } from './actions'; @@ -66,19 +61,6 @@ import { SavedObjectsClientPublicToCommon } from './index_patterns'; import { getIndexPatternLoad } from './index_patterns/expressions'; import { UsageCollectionSetup } from '../../usage_collection/public'; import { getTableViewDescription } from './utils/table_inspector_view'; -import { TriggerId } from '../../ui_actions/public'; - -declare module '../../ui_actions/public' { - export interface TriggerContextMapping { - [APPLY_FILTER_TRIGGER]: ApplyGlobalFilterActionContext; - } - - export interface ActionContextMapping { - [ACTION_GLOBAL_APPLY_FILTER]: ApplyGlobalFilterActionContext; - [ACTION_SELECT_RANGE]: SelectRangeActionContext; - [ACTION_VALUE_CLICK]: ValueClickActionContext; - } -} export class DataPublicPlugin implements @@ -125,14 +107,14 @@ export class DataPublicPlugin ); uiActions.addTriggerAction( - 'SELECT_RANGE_TRIGGER' as TriggerId, + 'SELECT_RANGE_TRIGGER', createSelectRangeAction(() => ({ uiActions: startServices().plugins.uiActions, })) ); uiActions.addTriggerAction( - 'VALUE_CLICK_TRIGGER' as TriggerId, + 'VALUE_CLICK_TRIGGER', createValueClickAction(() => ({ uiActions: startServices().plugins.uiActions, })) diff --git a/src/plugins/data/public/triggers/apply_filter_trigger.ts b/src/plugins/data/public/triggers/apply_filter_trigger.ts index 816c1737608da..07422eb313ae3 100644 --- a/src/plugins/data/public/triggers/apply_filter_trigger.ts +++ b/src/plugins/data/public/triggers/apply_filter_trigger.ts @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n'; import { Trigger } from '../../../ui_actions/public'; export const APPLY_FILTER_TRIGGER = 'FILTER_TRIGGER'; -export const applyFilterTrigger: Trigger<'FILTER_TRIGGER'> = { +export const applyFilterTrigger: Trigger = { id: APPLY_FILTER_TRIGGER, title: i18n.translate('data.triggers.applyFilterTitle', { defaultMessage: 'Apply filter', diff --git a/src/plugins/data/public/utils/table_inspector_view/components/data_table.tsx b/src/plugins/data/public/utils/table_inspector_view/components/data_table.tsx index f842568859fc2..f4d1a8988da78 100644 --- a/src/plugins/data/public/utils/table_inspector_view/components/data_table.tsx +++ b/src/plugins/data/public/utils/table_inspector_view/components/data_table.tsx @@ -38,7 +38,7 @@ import { DataViewRow, DataViewColumn } from '../types'; import { IUiSettingsClient } from '../../../../../../core/public'; import { Datatable, DatatableColumn } from '../../../../../expressions/public'; import { FieldFormatsStart } from '../../../field_formats'; -import { TriggerId, UiActionsStart } from '../../../../../ui_actions/public'; +import { UiActionsStart } from '../../../../../ui_actions/public'; interface DataTableFormatState { columns: DataViewColumn[]; @@ -112,7 +112,7 @@ export class DataTableFormat extends Component { const value = table.rows[rowIndex][column.id]; const eventData = { table, column: columnIndex, row: rowIndex, value }; - uiActions.executeTriggerActions('VALUE_CLICK_TRIGGER' as TriggerId, { + uiActions.executeTriggerActions('VALUE_CLICK_TRIGGER', { data: { data: [eventData] }, }); }} @@ -145,7 +145,7 @@ export class DataTableFormat extends Component { const value = table.rows[rowIndex][column.id]; const eventData = { table, column: columnIndex, row: rowIndex, value }; - uiActions.executeTriggerActions('VALUE_CLICK_TRIGGER' as TriggerId, { + uiActions.executeTriggerActions('VALUE_CLICK_TRIGGER', { data: { data: [eventData], negate: true }, }); }} diff --git a/src/plugins/embeddable/public/bootstrap.ts b/src/plugins/embeddable/public/bootstrap.ts index efaff42c19e2f..7898fac16fd9e 100644 --- a/src/plugins/embeddable/public/bootstrap.ts +++ b/src/plugins/embeddable/public/bootstrap.ts @@ -18,44 +18,13 @@ */ import { UiActionsSetup } from '../../ui_actions/public'; import { - ACTION_ADD_PANEL, - ACTION_CUSTOMIZE_PANEL, - ACTION_EDIT_PANEL, - ACTION_INSPECT_PANEL, - CONTEXT_MENU_TRIGGER, contextMenuTrigger, - EmbeddableContext, - PANEL_BADGE_TRIGGER, - PANEL_NOTIFICATION_TRIGGER, panelBadgeTrigger, panelNotificationTrigger, - RangeSelectContext, - REMOVE_PANEL_ACTION, - SELECT_RANGE_TRIGGER, selectRangeTrigger, - ValueClickContext, - VALUE_CLICK_TRIGGER, valueClickTrigger, } from './lib'; -declare module '../../ui_actions/public' { - export interface TriggerContextMapping { - [CONTEXT_MENU_TRIGGER]: EmbeddableContext; - [PANEL_BADGE_TRIGGER]: EmbeddableContext; - [PANEL_NOTIFICATION_TRIGGER]: EmbeddableContext; - [SELECT_RANGE_TRIGGER]: RangeSelectContext; - [VALUE_CLICK_TRIGGER]: ValueClickContext; - } - - export interface ActionContextMapping { - [ACTION_CUSTOMIZE_PANEL]: EmbeddableContext; - [ACTION_ADD_PANEL]: EmbeddableContext; - [ACTION_INSPECT_PANEL]: EmbeddableContext; - [REMOVE_PANEL_ACTION]: EmbeddableContext; - [ACTION_EDIT_PANEL]: EmbeddableContext; - } -} - /** * This method initializes Embeddable plugin with initial set of * triggers and actions. diff --git a/src/plugins/embeddable/public/lib/embeddables/embeddable.tsx b/src/plugins/embeddable/public/lib/embeddables/embeddable.tsx index 2173082d67d3e..f776e41a20458 100644 --- a/src/plugins/embeddable/public/lib/embeddables/embeddable.tsx +++ b/src/plugins/embeddable/public/lib/embeddables/embeddable.tsx @@ -25,7 +25,6 @@ import { RenderCompleteDispatcher } from '../../../../kibana_utils/public'; import { Adapters } from '../types'; import { IContainer } from '../containers'; import { EmbeddableOutput, IEmbeddable } from './i_embeddable'; -import { TriggerContextMapping } from '../ui_actions'; import { EmbeddableInput, ViewMode } from '../../../common/types'; function getPanelTitle(input: EmbeddableInput, output: EmbeddableOutput) { @@ -248,7 +247,7 @@ export abstract class Embeddable< this.onResetInput(newInput); } - public supportedTriggers(): Array { + public supportedTriggers(): string[] { return []; } } diff --git a/src/plugins/embeddable/public/lib/embeddables/i_embeddable.ts b/src/plugins/embeddable/public/lib/embeddables/i_embeddable.ts index a19ec2345db8d..3b0c60f3fb08e 100644 --- a/src/plugins/embeddable/public/lib/embeddables/i_embeddable.ts +++ b/src/plugins/embeddable/public/lib/embeddables/i_embeddable.ts @@ -20,7 +20,6 @@ import { Observable } from 'rxjs'; import { Adapters } from '../types'; import { IContainer } from '../containers/i_container'; -import { TriggerContextMapping } from '../../../../ui_actions/public'; import { EmbeddableInput } from '../../../common/types'; export interface EmbeddableError { @@ -173,5 +172,5 @@ export interface IEmbeddable< /** * List of triggers that this embeddable will execute. */ - supportedTriggers(): Array; + supportedTriggers(): string[]; } diff --git a/src/plugins/embeddable/public/lib/panel/embeddable_panel.test.tsx b/src/plugins/embeddable/public/lib/panel/embeddable_panel.test.tsx index 2104d93da9ad8..80238b06ff9fa 100644 --- a/src/plugins/embeddable/public/lib/panel/embeddable_panel.test.tsx +++ b/src/plugins/embeddable/public/lib/panel/embeddable_panel.test.tsx @@ -24,7 +24,7 @@ import { mountWithIntl, nextTick } from '@kbn/test/jest'; import { findTestSubject } from '@elastic/eui/lib/test'; import { I18nProvider } from '@kbn/i18n/react'; import { CONTEXT_MENU_TRIGGER } from '../triggers'; -import { Action, UiActionsStart, ActionType } from '../../../../ui_actions/public'; +import { Action, UiActionsStart } from '../../../../ui_actions/public'; import { Trigger, ViewMode } from '../types'; import { isErrorEmbeddable } from '../embeddables'; import { EmbeddablePanel } from './embeddable_panel'; @@ -216,7 +216,7 @@ const renderInEditModeAndOpenContextMenu = async ( test('HelloWorldContainer in edit mode hides disabledActions', async () => { const action = { id: 'FOO', - type: 'FOO' as ActionType, + type: 'FOO', getIconType: () => undefined, getDisplayName: () => 'foo', isCompatible: async () => true, @@ -252,7 +252,7 @@ test('HelloWorldContainer in edit mode hides disabledActions', async () => { test('HelloWorldContainer hides disabled badges', async () => { const action = { id: 'BAR', - type: 'BAR' as ActionType, + type: 'BAR', getIconType: () => undefined, getDisplayName: () => 'bar', isCompatible: async () => true, diff --git a/src/plugins/embeddable/public/lib/test_samples/actions/edit_mode_action.ts b/src/plugins/embeddable/public/lib/test_samples/actions/edit_mode_action.ts index bb34b474efda0..ce13c40f08d7e 100644 --- a/src/plugins/embeddable/public/lib/test_samples/actions/edit_mode_action.ts +++ b/src/plugins/embeddable/public/lib/test_samples/actions/edit_mode_action.ts @@ -17,16 +17,15 @@ * under the License. */ -import { createAction, ActionType } from '../../ui_actions'; +import { createAction } from '../../ui_actions'; import { ViewMode } from '../../types'; import { IEmbeddable } from '../..'; -// Casting to ActionType is a hack - in a real situation use -// declare module and add this id to ActionContextMapping. -export const EDIT_MODE_ACTION = 'EDIT_MODE_ACTION' as ActionType; +export const EDIT_MODE_ACTION = 'EDIT_MODE_ACTION'; export function createEditModeAction() { - return createAction({ + return createAction({ + id: EDIT_MODE_ACTION, type: EDIT_MODE_ACTION, getDisplayName: () => 'I only show up in edit mode', isCompatible: async (context: { embeddable: IEmbeddable }) => diff --git a/src/plugins/embeddable/public/lib/test_samples/actions/say_hello_action.tsx b/src/plugins/embeddable/public/lib/test_samples/actions/say_hello_action.tsx index 968caf67b1826..2aa42cbc24554 100644 --- a/src/plugins/embeddable/public/lib/test_samples/actions/say_hello_action.tsx +++ b/src/plugins/embeddable/public/lib/test_samples/actions/say_hello_action.tsx @@ -17,12 +17,10 @@ * under the License. */ -import { IncompatibleActionError, ActionType, ActionDefinitionByType } from '../../ui_actions'; +import { IncompatibleActionError, Action } from '../../ui_actions'; import { EmbeddableInput, Embeddable, EmbeddableOutput, IEmbeddable } from '../../embeddables'; -// Casting to ActionType is a hack - in a real situation use -// declare module and add this id to ActionContextMapping. -export const SAY_HELLO_ACTION = 'SAY_HELLO_ACTION' as ActionType; +export const SAY_HELLO_ACTION = 'SAY_HELLO_ACTION'; export interface FullNameEmbeddableOutput extends EmbeddableOutput { fullName: string; @@ -42,7 +40,7 @@ export interface SayHelloActionContext { message?: string; } -export class SayHelloAction implements ActionDefinitionByType { +export class SayHelloAction implements Action { public readonly type = SAY_HELLO_ACTION; public readonly id = SAY_HELLO_ACTION; diff --git a/src/plugins/embeddable/public/lib/test_samples/actions/send_message_action.tsx b/src/plugins/embeddable/public/lib/test_samples/actions/send_message_action.tsx index 04898550532df..1427a8dcb736e 100644 --- a/src/plugins/embeddable/public/lib/test_samples/actions/send_message_action.tsx +++ b/src/plugins/embeddable/public/lib/test_samples/actions/send_message_action.tsx @@ -18,16 +18,14 @@ */ import React from 'react'; import { EuiFlyoutBody } from '@elastic/eui'; -import { createAction, IncompatibleActionError, ActionType } from '../../ui_actions'; +import { createAction, IncompatibleActionError } from '../../ui_actions'; import { CoreStart } from '../../../../../../core/public'; import { toMountPoint } from '../../../../../kibana_react/public'; import { Embeddable, EmbeddableInput } from '../../embeddables'; import { GetMessageModal } from './get_message_modal'; import { FullNameEmbeddableOutput, hasFullNameOutput } from './say_hello_action'; -// Casting to ActionType is a hack - in a real situation use -// declare module and add this id to ActionContextMapping. -export const ACTION_SEND_MESSAGE = 'ACTION_SEND_MESSAGE' as ActionType; +export const ACTION_SEND_MESSAGE = 'ACTION_SEND_MESSAGE'; interface ActionContext { embeddable: Embeddable; @@ -44,7 +42,8 @@ export function createSendMessageAction(overlays: CoreStart['overlays']) { overlays.openFlyout(toMountPoint({content})); }; - return createAction({ + return createAction({ + id: ACTION_SEND_MESSAGE, type: ACTION_SEND_MESSAGE, getDisplayName: () => 'Send message', isCompatible, diff --git a/src/plugins/embeddable/public/lib/test_samples/embeddables/contact_card/contact_card.tsx b/src/plugins/embeddable/public/lib/test_samples/embeddables/contact_card/contact_card.tsx index 01228c778754b..bacc764469a78 100644 --- a/src/plugins/embeddable/public/lib/test_samples/embeddables/contact_card/contact_card.tsx +++ b/src/plugins/embeddable/public/lib/test_samples/embeddables/contact_card/contact_card.tsx @@ -24,13 +24,6 @@ import { EuiButton } from '@elastic/eui'; import * as Rx from 'rxjs'; import { UiActionsStart } from '../../../../../../ui_actions/public'; import { ContactCardEmbeddable, CONTACT_USER_TRIGGER } from './contact_card_embeddable'; -import { EmbeddableContext } from '../../../triggers'; - -declare module '../../../../../../ui_actions/public' { - export interface TriggerContextMapping { - [CONTACT_USER_TRIGGER]: EmbeddableContext; - } -} interface Props { embeddable: ContactCardEmbeddable; diff --git a/src/plugins/embeddable/public/lib/triggers/triggers.ts b/src/plugins/embeddable/public/lib/triggers/triggers.ts index d9fb063a5bb56..cb315b8804484 100644 --- a/src/plugins/embeddable/public/lib/triggers/triggers.ts +++ b/src/plugins/embeddable/public/lib/triggers/triggers.ts @@ -56,7 +56,7 @@ export type ChartActionContext = | RowClickContext; export const CONTEXT_MENU_TRIGGER = 'CONTEXT_MENU_TRIGGER'; -export const contextMenuTrigger: Trigger<'CONTEXT_MENU_TRIGGER'> = { +export const contextMenuTrigger: Trigger = { id: CONTEXT_MENU_TRIGGER, title: i18n.translate('embeddableApi.contextMenuTrigger.title', { defaultMessage: 'Context menu', @@ -67,7 +67,7 @@ export const contextMenuTrigger: Trigger<'CONTEXT_MENU_TRIGGER'> = { }; export const PANEL_BADGE_TRIGGER = 'PANEL_BADGE_TRIGGER'; -export const panelBadgeTrigger: Trigger<'PANEL_BADGE_TRIGGER'> = { +export const panelBadgeTrigger: Trigger = { id: PANEL_BADGE_TRIGGER, title: i18n.translate('embeddableApi.panelBadgeTrigger.title', { defaultMessage: 'Panel badges', @@ -78,7 +78,7 @@ export const panelBadgeTrigger: Trigger<'PANEL_BADGE_TRIGGER'> = { }; export const PANEL_NOTIFICATION_TRIGGER = 'PANEL_NOTIFICATION_TRIGGER'; -export const panelNotificationTrigger: Trigger<'PANEL_NOTIFICATION_TRIGGER'> = { +export const panelNotificationTrigger: Trigger = { id: PANEL_NOTIFICATION_TRIGGER, title: i18n.translate('embeddableApi.panelNotificationTrigger.title', { defaultMessage: 'Panel notifications', @@ -89,7 +89,7 @@ export const panelNotificationTrigger: Trigger<'PANEL_NOTIFICATION_TRIGGER'> = { }; export const SELECT_RANGE_TRIGGER = 'SELECT_RANGE_TRIGGER'; -export const selectRangeTrigger: Trigger<'SELECT_RANGE_TRIGGER'> = { +export const selectRangeTrigger: Trigger = { id: SELECT_RANGE_TRIGGER, title: i18n.translate('embeddableApi.selectRangeTrigger.title', { defaultMessage: 'Range selection', @@ -100,7 +100,7 @@ export const selectRangeTrigger: Trigger<'SELECT_RANGE_TRIGGER'> = { }; export const VALUE_CLICK_TRIGGER = 'VALUE_CLICK_TRIGGER'; -export const valueClickTrigger: Trigger<'VALUE_CLICK_TRIGGER'> = { +export const valueClickTrigger: Trigger = { id: VALUE_CLICK_TRIGGER, title: i18n.translate('embeddableApi.valueClickTrigger.title', { defaultMessage: 'Single click', diff --git a/src/plugins/embeddable/public/public.api.md b/src/plugins/embeddable/public/public.api.md index b20d5866298d5..386f1b369bef8 100644 --- a/src/plugins/embeddable/public/public.api.md +++ b/src/plugins/embeddable/public/public.api.md @@ -215,7 +215,7 @@ export const CONTEXT_MENU_TRIGGER = "CONTEXT_MENU_TRIGGER"; // Warning: (ae-missing-release-tag) "contextMenuTrigger" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export const contextMenuTrigger: Trigger<'CONTEXT_MENU_TRIGGER'>; +export const contextMenuTrigger: Trigger; // Warning: (ae-missing-release-tag) "defaultEmbeddableFactoryProvider" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // @@ -298,10 +298,8 @@ export abstract class Embeddable; + supportedTriggers(): string[]; // (undocumented) abstract readonly type: string; // (undocumented) @@ -663,7 +661,7 @@ export interface IEmbeddable; + supportedTriggers(): string[]; readonly type: string; updateInput(changes: Partial): void; } @@ -741,7 +739,7 @@ export const PANEL_NOTIFICATION_TRIGGER = "PANEL_NOTIFICATION_TRIGGER"; // Warning: (ae-missing-release-tag) "panelBadgeTrigger" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export const panelBadgeTrigger: Trigger<'PANEL_BADGE_TRIGGER'>; +export const panelBadgeTrigger: Trigger; // Warning: (ae-missing-release-tag) "PanelNotFoundError" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // @@ -755,7 +753,7 @@ export class PanelNotFoundError extends Error { // Warning: (ae-missing-release-tag) "panelNotificationTrigger" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export const panelNotificationTrigger: Trigger<'PANEL_NOTIFICATION_TRIGGER'>; +export const panelNotificationTrigger: Trigger; // Warning: (ae-missing-release-tag) "PanelState" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // diff --git a/src/plugins/ui_actions/public/actions/action.test.ts b/src/plugins/ui_actions/public/actions/action.test.ts index 1f76223a0d7c4..4a51c0323fa8b 100644 --- a/src/plugins/ui_actions/public/actions/action.test.ts +++ b/src/plugins/ui_actions/public/actions/action.test.ts @@ -18,14 +18,12 @@ */ import { ActionExecutionContext, createAction } from '../../../ui_actions/public'; -import { ActionType } from '../types'; import { defaultTrigger } from '../triggers'; -const sayHelloAction = createAction({ - // Casting to ActionType is a hack - in a real situation use - // declare module and add this id to ActionContextMapping. - type: 'test' as ActionType, - isCompatible: ({ amICompatible }: { amICompatible: boolean }) => Promise.resolve(amICompatible), +const sayHelloAction = createAction<{ amICompatible: boolean }>({ + id: 'test', + type: 'test', + isCompatible: ({ amICompatible }) => Promise.resolve(amICompatible), execute: () => Promise.resolve(), }); @@ -33,7 +31,7 @@ test('action is not compatible based on context', async () => { const isCompatible = await sayHelloAction.isCompatible({ amICompatible: false, trigger: defaultTrigger, - } as ActionExecutionContext); + } as ActionExecutionContext<{ amICompatible: boolean }>); expect(isCompatible).toBe(false); }); @@ -41,6 +39,6 @@ test('action is compatible based on context', async () => { const isCompatible = await sayHelloAction.isCompatible({ amICompatible: true, trigger: defaultTrigger, - } as ActionExecutionContext); + } as ActionExecutionContext<{ amICompatible: boolean }>); expect(isCompatible).toBe(true); }); diff --git a/src/plugins/ui_actions/public/actions/action.ts b/src/plugins/ui_actions/public/actions/action.ts index 8005dadd8f5ef..5d479577d4bc6 100644 --- a/src/plugins/ui_actions/public/actions/action.ts +++ b/src/plugins/ui_actions/public/actions/action.ts @@ -18,15 +18,9 @@ */ import { UiComponent } from 'src/plugins/kibana_utils/public'; -import { ActionType, ActionContextMapping, BaseContext } from '../types'; import { Presentable } from '../util/presentable'; import { Trigger } from '../triggers'; -export type ActionByType = Action; -export type ActionDefinitionByType = ActionDefinition< - ActionContextMapping[T] ->; - /** * During action execution we can provide additional information, * for example, trigger, that caused the action execution @@ -41,19 +35,18 @@ export interface ActionExecutionMeta { /** * Action methods are executed with Context from trigger + {@link ActionExecutionMeta} */ -export type ActionExecutionContext = Context & - ActionExecutionMeta; +export type ActionExecutionContext = Context & ActionExecutionMeta; /** * Simplified action context for {@link ActionDefinition} * When defining action consumer may use either it's own Context * or an ActionExecutionContext to get access to {@link ActionExecutionMeta} params */ -export type ActionDefinitionContext = +export type ActionDefinitionContext = | Context | ActionExecutionContext; -export interface Action +export interface Action extends Partial>> { /** * Determined the order when there is more than one action matched to a trigger. @@ -69,7 +62,7 @@ export interface Action /** * The action type is what determines the context shape. */ - readonly type: T; + readonly type: string; /** * Optional EUI icon type that can be displayed along with the title. @@ -117,7 +110,7 @@ export interface Action /** * A convenience interface used to register an action. */ -export interface ActionDefinition +export interface ActionDefinition extends Partial>> { /** * ID of the action that uniquely identifies this action in the actions registry. @@ -127,7 +120,7 @@ export interface ActionDefinition /** * ID of the factory for this action. Used to construct dynamic actions. */ - readonly type?: ActionType; + readonly type?: string; /** * Returns a promise that resolves to true if this item is compatible given diff --git a/src/plugins/ui_actions/public/actions/action_internal.ts b/src/plugins/ui_actions/public/actions/action_internal.ts index fe7c986bdb7ef..7cae0f68bd004 100644 --- a/src/plugins/ui_actions/public/actions/action_internal.ts +++ b/src/plugins/ui_actions/public/actions/action_internal.ts @@ -22,7 +22,6 @@ import React from 'react'; import { Action, ActionContext as Context, ActionDefinition } from './action'; import { Presentable, PresentableGrouping } from '../util/presentable'; import { uiToReactComponent } from '../../../kibana_react/public'; -import { ActionType } from '../types'; /** * @internal @@ -32,7 +31,7 @@ export class ActionInternal constructor(public readonly definition: A) {} public readonly id: string = this.definition.id; - public readonly type: ActionType = this.definition.type || ''; + public readonly type: string = this.definition.type || ''; public readonly order: number = this.definition.order || 0; public readonly MenuItem? = this.definition.MenuItem; public readonly ReactMenuItem? = this.MenuItem ? uiToReactComponent(this.MenuItem) : undefined; diff --git a/src/plugins/ui_actions/public/actions/create_action.ts b/src/plugins/ui_actions/public/actions/create_action.ts index dea21678eccea..0199812c40802 100644 --- a/src/plugins/ui_actions/public/actions/create_action.ts +++ b/src/plugins/ui_actions/public/actions/create_action.ts @@ -17,25 +17,16 @@ * under the License. */ -import { ActionContextMapping } from '../types'; -import { ActionByType } from './action'; -import { ActionType } from '../types'; -import { ActionDefinition } from './action'; +import { ActionDefinition, Action } from './action'; -interface ActionDefinitionByType - extends Omit, 'id'> { - id?: string; -} - -export function createAction( - action: ActionDefinitionByType -): ActionByType { +export function createAction( + action: ActionDefinition +): Action { return { getIconType: () => undefined, order: 0, - id: action.type, isCompatible: () => Promise.resolve(true), getDisplayName: () => '', ...action, - } as ActionByType; + } as Action; } diff --git a/src/plugins/ui_actions/public/context_menu/build_eui_context_menu_panels.test.ts b/src/plugins/ui_actions/public/context_menu/build_eui_context_menu_panels.test.ts index 3111a0b55084c..ac19889aa6532 100644 --- a/src/plugins/ui_actions/public/context_menu/build_eui_context_menu_panels.test.ts +++ b/src/plugins/ui_actions/public/context_menu/build_eui_context_menu_panels.test.ts @@ -34,6 +34,7 @@ const createTestAction = ({ grouping?: PresentableGrouping; }) => createAction({ + id: type as any, // mapping doesn't matter for this test type: type as any, // mapping doesn't matter for this test getDisplayName: () => dispayName, order, diff --git a/src/plugins/ui_actions/public/context_menu/build_eui_context_menu_panels.tsx b/src/plugins/ui_actions/public/context_menu/build_eui_context_menu_panels.tsx index 63586ca3da1f7..aa3fd57be695a 100644 --- a/src/plugins/ui_actions/public/context_menu/build_eui_context_menu_panels.tsx +++ b/src/plugins/ui_actions/public/context_menu/build_eui_context_menu_panels.tsx @@ -24,7 +24,6 @@ import { i18n } from '@kbn/i18n'; import { uiToReactComponent } from '../../../kibana_react/public'; import { Action, ActionExecutionContext } from '../actions'; import { Trigger } from '../triggers'; -import { BaseContext } from '../types'; export const defaultTitle = i18n.translate('uiActions.actionPanel.title', { defaultMessage: 'Options', @@ -34,7 +33,7 @@ export const txtMore = i18n.translate('uiActions.actionPanel.more', { defaultMessage: 'More', }); -interface ActionWithContext { +interface ActionWithContext { action: Action; context: Context; diff --git a/src/plugins/ui_actions/public/index.ts b/src/plugins/ui_actions/public/index.ts index 7890e4bab44a3..9ac5c19033e45 100644 --- a/src/plugins/ui_actions/public/index.ts +++ b/src/plugins/ui_actions/public/index.ts @@ -39,7 +39,6 @@ export { } from './util'; export { Trigger, - TriggerContext, VISUALIZE_FIELD_TRIGGER, visualizeFieldTrigger, VISUALIZE_GEO_FIELD_TRIGGER, @@ -49,18 +48,9 @@ export { RowClickContext, } from './triggers'; export { - TriggerContextMapping, - TriggerId, - ActionContextMapping, - ActionType, VisualizeFieldContext, ACTION_VISUALIZE_FIELD, ACTION_VISUALIZE_GEO_FIELD, ACTION_VISUALIZE_LENS_FIELD, } from './types'; -export { - ActionByType, - ActionDefinitionByType, - ActionExecutionContext, - ActionExecutionMeta, -} from './actions'; +export { ActionExecutionContext, ActionExecutionMeta } from './actions'; diff --git a/src/plugins/ui_actions/public/mocks.ts b/src/plugins/ui_actions/public/mocks.ts index 759430169b613..fa24738014910 100644 --- a/src/plugins/ui_actions/public/mocks.ts +++ b/src/plugins/ui_actions/public/mocks.ts @@ -21,7 +21,6 @@ import { CoreSetup, CoreStart } from 'src/core/public'; import { UiActionsSetup, UiActionsStart } from '.'; import { plugin as pluginInitializer } from '.'; import { coreMock } from '../../../core/public/mocks'; -import { TriggerId } from './types'; export type Setup = jest.Mocked; export type Start = jest.Mocked; @@ -50,7 +49,7 @@ const createStartContract = (): Start => { getAction: jest.fn(), hasAction: jest.fn(), getTrigger: jest.fn(), - getTriggerActions: jest.fn((id: TriggerId) => []), + getTriggerActions: jest.fn((id: string) => []), getTriggerCompatibleActions: jest.fn(), registerAction: jest.fn(), registerTrigger: jest.fn(), diff --git a/src/plugins/ui_actions/public/public.api.md b/src/plugins/ui_actions/public/public.api.md index 808cb1f3fbca0..0d3ab1086904d 100644 --- a/src/plugins/ui_actions/public/public.api.md +++ b/src/plugins/ui_actions/public/public.api.md @@ -15,11 +15,10 @@ import { PublicMethodsOf } from '@kbn/utility-types'; import React from 'react'; import { UiComponent } from 'src/plugins/kibana_utils/public'; -// Warning: (ae-forgotten-export) The symbol "BaseContext" needs to be exported by the entry point index.d.ts // Warning: (ae-missing-release-tag) "Action" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export interface Action extends Partial>> { +export interface Action extends Partial>> { execute(context: ActionExecutionContext): Promise; getDisplayName(context: ActionExecutionContext): string; getHref?(context: ActionExecutionContext): Promise; @@ -31,7 +30,7 @@ export interface Action extend }>; order?: number; shouldAutoExecute?(context: ActionExecutionContext): Promise; - readonly type: T; + readonly type: string; } // Warning: (ae-missing-release-tag) "ACTION_VISUALIZE_FIELD" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) @@ -49,36 +48,10 @@ export const ACTION_VISUALIZE_GEO_FIELD = "ACTION_VISUALIZE_GEO_FIELD"; // @public (undocumented) export const ACTION_VISUALIZE_LENS_FIELD = "ACTION_VISUALIZE_LENS_FIELD"; -// Warning: (ae-missing-release-tag) "ActionByType" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type ActionByType = Action; - -// Warning: (ae-missing-release-tag) "ActionContextMapping" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export interface ActionContextMapping { - // Warning: (ae-forgotten-export) The symbol "DEFAULT_ACTION" needs to be exported by the entry point index.d.ts - // - // (undocumented) - [DEFAULT_ACTION]: BaseContext; - // (undocumented) - [ACTION_VISUALIZE_FIELD]: VisualizeFieldContext; - // (undocumented) - [ACTION_VISUALIZE_GEO_FIELD]: VisualizeFieldContext; - // (undocumented) - [ACTION_VISUALIZE_LENS_FIELD]: VisualizeFieldContext; -} - -// Warning: (ae-missing-release-tag) "ActionDefinitionByType" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type ActionDefinitionByType = UiActionsActionDefinition; - // Warning: (ae-missing-release-tag) "ActionExecutionContext" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public -export type ActionExecutionContext = Context & ActionExecutionMeta; +export type ActionExecutionContext = Context & ActionExecutionMeta; // Warning: (ae-missing-release-tag) "ActionExecutionMeta" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // @@ -87,22 +60,16 @@ export interface ActionExecutionMeta { trigger: Trigger; } -// Warning: (ae-missing-release-tag) "ActionType" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type ActionType = keyof ActionContextMapping; - // Warning: (ae-forgotten-export) The symbol "BuildContextMenuParams" needs to be exported by the entry point index.d.ts // Warning: (ae-missing-release-tag) "buildContextMenuForActions" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public export function buildContextMenuForActions({ actions, title, closeMenu, }: BuildContextMenuParams): Promise; -// Warning: (ae-forgotten-export) The symbol "ActionDefinitionByType" needs to be exported by the entry point index.d.ts // Warning: (ae-missing-release-tag) "createAction" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export function createAction(action: ActionDefinitionByType_2): ActionByType; +export function createAction(action: UiActionsActionDefinition): Action; // Warning: (ae-missing-release-tag) "IncompatibleActionError" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // @@ -142,61 +109,34 @@ export interface RowClickContext { // Warning: (ae-missing-release-tag) "rowClickTrigger" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export const rowClickTrigger: Trigger<'ROW_CLICK_TRIGGER'>; +export const rowClickTrigger: Trigger; // Warning: (ae-missing-release-tag) "Trigger" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public -export interface Trigger { +export interface Trigger { description?: string; - id: ID; + id: string; title?: string; } -// Warning: (ae-missing-release-tag) "TriggerContext" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type TriggerContext = T extends TriggerId ? TriggerContextMapping[T] : never; - -// Warning: (ae-missing-release-tag) "TriggerContextMapping" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export interface TriggerContextMapping { - // Warning: (ae-forgotten-export) The symbol "DEFAULT_TRIGGER" needs to be exported by the entry point index.d.ts - // Warning: (ae-forgotten-export) The symbol "TriggerContext" needs to be exported by the entry point index.d.ts - // - // (undocumented) - [DEFAULT_TRIGGER]: TriggerContext_2; - // (undocumented) - [ROW_CLICK_TRIGGER]: RowClickContext; - // (undocumented) - [VISUALIZE_FIELD_TRIGGER]: VisualizeFieldContext; - // (undocumented) - [VISUALIZE_GEO_FIELD_TRIGGER]: VisualizeFieldContext; -} - -// Warning: (ae-missing-release-tag) "TriggerId" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type TriggerId = keyof TriggerContextMapping; - // Warning: (ae-forgotten-export) The symbol "ActionDefinitionContext" needs to be exported by the entry point index.d.ts // Warning: (ae-missing-release-tag) "ActionDefinition" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public -export interface UiActionsActionDefinition extends Partial>> { +export interface UiActionsActionDefinition extends Partial>> { execute(context: ActionDefinitionContext): Promise; getHref?(context: ActionDefinitionContext): Promise; readonly id: string; isCompatible?(context: ActionDefinitionContext): Promise; shouldAutoExecute?(context: ActionDefinitionContext): Promise; - readonly type?: ActionType; + readonly type?: string; } // Warning: (ae-missing-release-tag) "Presentable" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public -export interface UiActionsPresentable { +export interface UiActionsPresentable { getDisplayName(context: Context): string; getDisplayNameTooltip(context: Context): string; getHref?(context: Context): Promise; @@ -214,7 +154,7 @@ export interface UiActionsPresentable { // Warning: (ae-missing-release-tag) "PresentableGrouping" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export type UiActionsPresentableGrouping = Array>; +export type UiActionsPresentableGrouping = Array>; // Warning: (ae-missing-release-tag) "UiActionsService" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // @@ -225,35 +165,35 @@ export class UiActionsService { // // (undocumented) protected readonly actions: ActionRegistry; - readonly addTriggerAction: (triggerId: T, action: UiActionsActionDefinition | Action) => void; + readonly addTriggerAction: (triggerId: string, action: UiActionsActionDefinition) => void; // (undocumented) - readonly attachAction: (triggerId: T, actionId: string) => void; + readonly attachAction: (triggerId: string, actionId: string) => void; readonly clear: () => void; // (undocumented) - readonly detachAction: (triggerId: TriggerId, actionId: string) => void; + readonly detachAction: (triggerId: string, actionId: string) => void; // @deprecated (undocumented) - readonly executeTriggerActions: (triggerId: T, context: TriggerContext) => Promise; + readonly executeTriggerActions: (triggerId: string, context: object) => Promise; // Warning: (ae-forgotten-export) The symbol "UiActionsExecutionService" needs to be exported by the entry point index.d.ts // // (undocumented) readonly executionService: UiActionsExecutionService; readonly fork: () => UiActionsService; // (undocumented) - readonly getAction: >(id: string) => Action, "" | "ACTION_VISUALIZE_FIELD" | "ACTION_VISUALIZE_GEO_FIELD" | "ACTION_VISUALIZE_LENS_FIELD" | "ACTION_GLOBAL_APPLY_FILTER" | "ACTION_SELECT_RANGE" | "ACTION_VALUE_CLICK" | "ACTION_CUSTOMIZE_PANEL" | "ACTION_ADD_PANEL" | "openInspector" | "deletePanel" | "editPanel">; + readonly getAction: >(id: string) => Action>; // Warning: (ae-forgotten-export) The symbol "TriggerContract" needs to be exported by the entry point index.d.ts // // (undocumented) - readonly getTrigger: (triggerId: T) => TriggerContract; + readonly getTrigger: (triggerId: string) => TriggerContract; // (undocumented) - readonly getTriggerActions: (triggerId: T) => Action[]; + readonly getTriggerActions: (triggerId: string) => Action[]; // (undocumented) - readonly getTriggerCompatibleActions: (triggerId: T, context: TriggerContextMapping[T]) => Promise[]>; + readonly getTriggerCompatibleActions: (triggerId: string, context: object) => Promise; // (undocumented) readonly hasAction: (actionId: string) => boolean; // Warning: (ae-forgotten-export) The symbol "ActionContext" needs to be exported by the entry point index.d.ts // // (undocumented) - readonly registerAction: >(definition: A) => Action, "" | "ACTION_VISUALIZE_FIELD" | "ACTION_VISUALIZE_GEO_FIELD" | "ACTION_VISUALIZE_LENS_FIELD" | "ACTION_GLOBAL_APPLY_FILTER" | "ACTION_SELECT_RANGE" | "ACTION_VALUE_CLICK" | "ACTION_CUSTOMIZE_PANEL" | "ACTION_ADD_PANEL" | "openInspector" | "deletePanel" | "editPanel">; + readonly registerAction: >(definition: A) => Action>; // (undocumented) readonly registerTrigger: (trigger: Trigger) => void; // Warning: (ae-forgotten-export) The symbol "TriggerRegistry" needs to be exported by the entry point index.d.ts @@ -314,12 +254,12 @@ export interface VisualizeFieldContext { // Warning: (ae-missing-release-tag) "visualizeFieldTrigger" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export const visualizeFieldTrigger: Trigger<'VISUALIZE_FIELD_TRIGGER'>; +export const visualizeFieldTrigger: Trigger; // Warning: (ae-missing-release-tag) "visualizeGeoFieldTrigger" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export const visualizeGeoFieldTrigger: Trigger<'VISUALIZE_GEO_FIELD_TRIGGER'>; +export const visualizeGeoFieldTrigger: Trigger; // Warnings were encountered during analysis: diff --git a/src/plugins/ui_actions/public/service/ui_actions_execution_service.ts b/src/plugins/ui_actions/public/service/ui_actions_execution_service.ts index 59616dcf3f38d..ea44448092a72 100644 --- a/src/plugins/ui_actions/public/service/ui_actions_execution_service.ts +++ b/src/plugins/ui_actions/public/service/ui_actions_execution_service.ts @@ -19,14 +19,13 @@ import { uniqBy } from 'lodash'; import { Action } from '../actions'; -import { BaseContext } from '../types'; import { defer as createDefer, Defer } from '../../../kibana_utils/public'; import { buildContextMenuForActions, openContextMenu } from '../context_menu'; import { Trigger } from '../triggers'; interface ExecuteActionTask { action: Action; - context: BaseContext; + context: object; trigger: Trigger; defer: Defer; alwaysShowPopup?: boolean; @@ -44,8 +43,8 @@ export class UiActionsExecutionService { context, trigger, }: { - action: Action; - context: BaseContext; + action: Action; + context: object; trigger: Trigger; }, alwaysShowPopup?: boolean diff --git a/src/plugins/ui_actions/public/service/ui_actions_service.test.ts b/src/plugins/ui_actions/public/service/ui_actions_service.test.ts index 39502c3dd17fc..137cfaeac4b67 100644 --- a/src/plugins/ui_actions/public/service/ui_actions_service.test.ts +++ b/src/plugins/ui_actions/public/service/ui_actions_service.test.ts @@ -20,19 +20,17 @@ import { UiActionsService } from './ui_actions_service'; import { Action, ActionInternal, createAction } from '../actions'; import { createHelloWorldAction } from '../tests/test_samples'; -import { TriggerRegistry, TriggerId, ActionType, ActionRegistry } from '../types'; +import { TriggerRegistry, ActionRegistry } from '../types'; import { Trigger } from '../triggers'; -// Casting to ActionType or TriggerId is a hack - in a real situation use -// declare module and add this id to the appropriate context mapping. -const FOO_TRIGGER: TriggerId = 'FOO_TRIGGER' as TriggerId; -const BAR_TRIGGER: TriggerId = 'BAR_TRIGGER' as TriggerId; -const MY_TRIGGER: TriggerId = 'MY_TRIGGER' as TriggerId; +const FOO_TRIGGER = 'FOO_TRIGGER'; +const BAR_TRIGGER = 'BAR_TRIGGER'; +const MY_TRIGGER = 'MY_TRIGGER'; const testAction1: Action = { id: 'action1', order: 1, - type: 'type1' as ActionType, + type: 'type1', execute: async () => {}, getDisplayName: () => 'test1', getIconType: () => '', @@ -42,7 +40,7 @@ const testAction1: Action = { const testAction2: Action = { id: 'action2', order: 2, - type: 'type2' as ActionType, + type: 'type2', execute: async () => {}, getDisplayName: () => 'test2', getIconType: () => '', @@ -99,7 +97,7 @@ describe('UiActionsService', () => { getDisplayName: () => 'test', getIconType: () => '', isCompatible: async () => true, - type: 'test' as ActionType, + type: 'test', }); }); @@ -111,7 +109,7 @@ describe('UiActionsService', () => { getDisplayName: () => 'test', getIconType: () => '', isCompatible: async () => true, - type: 'test' as ActionType, + type: 'test', }); expect(action).toBeInstanceOf(ActionInternal); @@ -123,7 +121,7 @@ describe('UiActionsService', () => { const action1: Action = { id: 'action1', order: 1, - type: 'type1' as ActionType, + type: 'type1', execute: async () => {}, getDisplayName: () => 'test', getIconType: () => '', @@ -132,7 +130,7 @@ describe('UiActionsService', () => { const action2: Action = { id: 'action2', order: 2, - type: 'type2' as ActionType, + type: 'type2', execute: async () => {}, getDisplayName: () => 'test', getIconType: () => '', @@ -207,7 +205,8 @@ describe('UiActionsService', () => { test('filters out actions not applicable based on the context', async () => { const service = new UiActionsService(); const action = createAction({ - type: 'test' as ActionType, + id: 'test', + type: 'test', isCompatible: ({ accept }: { accept: boolean }) => Promise.resolve(accept), execute: () => Promise.resolve(), }); @@ -238,16 +237,15 @@ describe('UiActionsService', () => { test(`throws an error with an invalid trigger ID`, async () => { const service = new UiActionsService(); - // Without the cast "as TriggerId" typescript will happily throw an error! - await expect( - service.getTriggerCompatibleActions('I do not exist' as TriggerId, {}) - ).rejects.toMatchObject(new Error('Trigger [triggerId = I do not exist] does not exist.')); + await expect(service.getTriggerCompatibleActions('I do not exist', {})).rejects.toMatchObject( + new Error('Trigger [triggerId = I do not exist] does not exist.') + ); }); test('returns empty list if trigger not attached to any action', async () => { const service = new UiActionsService(); const testTrigger: Trigger = { - id: '123' as TriggerId, + id: '123', title: '123', }; service.registerTrigger(testTrigger); @@ -445,9 +443,7 @@ describe('UiActionsService', () => { } as any; service.registerAction(action); - expect(() => - service.detachAction('i do not exist' as TriggerId, ACTION_HELLO_WORLD) - ).toThrowError( + expect(() => service.detachAction('i do not exist', ACTION_HELLO_WORLD)).toThrowError( 'No trigger [triggerId = i do not exist] exists, for detaching action [actionId = ACTION_HELLO_WORLD].' ); }); @@ -461,7 +457,7 @@ describe('UiActionsService', () => { } as any; service.registerAction(action); - expect(() => service.addTriggerAction('i do not exist' as TriggerId, action)).toThrowError( + expect(() => service.addTriggerAction('i do not exist', action)).toThrowError( 'No trigger [triggerId = i do not exist] exists, for attaching action [actionId = ACTION_HELLO_WORLD].' ); }); diff --git a/src/plugins/ui_actions/public/service/ui_actions_service.ts b/src/plugins/ui_actions/public/service/ui_actions_service.ts index ec5f3afa19c94..456341d98c5b5 100644 --- a/src/plugins/ui_actions/public/service/ui_actions_service.ts +++ b/src/plugins/ui_actions/public/service/ui_actions_service.ts @@ -17,15 +17,9 @@ * under the License. */ -import { - TriggerRegistry, - ActionRegistry, - TriggerToActionsRegistry, - TriggerId, - TriggerContextMapping, -} from '../types'; +import { TriggerRegistry, ActionRegistry, TriggerToActionsRegistry } from '../types'; import { ActionInternal, Action, ActionDefinition, ActionContext } from '../actions'; -import { Trigger, TriggerContext } from '../triggers/trigger'; +import { Trigger } from '../triggers/trigger'; import { TriggerInternal } from '../triggers/trigger_internal'; import { TriggerContract } from '../triggers/trigger_contract'; import { UiActionsExecutionService } from './ui_actions_execution_service'; @@ -67,7 +61,7 @@ export class UiActionsService { this.triggerToActions.set(trigger.id, []); }; - public readonly getTrigger = (triggerId: T): TriggerContract => { + public readonly getTrigger = (triggerId: string): TriggerContract => { const trigger = this.triggers.get(triggerId); if (!trigger) { @@ -103,7 +97,7 @@ export class UiActionsService { return this.actions.has(actionId); }; - public readonly attachAction = (triggerId: T, actionId: string): void => { + public readonly attachAction = (triggerId: string, actionId: string): void => { const trigger = this.triggers.get(triggerId); if (!trigger) { @@ -119,7 +113,7 @@ export class UiActionsService { } }; - public readonly detachAction = (triggerId: TriggerId, actionId: string) => { + public readonly detachAction = (triggerId: string, actionId: string) => { const trigger = this.triggers.get(triggerId); if (!trigger) { @@ -139,14 +133,10 @@ export class UiActionsService { /** * `addTriggerAction` is similar to `attachAction` as it attaches action to a * trigger, but it also registers the action, if it has not been registered, yet. - * - * `addTriggerAction` also infers better typing of the `action` argument. */ - public readonly addTriggerAction = ( - triggerId: T, - // The action can accept partial or no context, but if it needs context not provided - // by this type of trigger, typescript will complain. yay! - action: ActionDefinition | Action // TODO: remove `Action` https://github.com/elastic/kibana/issues/74501 + public readonly addTriggerAction = ( + triggerId: string, + action: ActionDefinition // TODO: remove `Action` https://github.com/elastic/kibana/issues/74501 ): void => { if (!this.actions.has(action.id)) this.registerAction(action); this.attachAction(triggerId, action.id); @@ -162,9 +152,7 @@ export class UiActionsService { return this.actions.get(id) as ActionInternal; }; - public readonly getTriggerActions = ( - triggerId: T - ): Array> => { + public readonly getTriggerActions = (triggerId: string): Action[] => { // This line checks if trigger exists, otherwise throws. this.getTrigger!(triggerId); @@ -174,13 +162,13 @@ export class UiActionsService { .map((actionId) => this.actions.get(actionId) as ActionInternal) .filter(Boolean); - return actions as Array>>; + return actions as Action[]; }; - public readonly getTriggerCompatibleActions = async ( - triggerId: T, - context: TriggerContextMapping[T] - ): Promise>> => { + public readonly getTriggerCompatibleActions = async ( + triggerId: string, + context: object + ): Promise => { const actions = this.getTriggerActions!(triggerId); const isCompatibles = await Promise.all( actions.map((action) => @@ -191,8 +179,7 @@ export class UiActionsService { ) ); return actions.reduce( - (acc: Array>, action, i) => - isCompatibles[i] ? [...acc, action] : acc, + (acc: Action[], action, i) => (isCompatibles[i] ? [...acc, action] : acc), [] ); }; @@ -202,11 +189,8 @@ export class UiActionsService { * * Use `plugins.uiActions.getTrigger(triggerId).exec(params)` instead. */ - public readonly executeTriggerActions = async ( - triggerId: T, - context: TriggerContext - ) => { - const trigger = this.getTrigger(triggerId); + public readonly executeTriggerActions = async (triggerId: string, context: object) => { + const trigger = this.getTrigger(triggerId); await trigger.exec(context); }; diff --git a/src/plugins/ui_actions/public/tests/execute_trigger_actions.test.ts b/src/plugins/ui_actions/public/tests/execute_trigger_actions.test.ts index 51ba165ba730b..6f8a45cc2e40a 100644 --- a/src/plugins/ui_actions/public/tests/execute_trigger_actions.test.ts +++ b/src/plugins/ui_actions/public/tests/execute_trigger_actions.test.ts @@ -21,7 +21,6 @@ import { Action, createAction } from '../actions'; import { openContextMenu } from '../context_menu'; import { uiActionsPluginMock } from '../mocks'; import { Trigger } from '../triggers'; -import { TriggerId, ActionType } from '../types'; import { waitFor } from '@testing-library/dom'; jest.mock('../context_menu'); @@ -31,17 +30,13 @@ const openContextMenuSpy = (openContextMenu as any) as jest.SpyInstance; const CONTACT_USER_TRIGGER = 'CONTACT_USER_TRIGGER'; -// Casting to ActionType is a hack - in a real situation use -// declare module and add this id to ActionContextMapping. -const TEST_ACTION_TYPE = 'TEST_ACTION_TYPE' as ActionType; - function createTestAction( type: string, checkCompatibility: (context: C) => boolean, autoExecutable = false ): Action { - return createAction({ - type: type as ActionType, + return createAction({ + type, id: type, isCompatible: (context: C) => Promise.resolve(checkCompatibility(context)), execute: (context) => executeFn(context), @@ -67,7 +62,7 @@ beforeEach(reset); test('executes a single action mapped to a trigger', async () => { const { setup, doStart } = uiActions; const trigger: Trigger = { - id: 'MY-TRIGGER' as TriggerId, + id: 'MY-TRIGGER', title: 'My trigger', }; const action = createTestAction('test1', () => true); @@ -77,7 +72,7 @@ test('executes a single action mapped to a trigger', async () => { const context = {}; const start = doStart(); - await start.executeTriggerActions('MY-TRIGGER' as TriggerId, context); + await start.executeTriggerActions('MY-TRIGGER', context); jest.runAllTimers(); @@ -88,7 +83,7 @@ test('executes a single action mapped to a trigger', async () => { test("doesn't throw an error if there are no compatible actions to execute", async () => { const { setup, doStart } = uiActions; const trigger: Trigger = { - id: 'MY-TRIGGER' as TriggerId, + id: 'MY-TRIGGER', title: 'My trigger', }; @@ -96,15 +91,13 @@ test("doesn't throw an error if there are no compatible actions to execute", asy const context = {}; const start = doStart(); - await expect( - start.executeTriggerActions('MY-TRIGGER' as TriggerId, context) - ).resolves.toBeUndefined(); + await expect(start.executeTriggerActions('MY-TRIGGER', context)).resolves.toBeUndefined(); }); test('does not execute an incompatible action', async () => { const { setup, doStart } = uiActions; const trigger: Trigger = { - id: 'MY-TRIGGER' as TriggerId, + id: 'MY-TRIGGER', title: 'My trigger', }; const action = createTestAction<{ name: string }>( @@ -119,7 +112,7 @@ test('does not execute an incompatible action', async () => { const context = { name: 'executeme', }; - await start.executeTriggerActions('MY-TRIGGER' as TriggerId, context); + await start.executeTriggerActions('MY-TRIGGER', context); jest.runAllTimers(); @@ -129,7 +122,7 @@ test('does not execute an incompatible action', async () => { test('shows a context menu when more than one action is mapped to a trigger', async () => { const { setup, doStart } = uiActions; const trigger: Trigger = { - id: 'MY-TRIGGER' as TriggerId, + id: 'MY-TRIGGER', title: 'My trigger', }; const action1 = createTestAction('test1', () => true); @@ -143,7 +136,7 @@ test('shows a context menu when more than one action is mapped to a trigger', as const start = doStart(); const context = {}; - await start.getTrigger('MY-TRIGGER' as TriggerId)!.exec(context); + await start.getTrigger('MY-TRIGGER')!.exec(context); jest.runAllTimers(); @@ -156,7 +149,7 @@ test('shows a context menu when more than one action is mapped to a trigger', as test('shows a context menu when there is only one action mapped to a trigger and "alwaysShowPopup" is set', async () => { const { setup, doStart } = uiActions; const trigger: Trigger = { - id: 'MY-TRIGGER' as TriggerId, + id: 'MY-TRIGGER', title: 'My trigger', }; const action1 = createTestAction('test1', () => true); @@ -168,7 +161,7 @@ test('shows a context menu when there is only one action mapped to a trigger and const start = doStart(); const context = {}; - await start.getTrigger('MY-TRIGGER' as TriggerId)!.exec(context, true); + await start.getTrigger('MY-TRIGGER')!.exec(context, true); jest.runAllTimers(); @@ -181,7 +174,7 @@ test('shows a context menu when there is only one action mapped to a trigger and test('passes whole action context to isCompatible()', async () => { const { setup, doStart } = uiActions; const trigger = { - id: 'MY-TRIGGER' as TriggerId, + id: 'MY-TRIGGER', title: 'My trigger', }; const action = createTestAction<{ foo: string }>('test', ({ foo }) => { @@ -195,14 +188,14 @@ test('passes whole action context to isCompatible()', async () => { const start = doStart(); const context = { foo: 'bar' }; - await start.executeTriggerActions('MY-TRIGGER' as TriggerId, context); + await start.executeTriggerActions('MY-TRIGGER', context); jest.runAllTimers(); }); test("doesn't show a context menu for auto executable actions", async () => { const { setup, doStart } = uiActions; const trigger: Trigger = { - id: 'MY-TRIGGER' as TriggerId, + id: 'MY-TRIGGER', title: 'My trigger', }; const action1 = createTestAction('test1', () => true, true); @@ -216,7 +209,7 @@ test("doesn't show a context menu for auto executable actions", async () => { const start = doStart(); const context = {}; - await start.executeTriggerActions('MY-TRIGGER' as TriggerId, context); + await start.executeTriggerActions('MY-TRIGGER', context); jest.runAllTimers(); @@ -229,7 +222,7 @@ test("doesn't show a context menu for auto executable actions", async () => { test('passes trigger into execute', async () => { const { setup, doStart } = uiActions; const trigger = { - id: 'MY-TRIGGER' as TriggerId, + id: 'MY-TRIGGER', title: 'My trigger', }; const action = createTestAction<{ foo: string }>('test', () => true); @@ -240,7 +233,7 @@ test('passes trigger into execute', async () => { const start = doStart(); const context = { foo: 'bar' }; - await start.executeTriggerActions('MY-TRIGGER' as TriggerId, context); + await start.executeTriggerActions('MY-TRIGGER', context); jest.runAllTimers(); expect(executeFn).toBeCalledWith({ ...context, diff --git a/src/plugins/ui_actions/public/tests/get_trigger_actions.test.ts b/src/plugins/ui_actions/public/tests/get_trigger_actions.test.ts index 55ccac42ff255..ddae251bb83d2 100644 --- a/src/plugins/ui_actions/public/tests/get_trigger_actions.test.ts +++ b/src/plugins/ui_actions/public/tests/get_trigger_actions.test.ts @@ -19,17 +19,16 @@ import { ActionInternal, Action } from '../actions'; import { uiActionsPluginMock } from '../mocks'; -import { TriggerId, ActionType } from '../types'; const action1: Action = { id: 'action1', order: 1, - type: 'type1' as ActionType, + type: 'type1', } as any; const action2: Action = { id: 'action2', order: 2, - type: 'type2' as ActionType, + type: 'type2', } as any; test('returns actions set on trigger', () => { @@ -38,24 +37,24 @@ test('returns actions set on trigger', () => { setup.registerAction(action2); setup.registerTrigger({ description: 'foo', - id: 'trigger' as TriggerId, + id: 'trigger', title: 'baz', }); const start = doStart(); - const list0 = start.getTriggerActions('trigger' as TriggerId); + const list0 = start.getTriggerActions('trigger'); expect(list0).toHaveLength(0); - setup.addTriggerAction('trigger' as TriggerId, action1); - const list1 = start.getTriggerActions('trigger' as TriggerId); + setup.addTriggerAction('trigger', action1); + const list1 = start.getTriggerActions('trigger'); expect(list1).toHaveLength(1); expect(list1[0]).toBeInstanceOf(ActionInternal); expect(list1[0].id).toBe(action1.id); - setup.addTriggerAction('trigger' as TriggerId, action2); - const list2 = start.getTriggerActions('trigger' as TriggerId); + setup.addTriggerAction('trigger', action2); + const list2 = start.getTriggerActions('trigger'); expect(list2).toHaveLength(2); expect(!!list2.find(({ id }: any) => id === 'action1')).toBe(true); diff --git a/src/plugins/ui_actions/public/tests/get_trigger_compatible_actions.test.ts b/src/plugins/ui_actions/public/tests/get_trigger_compatible_actions.test.ts index 21dd17ed82e3f..400a9453fe267 100644 --- a/src/plugins/ui_actions/public/tests/get_trigger_compatible_actions.test.ts +++ b/src/plugins/ui_actions/public/tests/get_trigger_compatible_actions.test.ts @@ -21,23 +21,23 @@ import { uiActionsPluginMock } from '../mocks'; import { createHelloWorldAction } from '../tests/test_samples'; import { Action, createAction } from '../actions'; import { Trigger } from '../triggers'; -import { TriggerId, ActionType } from '../types'; -let action: Action<{ name: string }, ActionType>; +let action: Action<{ name: string }>; let uiActions: ReturnType; beforeEach(() => { uiActions = uiActionsPluginMock.createPlugin(); action = createAction({ - type: 'test' as ActionType, + id: 'test', + type: 'test', execute: () => Promise.resolve(), }); uiActions.setup.registerAction(action); uiActions.setup.registerTrigger({ - id: 'trigger' as TriggerId, + id: 'trigger', title: 'trigger', }); - uiActions.setup.addTriggerAction('trigger' as TriggerId, action); + uiActions.setup.addTriggerAction('trigger', action); }); test('can register action', async () => { @@ -54,14 +54,14 @@ test('getTriggerCompatibleActions returns attached actions', async () => { setup.registerAction(helloWorldAction); const testTrigger: Trigger = { - id: 'MY-TRIGGER' as TriggerId, + id: 'MY-TRIGGER', title: 'My trigger', }; setup.registerTrigger(testTrigger); - setup.addTriggerAction('MY-TRIGGER' as TriggerId, helloWorldAction); + setup.addTriggerAction('MY-TRIGGER', helloWorldAction); const start = doStart(); - const actions = await start.getTriggerCompatibleActions('MY-TRIGGER' as TriggerId, {}); + const actions = await start.getTriggerCompatibleActions('MY-TRIGGER', {}); expect(actions.length).toBe(1); expect(actions[0].id).toBe(helloWorldAction.id); @@ -70,7 +70,8 @@ test('getTriggerCompatibleActions returns attached actions', async () => { test('filters out actions not applicable based on the context', async () => { const { setup, doStart } = uiActions; const action1 = createAction({ - type: 'test1' as ActionType, + id: 'test1', + type: 'test1', isCompatible: async (context: { accept: boolean }) => { return Promise.resolve(context.accept); }, @@ -78,7 +79,7 @@ test('filters out actions not applicable based on the context', async () => { }); const testTrigger: Trigger = { - id: 'MY-TRIGGER2' as TriggerId, + id: 'MY-TRIGGER2', title: 'My trigger', }; @@ -100,15 +101,15 @@ test(`throws an error with an invalid trigger ID`, async () => { const { doStart } = uiActions; const start = doStart(); - await expect( - start.getTriggerCompatibleActions('I do not exist' as TriggerId, {}) - ).rejects.toMatchObject(new Error('Trigger [triggerId = I do not exist] does not exist.')); + await expect(start.getTriggerCompatibleActions('I do not exist', {})).rejects.toMatchObject( + new Error('Trigger [triggerId = I do not exist] does not exist.') + ); }); test(`with a trigger mapping that maps to an non-existing action returns empty list`, async () => { const { setup, doStart } = uiActions; const testTrigger: Trigger = { - id: '123' as TriggerId, + id: '123', title: '123', }; setup.registerTrigger(testTrigger); diff --git a/src/plugins/ui_actions/public/tests/test_samples/hello_world_action.tsx b/src/plugins/ui_actions/public/tests/test_samples/hello_world_action.tsx index a4cfe172dd109..f9e1c0261e1a1 100644 --- a/src/plugins/ui_actions/public/tests/test_samples/hello_world_action.tsx +++ b/src/plugins/ui_actions/public/tests/test_samples/hello_world_action.tsx @@ -20,9 +20,8 @@ import React from 'react'; import { EuiFlexGroup, EuiFlexItem, EuiBadge, EuiFlyoutBody } from '@elastic/eui'; import { CoreStart } from 'src/core/public'; -import { createAction, ActionByType } from '../../actions'; +import { createAction, Action } from '../../actions'; import { toMountPoint, reactToUiComponent } from '../../../../kibana_react/public'; -import { ActionType } from '../../types'; const ReactMenuItem: React.FC = () => { return ( @@ -37,14 +36,11 @@ const ReactMenuItem: React.FC = () => { const UiMenuItem = reactToUiComponent(ReactMenuItem); -// Casting to ActionType is a hack - in a real situation use -// declare module and add this id to ActionContextMapping. -export const ACTION_HELLO_WORLD = 'ACTION_HELLO_WORLD' as ActionType; +export const ACTION_HELLO_WORLD = 'ACTION_HELLO_WORLD'; -export function createHelloWorldAction( - overlays: CoreStart['overlays'] -): ActionByType { - return createAction({ +export function createHelloWorldAction(overlays: CoreStart['overlays']): Action { + return createAction({ + id: ACTION_HELLO_WORLD, type: ACTION_HELLO_WORLD, getIconType: () => 'lock', MenuItem: UiMenuItem, diff --git a/src/plugins/ui_actions/public/triggers/default_trigger.ts b/src/plugins/ui_actions/public/triggers/default_trigger.ts index 74be0243bdac5..107cb3bda5b7d 100644 --- a/src/plugins/ui_actions/public/triggers/default_trigger.ts +++ b/src/plugins/ui_actions/public/triggers/default_trigger.ts @@ -20,7 +20,7 @@ import { Trigger } from '.'; export const DEFAULT_TRIGGER = ''; -export const defaultTrigger: Trigger<''> = { +export const defaultTrigger: Trigger = { id: DEFAULT_TRIGGER, title: 'Unknown', description: 'Unknown trigger.', diff --git a/src/plugins/ui_actions/public/triggers/row_click_trigger.ts b/src/plugins/ui_actions/public/triggers/row_click_trigger.ts index 0fc261b3e1fb3..3d47e017675c3 100644 --- a/src/plugins/ui_actions/public/triggers/row_click_trigger.ts +++ b/src/plugins/ui_actions/public/triggers/row_click_trigger.ts @@ -23,7 +23,7 @@ import { Datatable } from '../../../expressions'; export const ROW_CLICK_TRIGGER = 'ROW_CLICK_TRIGGER'; -export const rowClickTrigger: Trigger<'ROW_CLICK_TRIGGER'> = { +export const rowClickTrigger: Trigger = { id: ROW_CLICK_TRIGGER, title: i18n.translate('uiActions.triggers.rowClickTitle', { defaultMessage: 'Table row click', diff --git a/src/plugins/ui_actions/public/triggers/trigger.ts b/src/plugins/ui_actions/public/triggers/trigger.ts index 1b1231c132dde..b4def56d21395 100644 --- a/src/plugins/ui_actions/public/triggers/trigger.ts +++ b/src/plugins/ui_actions/public/triggers/trigger.ts @@ -17,8 +17,6 @@ * under the License. */ -import { TriggerContextMapping, TriggerId } from '../types'; - /** * This is a convenience interface used to register a *trigger*. * @@ -30,11 +28,11 @@ import { TriggerContextMapping, TriggerId } from '../types'; * trigger is *called* it first displays a context menu for user to pick a * single action to execute. */ -export interface Trigger { +export interface Trigger { /** * Unique name of the trigger as identified in `ui_actions` plugin trigger registry. */ - id: ID; + id: string; /** * User friendly name of the trigger. @@ -46,5 +44,3 @@ export interface Trigger { */ description?: string; } - -export type TriggerContext = T extends TriggerId ? TriggerContextMapping[T] : never; diff --git a/src/plugins/ui_actions/public/triggers/trigger_contract.ts b/src/plugins/ui_actions/public/triggers/trigger_contract.ts index 7e7fba0ba80d3..95e856f4d3eaa 100644 --- a/src/plugins/ui_actions/public/triggers/trigger_contract.ts +++ b/src/plugins/ui_actions/public/triggers/trigger_contract.ts @@ -18,16 +18,15 @@ */ import { TriggerInternal } from './trigger_internal'; -import { TriggerId, TriggerContextMapping } from '../types'; /** * This is a public representation of a trigger that is provided to other plugins. */ -export class TriggerContract { +export class TriggerContract { /** * Unique name of the trigger as identified in `ui_actions` plugin trigger registry. */ - public readonly id: T; + public readonly id: string; /** * User friendly name of the trigger. @@ -39,7 +38,7 @@ export class TriggerContract { */ public readonly description?: string; - constructor(private readonly internal: TriggerInternal) { + constructor(private readonly internal: TriggerInternal) { this.id = this.internal.trigger.id; this.title = this.internal.trigger.title; this.description = this.internal.trigger.description; @@ -48,7 +47,7 @@ export class TriggerContract { /** * Use this method to execute action attached to this trigger. */ - public readonly exec = async (context: TriggerContextMapping[T], alwaysShowPopup?: boolean) => { + public readonly exec = async (context: Context, alwaysShowPopup?: boolean) => { await this.internal.execute(context, alwaysShowPopup); }; } diff --git a/src/plugins/ui_actions/public/triggers/trigger_internal.ts b/src/plugins/ui_actions/public/triggers/trigger_internal.ts index fd43a020504c0..e78b2beaabc8e 100644 --- a/src/plugins/ui_actions/public/triggers/trigger_internal.ts +++ b/src/plugins/ui_actions/public/triggers/trigger_internal.ts @@ -20,18 +20,17 @@ import { Trigger } from './trigger'; import { TriggerContract } from './trigger_contract'; import { UiActionsService } from '../service'; -import { TriggerId, TriggerContextMapping } from '../types'; /** * Internal representation of a trigger kept for consumption only internally * within `ui_actions` plugin. */ -export class TriggerInternal { - public readonly contract = new TriggerContract(this); +export class TriggerInternal { + public readonly contract: TriggerContract = new TriggerContract(this); - constructor(public readonly service: UiActionsService, public readonly trigger: Trigger) {} + constructor(public readonly service: UiActionsService, public readonly trigger: Trigger) {} - public async execute(context: TriggerContextMapping[T], alwaysShowPopup?: boolean) { + public async execute(context: Context, alwaysShowPopup?: boolean) { const triggerId = this.trigger.id; const actions = await this.service.getTriggerCompatibleActions!(triggerId, context); diff --git a/src/plugins/ui_actions/public/triggers/visualize_field_trigger.ts b/src/plugins/ui_actions/public/triggers/visualize_field_trigger.ts index 4f3c5f613eddf..0c85f4d38dee4 100644 --- a/src/plugins/ui_actions/public/triggers/visualize_field_trigger.ts +++ b/src/plugins/ui_actions/public/triggers/visualize_field_trigger.ts @@ -20,7 +20,7 @@ import { Trigger } from '.'; export const VISUALIZE_FIELD_TRIGGER = 'VISUALIZE_FIELD_TRIGGER'; -export const visualizeFieldTrigger: Trigger<'VISUALIZE_FIELD_TRIGGER'> = { +export const visualizeFieldTrigger: Trigger = { id: VISUALIZE_FIELD_TRIGGER, title: 'Visualize field', description: 'Triggered when user wants to visualize a field.', diff --git a/src/plugins/ui_actions/public/triggers/visualize_geo_field_trigger.ts b/src/plugins/ui_actions/public/triggers/visualize_geo_field_trigger.ts index 5582b3b42660c..0ee0be3a644d4 100644 --- a/src/plugins/ui_actions/public/triggers/visualize_geo_field_trigger.ts +++ b/src/plugins/ui_actions/public/triggers/visualize_geo_field_trigger.ts @@ -20,7 +20,7 @@ import { Trigger } from '.'; export const VISUALIZE_GEO_FIELD_TRIGGER = 'VISUALIZE_GEO_FIELD_TRIGGER'; -export const visualizeGeoFieldTrigger: Trigger<'VISUALIZE_GEO_FIELD_TRIGGER'> = { +export const visualizeGeoFieldTrigger: Trigger = { id: VISUALIZE_GEO_FIELD_TRIGGER, title: 'Visualize Geo field', description: 'Triggered when user wants to visualize a geo field.', diff --git a/src/plugins/ui_actions/public/types.ts b/src/plugins/ui_actions/public/types.ts index 62fac245514cd..dc3b25f69f513 100644 --- a/src/plugins/ui_actions/public/types.ts +++ b/src/plugins/ui_actions/public/types.ts @@ -19,17 +19,10 @@ import { ActionInternal } from './actions/action_internal'; import { TriggerInternal } from './triggers/trigger_internal'; -import { - ROW_CLICK_TRIGGER, - VISUALIZE_FIELD_TRIGGER, - VISUALIZE_GEO_FIELD_TRIGGER, - DEFAULT_TRIGGER, - RowClickContext, -} from './triggers'; -export type TriggerRegistry = Map>; +export type TriggerRegistry = Map>; export type ActionRegistry = Map; -export type TriggerToActionsRegistry = Map; +export type TriggerToActionsRegistry = Map; export interface VisualizeFieldContext { fieldName: string; @@ -37,27 +30,6 @@ export interface VisualizeFieldContext { contextualFields?: string[]; } -export type TriggerId = keyof TriggerContextMapping; - -export type BaseContext = object; -export type TriggerContext = BaseContext; - -export interface TriggerContextMapping { - [DEFAULT_TRIGGER]: TriggerContext; - [ROW_CLICK_TRIGGER]: RowClickContext; - [VISUALIZE_FIELD_TRIGGER]: VisualizeFieldContext; - [VISUALIZE_GEO_FIELD_TRIGGER]: VisualizeFieldContext; -} - -const DEFAULT_ACTION = ''; export const ACTION_VISUALIZE_FIELD = 'ACTION_VISUALIZE_FIELD'; export const ACTION_VISUALIZE_GEO_FIELD = 'ACTION_VISUALIZE_GEO_FIELD'; export const ACTION_VISUALIZE_LENS_FIELD = 'ACTION_VISUALIZE_LENS_FIELD'; -export type ActionType = keyof ActionContextMapping; - -export interface ActionContextMapping { - [DEFAULT_ACTION]: BaseContext; - [ACTION_VISUALIZE_FIELD]: VisualizeFieldContext; - [ACTION_VISUALIZE_GEO_FIELD]: VisualizeFieldContext; - [ACTION_VISUALIZE_LENS_FIELD]: VisualizeFieldContext; -} diff --git a/src/plugins/ui_actions/public/util/presentable.ts b/src/plugins/ui_actions/public/util/presentable.ts index 59440d6c75976..c586a996920ac 100644 --- a/src/plugins/ui_actions/public/util/presentable.ts +++ b/src/plugins/ui_actions/public/util/presentable.ts @@ -22,7 +22,7 @@ import { UiComponent } from 'src/plugins/kibana_utils/public'; /** * Represents something that can be displayed to user in UI. */ -export interface Presentable { +export interface Presentable { /** * ID that uniquely identifies this object. */ @@ -77,11 +77,11 @@ export interface Presentable { readonly grouping?: PresentableGrouping; } -export interface PresentableGroup +export interface PresentableGroup extends Partial< Pick, 'getDisplayName' | 'getDisplayNameTooltip' | 'getIconType' | 'order'> > { id: string; } -export type PresentableGrouping = Array>; +export type PresentableGrouping = Array>; diff --git a/src/plugins/visualizations/public/embeddable/visualize_embeddable.ts b/src/plugins/visualizations/public/embeddable/visualize_embeddable.ts index 5661acc26fdb6..3956f930758d7 100644 --- a/src/plugins/visualizations/public/embeddable/visualize_embeddable.ts +++ b/src/plugins/visualizations/public/embeddable/visualize_embeddable.ts @@ -49,7 +49,6 @@ import { Vis, SerializedVis } from '../vis'; import { getExpressions, getUiActions } from '../services'; import { VIS_EVENT_TO_TRIGGER } from './events'; import { VisualizeEmbeddableFactoryDeps } from './visualize_embeddable_factory'; -import { TriggerId } from '../../../ui_actions/public'; import { SavedObjectAttributes } from '../../../../core/types'; import { SavedVisualizationsLoader } from '../saved_visualizations'; import { VisSavedObject } from '../types'; @@ -414,7 +413,7 @@ export class VisualizeEmbeddable }); }; - public supportedTriggers(): TriggerId[] { + public supportedTriggers(): string[] { return this.vis.type.getSupportedTriggers?.() ?? []; } diff --git a/src/plugins/visualizations/public/vis_types/types.ts b/src/plugins/visualizations/public/vis_types/types.ts index 6ea44dc360559..5b75d065118da 100644 --- a/src/plugins/visualizations/public/vis_types/types.ts +++ b/src/plugins/visualizations/public/vis_types/types.ts @@ -23,7 +23,6 @@ import { Adapters } from 'src/plugins/inspector'; import { IndexPattern } from 'src/plugins/data/public'; import { VisEditorConstructor } from 'src/plugins/visualize/public'; import { ISchemas } from 'src/plugins/vis_default_editor/public'; -import { TriggerContextMapping } from '../../../ui_actions/public'; import { Vis, VisParams, VisToExpressionAst, VisualizationControllerConstructor } from '../types'; export interface VisTypeOptions { @@ -64,7 +63,7 @@ export interface VisType { /** * If given, it will return the supported triggers for this vis. */ - readonly getSupportedTriggers?: () => Array; + readonly getSupportedTriggers?: () => string[]; /** * Some visualizations are created without SearchSource and may change the used indexes during the visualization configuration. diff --git a/src/plugins/visualizations/public/vis_types/vis_type_alias_registry.ts b/src/plugins/visualizations/public/vis_types/vis_type_alias_registry.ts index fc5dfd4e123fb..c05f42d684dbe 100644 --- a/src/plugins/visualizations/public/vis_types/vis_type_alias_registry.ts +++ b/src/plugins/visualizations/public/vis_types/vis_type_alias_registry.ts @@ -16,7 +16,6 @@ * specific language governing permissions and limitations * under the License. */ -import { TriggerContextMapping } from '../../../ui_actions/public'; export interface VisualizationListItem { editUrl: string; @@ -28,7 +27,7 @@ export interface VisualizationListItem { savedObjectType: string; title: string; description?: string; - getSupportedTriggers?: () => Array; + getSupportedTriggers?: () => string[]; typeTitle: string; image?: string; } @@ -59,7 +58,7 @@ export interface VisTypeAlias { description: string; note?: string; disabled?: boolean; - getSupportedTriggers?: () => Array; + getSupportedTriggers?: () => string[]; stage: 'experimental' | 'beta' | 'production'; appExtensions?: { diff --git a/src/plugins/visualize/public/actions/visualize_field_action.ts b/src/plugins/visualize/public/actions/visualize_field_action.ts index e570ed5e49e6a..a825ad9e60641 100644 --- a/src/plugins/visualize/public/actions/visualize_field_action.ts +++ b/src/plugins/visualize/public/actions/visualize_field_action.ts @@ -32,7 +32,7 @@ import { import { VISUALIZE_APP_URL_GENERATOR, VisualizeUrlGeneratorState } from '../url_generator'; import { AGGS_TERMS_SIZE_SETTING } from '../../common/constants'; -export const visualizeFieldAction = createAction({ +export const visualizeFieldAction = createAction({ type: ACTION_VISUALIZE_FIELD, id: ACTION_VISUALIZE_FIELD, getDisplayName: () => diff --git a/test/plugin_functional/plugins/kbn_sample_panel_action/public/sample_panel_action.tsx b/test/plugin_functional/plugins/kbn_sample_panel_action/public/sample_panel_action.tsx index 18e45c22abaca..1d79fcae3c1a3 100644 --- a/test/plugin_functional/plugins/kbn_sample_panel_action/public/sample_panel_action.tsx +++ b/test/plugin_functional/plugins/kbn_sample_panel_action/public/sample_panel_action.tsx @@ -21,19 +21,18 @@ import { EuiFlyoutBody, EuiFlyoutHeader, EuiTitle } from '@elastic/eui'; import React from 'react'; import { IEmbeddable } from '../../../../../src/plugins/embeddable/public'; -import { createAction, ActionType } from '../../../../../src/plugins/ui_actions/public'; +import { createAction } from '../../../../../src/plugins/ui_actions/public'; import { toMountPoint } from '../../../../../src/plugins/kibana_react/public'; -// Casting to ActionType is a hack - in a real situation use -// declare module and add this id to ActionContextMapping. -export const SAMPLE_PANEL_ACTION = 'samplePanelAction' as ActionType; +export const SAMPLE_PANEL_ACTION = 'samplePanelAction'; export interface SamplePanelActionContext { embeddable: IEmbeddable; } export function createSamplePanelAction(getStartServices: CoreSetup['getStartServices']) { - return createAction({ + return createAction({ + id: SAMPLE_PANEL_ACTION, type: SAMPLE_PANEL_ACTION, getDisplayName: () => 'Sample Panel Action', execute: async ({ embeddable }: SamplePanelActionContext) => { diff --git a/test/plugin_functional/plugins/kbn_sample_panel_action/public/sample_panel_link.ts b/test/plugin_functional/plugins/kbn_sample_panel_action/public/sample_panel_link.ts index faa774b8485b1..ec6a2286ca33f 100644 --- a/test/plugin_functional/plugins/kbn_sample_panel_action/public/sample_panel_link.ts +++ b/test/plugin_functional/plugins/kbn_sample_panel_action/public/sample_panel_link.ts @@ -16,14 +16,13 @@ * specific language governing permissions and limitations * under the License. */ -import { Action, createAction, ActionType } from '../../../../../src/plugins/ui_actions/public'; +import { Action, createAction } from '../../../../../src/plugins/ui_actions/public'; -// Casting to ActionType is a hack - in a real situation use -// declare module and add this id to ActionContextMapping. -export const SAMPLE_PANEL_LINK = 'samplePanelLink' as ActionType; +export const SAMPLE_PANEL_LINK = 'samplePanelLink'; export const createSamplePanelLink = (): Action => - createAction({ + createAction({ + id: SAMPLE_PANEL_LINK, type: SAMPLE_PANEL_LINK, getDisplayName: () => 'Sample panel Link', execute: async () => { diff --git a/x-pack/examples/ui_actions_enhanced_examples/public/drilldowns/app1_hello_world_drilldown/app1_hello_world_drilldown.tsx b/x-pack/examples/ui_actions_enhanced_examples/public/drilldowns/app1_hello_world_drilldown/app1_hello_world_drilldown.tsx index 25de2f5953f31..fd1c708b80bf2 100644 --- a/x-pack/examples/ui_actions_enhanced_examples/public/drilldowns/app1_hello_world_drilldown/app1_hello_world_drilldown.tsx +++ b/x-pack/examples/ui_actions_enhanced_examples/public/drilldowns/app1_hello_world_drilldown/app1_hello_world_drilldown.tsx @@ -23,7 +23,7 @@ export type CollectConfigProps = CollectConfigPropsBase { +export class App1HelloWorldDrilldown implements Drilldown { public readonly id = APP1_HELLO_WORLD_DRILLDOWN; public readonly order = 8; diff --git a/x-pack/examples/ui_actions_enhanced_examples/public/drilldowns/app1_to_dashboard_drilldown/app1_to_dashboard_drilldown.ts b/x-pack/examples/ui_actions_enhanced_examples/public/drilldowns/app1_to_dashboard_drilldown/app1_to_dashboard_drilldown.ts index 058b52c78b427..a6c3ce652f2c9 100644 --- a/x-pack/examples/ui_actions_enhanced_examples/public/drilldowns/app1_to_dashboard_drilldown/app1_to_dashboard_drilldown.ts +++ b/x-pack/examples/ui_actions_enhanced_examples/public/drilldowns/app1_to_dashboard_drilldown/app1_to_dashboard_drilldown.ts @@ -13,13 +13,12 @@ import { KibanaURL } from '../../../../../../src/plugins/share/public'; export const APP1_TO_DASHBOARD_DRILLDOWN = 'APP1_TO_DASHBOARD_DRILLDOWN'; -type Trigger = typeof SAMPLE_APP1_CLICK_TRIGGER; type Context = SampleApp1ClickContext; -export class App1ToDashboardDrilldown extends AbstractDashboardDrilldown { +export class App1ToDashboardDrilldown extends AbstractDashboardDrilldown { public readonly id = APP1_TO_DASHBOARD_DRILLDOWN; - public readonly supportedTriggers = () => [SAMPLE_APP1_CLICK_TRIGGER] as Trigger[]; + public readonly supportedTriggers = () => [SAMPLE_APP1_CLICK_TRIGGER]; protected async getURL(config: Config, context: Context): Promise { const path = await this.urlGenerator.createUrl({ diff --git a/x-pack/examples/ui_actions_enhanced_examples/public/drilldowns/app2_to_dashboard_drilldown/app2_to_dashboard_drilldown.ts b/x-pack/examples/ui_actions_enhanced_examples/public/drilldowns/app2_to_dashboard_drilldown/app2_to_dashboard_drilldown.ts index 33bf54d4b4cc2..9a59a715be5f8 100644 --- a/x-pack/examples/ui_actions_enhanced_examples/public/drilldowns/app2_to_dashboard_drilldown/app2_to_dashboard_drilldown.ts +++ b/x-pack/examples/ui_actions_enhanced_examples/public/drilldowns/app2_to_dashboard_drilldown/app2_to_dashboard_drilldown.ts @@ -13,13 +13,12 @@ import { KibanaURL } from '../../../../../../src/plugins/share/public'; export const APP2_TO_DASHBOARD_DRILLDOWN = 'APP2_TO_DASHBOARD_DRILLDOWN'; -type Trigger = typeof SAMPLE_APP2_CLICK_TRIGGER; type Context = SampleApp2ClickContext; -export class App2ToDashboardDrilldown extends AbstractDashboardDrilldown { +export class App2ToDashboardDrilldown extends AbstractDashboardDrilldown { public readonly id = APP2_TO_DASHBOARD_DRILLDOWN; - public readonly supportedTriggers = () => [SAMPLE_APP2_CLICK_TRIGGER] as Trigger[]; + public readonly supportedTriggers = () => [SAMPLE_APP2_CLICK_TRIGGER]; protected async getURL(config: Config, context: Context): Promise { const path = await this.urlGenerator.createUrl({ diff --git a/x-pack/examples/ui_actions_enhanced_examples/public/drilldowns/dashboard_hello_world_drilldown/index.tsx b/x-pack/examples/ui_actions_enhanced_examples/public/drilldowns/dashboard_hello_world_drilldown/index.tsx index 50ad350cd90b9..8c90b38358fd6 100644 --- a/x-pack/examples/ui_actions_enhanced_examples/public/drilldowns/dashboard_hello_world_drilldown/index.tsx +++ b/x-pack/examples/ui_actions_enhanced_examples/public/drilldowns/dashboard_hello_world_drilldown/index.tsx @@ -23,8 +23,7 @@ export type Config = { const SAMPLE_DASHBOARD_HELLO_WORLD_DRILLDOWN = 'SAMPLE_DASHBOARD_HELLO_WORLD_DRILLDOWN'; -export class DashboardHelloWorldDrilldown - implements Drilldown { +export class DashboardHelloWorldDrilldown implements Drilldown { public readonly id = SAMPLE_DASHBOARD_HELLO_WORLD_DRILLDOWN; public readonly order = 6; @@ -33,7 +32,7 @@ export class DashboardHelloWorldDrilldown public readonly euiIcon = 'cheer'; - supportedTriggers(): Array { + supportedTriggers(): string[] { return [VALUE_CLICK_TRIGGER, SELECT_RANGE_TRIGGER]; } diff --git a/x-pack/examples/ui_actions_enhanced_examples/public/drilldowns/dashboard_hello_world_only_range_select_drilldown/index.tsx b/x-pack/examples/ui_actions_enhanced_examples/public/drilldowns/dashboard_hello_world_only_range_select_drilldown/index.tsx index 4e5b3187af42b..cac454d747318 100644 --- a/x-pack/examples/ui_actions_enhanced_examples/public/drilldowns/dashboard_hello_world_only_range_select_drilldown/index.tsx +++ b/x-pack/examples/ui_actions_enhanced_examples/public/drilldowns/dashboard_hello_world_only_range_select_drilldown/index.tsx @@ -23,7 +23,7 @@ const SAMPLE_DASHBOARD_HELLO_WORLD_DRILLDOWN_ONLY_RANGE_SELECT = 'SAMPLE_DASHBOARD_HELLO_WORLD_DRILLDOWN_ONLY_RANGE_SELECT'; export class DashboardHelloWorldOnlyRangeSelectDrilldown - implements Drilldown { + implements Drilldown { public readonly id = SAMPLE_DASHBOARD_HELLO_WORLD_DRILLDOWN_ONLY_RANGE_SELECT; public readonly order = 7; @@ -57,7 +57,7 @@ export class DashboardHelloWorldOnlyRangeSelectDrilldown public readonly isConfigValid = ( config: Config, - context: BaseActionFactoryContext + context: BaseActionFactoryContext ): config is Config => { // eslint-disable-next-line no-console console.log('Showcasing, that can access action factory context:', context); diff --git a/x-pack/examples/ui_actions_enhanced_examples/public/drilldowns/dashboard_to_discover_drilldown/drilldown.tsx b/x-pack/examples/ui_actions_enhanced_examples/public/drilldowns/dashboard_to_discover_drilldown/drilldown.tsx index 2f161efe6f388..d876143a036fd 100644 --- a/x-pack/examples/ui_actions_enhanced_examples/public/drilldowns/dashboard_to_discover_drilldown/drilldown.tsx +++ b/x-pack/examples/ui_actions_enhanced_examples/public/drilldowns/dashboard_to_discover_drilldown/drilldown.tsx @@ -13,7 +13,10 @@ import { CollectConfigContainer } from './collect_config_container'; import { SAMPLE_DASHBOARD_TO_DISCOVER_DRILLDOWN } from './constants'; import { UiActionsEnhancedDrilldownDefinition as Drilldown } from '../../../../../plugins/ui_actions_enhanced/public'; import { txtGoToDiscover } from './i18n'; -import { APPLY_FILTER_TRIGGER } from '../../../../../../src/plugins/data/public'; +import { + ApplyGlobalFilterActionContext, + APPLY_FILTER_TRIGGER, +} from '../../../../../../src/plugins/data/public'; const isOutputWithIndexPatterns = ( output: unknown @@ -27,7 +30,7 @@ export interface Params { } export class DashboardToDiscoverDrilldown - implements Drilldown { + implements Drilldown { constructor(protected readonly params: Params) {} public readonly id = SAMPLE_DASHBOARD_TO_DISCOVER_DRILLDOWN; diff --git a/x-pack/examples/ui_actions_enhanced_examples/public/triggers/sample_app1_trigger.ts b/x-pack/examples/ui_actions_enhanced_examples/public/triggers/sample_app1_trigger.ts index 93a985626c6cd..aaec3f6b16ea5 100644 --- a/x-pack/examples/ui_actions_enhanced_examples/public/triggers/sample_app1_trigger.ts +++ b/x-pack/examples/ui_actions_enhanced_examples/public/triggers/sample_app1_trigger.ts @@ -8,18 +8,12 @@ import { Trigger } from '../../../../../src/plugins/ui_actions/public'; export const SAMPLE_APP1_CLICK_TRIGGER = 'SAMPLE_APP1_CLICK_TRIGGER'; -export const sampleApp1ClickTrigger: Trigger<'SAMPLE_APP1_CLICK_TRIGGER'> = { +export const sampleApp1ClickTrigger: Trigger = { id: SAMPLE_APP1_CLICK_TRIGGER, title: 'App 1 trigger fired on click', description: 'Could be a click on a ML job in ML app.', }; -declare module '../../../../../src/plugins/ui_actions/public' { - export interface TriggerContextMapping { - [SAMPLE_APP1_CLICK_TRIGGER]: SampleApp1ClickContext; - } -} - export interface SampleApp1ClickContext { job: SampleMlJob; } diff --git a/x-pack/examples/ui_actions_enhanced_examples/public/triggers/sample_app2_trigger.ts b/x-pack/examples/ui_actions_enhanced_examples/public/triggers/sample_app2_trigger.ts index 664c99afc94a5..f8e214cf7d440 100644 --- a/x-pack/examples/ui_actions_enhanced_examples/public/triggers/sample_app2_trigger.ts +++ b/x-pack/examples/ui_actions_enhanced_examples/public/triggers/sample_app2_trigger.ts @@ -8,18 +8,12 @@ import { Trigger } from '../../../../../src/plugins/ui_actions/public'; export const SAMPLE_APP2_CLICK_TRIGGER = 'SAMPLE_APP2_CLICK_TRIGGER'; -export const sampleApp2ClickTrigger: Trigger<'SAMPLE_APP2_CLICK_TRIGGER'> = { +export const sampleApp2ClickTrigger: Trigger = { id: SAMPLE_APP2_CLICK_TRIGGER, title: 'App 2 trigger fired on click', description: 'Could be a click on an element in Canvas app.', }; -declare module '../../../../../src/plugins/ui_actions/public' { - export interface TriggerContextMapping { - [SAMPLE_APP2_CLICK_TRIGGER]: SampleApp2ClickContext; - } -} - export interface SampleApp2ClickContext { workpadId: string; elementId: string; diff --git a/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/abstract_dashboard_drilldown/abstract_dashboard_drilldown.tsx b/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/abstract_dashboard_drilldown/abstract_dashboard_drilldown.tsx index 451254efd9648..66f64fe95ff53 100644 --- a/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/abstract_dashboard_drilldown/abstract_dashboard_drilldown.tsx +++ b/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/abstract_dashboard_drilldown/abstract_dashboard_drilldown.tsx @@ -8,10 +8,6 @@ import React from 'react'; import { DataPublicPluginStart } from 'src/plugins/data/public'; import { DashboardStart } from 'src/plugins/dashboard/public'; import { reactToUiComponent } from '../../../../../../../src/plugins/kibana_react/public'; -import { - TriggerContextMapping, - TriggerId, -} from '../../../../../../../src/plugins/ui_actions/public'; import { CollectConfigContainer } from './components'; import { AdvancedUiActionsStart, @@ -34,15 +30,15 @@ export interface Params { }>; } -export abstract class AbstractDashboardDrilldown - implements Drilldown> { +export abstract class AbstractDashboardDrilldown + implements Drilldown { constructor(protected readonly params: Params) {} public abstract readonly id: string; - public abstract readonly supportedTriggers: () => T[]; + public abstract readonly supportedTriggers: () => string[]; - protected abstract getURL(config: Config, context: TriggerContextMapping[T]): Promise; + protected abstract getURL(config: Config, context: Context): Promise; public readonly order = 100; @@ -51,7 +47,7 @@ export abstract class AbstractDashboardDrilldown public readonly euiIcon = 'dashboardApp'; private readonly ReactCollectConfig: React.FC< - CollectConfigProps> + CollectConfigProps > = (props) => ; public readonly CollectConfig = reactToUiComponent(this.ReactCollectConfig); @@ -67,15 +63,12 @@ export abstract class AbstractDashboardDrilldown return true; }; - public readonly getHref = async ( - config: Config, - context: TriggerContextMapping[T] - ): Promise => { + public readonly getHref = async (config: Config, context: Context): Promise => { const url = await this.getURL(config, context); return url.path; }; - public readonly execute = async (config: Config, context: TriggerContextMapping[T]) => { + public readonly execute = async (config: Config, context: Context) => { const url = await this.getURL(config, context); await this.params.start().core.application.navigateToApp(url.appName, { path: url.appPath }); }; diff --git a/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/abstract_dashboard_drilldown/types.ts b/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/abstract_dashboard_drilldown/types.ts index d2d3c37a69287..04256362da4a8 100644 --- a/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/abstract_dashboard_drilldown/types.ts +++ b/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/abstract_dashboard_drilldown/types.ts @@ -5,9 +5,8 @@ */ import { UiActionsEnhancedBaseActionFactoryContext } from '../../../../../ui_actions_enhanced/public'; -import { APPLY_FILTER_TRIGGER } from '../../../../../../../src/plugins/data/public'; import { DrilldownConfig } from '../../../../common'; export type Config = DrilldownConfig; -export type FactoryContext = UiActionsEnhancedBaseActionFactoryContext; +export type FactoryContext = UiActionsEnhancedBaseActionFactoryContext; diff --git a/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/drilldown_shared.ts b/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/drilldown_shared.ts index ff79cda1bb215..5c959432011f2 100644 --- a/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/drilldown_shared.ts +++ b/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/drilldown_shared.ts @@ -9,7 +9,6 @@ import { SELECT_RANGE_TRIGGER, VALUE_CLICK_TRIGGER, } from '../../../../../../../src/plugins/embeddable/public'; -import { TriggerId } from '../../../../../../../src/plugins/ui_actions/public'; /** * We know that VALUE_CLICK_TRIGGER and SELECT_RANGE_TRIGGER are also triggering APPLY_FILTER_TRIGGER. @@ -21,7 +20,7 @@ import { TriggerId } from '../../../../../../../src/plugins/ui_actions/public'; * * @param triggers */ -export function ensureNestedTriggers(triggers: TriggerId[]): TriggerId[] { +export function ensureNestedTriggers(triggers: string[]): string[] { if ( !triggers.includes(APPLY_FILTER_TRIGGER) && (triggers.includes(VALUE_CLICK_TRIGGER) || triggers.includes(SELECT_RANGE_TRIGGER)) diff --git a/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/flyout_create_drilldown/flyout_create_drilldown.test.tsx b/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/flyout_create_drilldown/flyout_create_drilldown.test.tsx index ff54e0812975d..02b086fb301c8 100644 --- a/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/flyout_create_drilldown/flyout_create_drilldown.test.tsx +++ b/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/flyout_create_drilldown/flyout_create_drilldown.test.tsx @@ -10,10 +10,6 @@ import { } from './flyout_create_drilldown'; import { coreMock } from '../../../../../../../../src/core/public/mocks'; import { ViewMode } from '../../../../../../../../src/plugins/embeddable/public'; -import { - TriggerContextMapping, - TriggerId, -} from '../../../../../../../../src/plugins/ui_actions/public'; import { MockEmbeddable, enhanceEmbeddable } from '../test_helpers'; import { uiActionsEnhancedPluginMock } from '../../../../../../ui_actions_enhanced/public/mocks'; import { UiActionsEnhancedActionFactory } from '../../../../../../ui_actions_enhanced/public/'; @@ -54,7 +50,7 @@ interface CompatibilityParams { isValueClickTriggerSupported?: boolean; isEmbeddableEnhanced?: boolean; rootType?: string; - actionFactoriesTriggers?: TriggerId[]; + actionFactoriesTriggers?: string[]; } describe('isCompatible', () => { @@ -79,9 +75,7 @@ describe('isCompatible', () => { let embeddable = new MockEmbeddable( { id: '', viewMode: isEdit ? ViewMode.EDIT : ViewMode.VIEW }, { - supportedTriggers: (isValueClickTriggerSupported ? ['VALUE_CLICK_TRIGGER'] : []) as Array< - keyof TriggerContextMapping - >, + supportedTriggers: isValueClickTriggerSupported ? ['VALUE_CLICK_TRIGGER'] : [], } ); diff --git a/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/flyout_create_drilldown/flyout_create_drilldown.tsx b/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/flyout_create_drilldown/flyout_create_drilldown.tsx index a417deb47db53..12aa2f8250e24 100644 --- a/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/flyout_create_drilldown/flyout_create_drilldown.tsx +++ b/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/flyout_create_drilldown/flyout_create_drilldown.tsx @@ -6,7 +6,7 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; -import { ActionByType } from '../../../../../../../../src/plugins/ui_actions/public'; +import { Action } from '../../../../../../../../src/plugins/ui_actions/public'; import { toMountPoint } from '../../../../../../../../src/plugins/kibana_react/public'; import { isEnhancedEmbeddable, @@ -26,7 +26,7 @@ export interface OpenFlyoutAddDrilldownParams { start: StartServicesGetter>; } -export class FlyoutCreateDrilldownAction implements ActionByType { +export class FlyoutCreateDrilldownAction implements Action { public readonly type = OPEN_FLYOUT_ADD_DRILLDOWN; public readonly id = OPEN_FLYOUT_ADD_DRILLDOWN; public order = 12; diff --git a/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/flyout_edit_drilldown/flyout_edit_drilldown.tsx b/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/flyout_edit_drilldown/flyout_edit_drilldown.tsx index 1f0570445a8fc..10d82707d0817 100644 --- a/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/flyout_edit_drilldown/flyout_edit_drilldown.tsx +++ b/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/flyout_edit_drilldown/flyout_edit_drilldown.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { ActionByType } from '../../../../../../../../src/plugins/ui_actions/public'; +import { Action } from '../../../../../../../../src/plugins/ui_actions/public'; import { reactToUiComponent, toMountPoint, @@ -31,7 +31,7 @@ export interface FlyoutEditDrilldownParams { start: StartServicesGetter>; } -export class FlyoutEditDrilldownAction implements ActionByType { +export class FlyoutEditDrilldownAction implements Action { public readonly type = OPEN_FLYOUT_EDIT_DRILLDOWN; public readonly id = OPEN_FLYOUT_EDIT_DRILLDOWN; public order = 10; diff --git a/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/flyout_edit_drilldown/menu_item.test.tsx b/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/flyout_edit_drilldown/menu_item.test.tsx index 27a8d73f32944..6f000756601ea 100644 --- a/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/flyout_edit_drilldown/menu_item.test.tsx +++ b/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/flyout_edit_drilldown/menu_item.test.tsx @@ -21,6 +21,7 @@ test('', () => { dynamicActions: ({ state } as unknown) as DynamicActionManager, }, } as unknown) as EnhancedEmbeddable, + trigger: {} as any, }} /> ); diff --git a/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/flyout_edit_drilldown/menu_item.tsx b/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/flyout_edit_drilldown/menu_item.tsx index 5a04e03e03457..f834d925a6494 100644 --- a/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/flyout_edit_drilldown/menu_item.tsx +++ b/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/flyout_edit_drilldown/menu_item.tsx @@ -9,8 +9,11 @@ import { EuiNotificationBadge, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; import { useContainerState } from '../../../../../../../../src/plugins/kibana_utils/public'; import { EnhancedEmbeddableContext } from '../../../../../../embeddable_enhanced/public'; import { txtDisplayName } from './i18n'; +import { ActionExecutionContext } from '../../../../../../../../src/plugins/ui_actions/public'; -export const MenuItem: React.FC<{ context: EnhancedEmbeddableContext }> = ({ context }) => { +export const MenuItem: React.FC<{ context: ActionExecutionContext }> = ({ + context, +}) => { const { events } = useContainerState(context.embeddable.enhancements.dynamicActions.state); const count = events.length; diff --git a/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/test_helpers.ts b/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/test_helpers.ts index e831f87baa11c..432ee6d3070ad 100644 --- a/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/test_helpers.ts +++ b/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/test_helpers.ts @@ -11,23 +11,19 @@ import { UiActionsEnhancedDynamicActionManager as DynamicActionManager, AdvancedUiActionsStart, } from '../../../../../ui_actions_enhanced/public'; -import { TriggerContextMapping } from '../../../../../../../src/plugins/ui_actions/public'; import { uiActionsEnhancedPluginMock } from '../../../../../ui_actions_enhanced/public/mocks'; export class MockEmbeddable extends Embeddable { public rootType = 'dashboard'; public readonly type = 'mock'; - private readonly triggers: Array = []; - constructor( - initialInput: EmbeddableInput, - params: { supportedTriggers?: Array } - ) { + private readonly triggers: string[] = []; + constructor(initialInput: EmbeddableInput, params: { supportedTriggers?: string[] }) { super(initialInput, {}, undefined); this.triggers = params.supportedTriggers ?? []; } public render(node: HTMLElement) {} public reload() {} - public supportedTriggers(): Array { + public supportedTriggers(): string[] { return this.triggers; } public getRoot() { diff --git a/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/dashboard_drilldowns_services.ts b/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/dashboard_drilldowns_services.ts index e1b6493be5200..d43a50775148d 100644 --- a/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/dashboard_drilldowns_services.ts +++ b/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/dashboard_drilldowns_services.ts @@ -7,23 +7,10 @@ import { CoreSetup } from 'src/core/public'; import { SetupDependencies, StartDependencies } from '../../plugin'; import { CONTEXT_MENU_TRIGGER } from '../../../../../../src/plugins/embeddable/public'; -import { EnhancedEmbeddableContext } from '../../../../embeddable_enhanced/public'; -import { - FlyoutCreateDrilldownAction, - FlyoutEditDrilldownAction, - OPEN_FLYOUT_ADD_DRILLDOWN, - OPEN_FLYOUT_EDIT_DRILLDOWN, -} from './actions'; +import { FlyoutCreateDrilldownAction, FlyoutEditDrilldownAction } from './actions'; import { EmbeddableToDashboardDrilldown } from './embeddable_to_dashboard_drilldown'; import { createStartServicesGetter } from '../../../../../../src/plugins/kibana_utils/public'; -declare module '../../../../../../src/plugins/ui_actions/public' { - export interface ActionContextMapping { - [OPEN_FLYOUT_ADD_DRILLDOWN]: EnhancedEmbeddableContext; - [OPEN_FLYOUT_EDIT_DRILLDOWN]: EnhancedEmbeddableContext; - } -} - interface BootstrapParams { enableDrilldowns: boolean; } diff --git a/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/embeddable_to_dashboard_drilldown/embeddable_to_dashboard_drilldown.test.tsx b/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/embeddable_to_dashboard_drilldown/embeddable_to_dashboard_drilldown.test.tsx index 5bfb175ea0d00..c33b26b42cb32 100644 --- a/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/embeddable_to_dashboard_drilldown/embeddable_to_dashboard_drilldown.test.tsx +++ b/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/embeddable_to_dashboard_drilldown/embeddable_to_dashboard_drilldown.test.tsx @@ -23,6 +23,7 @@ import { UrlGeneratorsService } from '../../../../../../../src/plugins/share/pub import { StartDependencies } from '../../../plugin'; import { SavedObjectLoader } from '../../../../../../../src/plugins/saved_objects/public'; import { StartServicesGetter } from '../../../../../../../src/plugins/kibana_utils/public/core'; +import { EnhancedEmbeddableContext } from '../../../../../embeddable_enhanced/public'; describe('.isConfigValid()', () => { const drilldown = new EmbeddableToDashboardDrilldown({} as any); @@ -140,7 +141,7 @@ describe('.execute() & getHref', () => { }), }, timeFieldName, - } as unknown) as ApplyGlobalFilterActionContext; + } as unknown) as ApplyGlobalFilterActionContext & EnhancedEmbeddableContext; await drilldown.execute(completeConfig, context); diff --git a/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/embeddable_to_dashboard_drilldown/embeddable_to_dashboard_drilldown.tsx b/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/embeddable_to_dashboard_drilldown/embeddable_to_dashboard_drilldown.tsx index c2bf48188c313..0bd21a82af54b 100644 --- a/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/embeddable_to_dashboard_drilldown/embeddable_to_dashboard_drilldown.tsx +++ b/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/embeddable_to_dashboard_drilldown/embeddable_to_dashboard_drilldown.tsx @@ -4,9 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -import { TriggerContextMapping } from '../../../../../../../src/plugins/ui_actions/public'; import { DashboardUrlGeneratorState } from '../../../../../../../src/plugins/dashboard/public'; import { + ApplyGlobalFilterActionContext, APPLY_FILTER_TRIGGER, esFilters, Filter, @@ -25,6 +25,7 @@ import { import { KibanaURL } from '../../../../../../../src/plugins/share/public'; import { EMBEDDABLE_TO_DASHBOARD_DRILLDOWN } from './constants'; import { createExtract, createInject } from '../../../../common'; +import { EnhancedEmbeddableContext } from '../../../../../embeddable_enhanced/public'; interface EmbeddableQueryInput extends EmbeddableInput { query?: Query; @@ -32,8 +33,7 @@ interface EmbeddableQueryInput extends EmbeddableInput { timeRange?: TimeRange; } -type Trigger = typeof APPLY_FILTER_TRIGGER; -type Context = TriggerContextMapping[Trigger]; +type Context = EnhancedEmbeddableContext & ApplyGlobalFilterActionContext; export type Params = AbstractDashboardDrilldownParams; /** @@ -43,10 +43,10 @@ export type Params = AbstractDashboardDrilldownParams; * by embeddables (but not necessarily); (2) its `getURL` method depends on * `embeddable` field being present in `context`. */ -export class EmbeddableToDashboardDrilldown extends AbstractDashboardDrilldown { +export class EmbeddableToDashboardDrilldown extends AbstractDashboardDrilldown { public readonly id = EMBEDDABLE_TO_DASHBOARD_DRILLDOWN; - public readonly supportedTriggers = () => [APPLY_FILTER_TRIGGER] as Trigger[]; + public readonly supportedTriggers = () => [APPLY_FILTER_TRIGGER]; protected async getURL(config: Config, context: Context): Promise { const state: DashboardUrlGeneratorState = { diff --git a/x-pack/plugins/discover_enhanced/public/index.ts b/x-pack/plugins/discover_enhanced/public/index.ts index 943a212dd7c4e..c44815707b9be 100644 --- a/x-pack/plugins/discover_enhanced/public/index.ts +++ b/x-pack/plugins/discover_enhanced/public/index.ts @@ -4,10 +4,12 @@ * you may not use this file except in compliance with the Elastic License. */ -import { PluginInitializerContext } from 'kibana/public'; +import type { PluginInitializerContext } from 'kibana/public'; import { DiscoverEnhancedPlugin } from './plugin'; -export { +export type { ExploreDataContextMenuAction, ExploreDataChartAction } from './actions'; + +export type { DiscoverEnhancedPlugin, DiscoverEnhancedSetupDependencies, DiscoverEnhancedStartDependencies, diff --git a/x-pack/plugins/discover_enhanced/public/plugin.ts b/x-pack/plugins/discover_enhanced/public/plugin.ts index 78f3464484ccf..7f6f83fba16f6 100644 --- a/x-pack/plugins/discover_enhanced/public/plugin.ts +++ b/x-pack/plugins/discover_enhanced/public/plugin.ts @@ -15,25 +15,11 @@ import { KibanaLegacySetup, KibanaLegacyStart } from '../../../../src/plugins/ki import { EmbeddableSetup, EmbeddableStart, - EmbeddableContext, CONTEXT_MENU_TRIGGER, } from '../../../../src/plugins/embeddable/public'; -import { - ExploreDataContextMenuAction, - ExploreDataChartAction, - ACTION_EXPLORE_DATA, - ACTION_EXPLORE_DATA_CHART, - ExploreDataChartActionContext, -} from './actions'; +import { ExploreDataContextMenuAction, ExploreDataChartAction } from './actions'; import { Config } from '../common'; -declare module '../../../../src/plugins/ui_actions/public' { - export interface ActionContextMapping { - [ACTION_EXPLORE_DATA]: EmbeddableContext; - [ACTION_EXPLORE_DATA_CHART]: ExploreDataChartActionContext; - } -} - export interface DiscoverEnhancedSetupDependencies { discover: DiscoverSetup; embeddable: EmbeddableSetup; diff --git a/x-pack/plugins/drilldowns/url_drilldown/public/lib/url_drilldown.tsx b/x-pack/plugins/drilldowns/url_drilldown/public/lib/url_drilldown.tsx index ffb0687305168..3587e472324c6 100644 --- a/x-pack/plugins/drilldowns/url_drilldown/public/lib/url_drilldown.tsx +++ b/x-pack/plugins/drilldowns/url_drilldown/public/lib/url_drilldown.tsx @@ -56,14 +56,14 @@ export type UrlTrigger = | typeof ROW_CLICK_TRIGGER | typeof CONTEXT_MENU_TRIGGER; -export interface ActionFactoryContext extends BaseActionFactoryContext { +export interface ActionFactoryContext extends BaseActionFactoryContext { embeddable?: EmbeddableWithQueryInput; } export type CollectConfigProps = CollectConfigPropsBase; const URL_DRILLDOWN = 'URL_DRILLDOWN'; -export class UrlDrilldown implements Drilldown { +export class UrlDrilldown implements Drilldown { public readonly id = URL_DRILLDOWN; constructor(private readonly deps: UrlDrilldownDeps) {} diff --git a/x-pack/plugins/embeddable_enhanced/public/plugin.ts b/x-pack/plugins/embeddable_enhanced/public/plugin.ts index 5d5ad852839d4..a901584080dce 100644 --- a/x-pack/plugins/embeddable_enhanced/public/plugin.ts +++ b/x-pack/plugins/embeddable_enhanced/public/plugin.ts @@ -19,7 +19,7 @@ import { PANEL_NOTIFICATION_TRIGGER, ViewMode, } from '../../../../src/plugins/embeddable/public'; -import { EnhancedEmbeddable, EnhancedEmbeddableContext } from './types'; +import { EnhancedEmbeddable } from './types'; import { EmbeddableActionStorage, EmbeddableWithDynamicActions, @@ -29,13 +29,7 @@ import { AdvancedUiActionsSetup, AdvancedUiActionsStart, } from '../../ui_actions_enhanced/public'; -import { PanelNotificationsAction, ACTION_PANEL_NOTIFICATIONS } from './actions'; - -declare module '../../../../src/plugins/ui_actions/public' { - export interface ActionContextMapping { - [ACTION_PANEL_NOTIFICATIONS]: EnhancedEmbeddableContext; - } -} +import { PanelNotificationsAction } from './actions'; export interface SetupDependencies { embeddable: EmbeddableSetup; diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.test.tsx b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.test.tsx index deb48027512cc..6411b0e5f1ad9 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.test.tsx +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.test.tsx @@ -34,7 +34,7 @@ import { IFieldType, IIndexPattern, } from '../../../../../../../src/plugins/data/public'; -import { TriggerId, UiActionsStart } from '../../../../../../../src/plugins/ui_actions/public'; +import { UiActionsStart } from '../../../../../../../src/plugins/ui_actions/public'; import { uiActionsPluginMock } from '../../../../../../../src/plugins/ui_actions/public/mocks'; import { TriggerContract } from '../../../../../../../src/plugins/ui_actions/public/triggers'; import { VIS_EVENT_TO_TRIGGER } from '../../../../../../../src/plugins/visualizations/public/embeddable'; @@ -48,12 +48,12 @@ describe('workspace_panel', () => { let expressionRendererMock: jest.Mock; let uiActionsMock: jest.Mocked; let dataMock: jest.Mocked; - let trigger: jest.Mocked>; + let trigger: jest.Mocked; let instance: ReactWrapper; beforeEach(() => { - trigger = ({ exec: jest.fn() } as unknown) as jest.Mocked>; + trigger = ({ exec: jest.fn() } as unknown) as jest.Mocked; uiActionsMock = uiActionsPluginMock.createStartContract(); dataMock = dataPluginMock.createStartContract(); uiActionsMock.getTrigger.mockReturnValue(trigger); diff --git a/x-pack/plugins/lens/public/trigger_actions/visualize_field_actions.ts b/x-pack/plugins/lens/public/trigger_actions/visualize_field_actions.ts index a473d433ac89d..caf22088daf96 100644 --- a/x-pack/plugins/lens/public/trigger_actions/visualize_field_actions.ts +++ b/x-pack/plugins/lens/public/trigger_actions/visualize_field_actions.ts @@ -12,7 +12,7 @@ import { import { ApplicationStart } from '../../../../../src/core/public'; export const visualizeFieldAction = (application: ApplicationStart) => - createAction({ + createAction({ type: ACTION_VISUALIZE_LENS_FIELD, id: ACTION_VISUALIZE_LENS_FIELD, getDisplayName: () => diff --git a/x-pack/plugins/lens/public/types.ts b/x-pack/plugins/lens/public/types.ts index a5e17a05cf71d..8a90e24a5dbe5 100644 --- a/x-pack/plugins/lens/public/types.ts +++ b/x-pack/plugins/lens/public/types.ts @@ -8,7 +8,7 @@ import { IconType } from '@elastic/eui/src/components/icon/icon'; import { CoreSetup } from 'kibana/public'; import { PaletteOutput, PaletteRegistry } from 'src/plugins/charts/public'; import { SavedObjectReference } from 'kibana/public'; -import { ROW_CLICK_TRIGGER } from '../../../../src/plugins/ui_actions/public'; +import { RowClickContext } from '../../../../src/plugins/ui_actions/public'; import { ExpressionAstExpression, ExpressionRendererEvent, @@ -20,11 +20,8 @@ import { DragContextState } from './drag_drop'; import { Document } from './persistence'; import { DateRange } from '../common'; import { Query, Filter, SavedQuery, IFieldFormat } from '../../../../src/plugins/data/public'; -import { TriggerContext, VisualizeFieldContext } from '../../../../src/plugins/ui_actions/public'; -import { - SELECT_RANGE_TRIGGER, - VALUE_CLICK_TRIGGER, -} from '../../../../src/plugins/embeddable/public'; +import { VisualizeFieldContext } from '../../../../src/plugins/ui_actions/public'; +import { RangeSelectContext, ValueClickContext } from '../../../../src/plugins/embeddable/public'; import type { LensSortActionData, LENS_EDIT_SORT_ACTION, @@ -623,12 +620,12 @@ export interface Visualization { export interface LensFilterEvent { name: 'filter'; - data: TriggerContext['data']; + data: ValueClickContext['data']; } export interface LensBrushEvent { name: 'brush'; - data: TriggerContext['data']; + data: RangeSelectContext['data']; } // Use same technique as TriggerContext @@ -649,7 +646,7 @@ export interface LensEditEvent { } export interface LensTableRowContextMenuEvent { name: 'tableRowContextMenuClick'; - data: TriggerContext['data']; + data: RowClickContext['data']; } export function isLensFilterEvent(event: ExpressionRendererEvent): event is LensFilterEvent { diff --git a/x-pack/plugins/maps/public/embeddable/map_embeddable.tsx b/x-pack/plugins/maps/public/embeddable/map_embeddable.tsx index 5e5d431c7c212..1848f841c771b 100644 --- a/x-pack/plugins/maps/public/embeddable/map_embeddable.tsx +++ b/x-pack/plugins/maps/public/embeddable/map_embeddable.tsx @@ -16,10 +16,7 @@ import { ReferenceOrValueEmbeddable, VALUE_CLICK_TRIGGER, } from '../../../../../src/plugins/embeddable/public'; -import { - ActionExecutionContext, - TriggerContextMapping, -} from '../../../../../src/plugins/ui_actions/public'; +import { ActionExecutionContext } from '../../../../../src/plugins/ui_actions/public'; import { ACTION_GLOBAL_APPLY_FILTER, APPLY_FILTER_TRIGGER, @@ -204,7 +201,7 @@ export class MapEmbeddable return this._isInitialized ? this._savedMap.getAttributes().description : ''; } - public supportedTriggers(): Array { + public supportedTriggers(): string[] { return [APPLY_FILTER_TRIGGER, VALUE_CLICK_TRIGGER]; } diff --git a/x-pack/plugins/maps/public/trigger_actions/trigger_utils.ts b/x-pack/plugins/maps/public/trigger_actions/trigger_utils.ts index 3505588a9c049..5b530173f9e26 100644 --- a/x-pack/plugins/maps/public/trigger_actions/trigger_utils.ts +++ b/x-pack/plugins/maps/public/trigger_actions/trigger_utils.ts @@ -9,7 +9,6 @@ import { RawValue } from '../../common/constants'; import { DatatableColumnType } from '../../../../../src/plugins/expressions'; export function isUrlDrilldown(action: Action) { - // @ts-expect-error return action.type === 'URL_DRILLDOWN'; } diff --git a/x-pack/plugins/maps/public/trigger_actions/visualize_geo_field_action.ts b/x-pack/plugins/maps/public/trigger_actions/visualize_geo_field_action.ts index bdeab292b214c..fdfca4877428c 100644 --- a/x-pack/plugins/maps/public/trigger_actions/visualize_geo_field_action.ts +++ b/x-pack/plugins/maps/public/trigger_actions/visualize_geo_field_action.ts @@ -21,7 +21,8 @@ import { import { MAPS_APP_URL_GENERATOR, MapsUrlGeneratorState } from '../url_generator'; import { LAYER_TYPE, SOURCE_TYPES, SCALING_TYPES, APP_ID, MAP_PATH } from '../../common/constants'; -export const visualizeGeoFieldAction = createAction({ +export const visualizeGeoFieldAction = createAction({ + id: ACTION_VISUALIZE_GEO_FIELD, type: ACTION_VISUALIZE_GEO_FIELD, getDisplayName: () => i18n.translate('xpack.maps.discover.visualizeFieldLabel', { diff --git a/x-pack/plugins/ml/public/embeddables/anomaly_swimlane/embeddable_swim_lane_container.test.tsx b/x-pack/plugins/ml/public/embeddables/anomaly_swimlane/embeddable_swim_lane_container.test.tsx index ff621953cc577..b4740ea9333f6 100644 --- a/x-pack/plugins/ml/public/embeddables/anomaly_swimlane/embeddable_swim_lane_container.test.tsx +++ b/x-pack/plugins/ml/public/embeddables/anomaly_swimlane/embeddable_swim_lane_container.test.tsx @@ -20,7 +20,6 @@ import { SwimlaneContainer } from '../../application/explorer/swimlane_container import { MlDependencies } from '../../application/app'; import { uiActionsPluginMock } from 'src/plugins/ui_actions/public/mocks'; import { TriggerContract } from 'src/plugins/ui_actions/public/triggers'; -import { TriggerId } from 'src/plugins/ui_actions/public'; import { AnomalySwimlaneEmbeddableInput, AnomalySwimlaneServices } from '..'; jest.mock('./swimlane_input_resolver', () => ({ @@ -43,7 +42,7 @@ describe('ExplorerSwimlaneContainer', () => { let refresh: BehaviorSubject; let services: jest.Mocked<[CoreStart, MlDependencies, AnomalySwimlaneServices]>; let embeddableContext: AnomalySwimlaneEmbeddable; - let trigger: jest.Mocked>; + let trigger: jest.Mocked; const onInputChange = jest.fn(); const onOutputChange = jest.fn(); @@ -54,7 +53,7 @@ describe('ExplorerSwimlaneContainer', () => { id: 'test-swimlane-embeddable', } as Partial); - trigger = ({ exec: jest.fn() } as unknown) as jest.Mocked>; + trigger = ({ exec: jest.fn() } as unknown) as jest.Mocked; const uiActionsMock = uiActionsPluginMock.createStartContract(); uiActionsMock.getTrigger.mockReturnValue(trigger); diff --git a/x-pack/plugins/ml/public/ui_actions/apply_influencer_filters_action.tsx b/x-pack/plugins/ml/public/ui_actions/apply_influencer_filters_action.tsx index 50f00ac53edab..51784815bcc4b 100644 --- a/x-pack/plugins/ml/public/ui_actions/apply_influencer_filters_action.tsx +++ b/x-pack/plugins/ml/public/ui_actions/apply_influencer_filters_action.tsx @@ -5,7 +5,7 @@ */ import { i18n } from '@kbn/i18n'; -import { ActionContextMapping, createAction } from '../../../../../src/plugins/ui_actions/public'; +import { createAction } from '../../../../../src/plugins/ui_actions/public'; import { MlCoreSetup } from '../plugin'; import { SWIMLANE_TYPE, VIEW_BY_JOB_LABEL } from '../application/explorer/explorer_constants'; import { Filter, FilterStateStore } from '../../../../../src/plugins/data/common'; @@ -18,10 +18,10 @@ export const CONTROLLED_BY_SWIM_LANE_FILTER = 'anomaly-swim-lane'; export function createApplyInfluencerFiltersAction( getStartServices: MlCoreSetup['getStartServices'] ) { - return createAction({ + return createAction({ id: 'apply-to-current-view', type: APPLY_INFLUENCER_FILTERS_ACTION, - getIconType(context: ActionContextMapping[typeof APPLY_INFLUENCER_FILTERS_ACTION]): string { + getIconType(context: SwimLaneDrilldownContext): string { return 'filter'; }, getDisplayName() { @@ -29,7 +29,7 @@ export function createApplyInfluencerFiltersAction( defaultMessage: 'Filter for value', }); }, - async execute({ data }: SwimLaneDrilldownContext) { + async execute({ data }) { if (!data) { throw new Error('No swim lane selection data provided'); } @@ -67,7 +67,7 @@ export function createApplyInfluencerFiltersAction( }) ); }, - async isCompatible({ embeddable, data }: SwimLaneDrilldownContext) { + async isCompatible({ embeddable, data }) { // Only compatible with view by influencer swim lanes and single selection return ( embeddable.type === ANOMALY_SWIMLANE_EMBEDDABLE_TYPE && diff --git a/x-pack/plugins/ml/public/ui_actions/apply_time_range_action.tsx b/x-pack/plugins/ml/public/ui_actions/apply_time_range_action.tsx index 79e6ff53bff43..a92974772601d 100644 --- a/x-pack/plugins/ml/public/ui_actions/apply_time_range_action.tsx +++ b/x-pack/plugins/ml/public/ui_actions/apply_time_range_action.tsx @@ -6,7 +6,7 @@ import { i18n } from '@kbn/i18n'; import moment from 'moment'; -import { ActionContextMapping, createAction } from '../../../../../src/plugins/ui_actions/public'; +import { createAction } from '../../../../../src/plugins/ui_actions/public'; import { MlCoreSetup } from '../plugin'; import { ANOMALY_SWIMLANE_EMBEDDABLE_TYPE, SwimLaneDrilldownContext } from '../embeddables'; @@ -15,17 +15,17 @@ export const APPLY_TIME_RANGE_SELECTION_ACTION = 'applyTimeRangeSelectionAction' export function createApplyTimeRangeSelectionAction( getStartServices: MlCoreSetup['getStartServices'] ) { - return createAction({ + return createAction({ id: 'apply-time-range-selection', type: APPLY_TIME_RANGE_SELECTION_ACTION, - getIconType(context: ActionContextMapping[typeof APPLY_TIME_RANGE_SELECTION_ACTION]): string { + getIconType(context): string { return 'timeline'; }, getDisplayName: () => i18n.translate('xpack.ml.actions.applyTimeRangeSelectionTitle', { defaultMessage: 'Apply time range selection', }), - async execute({ embeddable, data }: SwimLaneDrilldownContext) { + async execute({ embeddable, data }) { if (!data) { throw new Error('No swim lane selection data provided'); } @@ -47,7 +47,7 @@ export function createApplyTimeRangeSelectionAction( mode: 'absolute', }); }, - async isCompatible({ embeddable, data }: SwimLaneDrilldownContext) { + async isCompatible({ embeddable, data }) { return embeddable.type === ANOMALY_SWIMLANE_EMBEDDABLE_TYPE && data !== undefined; }, }); diff --git a/x-pack/plugins/ml/public/ui_actions/clear_selection_action.tsx b/x-pack/plugins/ml/public/ui_actions/clear_selection_action.tsx index acafc787d05c2..46d71d61c361d 100644 --- a/x-pack/plugins/ml/public/ui_actions/clear_selection_action.tsx +++ b/x-pack/plugins/ml/public/ui_actions/clear_selection_action.tsx @@ -5,7 +5,7 @@ */ import { i18n } from '@kbn/i18n'; -import { ActionContextMapping, createAction } from '../../../../../src/plugins/ui_actions/public'; +import { createAction } from '../../../../../src/plugins/ui_actions/public'; import { MlCoreSetup } from '../plugin'; export const CLEAR_SELECTION_ACTION = 'clearSelectionAction'; @@ -15,10 +15,10 @@ export interface ClearSelectionContext { } export function createClearSelectionAction(getStartServices: MlCoreSetup['getStartServices']) { - return createAction({ + return createAction({ id: 'clear-selection-action', type: CLEAR_SELECTION_ACTION, - getIconType(context: ActionContextMapping[typeof CLEAR_SELECTION_ACTION]): string { + getIconType(context): string { return 'cross'; }, getDisplayName: () => @@ -26,10 +26,10 @@ export function createClearSelectionAction(getStartServices: MlCoreSetup['getSta defaultMessage: 'Clear selection', }), shouldAutoExecute: () => Promise.resolve(false), - async execute({ updateCallback }: ClearSelectionContext) { + async execute({ updateCallback }) { updateCallback(); }, - async isCompatible({ updateCallback }: ClearSelectionContext) { + async isCompatible({ updateCallback }) { return typeof updateCallback === 'function'; }, }); diff --git a/x-pack/plugins/ml/public/ui_actions/edit_swimlane_panel_action.tsx b/x-pack/plugins/ml/public/ui_actions/edit_swimlane_panel_action.tsx index c40d1e175ec77..034f8be65af6f 100644 --- a/x-pack/plugins/ml/public/ui_actions/edit_swimlane_panel_action.tsx +++ b/x-pack/plugins/ml/public/ui_actions/edit_swimlane_panel_action.tsx @@ -5,7 +5,7 @@ */ import { i18n } from '@kbn/i18n'; -import { ActionContextMapping, createAction } from '../../../../../src/plugins/ui_actions/public'; +import { createAction } from '../../../../../src/plugins/ui_actions/public'; import { ViewMode } from '../../../../../src/plugins/embeddable/public'; import { MlCoreSetup } from '../plugin'; import { ANOMALY_SWIMLANE_EMBEDDABLE_TYPE, EditSwimlanePanelContext } from '../embeddables'; @@ -13,17 +13,17 @@ import { ANOMALY_SWIMLANE_EMBEDDABLE_TYPE, EditSwimlanePanelContext } from '../e export const EDIT_SWIMLANE_PANEL_ACTION = 'editSwimlanePanelAction'; export function createEditSwimlanePanelAction(getStartServices: MlCoreSetup['getStartServices']) { - return createAction({ + return createAction({ id: 'edit-anomaly-swimlane', type: EDIT_SWIMLANE_PANEL_ACTION, - getIconType(context: ActionContextMapping[typeof EDIT_SWIMLANE_PANEL_ACTION]): string { + getIconType(context): string { return 'pencil'; }, getDisplayName: () => i18n.translate('xpack.ml.actions.editSwimlaneTitle', { defaultMessage: 'Edit swim lane', }), - async execute({ embeddable }: EditSwimlanePanelContext) { + async execute({ embeddable }) { if (!embeddable) { throw new Error('Not possible to execute an action without the embeddable context'); } @@ -41,7 +41,7 @@ export function createEditSwimlanePanelAction(getStartServices: MlCoreSetup['get return Promise.reject(); } }, - async isCompatible({ embeddable }: EditSwimlanePanelContext) { + async isCompatible({ embeddable }) { return ( embeddable.type === ANOMALY_SWIMLANE_EMBEDDABLE_TYPE && embeddable.getInput().viewMode === ViewMode.EDIT diff --git a/x-pack/plugins/ml/public/ui_actions/index.ts b/x-pack/plugins/ml/public/ui_actions/index.ts index 2b01a74070b22..8d515027a2ff4 100644 --- a/x-pack/plugins/ml/public/ui_actions/index.ts +++ b/x-pack/plugins/ml/public/ui_actions/index.ts @@ -5,32 +5,15 @@ */ import { CoreSetup } from 'kibana/public'; -import { - createEditSwimlanePanelAction, - EDIT_SWIMLANE_PANEL_ACTION, -} from './edit_swimlane_panel_action'; -import { - createOpenInExplorerAction, - OPEN_IN_ANOMALY_EXPLORER_ACTION, -} from './open_in_anomaly_explorer_action'; +import { createEditSwimlanePanelAction } from './edit_swimlane_panel_action'; +import { createOpenInExplorerAction } from './open_in_anomaly_explorer_action'; import { UiActionsSetup } from '../../../../../src/plugins/ui_actions/public'; import { MlPluginStart, MlStartDependencies } from '../plugin'; import { CONTEXT_MENU_TRIGGER } from '../../../../../src/plugins/embeddable/public'; -import { - APPLY_INFLUENCER_FILTERS_ACTION, - createApplyInfluencerFiltersAction, -} from './apply_influencer_filters_action'; +import { createApplyInfluencerFiltersAction } from './apply_influencer_filters_action'; import { SWIM_LANE_SELECTION_TRIGGER, swimLaneSelectionTrigger } from './triggers'; -import { - APPLY_TIME_RANGE_SELECTION_ACTION, - createApplyTimeRangeSelectionAction, -} from './apply_time_range_action'; -import { EditSwimlanePanelContext, SwimLaneDrilldownContext } from '../embeddables'; -import { - CLEAR_SELECTION_ACTION, - ClearSelectionContext, - createClearSelectionAction, -} from './clear_selection_action'; +import { createApplyTimeRangeSelectionAction } from './apply_time_range_action'; +import { createClearSelectionAction } from './clear_selection_action'; export { APPLY_TIME_RANGE_SELECTION_ACTION } from './apply_time_range_action'; export { EDIT_SWIMLANE_PANEL_ACTION } from './edit_swimlane_panel_action'; @@ -71,17 +54,3 @@ export function registerMlUiActions( uiActions.addTriggerAction(SWIM_LANE_SELECTION_TRIGGER, openInExplorerAction); uiActions.addTriggerAction(SWIM_LANE_SELECTION_TRIGGER, clearSelectionAction); } - -declare module '../../../../../src/plugins/ui_actions/public' { - export interface ActionContextMapping { - [EDIT_SWIMLANE_PANEL_ACTION]: EditSwimlanePanelContext; - [OPEN_IN_ANOMALY_EXPLORER_ACTION]: SwimLaneDrilldownContext; - [APPLY_INFLUENCER_FILTERS_ACTION]: SwimLaneDrilldownContext; - [APPLY_TIME_RANGE_SELECTION_ACTION]: SwimLaneDrilldownContext; - [CLEAR_SELECTION_ACTION]: ClearSelectionContext; - } - - export interface TriggerContextMapping { - [SWIM_LANE_SELECTION_TRIGGER]: SwimLaneDrilldownContext | ClearSelectionContext; - } -} diff --git a/x-pack/plugins/ml/public/ui_actions/open_in_anomaly_explorer_action.tsx b/x-pack/plugins/ml/public/ui_actions/open_in_anomaly_explorer_action.tsx index e4d7cfa32c2cd..da0c43f231f8a 100644 --- a/x-pack/plugins/ml/public/ui_actions/open_in_anomaly_explorer_action.tsx +++ b/x-pack/plugins/ml/public/ui_actions/open_in_anomaly_explorer_action.tsx @@ -5,7 +5,7 @@ */ import { i18n } from '@kbn/i18n'; -import { ActionContextMapping, createAction } from '../../../../../src/plugins/ui_actions/public'; +import { createAction } from '../../../../../src/plugins/ui_actions/public'; import { MlCoreSetup } from '../plugin'; import { ML_APP_URL_GENERATOR } from '../../common/constants/ml_url_generator'; import { ANOMALY_SWIMLANE_EMBEDDABLE_TYPE, SwimLaneDrilldownContext } from '../embeddables'; @@ -13,10 +13,10 @@ import { ANOMALY_SWIMLANE_EMBEDDABLE_TYPE, SwimLaneDrilldownContext } from '../e export const OPEN_IN_ANOMALY_EXPLORER_ACTION = 'openInAnomalyExplorerAction'; export function createOpenInExplorerAction(getStartServices: MlCoreSetup['getStartServices']) { - return createAction({ + return createAction({ id: 'open-in-anomaly-explorer', type: OPEN_IN_ANOMALY_EXPLORER_ACTION, - getIconType(context: ActionContextMapping[typeof OPEN_IN_ANOMALY_EXPLORER_ACTION]): string { + getIconType(context): string { return 'visTable'; }, getDisplayName() { @@ -24,7 +24,7 @@ export function createOpenInExplorerAction(getStartServices: MlCoreSetup['getSta defaultMessage: 'Open in Anomaly Explorer', }); }, - async getHref({ embeddable, data }: SwimLaneDrilldownContext): Promise { + async getHref({ embeddable, data }): Promise { const [, pluginsStart] = await getStartServices(); const urlGenerator = pluginsStart.share.urlGenerators.getUrlGenerator(ML_APP_URL_GENERATOR); const { jobIds, timeRange, viewBy } = embeddable.getInput(); @@ -50,7 +50,7 @@ export function createOpenInExplorerAction(getStartServices: MlCoreSetup['getSta }, }); }, - async execute({ embeddable, data }: SwimLaneDrilldownContext) { + async execute({ embeddable, data }) { if (!embeddable) { throw new Error('Not possible to execute an action without the embeddable context'); } diff --git a/x-pack/plugins/ml/public/ui_actions/triggers.ts b/x-pack/plugins/ml/public/ui_actions/triggers.ts index 8a8b2602573a1..9db7536d7d5ba 100644 --- a/x-pack/plugins/ml/public/ui_actions/triggers.ts +++ b/x-pack/plugins/ml/public/ui_actions/triggers.ts @@ -8,7 +8,7 @@ import { Trigger } from '../../../../../src/plugins/ui_actions/public'; export const SWIM_LANE_SELECTION_TRIGGER = 'SWIM_LANE_SELECTION_TRIGGER'; -export const swimLaneSelectionTrigger: Trigger<'SWIM_LANE_SELECTION_TRIGGER'> = { +export const swimLaneSelectionTrigger: Trigger = { id: SWIM_LANE_SELECTION_TRIGGER, // This is empty string to hide title of ui_actions context menu that appears // when this trigger is executed. diff --git a/x-pack/plugins/ui_actions_enhanced/public/components/action_wizard/action_wizard.tsx b/x-pack/plugins/ui_actions_enhanced/public/components/action_wizard/action_wizard.tsx index 7a705f03c0650..519d4ffb50ba6 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/components/action_wizard/action_wizard.tsx +++ b/x-pack/plugins/ui_actions_enhanced/public/components/action_wizard/action_wizard.tsx @@ -32,7 +32,7 @@ import { } from './i18n'; import './action_wizard.scss'; import { ActionFactory, BaseActionConfig, BaseActionFactoryContext } from '../../dynamic_actions'; -import { Trigger, TriggerId } from '../../../../../../src/plugins/ui_actions/public'; +import { Trigger } from '../../../../../../src/plugins/ui_actions/public'; export interface ActionWizardProps< ActionFactoryContext extends BaseActionFactoryContext = BaseActionFactoryContext @@ -73,14 +73,14 @@ export interface ActionWizardProps< * Trigger selection has changed * @param triggers */ - onSelectedTriggersChange: (triggers?: TriggerId[]) => void; + onSelectedTriggersChange: (triggers?: string[]) => void; - getTriggerInfo: (triggerId: TriggerId) => Trigger; + getTriggerInfo: (triggerId: string) => Trigger; /** * List of possible triggers in current context */ - triggers: TriggerId[]; + triggers: string[]; triggerPickerDocsLink?: string; } @@ -148,10 +148,10 @@ export const ActionWizard: React.FC = ({ }; interface TriggerPickerProps { - triggers: TriggerId[]; - selectedTriggers?: TriggerId[]; - getTriggerInfo: (triggerId: TriggerId) => Trigger; - onSelectedTriggersChange: (triggers?: TriggerId[]) => void; + triggers: string[]; + selectedTriggers?: string[]; + getTriggerInfo: (triggerId: string) => Trigger; + onSelectedTriggersChange: (triggers?: string[]) => void; triggerPickerDocsLink?: string; } @@ -224,9 +224,9 @@ interface SelectedActionFactoryProps< onConfigChange: (config: BaseActionConfig) => void; showDeselect: boolean; onDeselect: () => void; - allTriggers: TriggerId[]; - getTriggerInfo: (triggerId: TriggerId) => Trigger; - onSelectedTriggersChange: (triggers?: TriggerId[]) => void; + allTriggers: string[]; + getTriggerInfo: (triggerId: string) => Trigger; + onSelectedTriggersChange: (triggers?: string[]) => void; triggerPickerDocsLink?: string; } @@ -379,7 +379,7 @@ const ActionFactorySelector: React.FC = ({ function getTriggersForActionFactory( actionFactory: ActionFactory, - allTriggers: TriggerId[] -): TriggerId[] { + allTriggers: string[] +): string[] { return actionFactory.supportedTriggers().filter((trigger) => allTriggers.includes(trigger)); } diff --git a/x-pack/plugins/ui_actions_enhanced/public/components/action_wizard/test_data.tsx b/x-pack/plugins/ui_actions_enhanced/public/components/action_wizard/test_data.tsx index 77362752f6960..e3dd070a5d42e 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/components/action_wizard/test_data.tsx +++ b/x-pack/plugins/ui_actions_enhanced/public/components/action_wizard/test_data.tsx @@ -11,7 +11,7 @@ import { ActionWizard } from './action_wizard'; import { ActionFactory, ActionFactoryDefinition, BaseActionConfig } from '../../dynamic_actions'; import { CollectConfigProps } from '../../../../../../src/plugins/kibana_utils/public'; import { licensingMock } from '../../../../licensing/public/mocks'; -import { Trigger, TriggerId } from '../../../../../../src/plugins/ui_actions/public'; +import { Trigger } from '../../../../../../src/plugins/ui_actions/public'; import { APPLY_FILTER_TRIGGER } from '../../../../../../src/plugins/data/public'; import { SELECT_RANGE_TRIGGER, @@ -80,7 +80,6 @@ function DashboardDrilldownCollectConfig(props: CollectConfigProps = { id: 'Dashboard', @@ -184,12 +183,12 @@ export const mockActionFactories: ActionFactory[] = ([dashboardFactory, urlFacto ActionFactory >) as ActionFactory[]; -export const mockSupportedTriggers: TriggerId[] = [ +export const mockSupportedTriggers: string[] = [ VALUE_CLICK_TRIGGER, SELECT_RANGE_TRIGGER, APPLY_FILTER_TRIGGER, ]; -export const mockGetTriggerInfo = (triggerId: TriggerId): Trigger => { +export const mockGetTriggerInfo = (triggerId: string): Trigger => { const titleMap = { [VALUE_CLICK_TRIGGER]: 'Single click', [SELECT_RANGE_TRIGGER]: 'Range selection', @@ -213,7 +212,7 @@ export function Demo({ actionFactories }: { actionFactories: Array({}); function changeActionFactory(newActionFactory?: ActionFactory) { diff --git a/x-pack/plugins/ui_actions_enhanced/public/custom_time_range_action.tsx b/x-pack/plugins/ui_actions_enhanced/public/custom_time_range_action.tsx index 259fe5c774c4b..eb6259f10896c 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/custom_time_range_action.tsx +++ b/x-pack/plugins/ui_actions_enhanced/public/custom_time_range_action.tsx @@ -7,10 +7,7 @@ import { i18n } from '@kbn/i18n'; import React from 'react'; import { IEmbeddable, Embeddable, EmbeddableInput } from 'src/plugins/embeddable/public'; -import { - ActionDefinitionByType, - IncompatibleActionError, -} from '../../../../src/plugins/ui_actions/public'; +import { Action, IncompatibleActionError } from '../../../../src/plugins/ui_actions/public'; import { TimeRange } from '../../../../src/plugins/data/public'; import { CustomizeTimeRangeModal } from './customize_time_range_modal'; import { OpenModal, CommonlyUsedRange } from './types'; @@ -41,7 +38,7 @@ export interface TimeRangeActionContext { embeddable: Embeddable; } -export class CustomTimeRangeAction implements ActionDefinitionByType { +export class CustomTimeRangeAction implements Action { public readonly type = CUSTOM_TIME_RANGE; private openModal: OpenModal; private dateFormat?: string; diff --git a/x-pack/plugins/ui_actions_enhanced/public/custom_time_range_badge.tsx b/x-pack/plugins/ui_actions_enhanced/public/custom_time_range_badge.tsx index 28d99db9b3ef7..764fe520223bf 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/custom_time_range_badge.tsx +++ b/x-pack/plugins/ui_actions_enhanced/public/custom_time_range_badge.tsx @@ -7,7 +7,7 @@ import React from 'react'; import { prettyDuration, commonDurationRanges } from '@elastic/eui'; import { IEmbeddable, Embeddable, EmbeddableInput } from 'src/plugins/embeddable/public'; -import { ActionByType, IncompatibleActionError } from '../../../../src/plugins/ui_actions/public'; +import { Action, IncompatibleActionError } from '../../../../src/plugins/ui_actions/public'; import { TimeRange } from '../../../../src/plugins/data/public'; import { CustomizeTimeRangeModal } from './customize_time_range_modal'; import { doesInheritTimeRange } from './does_inherit_time_range'; @@ -29,7 +29,7 @@ export interface TimeBadgeActionContext { embeddable: Embeddable; } -export class CustomTimeRangeBadge implements ActionByType { +export class CustomTimeRangeBadge implements Action { public readonly type = CUSTOM_TIME_RANGE_BADGE; public readonly id = CUSTOM_TIME_RANGE_BADGE; public order = 7; diff --git a/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/connected_flyout_manage_drilldowns/connected_flyout_manage_drilldowns.tsx b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/connected_flyout_manage_drilldowns/connected_flyout_manage_drilldowns.tsx index 1f148de7b5178..0c804cf584fee 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/connected_flyout_manage_drilldowns/connected_flyout_manage_drilldowns.tsx +++ b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/connected_flyout_manage_drilldowns/connected_flyout_manage_drilldowns.tsx @@ -10,7 +10,7 @@ import { intersection } from 'lodash'; import { DrilldownWizardConfig, FlyoutDrilldownWizard } from '../flyout_drilldown_wizard'; import { FlyoutListManageDrilldowns } from '../flyout_list_manage_drilldowns'; import { IStorageWrapper } from '../../../../../../../src/plugins/kibana_utils/public'; -import { Trigger, TriggerId } from '../../../../../../../src/plugins/ui_actions/public'; +import { Trigger } from '../../../../../../../src/plugins/ui_actions/public'; import { DrilldownListItem } from '../list_manage_drilldowns'; import { insufficientLicenseLevel, invalidDrilldownType } from './i18n'; import { @@ -35,7 +35,7 @@ interface ConnectedFlyoutManageDrilldownsProps< /** * List of possible triggers in current context */ - triggers: TriggerId[]; + triggers: string[]; /** * Extra action factory context passed into action factories CollectConfig, getIconType, getDisplayName and etc... @@ -61,7 +61,7 @@ export function createFlyoutManageDrilldowns({ getTrigger, }: { actionFactories: ActionFactory[]; - getTrigger: (triggerId: TriggerId) => Trigger; + getTrigger: (triggerId: string) => Trigger; storage: IStorageWrapper; toastService: ToastsStart; docsLink?: string; @@ -122,7 +122,7 @@ export function createFlyoutManageDrilldowns({ actionFactory: allActionFactoriesById[drilldownToEdit.action.factoryId], actionConfig: drilldownToEdit.action.config as BaseActionConfig, name: drilldownToEdit.action.name, - selectedTriggers: (drilldownToEdit.triggers ?? []) as TriggerId[], + selectedTriggers: (drilldownToEdit.triggers ?? []) as string[], }; } @@ -133,7 +133,7 @@ export function createFlyoutManageDrilldowns({ const actionFactory = allActionFactoriesById[drilldown.action.factoryId]; const drilldownFactoryContext: BaseActionFactoryContext = { ...props.placeContext, - triggers: drilldown.triggers as TriggerId[], + triggers: drilldown.triggers as string[], }; return { id: drilldown.eventId, @@ -146,7 +146,7 @@ export function createFlyoutManageDrilldowns({ : !actionFactory.isCompatibleLicense() ? insufficientLicenseLevel : undefined, - triggers: drilldown.triggers.map((trigger) => getTrigger(trigger as TriggerId)), + triggers: drilldown.triggers.map((trigger) => getTrigger(trigger as string)), }; } diff --git a/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/connected_flyout_manage_drilldowns/test_data.ts b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/connected_flyout_manage_drilldowns/test_data.ts index 06f63949f6d63..4851a5fab2209 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/connected_flyout_manage_drilldowns/test_data.ts +++ b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/connected_flyout_manage_drilldowns/test_data.ts @@ -11,7 +11,6 @@ import { UiActionsEnhancedDynamicActionManagerState as DynamicActionManagerState, UiActionsEnhancedSerializedAction, } from '../../../index'; -import { TriggerContextMapping } from '../../../../../../../src/plugins/ui_actions/public'; import { createStateContainer } from '../../../../../../../src/plugins/kibana_utils/common'; class MockDynamicActionManager implements PublicMethodsOf { @@ -29,10 +28,7 @@ class MockDynamicActionManager implements PublicMethodsOf return this.state.get().events; } - async createEvent( - action: UiActionsEnhancedSerializedAction, - triggers: Array - ) { + async createEvent(action: UiActionsEnhancedSerializedAction, triggers: string[]) { const event = { action, triggers, @@ -62,7 +58,7 @@ class MockDynamicActionManager implements PublicMethodsOf async updateEvent( eventId: string, action: UiActionsEnhancedSerializedAction, - triggers: Array + triggers: string[] ) { const state = this.state.get(); const events = state.events; diff --git a/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/flyout_drilldown_wizard/flyout_drilldown_wizard.stories.tsx b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/flyout_drilldown_wizard/flyout_drilldown_wizard.stories.tsx index 2f5f7760d40bd..797792eaf9977 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/flyout_drilldown_wizard/flyout_drilldown_wizard.stories.tsx +++ b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/flyout_drilldown_wizard/flyout_drilldown_wizard.stories.tsx @@ -9,16 +9,12 @@ import { EuiFlyout } from '@elastic/eui'; import { storiesOf } from '@storybook/react'; import { FlyoutDrilldownWizard } from './index'; import { mockActionFactories } from '../../../components/action_wizard/test_data'; -import { Trigger, TriggerId } from '../../../../../../../src/plugins/ui_actions/public'; +import { Trigger } from '../../../../../../../src/plugins/ui_actions/public'; const otherProps = { - supportedTriggers: [ - 'VALUE_CLICK_TRIGGER', - 'SELECT_RANGE_TRIGGER', - 'FILTER_TRIGGER', - ] as TriggerId[], + supportedTriggers: ['VALUE_CLICK_TRIGGER', 'SELECT_RANGE_TRIGGER', 'FILTER_TRIGGER'] as string[], onClose: () => {}, - getTrigger: (id: TriggerId) => ({ id } as Trigger), + getTrigger: (id: string) => ({ id } as Trigger), }; storiesOf('components/FlyoutDrilldownWizard', module) diff --git a/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/flyout_drilldown_wizard/flyout_drilldown_wizard.tsx b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/flyout_drilldown_wizard/flyout_drilldown_wizard.tsx index d54bfe0af3b8b..79e94504d8e38 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/flyout_drilldown_wizard/flyout_drilldown_wizard.tsx +++ b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/flyout_drilldown_wizard/flyout_drilldown_wizard.tsx @@ -21,14 +21,14 @@ import { BaseActionConfig, BaseActionFactoryContext, } from '../../../dynamic_actions'; -import { Trigger, TriggerId } from '../../../../../../../src/plugins/ui_actions/public'; +import { Trigger } from '../../../../../../../src/plugins/ui_actions/public'; import { ActionFactoryPlaceContext } from '../types'; export interface DrilldownWizardConfig { name: string; actionFactory?: ActionFactory; actionConfig?: ActionConfig; - selectedTriggers?: TriggerId[]; + selectedTriggers?: string[]; } export interface FlyoutDrilldownWizardProps< @@ -60,12 +60,12 @@ export interface FlyoutDrilldownWizardProps< */ triggerPickerDocsLink?: string; - getTrigger: (triggerId: TriggerId) => Trigger; + getTrigger: (triggerId: string) => Trigger; /** * List of possible triggers in current context */ - supportedTriggers: TriggerId[]; + supportedTriggers: string[]; } function useWizardConfigState( @@ -77,7 +77,7 @@ function useWizardConfigState( setName: (name: string) => void; setActionConfig: (actionConfig: BaseActionConfig) => void; setActionFactory: (actionFactory?: ActionFactory) => void; - setSelectedTriggers: (triggers?: TriggerId[]) => void; + setSelectedTriggers: (triggers?: string[]) => void; } ] { const [wizardConfig, setWizardConfig] = useState( @@ -135,7 +135,7 @@ function useWizardConfigState( }); } }, - setSelectedTriggers: (selectedTriggers: TriggerId[] = []) => { + setSelectedTriggers: (selectedTriggers: string[] = []) => { setWizardConfig({ ...wizardConfig, selectedTriggers, diff --git a/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/form_drilldown_wizard/form_drilldown_wizard.stories.tsx b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/form_drilldown_wizard/form_drilldown_wizard.stories.tsx index 386ec0fb0e62b..65b3bf02eca76 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/form_drilldown_wizard/form_drilldown_wizard.stories.tsx +++ b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/form_drilldown_wizard/form_drilldown_wizard.stories.tsx @@ -7,13 +7,13 @@ import * as React from 'react'; import { storiesOf } from '@storybook/react'; import { FormDrilldownWizard } from './index'; -import { Trigger, TriggerId } from '../../../../../../../src/plugins/ui_actions/public'; +import { Trigger } from '../../../../../../../src/plugins/ui_actions/public'; const otherProps = { - triggers: ['VALUE_CLICK_TRIGGER', 'SELECT_RANGE_TRIGGER', 'FILTER_TRIGGER'] as TriggerId[], - getTriggerInfo: (id: TriggerId) => ({ id } as Trigger), + triggers: ['VALUE_CLICK_TRIGGER', 'SELECT_RANGE_TRIGGER', 'FILTER_TRIGGER'], + getTriggerInfo: (id: string) => ({ id } as Trigger), onSelectedTriggersChange: () => {}, - actionFactoryContext: { triggers: [] as TriggerId[] }, + actionFactoryContext: { triggers: [] as string[] }, }; const DemoEditName: React.FC = () => { diff --git a/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/form_drilldown_wizard/form_drilldown_wizard.test.tsx b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/form_drilldown_wizard/form_drilldown_wizard.test.tsx index 35a897913b537..0483e175b6187 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/form_drilldown_wizard/form_drilldown_wizard.test.tsx +++ b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/form_drilldown_wizard/form_drilldown_wizard.test.tsx @@ -9,12 +9,12 @@ import { render } from 'react-dom'; import { FormDrilldownWizard } from './form_drilldown_wizard'; import { render as renderTestingLibrary, fireEvent } from '@testing-library/react'; import { txtNameOfDrilldown } from './i18n'; -import { Trigger, TriggerId } from '../../../../../../../src/plugins/ui_actions/public'; +import { Trigger } from '../../../../../../../src/plugins/ui_actions/public'; const otherProps = { - actionFactoryContext: { triggers: [] as TriggerId[] }, - triggers: ['VALUE_CLICK_TRIGGER', 'SELECT_RANGE_TRIGGER', 'FILTER_TRIGGER'] as TriggerId[], - getTriggerInfo: (id: TriggerId) => ({ id } as Trigger), + actionFactoryContext: { triggers: [] as string[] }, + triggers: ['VALUE_CLICK_TRIGGER', 'SELECT_RANGE_TRIGGER', 'FILTER_TRIGGER'] as string[], + getTriggerInfo: (id: string) => ({ id } as Trigger), onSelectedTriggersChange: () => {}, }; diff --git a/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/form_drilldown_wizard/form_drilldown_wizard.tsx b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/form_drilldown_wizard/form_drilldown_wizard.tsx index 5f5b577706cf9..9679a8d5d3e44 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/form_drilldown_wizard/form_drilldown_wizard.tsx +++ b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/form_drilldown_wizard/form_drilldown_wizard.tsx @@ -15,7 +15,7 @@ import { BaseActionFactoryContext, } from '../../../dynamic_actions'; import { ActionWizard } from '../../../components/action_wizard'; -import { Trigger, TriggerId } from '../../../../../../../src/plugins/ui_actions/public'; +import { Trigger } from '../../../../../../../src/plugins/ui_actions/public'; import { txtGetMoreActions } from './i18n'; const GET_MORE_ACTIONS_LINK = 'https://www.elastic.co/subscriptions'; @@ -41,14 +41,14 @@ export interface FormDrilldownWizardProps< * Trigger selection has changed * @param triggers */ - onSelectedTriggersChange: (triggers?: TriggerId[]) => void; + onSelectedTriggersChange: (triggers?: string[]) => void; - getTriggerInfo: (triggerId: TriggerId) => Trigger; + getTriggerInfo: (triggerId: string) => Trigger; /** * List of possible triggers in current context */ - triggers: TriggerId[]; + triggers: string[]; triggerPickerDocsLink?: string; } diff --git a/x-pack/plugins/ui_actions_enhanced/public/drilldowns/drilldown_definition.ts b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/drilldown_definition.ts index b55b4b87ebccd..26e670abd7cc9 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/drilldowns/drilldown_definition.ts +++ b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/drilldown_definition.ts @@ -11,7 +11,6 @@ import { SerializedEvent, } from '../dynamic_actions'; import { LicenseType } from '../../../licensing/public'; -import { TriggerContextMapping, TriggerId } from '../../../../../src/plugins/ui_actions/public'; import { ActionExecutionContext } from '../../../../../src/plugins/ui_actions/public'; import { PersistableStateDefinition } from '../../../../../src/plugins/kibana_utils/common'; @@ -31,11 +30,8 @@ import { PersistableStateDefinition } from '../../../../../src/plugins/kibana_ut export interface DrilldownDefinition< Config extends BaseActionConfig = BaseActionConfig, - SupportedTriggers extends TriggerId = TriggerId, - FactoryContext extends BaseActionFactoryContext = { - triggers: SupportedTriggers[]; - }, - ExecutionContext extends TriggerContextMapping[SupportedTriggers] = TriggerContextMapping[SupportedTriggers] + ExecutionContext extends object = object, + FactoryContext extends BaseActionFactoryContext = BaseActionFactoryContext > extends PersistableStateDefinition { /** * Globally unique identifier for this drilldown. @@ -70,12 +66,7 @@ export interface DrilldownDefinition< /** * Function that returns default config for this drilldown. */ - createConfig: ActionFactoryDefinition< - Config, - SupportedTriggers, - FactoryContext, - ExecutionContext - >['createConfig']; + createConfig: ActionFactoryDefinition['createConfig']; /** * `UiComponent` that collections config for this drilldown. You can create @@ -96,23 +87,13 @@ export interface DrilldownDefinition< * export const CollectConfig = uiToReactComponent(ReactCollectConfig); * ``` */ - CollectConfig: ActionFactoryDefinition< - Config, - SupportedTriggers, - FactoryContext, - ExecutionContext - >['CollectConfig']; + CollectConfig: ActionFactoryDefinition['CollectConfig']; /** * A validator function for the config object. Should always return a boolean * given any input. */ - isConfigValid: ActionFactoryDefinition< - Config, - SupportedTriggers, - FactoryContext, - ExecutionContext - >['isConfigValid']; + isConfigValid: ActionFactoryDefinition['isConfigValid']; /** * Name of EUI icon to display when showing this drilldown to user. @@ -160,5 +141,5 @@ export interface DrilldownDefinition< * List of triggers supported by this drilldown type * This is used in trigger picker when configuring drilldown */ - supportedTriggers(): SupportedTriggers[]; + supportedTriggers(): string[]; } diff --git a/x-pack/plugins/ui_actions_enhanced/public/drilldowns/hooks/use_drilldown_state_manager.tsx b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/hooks/use_drilldown_state_manager.tsx index b578e36ba0606..0a546be7e2344 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/drilldowns/hooks/use_drilldown_state_manager.tsx +++ b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/hooks/use_drilldown_state_manager.tsx @@ -7,7 +7,6 @@ import { useState } from 'react'; import { ToastsStart } from 'kibana/public'; import useMountedState from 'react-use/lib/useMountedState'; -import { TriggerId } from '../../../../../../src/plugins/ui_actions/public'; import { useContainerState } from '../../../../../../src/plugins/kibana_utils/public'; import { toastDrilldownCreated, @@ -40,7 +39,7 @@ export function useDrilldownsStateManager( } } - async function createDrilldown(action: SerializedAction, selectedTriggers: TriggerId[]) { + async function createDrilldown(action: SerializedAction, selectedTriggers: string[]) { await run(async () => { await actionManager.createEvent(action, selectedTriggers); toastService.addSuccess({ @@ -53,7 +52,7 @@ export function useDrilldownsStateManager( async function editDrilldown( drilldownId: string, action: SerializedAction, - selectedTriggers: TriggerId[] + selectedTriggers: string[] ) { await run(async () => { await actionManager.updateEvent(drilldownId, action, selectedTriggers); diff --git a/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/action_factory.ts b/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/action_factory.ts index a9c498c0210db..af7a2122fc32b 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/action_factory.ts +++ b/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/action_factory.ts @@ -5,11 +5,7 @@ */ import { uiToReactComponent } from '../../../../../src/plugins/kibana_react/public'; -import { - TriggerContextMapping, - TriggerId, - UiActionsPresentable as Presentable, -} from '../../../../../src/plugins/ui_actions/public'; +import { UiActionsPresentable as Presentable } from '../../../../../src/plugins/ui_actions/public'; import { ActionFactoryDefinition } from './action_factory_definition'; import { Configurable } from '../../../../../src/plugins/kibana_utils/public'; import { @@ -30,22 +26,14 @@ export interface ActionFactoryDeps { export class ActionFactory< Config extends BaseActionConfig = BaseActionConfig, - SupportedTriggers extends TriggerId = TriggerId, - FactoryContext extends BaseActionFactoryContext = { - triggers: SupportedTriggers[]; - }, - ActionContext extends TriggerContextMapping[SupportedTriggers] = TriggerContextMapping[SupportedTriggers] + ExecutionContext extends object = object, + FactoryContext extends BaseActionFactoryContext = BaseActionFactoryContext > implements Omit, 'getHref'>, Configurable, PersistableState { constructor( - protected readonly def: ActionFactoryDefinition< - Config, - SupportedTriggers, - FactoryContext, - ActionContext - >, + protected readonly def: ActionFactoryDefinition, protected readonly deps: ActionFactoryDeps ) { if (def.minimalLicense && !def.licenseFeatureName) { @@ -100,23 +88,23 @@ export class ActionFactory< public create( serializedAction: Omit, 'factoryId'> - ): ActionDefinition { + ): ActionDefinition { const action = this.def.create(serializedAction); return { ...action, - isCompatible: async (context: ActionContext): Promise => { + isCompatible: async (context: ExecutionContext): Promise => { if (!this.isCompatibleLicense()) return false; if (!action.isCompatible) return true; return action.isCompatible(context); }, - execute: async (context: ActionContext): Promise => { + execute: async (context: ExecutionContext): Promise => { this.notifyFeatureUsage(); return action.execute(context); }, }; } - public supportedTriggers(): SupportedTriggers[] { + public supportedTriggers(): string[] { return this.def.supportedTriggers(); } diff --git a/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/action_factory_definition.ts b/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/action_factory_definition.ts index b4df1f827a2a3..1bfbb2edb98b5 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/action_factory_definition.ts +++ b/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/action_factory_definition.ts @@ -13,8 +13,6 @@ import { } from './types'; import { LicenseType } from '../../../licensing/public'; import { - TriggerContextMapping, - TriggerId, UiActionsActionDefinition as ActionDefinition, UiActionsPresentable as Presentable, } from '../../../../../src/plugins/ui_actions/public'; @@ -25,11 +23,8 @@ import { PersistableStateDefinition } from '../../../../../src/plugins/kibana_ut */ export interface ActionFactoryDefinition< Config extends BaseActionConfig = BaseActionConfig, - SupportedTriggers extends TriggerId = TriggerId, - FactoryContext extends BaseActionFactoryContext = { - triggers: SupportedTriggers[]; - }, - ActionContext extends TriggerContextMapping[SupportedTriggers] = TriggerContextMapping[SupportedTriggers] + ExecutionContext extends object = object, + FactoryContext extends BaseActionFactoryContext = BaseActionFactoryContext > extends Partial, 'getHref'>>, Configurable, PersistableStateDefinition { @@ -65,7 +60,7 @@ export interface ActionFactoryDefinition< */ create( serializedAction: Omit, 'factoryId'> - ): ActionDefinition; + ): ActionDefinition; - supportedTriggers(): SupportedTriggers[]; + supportedTriggers(): string[]; } diff --git a/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/dynamic_action_manager.ts b/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/dynamic_action_manager.ts index f096b17f8a78d..ff8528e6791f9 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/dynamic_action_manager.ts +++ b/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/dynamic_action_manager.ts @@ -7,10 +7,7 @@ import { v4 as uuidv4 } from 'uuid'; import { Subscription } from 'rxjs'; import { ActionStorage } from './dynamic_action_storage'; -import { - TriggerContextMapping, - UiActionsActionDefinition as ActionDefinition, -} from '../../../../../src/plugins/ui_actions/public'; +import { UiActionsActionDefinition as ActionDefinition } from '../../../../../src/plugins/ui_actions/public'; import { defaultState, transitions, selectors, State } from './dynamic_action_manager_state'; import { StateContainer, @@ -214,7 +211,7 @@ export class DynamicActionManager { * @param action Dynamic action for which to create an event. * @param triggers List of triggers to which action should react. */ - public async createEvent(action: SerializedAction, triggers: Array) { + public async createEvent(action: SerializedAction, triggers: string[]) { const event: SerializedEvent = { eventId: uuidv4(), triggers, @@ -245,11 +242,7 @@ export class DynamicActionManager { * @param action New action for which to create the event. * @param triggers List of triggers to which action should react. */ - public async updateEvent( - eventId: string, - action: SerializedAction, - triggers: Array - ) { + public async updateEvent(eventId: string, action: SerializedAction, triggers: string[]) { const event: SerializedEvent = { eventId, triggers, diff --git a/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/types.ts b/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/types.ts index 28d104093f64f..78e8b20870ed8 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/types.ts +++ b/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/types.ts @@ -4,7 +4,6 @@ * you may not use this file except in compliance with the Elastic License. */ -import { TriggerId } from '../../../../../src/plugins/ui_actions/public'; import { SerializedAction, SerializedEvent, BaseActionConfig } from '../../common/types'; export { SerializedAction, SerializedEvent, BaseActionConfig }; @@ -12,6 +11,6 @@ export { SerializedAction, SerializedEvent, BaseActionConfig }; /** * Action factory context passed into ActionFactories' CollectConfig, getDisplayName, getIconType */ -export interface BaseActionFactoryContext { - triggers: SupportedTriggers[]; +export interface BaseActionFactoryContext { + triggers: string[]; } diff --git a/x-pack/plugins/ui_actions_enhanced/public/plugin.ts b/x-pack/plugins/ui_actions_enhanced/public/plugin.ts index 31236d2ea9779..dc46f021cd77b 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/plugin.ts +++ b/x-pack/plugins/ui_actions_enhanced/public/plugin.ts @@ -13,27 +13,15 @@ import { } from '../../../../src/core/public'; import { createReactOverlays } from '../../../../src/plugins/kibana_react/public'; import { UI_SETTINGS } from '../../../../src/plugins/data/public'; -import { - TriggerId, - UiActionsSetup, - UiActionsStart, -} from '../../../../src/plugins/ui_actions/public'; +import { UiActionsSetup, UiActionsStart } from '../../../../src/plugins/ui_actions/public'; import { CONTEXT_MENU_TRIGGER, PANEL_BADGE_TRIGGER, EmbeddableSetup, EmbeddableStart, } from '../../../../src/plugins/embeddable/public'; -import { - CustomTimeRangeAction, - CUSTOM_TIME_RANGE, - TimeRangeActionContext, -} from './custom_time_range_action'; -import { - CustomTimeRangeBadge, - CUSTOM_TIME_RANGE_BADGE, - TimeBadgeActionContext, -} from './custom_time_range_badge'; +import { CustomTimeRangeAction } from './custom_time_range_action'; +import { CustomTimeRangeBadge } from './custom_time_range_badge'; import { CommonlyUsedRange } from './types'; import { UiActionsServiceEnhancements } from './services'; import { ILicense, LicensingPluginSetup, LicensingPluginStart } from '../../licensing/public'; @@ -71,13 +59,6 @@ export interface StartContract FlyoutManageDrilldowns: ReturnType; } -declare module '../../../../src/plugins/ui_actions/public' { - export interface ActionContextMapping { - [CUSTOM_TIME_RANGE]: TimeRangeActionContext; - [CUSTOM_TIME_RANGE_BADGE]: TimeBadgeActionContext; - } -} - export class AdvancedUiActionsPublicPlugin implements Plugin { readonly licenseInfo = new BehaviorSubject(undefined); @@ -138,7 +119,7 @@ export class AdvancedUiActionsPublicPlugin ...this.enhancements!, FlyoutManageDrilldowns: createFlyoutManageDrilldowns({ actionFactories: this.enhancements!.getActionFactories(), - getTrigger: (triggerId: TriggerId) => uiActions.getTrigger(triggerId), + getTrigger: (triggerId) => uiActions.getTrigger(triggerId), storage: new Storage(window?.localStorage), toastService: core.notifications.toasts, docsLink: core.docLinks.links.dashboard.drilldowns, diff --git a/x-pack/plugins/ui_actions_enhanced/public/services/ui_actions_service_enhancements.ts b/x-pack/plugins/ui_actions_enhanced/public/services/ui_actions_service_enhancements.ts index 0da2dc6da2c25..2225c77a31101 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/services/ui_actions_service_enhancements.ts +++ b/x-pack/plugins/ui_actions_enhanced/public/services/ui_actions_service_enhancements.ts @@ -14,7 +14,6 @@ import { } from '../dynamic_actions'; import { DrilldownDefinition } from '../drilldowns'; import { ILicense } from '../../../licensing/common/types'; -import { TriggerContextMapping, TriggerId } from '../../../../../src/plugins/ui_actions/public'; import { LicensingPluginSetup, LicensingPluginStart } from '../../../licensing/public'; import { SavedObjectReference } from '../../../../../src/core/types'; import { PersistableStateDefinition } from '../../../../../src/plugins/kibana_utils/common'; @@ -46,24 +45,19 @@ export class UiActionsServiceEnhancements */ public readonly registerActionFactory = < Config extends BaseActionConfig = BaseActionConfig, - SupportedTriggers extends TriggerId = TriggerId, - FactoryContext extends BaseActionFactoryContext = { - triggers: SupportedTriggers[]; - }, - ActionContext extends TriggerContextMapping[SupportedTriggers] = TriggerContextMapping[SupportedTriggers] + ExecutionContext extends object = object, + FactoryContext extends BaseActionFactoryContext = BaseActionFactoryContext >( - definition: ActionFactoryDefinition + definition: ActionFactoryDefinition ) => { if (this.actionFactories.has(definition.id)) { throw new Error(`ActionFactory [actionFactory.id = ${definition.id}] already registered.`); } - const actionFactory = new ActionFactory< - Config, - SupportedTriggers, - FactoryContext, - ActionContext - >(definition, this.deps); + const actionFactory = new ActionFactory( + definition, + this.deps + ); this.actionFactories.set(actionFactory.id, actionFactory as ActionFactory); this.registerFeatureUsage(definition); @@ -95,11 +89,8 @@ export class UiActionsServiceEnhancements */ public readonly registerDrilldown = < Config extends BaseActionConfig = BaseActionConfig, - SupportedTriggers extends TriggerId = TriggerId, - FactoryContext extends BaseActionFactoryContext = { - triggers: SupportedTriggers[]; - }, - ExecutionContext extends TriggerContextMapping[SupportedTriggers] = TriggerContextMapping[SupportedTriggers] + ExecutionContext extends object = object, + FactoryContext extends BaseActionFactoryContext = BaseActionFactoryContext >({ id: factoryId, isBeta, @@ -118,13 +109,8 @@ export class UiActionsServiceEnhancements telemetry, extract, inject, - }: DrilldownDefinition): void => { - const actionFactory: ActionFactoryDefinition< - Config, - SupportedTriggers, - FactoryContext, - ExecutionContext - > = { + }: DrilldownDefinition): void => { + const actionFactory: ActionFactoryDefinition = { id: factoryId, isBeta, minimalLicense, @@ -151,7 +137,7 @@ export class UiActionsServiceEnhancements ? async (context) => isCompatible(serializedAction.config, context) : undefined, }), - } as ActionFactoryDefinition; + } as ActionFactoryDefinition; this.registerActionFactory(actionFactory); };