* 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 <restrry@gmail.com> Co-authored-by: Josh Dover <me@joshdover.com>
This commit is contained in:
parent
23083b1404
commit
5bb0186c15
|
@ -7,5 +7,5 @@
|
||||||
<b>Signature:</b>
|
<b>Signature:</b>
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
contextMenuTrigger: Trigger<'CONTEXT_MENU_TRIGGER'>
|
contextMenuTrigger: Trigger
|
||||||
```
|
```
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
<b>Signature:</b>
|
<b>Signature:</b>
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
supportedTriggers(): Array<keyof TriggerContextMapping>;
|
supportedTriggers(): string[];
|
||||||
```
|
```
|
||||||
<b>Returns:</b>
|
<b>Returns:</b>
|
||||||
|
|
||||||
`Array<keyof TriggerContextMapping>`
|
`string[]`
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,9 @@ List of triggers that this embeddable will execute.
|
||||||
<b>Signature:</b>
|
<b>Signature:</b>
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
supportedTriggers(): Array<keyof TriggerContextMapping>;
|
supportedTriggers(): string[];
|
||||||
```
|
```
|
||||||
<b>Returns:</b>
|
<b>Returns:</b>
|
||||||
|
|
||||||
`Array<keyof TriggerContextMapping>`
|
`string[]`
|
||||||
|
|
||||||
|
|
|
@ -7,5 +7,5 @@
|
||||||
<b>Signature:</b>
|
<b>Signature:</b>
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
panelBadgeTrigger: Trigger<'PANEL_BADGE_TRIGGER'>
|
panelBadgeTrigger: Trigger
|
||||||
```
|
```
|
||||||
|
|
|
@ -7,5 +7,5 @@
|
||||||
<b>Signature:</b>
|
<b>Signature:</b>
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
panelNotificationTrigger: Trigger<'PANEL_NOTIFICATION_TRIGGER'>
|
panelNotificationTrigger: Trigger
|
||||||
```
|
```
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<b>Signature:</b>
|
<b>Signature:</b>
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
export interface Action<Context extends BaseContext = {}, T = ActionType> extends Partial<Presentable<ActionExecutionContext<Context>>>
|
export interface Action<Context extends object = object> extends Partial<Presentable<ActionExecutionContext<Context>>>
|
||||||
```
|
```
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
@ -17,7 +17,7 @@ export interface Action<Context extends BaseContext = {}, T = ActionType> extend
|
||||||
| [id](./kibana-plugin-plugins-ui_actions-public.action.id.md) | <code>string</code> | A unique identifier for this action instance. |
|
| [id](./kibana-plugin-plugins-ui_actions-public.action.id.md) | <code>string</code> | A unique identifier for this action instance. |
|
||||||
| [MenuItem](./kibana-plugin-plugins-ui_actions-public.action.menuitem.md) | <code>UiComponent<{</code><br/><code> context: ActionExecutionContext<Context>;</code><br/><code> }></code> | <code>UiComponent</code> to render when displaying this action as a context menu item. If not provided, <code>getDisplayName</code> will be used instead. |
|
| [MenuItem](./kibana-plugin-plugins-ui_actions-public.action.menuitem.md) | <code>UiComponent<{</code><br/><code> context: ActionExecutionContext<Context>;</code><br/><code> }></code> | <code>UiComponent</code> to render when displaying this action as a context menu item. If not provided, <code>getDisplayName</code> will be used instead. |
|
||||||
| [order](./kibana-plugin-plugins-ui_actions-public.action.order.md) | <code>number</code> | Determined the order when there is more than one action matched to a trigger. Higher numbers are displayed first. |
|
| [order](./kibana-plugin-plugins-ui_actions-public.action.order.md) | <code>number</code> | 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) | <code>T</code> | The action type is what determines the context shape. |
|
| [type](./kibana-plugin-plugins-ui_actions-public.action.type.md) | <code>string</code> | The action type is what determines the context shape. |
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
|
|
|
@ -9,5 +9,5 @@ The action type is what determines the context shape.
|
||||||
<b>Signature:</b>
|
<b>Signature:</b>
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
readonly type: T;
|
readonly type: string;
|
||||||
```
|
```
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
||||||
|
|
||||||
[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
|
|
||||||
|
|
||||||
<b>Signature:</b>
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
export declare type ActionByType<T extends ActionType> = Action<ActionContextMapping[T], T>;
|
|
||||||
```
|
|
|
@ -1,11 +0,0 @@
|
||||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
||||||
|
|
||||||
[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
|
|
||||||
|
|
||||||
<b>Signature:</b>
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
[DEFAULT_ACTION]: BaseContext;
|
|
||||||
```
|
|
|
@ -1,11 +0,0 @@
|
||||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
||||||
|
|
||||||
[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
|
|
||||||
|
|
||||||
<b>Signature:</b>
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
[ACTION_VISUALIZE_FIELD]: VisualizeFieldContext;
|
|
||||||
```
|
|
|
@ -1,11 +0,0 @@
|
||||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
||||||
|
|
||||||
[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
|
|
||||||
|
|
||||||
<b>Signature:</b>
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
[ACTION_VISUALIZE_GEO_FIELD]: VisualizeFieldContext;
|
|
||||||
```
|
|
|
@ -1,11 +0,0 @@
|
||||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
||||||
|
|
||||||
[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
|
|
||||||
|
|
||||||
<b>Signature:</b>
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
[ACTION_VISUALIZE_LENS_FIELD]: VisualizeFieldContext;
|
|
||||||
```
|
|
|
@ -1,21 +0,0 @@
|
||||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
||||||
|
|
||||||
[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
|
|
||||||
|
|
||||||
<b>Signature:</b>
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
export interface ActionContextMapping
|
|
||||||
```
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
| Property | Type | Description |
|
|
||||||
| --- | --- | --- |
|
|
||||||
| [""](./kibana-plugin-plugins-ui_actions-public.actioncontextmapping.__.md) | <code>BaseContext</code> | |
|
|
||||||
| [ACTION\_VISUALIZE\_FIELD](./kibana-plugin-plugins-ui_actions-public.actioncontextmapping.action_visualize_field.md) | <code>VisualizeFieldContext</code> | |
|
|
||||||
| [ACTION\_VISUALIZE\_GEO\_FIELD](./kibana-plugin-plugins-ui_actions-public.actioncontextmapping.action_visualize_geo_field.md) | <code>VisualizeFieldContext</code> | |
|
|
||||||
| [ACTION\_VISUALIZE\_LENS\_FIELD](./kibana-plugin-plugins-ui_actions-public.actioncontextmapping.action_visualize_lens_field.md) | <code>VisualizeFieldContext</code> | |
|
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
||||||
|
|
||||||
[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
|
|
||||||
|
|
||||||
<b>Signature:</b>
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
export declare type ActionDefinitionByType<T extends ActionType> = ActionDefinition<ActionContextMapping[T]>;
|
|
||||||
```
|
|
|
@ -9,5 +9,5 @@ Action methods are executed with Context from trigger + [ActionExecutionMeta](./
|
||||||
<b>Signature:</b>
|
<b>Signature:</b>
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
export declare type ActionExecutionContext<Context extends BaseContext = BaseContext> = Context & ActionExecutionMeta;
|
export declare type ActionExecutionContext<Context extends object = object> = Context & ActionExecutionMeta;
|
||||||
```
|
```
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
||||||
|
|
||||||
[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
|
|
||||||
|
|
||||||
<b>Signature:</b>
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
export declare type ActionType = keyof ActionContextMapping;
|
|
||||||
```
|
|
|
@ -7,16 +7,16 @@
|
||||||
<b>Signature:</b>
|
<b>Signature:</b>
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
export declare function createAction<T extends ActionType>(action: ActionDefinitionByType<T>): ActionByType<T>;
|
export declare function createAction<Context extends object = object>(action: ActionDefinition<Context>): Action<Context>;
|
||||||
```
|
```
|
||||||
|
|
||||||
## Parameters
|
## Parameters
|
||||||
|
|
||||||
| Parameter | Type | Description |
|
| Parameter | Type | Description |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| action | <code>ActionDefinitionByType<T></code> | |
|
| action | <code>ActionDefinition<Context></code> | |
|
||||||
|
|
||||||
<b>Returns:</b>
|
<b>Returns:</b>
|
||||||
|
|
||||||
`ActionByType<T>`
|
`Action<Context>`
|
||||||
|
|
||||||
|
|
|
@ -24,11 +24,9 @@
|
||||||
| Interface | Description |
|
| Interface | Description |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| [Action](./kibana-plugin-plugins-ui_actions-public.action.md) | |
|
| [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 |
|
| [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) | |
|
| [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\*.<code>Trigger</code> specifies a named anchor to which <code>Action</code> can be attached. When <code>Trigger</code> is being \*called\* it creates a <code>Context</code> object and passes it to the <code>execute</code> method of an <code>Action</code>.<!-- -->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. |
|
| [Trigger](./kibana-plugin-plugins-ui_actions-public.trigger.md) | This is a convenience interface used to register a \*trigger\*.<code>Trigger</code> specifies a named anchor to which <code>Action</code> can be attached. When <code>Trigger</code> is being \*called\* it creates a <code>Context</code> object and passes it to the <code>execute</code> method of an <code>Action</code>.<!-- -->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. |
|
| [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. |
|
| [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) | |
|
| [UiActionsServiceParams](./kibana-plugin-plugins-ui_actions-public.uiactionsserviceparams.md) | |
|
||||||
|
@ -52,12 +50,7 @@
|
||||||
|
|
||||||
| Type Alias | Description |
|
| 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) |
|
| [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) | |
|
| [UiActionsPresentableGrouping](./kibana-plugin-plugins-ui_actions-public.uiactionspresentablegrouping.md) | |
|
||||||
| [UiActionsSetup](./kibana-plugin-plugins-ui_actions-public.uiactionssetup.md) | |
|
| [UiActionsSetup](./kibana-plugin-plugins-ui_actions-public.uiactionssetup.md) | |
|
||||||
| [UiActionsStart](./kibana-plugin-plugins-ui_actions-public.uiactionsstart.md) | |
|
| [UiActionsStart](./kibana-plugin-plugins-ui_actions-public.uiactionsstart.md) | |
|
||||||
|
|
|
@ -7,5 +7,5 @@
|
||||||
<b>Signature:</b>
|
<b>Signature:</b>
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
rowClickTrigger: Trigger<'ROW_CLICK_TRIGGER'>
|
rowClickTrigger: Trigger
|
||||||
```
|
```
|
||||||
|
|
|
@ -9,5 +9,5 @@ Unique name of the trigger as identified in `ui_actions` plugin trigger registry
|
||||||
<b>Signature:</b>
|
<b>Signature:</b>
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
id: ID;
|
id: string;
|
||||||
```
|
```
|
||||||
|
|
|
@ -13,7 +13,7 @@ More than one action can be attached to a single trigger, in which case when tri
|
||||||
<b>Signature:</b>
|
<b>Signature:</b>
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
export interface Trigger<ID extends TriggerId = TriggerId>
|
export interface Trigger
|
||||||
```
|
```
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
@ -21,6 +21,6 @@ export interface Trigger<ID extends TriggerId = TriggerId>
|
||||||
| Property | Type | Description |
|
| Property | Type | Description |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| [description](./kibana-plugin-plugins-ui_actions-public.trigger.description.md) | <code>string</code> | A longer user friendly description of the trigger. |
|
| [description](./kibana-plugin-plugins-ui_actions-public.trigger.description.md) | <code>string</code> | A longer user friendly description of the trigger. |
|
||||||
| [id](./kibana-plugin-plugins-ui_actions-public.trigger.id.md) | <code>ID</code> | Unique name of the trigger as identified in <code>ui_actions</code> plugin trigger registry. |
|
| [id](./kibana-plugin-plugins-ui_actions-public.trigger.id.md) | <code>string</code> | Unique name of the trigger as identified in <code>ui_actions</code> plugin trigger registry. |
|
||||||
| [title](./kibana-plugin-plugins-ui_actions-public.trigger.title.md) | <code>string</code> | User friendly name of the trigger. |
|
| [title](./kibana-plugin-plugins-ui_actions-public.trigger.title.md) | <code>string</code> | User friendly name of the trigger. |
|
||||||
|
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
||||||
|
|
||||||
[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
|
|
||||||
|
|
||||||
<b>Signature:</b>
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
export declare type TriggerContext<T> = T extends TriggerId ? TriggerContextMapping[T] : never;
|
|
||||||
```
|
|
|
@ -1,11 +0,0 @@
|
||||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
||||||
|
|
||||||
[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
|
|
||||||
|
|
||||||
<b>Signature:</b>
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
[DEFAULT_TRIGGER]: TriggerContext;
|
|
||||||
```
|
|
|
@ -1,21 +0,0 @@
|
||||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
||||||
|
|
||||||
[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
|
|
||||||
|
|
||||||
<b>Signature:</b>
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
export interface TriggerContextMapping
|
|
||||||
```
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
| Property | Type | Description |
|
|
||||||
| --- | --- | --- |
|
|
||||||
| [""](./kibana-plugin-plugins-ui_actions-public.triggercontextmapping.__.md) | <code>TriggerContext</code> | |
|
|
||||||
| [ROW\_CLICK\_TRIGGER](./kibana-plugin-plugins-ui_actions-public.triggercontextmapping.row_click_trigger.md) | <code>RowClickContext</code> | |
|
|
||||||
| [VISUALIZE\_FIELD\_TRIGGER](./kibana-plugin-plugins-ui_actions-public.triggercontextmapping.visualize_field_trigger.md) | <code>VisualizeFieldContext</code> | |
|
|
||||||
| [VISUALIZE\_GEO\_FIELD\_TRIGGER](./kibana-plugin-plugins-ui_actions-public.triggercontextmapping.visualize_geo_field_trigger.md) | <code>VisualizeFieldContext</code> | |
|
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
||||||
|
|
||||||
[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
|
|
||||||
|
|
||||||
<b>Signature:</b>
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
[ROW_CLICK_TRIGGER]: RowClickContext;
|
|
||||||
```
|
|
|
@ -1,11 +0,0 @@
|
||||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
||||||
|
|
||||||
[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
|
|
||||||
|
|
||||||
<b>Signature:</b>
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
[VISUALIZE_FIELD_TRIGGER]: VisualizeFieldContext;
|
|
||||||
```
|
|
|
@ -1,11 +0,0 @@
|
||||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
||||||
|
|
||||||
[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
|
|
||||||
|
|
||||||
<b>Signature:</b>
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
[VISUALIZE_GEO_FIELD_TRIGGER]: VisualizeFieldContext;
|
|
||||||
```
|
|
|
@ -1,11 +0,0 @@
|
||||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
||||||
|
|
||||||
[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
|
|
||||||
|
|
||||||
<b>Signature:</b>
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
export declare type TriggerId = keyof TriggerContextMapping;
|
|
||||||
```
|
|
|
@ -9,7 +9,7 @@ A convenience interface used to register an action.
|
||||||
<b>Signature:</b>
|
<b>Signature:</b>
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
export interface ActionDefinition<Context extends BaseContext = {}> extends Partial<Presentable<ActionDefinitionContext<Context>>>
|
export interface ActionDefinition<Context extends object = object> extends Partial<Presentable<ActionDefinitionContext<Context>>>
|
||||||
```
|
```
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
@ -17,7 +17,7 @@ export interface ActionDefinition<Context extends BaseContext = {}> extends Part
|
||||||
| Property | Type | Description |
|
| Property | Type | Description |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| [id](./kibana-plugin-plugins-ui_actions-public.uiactionsactiondefinition.id.md) | <code>string</code> | ID of the action that uniquely identifies this action in the actions registry. |
|
| [id](./kibana-plugin-plugins-ui_actions-public.uiactionsactiondefinition.id.md) | <code>string</code> | ID of the action that uniquely identifies this action in the actions registry. |
|
||||||
| [type](./kibana-plugin-plugins-ui_actions-public.uiactionsactiondefinition.type.md) | <code>ActionType</code> | ID of the factory for this action. Used to construct dynamic actions. |
|
| [type](./kibana-plugin-plugins-ui_actions-public.uiactionsactiondefinition.type.md) | <code>string</code> | ID of the factory for this action. Used to construct dynamic actions. |
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
|
|
|
@ -9,5 +9,5 @@ ID of the factory for this action. Used to construct dynamic actions.
|
||||||
<b>Signature:</b>
|
<b>Signature:</b>
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
readonly type?: ActionType;
|
readonly type?: string;
|
||||||
```
|
```
|
||||||
|
|
|
@ -9,7 +9,7 @@ Represents something that can be displayed to user in UI.
|
||||||
<b>Signature:</b>
|
<b>Signature:</b>
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
export interface Presentable<Context extends object = object>
|
export interface Presentable<Context = unknown>
|
||||||
```
|
```
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
|
@ -7,5 +7,5 @@
|
||||||
<b>Signature:</b>
|
<b>Signature:</b>
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
export declare type PresentableGrouping<Context extends object = object> = Array<PresentableGroup<Context>>;
|
export declare type PresentableGrouping<Context = unknown> = Array<PresentableGroup<Context>>;
|
||||||
```
|
```
|
||||||
|
|
|
@ -11,5 +11,5 @@
|
||||||
<b>Signature:</b>
|
<b>Signature:</b>
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
readonly addTriggerAction: <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;
|
readonly addTriggerAction: (triggerId: string, action: ActionDefinition) => void;
|
||||||
```
|
```
|
||||||
|
|
|
@ -7,5 +7,5 @@
|
||||||
<b>Signature:</b>
|
<b>Signature:</b>
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
readonly attachAction: <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;
|
readonly attachAction: (triggerId: string, actionId: string) => void;
|
||||||
```
|
```
|
||||||
|
|
|
@ -7,5 +7,5 @@
|
||||||
<b>Signature:</b>
|
<b>Signature:</b>
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
readonly detachAction: (triggerId: TriggerId, actionId: string) => void;
|
readonly detachAction: (triggerId: string, actionId: string) => void;
|
||||||
```
|
```
|
||||||
|
|
|
@ -12,5 +12,5 @@
|
||||||
<b>Signature:</b>
|
<b>Signature:</b>
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
readonly executeTriggerActions: <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>;
|
readonly executeTriggerActions: (triggerId: string, context: object) => Promise<void>;
|
||||||
```
|
```
|
||||||
|
|
|
@ -7,5 +7,5 @@
|
||||||
<b>Signature:</b>
|
<b>Signature:</b>
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
readonly getAction: <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">;
|
readonly getAction: <T extends ActionDefinition<object>>(id: string) => Action<ActionContext<T>>;
|
||||||
```
|
```
|
||||||
|
|
|
@ -7,5 +7,5 @@
|
||||||
<b>Signature:</b>
|
<b>Signature:</b>
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
readonly getTrigger: <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>;
|
readonly getTrigger: (triggerId: string) => TriggerContract;
|
||||||
```
|
```
|
||||||
|
|
|
@ -7,5 +7,5 @@
|
||||||
<b>Signature:</b>
|
<b>Signature:</b>
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
readonly getTriggerActions: <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">[];
|
readonly getTriggerActions: (triggerId: string) => Action[];
|
||||||
```
|
```
|
||||||
|
|
|
@ -7,5 +7,5 @@
|
||||||
<b>Signature:</b>
|
<b>Signature:</b>
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
readonly getTriggerCompatibleActions: <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">[]>;
|
readonly getTriggerCompatibleActions: (triggerId: string, context: object) => Promise<Action[]>;
|
||||||
```
|
```
|
||||||
|
|
|
@ -21,19 +21,19 @@ export declare class UiActionsService
|
||||||
| Property | Modifiers | Type | Description |
|
| Property | Modifiers | Type | Description |
|
||||||
| --- | --- | --- | --- |
|
| --- | --- | --- | --- |
|
||||||
| [actions](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.actions.md) | | <code>ActionRegistry</code> | |
|
| [actions](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.actions.md) | | <code>ActionRegistry</code> | |
|
||||||
| [addTriggerAction](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.addtriggeraction.md) | | <code><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</code> | <code>addTriggerAction</code> is similar to <code>attachAction</code> as it attaches action to a trigger, but it also registers the action, if it has not been registered, yet.<code>addTriggerAction</code> also infers better typing of the <code>action</code> argument. |
|
| [addTriggerAction](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.addtriggeraction.md) | | <code>(triggerId: string, action: ActionDefinition) => void</code> | <code>addTriggerAction</code> is similar to <code>attachAction</code> as it attaches action to a trigger, but it also registers the action, if it has not been registered, yet.<code>addTriggerAction</code> also infers better typing of the <code>action</code> argument. |
|
||||||
| [attachAction](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.attachaction.md) | | <code><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</code> | |
|
| [attachAction](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.attachaction.md) | | <code>(triggerId: string, actionId: string) => void</code> | |
|
||||||
| [clear](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.clear.md) | | <code>() => void</code> | Removes all registered triggers and actions. |
|
| [clear](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.clear.md) | | <code>() => void</code> | Removes all registered triggers and actions. |
|
||||||
| [detachAction](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.detachaction.md) | | <code>(triggerId: TriggerId, actionId: string) => void</code> | |
|
| [detachAction](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.detachaction.md) | | <code>(triggerId: string, actionId: string) => void</code> | |
|
||||||
| [executeTriggerActions](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.executetriggeractions.md) | | <code><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></code> | |
|
| [executeTriggerActions](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.executetriggeractions.md) | | <code>(triggerId: string, context: object) => Promise<void></code> | |
|
||||||
| [executionService](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.executionservice.md) | | <code>UiActionsExecutionService</code> | |
|
| [executionService](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.executionservice.md) | | <code>UiActionsExecutionService</code> | |
|
||||||
| [fork](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.fork.md) | | <code>() => UiActionsService</code> | "Fork" a separate instance of <code>UiActionsService</code> that inherits all existing triggers and actions, but going forward all new triggers and actions added to this instance of <code>UiActionsService</code> are only available within this instance. |
|
| [fork](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.fork.md) | | <code>() => UiActionsService</code> | "Fork" a separate instance of <code>UiActionsService</code> that inherits all existing triggers and actions, but going forward all new triggers and actions added to this instance of <code>UiActionsService</code> are only available within this instance. |
|
||||||
| [getAction](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.getaction.md) | | <code><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"></code> | |
|
| [getAction](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.getaction.md) | | <code><T extends ActionDefinition<object>>(id: string) => Action<ActionContext<T>></code> | |
|
||||||
| [getTrigger](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.gettrigger.md) | | <code><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></code> | |
|
| [getTrigger](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.gettrigger.md) | | <code>(triggerId: string) => TriggerContract</code> | |
|
||||||
| [getTriggerActions](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.gettriggeractions.md) | | <code><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">[]</code> | |
|
| [getTriggerActions](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.gettriggeractions.md) | | <code>(triggerId: string) => Action[]</code> | |
|
||||||
| [getTriggerCompatibleActions](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.gettriggercompatibleactions.md) | | <code><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">[]></code> | |
|
| [getTriggerCompatibleActions](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.gettriggercompatibleactions.md) | | <code>(triggerId: string, context: object) => Promise<Action[]></code> | |
|
||||||
| [hasAction](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.hasaction.md) | | <code>(actionId: string) => boolean</code> | |
|
| [hasAction](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.hasaction.md) | | <code>(actionId: string) => boolean</code> | |
|
||||||
| [registerAction](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.registeraction.md) | | <code><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"></code> | |
|
| [registerAction](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.registeraction.md) | | <code><A extends ActionDefinition<object>>(definition: A) => Action<ActionContext<A>></code> | |
|
||||||
| [registerTrigger](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.registertrigger.md) | | <code>(trigger: Trigger) => void</code> | |
|
| [registerTrigger](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.registertrigger.md) | | <code>(trigger: Trigger) => void</code> | |
|
||||||
| [triggers](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.triggers.md) | | <code>TriggerRegistry</code> | |
|
| [triggers](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.triggers.md) | | <code>TriggerRegistry</code> | |
|
||||||
| [triggerToActions](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.triggertoactions.md) | | <code>TriggerToActionsRegistry</code> | |
|
| [triggerToActions](./kibana-plugin-plugins-ui_actions-public.uiactionsservice.triggertoactions.md) | | <code>TriggerToActionsRegistry</code> | |
|
||||||
|
|
|
@ -7,5 +7,5 @@
|
||||||
<b>Signature:</b>
|
<b>Signature:</b>
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
readonly registerAction: <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">;
|
readonly registerAction: <A extends ActionDefinition<object>>(definition: A) => Action<ActionContext<A>>;
|
||||||
```
|
```
|
||||||
|
|
|
@ -7,5 +7,5 @@
|
||||||
<b>Signature:</b>
|
<b>Signature:</b>
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
visualizeFieldTrigger: Trigger<'VISUALIZE_FIELD_TRIGGER'>
|
visualizeFieldTrigger: Trigger
|
||||||
```
|
```
|
||||||
|
|
|
@ -7,5 +7,5 @@
|
||||||
<b>Signature:</b>
|
<b>Signature:</b>
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
visualizeGeoFieldTrigger: Trigger<'VISUALIZE_GEO_FIELD_TRIGGER'>
|
visualizeGeoFieldTrigger: Trigger
|
||||||
```
|
```
|
||||||
|
|
|
@ -35,6 +35,7 @@ export const createAddBookToLibraryAction = () =>
|
||||||
i18n.translate('embeddableExamples.book.addToLibrary', {
|
i18n.translate('embeddableExamples.book.addToLibrary', {
|
||||||
defaultMessage: 'Add Book To Library',
|
defaultMessage: 'Add Book To Library',
|
||||||
}),
|
}),
|
||||||
|
id: ACTION_ADD_BOOK_TO_LIBRARY,
|
||||||
type: ACTION_ADD_BOOK_TO_LIBRARY,
|
type: ACTION_ADD_BOOK_TO_LIBRARY,
|
||||||
order: 100,
|
order: 100,
|
||||||
getIconType: () => 'folderCheck',
|
getIconType: () => 'folderCheck',
|
||||||
|
|
|
@ -53,6 +53,7 @@ export const createEditBookAction = (getStartServices: () => Promise<StartServic
|
||||||
createAction({
|
createAction({
|
||||||
getDisplayName: () =>
|
getDisplayName: () =>
|
||||||
i18n.translate('embeddableExamples.book.edit', { defaultMessage: 'Edit Book' }),
|
i18n.translate('embeddableExamples.book.edit', { defaultMessage: 'Edit Book' }),
|
||||||
|
id: ACTION_EDIT_BOOK,
|
||||||
type: ACTION_EDIT_BOOK,
|
type: ACTION_EDIT_BOOK,
|
||||||
order: 100,
|
order: 100,
|
||||||
getIconType: () => 'documents',
|
getIconType: () => 'documents',
|
||||||
|
|
|
@ -35,6 +35,7 @@ export const createUnlinkBookFromLibraryAction = () =>
|
||||||
i18n.translate('embeddableExamples.book.unlinkFromLibrary', {
|
i18n.translate('embeddableExamples.book.unlinkFromLibrary', {
|
||||||
defaultMessage: 'Unlink Book from Library Item',
|
defaultMessage: 'Unlink Book from Library Item',
|
||||||
}),
|
}),
|
||||||
|
id: ACTION_UNLINK_BOOK_FROM_LIBRARY,
|
||||||
type: ACTION_UNLINK_BOOK_FROM_LIBRARY,
|
type: ACTION_UNLINK_BOOK_FROM_LIBRARY,
|
||||||
order: 100,
|
order: 100,
|
||||||
getIconType: () => 'folderExclamation',
|
getIconType: () => 'folderExclamation',
|
||||||
|
|
|
@ -51,21 +51,15 @@ import {
|
||||||
TodoRefEmbeddableFactory,
|
TodoRefEmbeddableFactory,
|
||||||
TodoRefEmbeddableFactoryDefinition,
|
TodoRefEmbeddableFactoryDefinition,
|
||||||
} from './todo/todo_ref_embeddable_factory';
|
} from './todo/todo_ref_embeddable_factory';
|
||||||
import { ACTION_EDIT_BOOK, createEditBookAction } from './book/edit_book_action';
|
import { createEditBookAction } from './book/edit_book_action';
|
||||||
import { BookEmbeddable, BOOK_EMBEDDABLE } from './book/book_embeddable';
|
import { BOOK_EMBEDDABLE } from './book/book_embeddable';
|
||||||
import {
|
import {
|
||||||
BookEmbeddableFactory,
|
BookEmbeddableFactory,
|
||||||
BookEmbeddableFactoryDefinition,
|
BookEmbeddableFactoryDefinition,
|
||||||
} from './book/book_embeddable_factory';
|
} from './book/book_embeddable_factory';
|
||||||
import { UiActionsStart } from '../../../src/plugins/ui_actions/public';
|
import { UiActionsStart } from '../../../src/plugins/ui_actions/public';
|
||||||
import {
|
import { createAddBookToLibraryAction } from './book/add_book_to_library_action';
|
||||||
ACTION_ADD_BOOK_TO_LIBRARY,
|
import { createUnlinkBookFromLibraryAction } from './book/unlink_book_from_library_action';
|
||||||
createAddBookToLibraryAction,
|
|
||||||
} from './book/add_book_to_library_action';
|
|
||||||
import {
|
|
||||||
ACTION_UNLINK_BOOK_FROM_LIBRARY,
|
|
||||||
createUnlinkBookFromLibraryAction,
|
|
||||||
} from './book/unlink_book_from_library_action';
|
|
||||||
|
|
||||||
export interface EmbeddableExamplesSetupDependencies {
|
export interface EmbeddableExamplesSetupDependencies {
|
||||||
embeddable: EmbeddableSetup;
|
embeddable: EmbeddableSetup;
|
||||||
|
@ -92,14 +86,6 @@ export interface EmbeddableExamplesStart {
|
||||||
factories: ExampleEmbeddableFactories;
|
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
|
export class EmbeddableExamplesPlugin
|
||||||
implements
|
implements
|
||||||
Plugin<
|
Plugin<
|
||||||
|
|
|
@ -30,6 +30,7 @@ interface StartServices {
|
||||||
|
|
||||||
export const createHelloWorldAction = (getStartServices: () => Promise<StartServices>) =>
|
export const createHelloWorldAction = (getStartServices: () => Promise<StartServices>) =>
|
||||||
createAction({
|
createAction({
|
||||||
|
id: ACTION_HELLO_WORLD,
|
||||||
type: ACTION_HELLO_WORLD,
|
type: ACTION_HELLO_WORLD,
|
||||||
getDisplayName: () => 'Hello World!',
|
getDisplayName: () => 'Hello World!',
|
||||||
execute: async () => {
|
execute: async () => {
|
||||||
|
|
|
@ -19,8 +19,8 @@
|
||||||
|
|
||||||
import { Plugin, CoreSetup, CoreStart } from '../../../src/core/public';
|
import { Plugin, CoreSetup, CoreStart } from '../../../src/core/public';
|
||||||
import { UiActionsSetup, UiActionsStart } from '../../../src/plugins/ui_actions/public';
|
import { UiActionsSetup, UiActionsStart } from '../../../src/plugins/ui_actions/public';
|
||||||
import { createHelloWorldAction, ACTION_HELLO_WORLD } from './hello_world_action';
|
import { createHelloWorldAction } from './hello_world_action';
|
||||||
import { helloWorldTrigger, HELLO_WORLD_TRIGGER_ID } from './hello_world_trigger';
|
import { helloWorldTrigger } from './hello_world_trigger';
|
||||||
|
|
||||||
export interface UiActionExamplesSetupDependencies {
|
export interface UiActionExamplesSetupDependencies {
|
||||||
uiActions: UiActionsSetup;
|
uiActions: UiActionsSetup;
|
||||||
|
@ -30,16 +30,6 @@ export interface UiActionExamplesStartDependencies {
|
||||||
uiActions: UiActionsStart;
|
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
|
export class UiActionExamplesPlugin
|
||||||
implements
|
implements
|
||||||
Plugin<void, void, UiActionExamplesSetupDependencies, UiActionExamplesStartDependencies> {
|
Plugin<void, void, UiActionExamplesSetupDependencies, UiActionExamplesStartDependencies> {
|
||||||
|
|
|
@ -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_TRIGGER_PHONE_USER = 'ACTION_TRIGGER_PHONE_USER';
|
||||||
export const ACTION_SHOWCASE_PLUGGABILITY = 'ACTION_SHOWCASE_PLUGGABILITY';
|
export const ACTION_SHOWCASE_PLUGGABILITY = 'ACTION_SHOWCASE_PLUGGABILITY';
|
||||||
|
|
||||||
export const showcasePluggability = createAction<typeof ACTION_SHOWCASE_PLUGGABILITY>({
|
export const showcasePluggability = createAction({
|
||||||
|
id: ACTION_SHOWCASE_PLUGGABILITY,
|
||||||
type: ACTION_SHOWCASE_PLUGGABILITY,
|
type: ACTION_SHOWCASE_PLUGGABILITY,
|
||||||
getDisplayName: () => 'This is pluggable! Any plugin can inject their actions here.',
|
getDisplayName: () => 'This is pluggable! Any plugin can inject their actions here.',
|
||||||
execute: async (context: ActionExecutionContext) =>
|
execute: async (context: ActionExecutionContext) =>
|
||||||
|
@ -49,13 +50,15 @@ export interface PhoneContext {
|
||||||
phone: string;
|
phone: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const makePhoneCallAction = createAction<typeof ACTION_CALL_PHONE_NUMBER>({
|
export const makePhoneCallAction = createAction<PhoneContext>({
|
||||||
|
id: ACTION_CALL_PHONE_NUMBER,
|
||||||
type: ACTION_CALL_PHONE_NUMBER,
|
type: ACTION_CALL_PHONE_NUMBER,
|
||||||
getDisplayName: () => 'Call phone number',
|
getDisplayName: () => 'Call phone number',
|
||||||
execute: async (context) => alert(`Pretend calling ${context.phone}...`),
|
execute: async (context) => alert(`Pretend calling ${context.phone}...`),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const lookUpWeatherAction = createAction<typeof ACTION_TRAVEL_GUIDE>({
|
export const lookUpWeatherAction = createAction<CountryContext>({
|
||||||
|
id: ACTION_TRAVEL_GUIDE,
|
||||||
type: ACTION_TRAVEL_GUIDE,
|
type: ACTION_TRAVEL_GUIDE,
|
||||||
getIconType: () => 'popout',
|
getIconType: () => 'popout',
|
||||||
getDisplayName: () => 'View travel guide',
|
getDisplayName: () => 'View travel guide',
|
||||||
|
@ -68,7 +71,8 @@ export interface CountryContext {
|
||||||
country: string;
|
country: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const viewInMapsAction = createAction<typeof ACTION_VIEW_IN_MAPS>({
|
export const viewInMapsAction = createAction<CountryContext>({
|
||||||
|
id: ACTION_VIEW_IN_MAPS,
|
||||||
type: ACTION_VIEW_IN_MAPS,
|
type: ACTION_VIEW_IN_MAPS,
|
||||||
getIconType: () => 'popout',
|
getIconType: () => 'popout',
|
||||||
getDisplayName: () => 'View in maps',
|
getDisplayName: () => 'View in maps',
|
||||||
|
@ -109,7 +113,8 @@ function EditUserModal({
|
||||||
}
|
}
|
||||||
|
|
||||||
export const createEditUserAction = (getOpenModal: () => Promise<OverlayStart['openModal']>) =>
|
export const createEditUserAction = (getOpenModal: () => Promise<OverlayStart['openModal']>) =>
|
||||||
createAction<typeof ACTION_EDIT_USER>({
|
createAction<UserContext>({
|
||||||
|
id: ACTION_EDIT_USER,
|
||||||
type: ACTION_EDIT_USER,
|
type: ACTION_EDIT_USER,
|
||||||
getIconType: () => 'pencil',
|
getIconType: () => 'pencil',
|
||||||
getDisplayName: () => 'Edit user',
|
getDisplayName: () => 'Edit user',
|
||||||
|
@ -126,7 +131,8 @@ export interface UserContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const createTriggerPhoneTriggerAction = (getUiActionsApi: () => Promise<UiActionsStart>) =>
|
export const createTriggerPhoneTriggerAction = (getUiActionsApi: () => Promise<UiActionsStart>) =>
|
||||||
createAction<typeof ACTION_TRIGGER_PHONE_USER>({
|
createAction<UserContext>({
|
||||||
|
id: ACTION_TRIGGER_PHONE_USER,
|
||||||
type: ACTION_TRIGGER_PHONE_USER,
|
type: ACTION_TRIGGER_PHONE_USER,
|
||||||
getDisplayName: () => 'Call phone number',
|
getDisplayName: () => 'Call phone number',
|
||||||
shouldAutoExecute: async () => true,
|
shouldAutoExecute: async () => true,
|
||||||
|
|
|
@ -77,7 +77,7 @@ const ActionsExplorer = ({ uiActionsApi, openModal }: Props) => {
|
||||||
<EuiButton
|
<EuiButton
|
||||||
data-test-subj="addDynamicAction"
|
data-test-subj="addDynamicAction"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
const dynamicAction = createAction<typeof ACTION_HELLO_WORLD>({
|
const dynamicAction = createAction({
|
||||||
id: `${ACTION_HELLO_WORLD}-${name}`,
|
id: `${ACTION_HELLO_WORLD}-${name}`,
|
||||||
type: ACTION_HELLO_WORLD,
|
type: ACTION_HELLO_WORLD,
|
||||||
getDisplayName: () => `Say hello to ${name}`,
|
getDisplayName: () => `Say hello to ${name}`,
|
||||||
|
|
|
@ -28,15 +28,6 @@ import {
|
||||||
createEditUserAction,
|
createEditUserAction,
|
||||||
makePhoneCallAction,
|
makePhoneCallAction,
|
||||||
showcasePluggability,
|
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,
|
createTriggerPhoneTriggerAction,
|
||||||
} from './actions/actions';
|
} from './actions/actions';
|
||||||
import { DeveloperExamplesSetup } from '../../developer_examples/public';
|
import { DeveloperExamplesSetup } from '../../developer_examples/public';
|
||||||
|
@ -51,23 +42,6 @@ interface SetupDeps {
|
||||||
developerExamples: DeveloperExamplesSetup;
|
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<void, void, {}, StartDeps> {
|
export class UiActionsExplorerPlugin implements Plugin<void, void, {}, StartDeps> {
|
||||||
public setup(core: CoreSetup<StartDeps>, deps: SetupDeps) {
|
public setup(core: CoreSetup<StartDeps>, deps: SetupDeps) {
|
||||||
deps.uiActions.registerTrigger({
|
deps.uiActions.registerTrigger({
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
|
||||||
import { ActionByType, IncompatibleActionError } from '../../services/ui_actions';
|
import { Action, IncompatibleActionError } from '../../services/ui_actions';
|
||||||
import {
|
import {
|
||||||
ViewMode,
|
ViewMode,
|
||||||
PanelState,
|
PanelState,
|
||||||
|
@ -39,7 +39,7 @@ export interface AddToLibraryActionContext {
|
||||||
embeddable: IEmbeddable;
|
embeddable: IEmbeddable;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class AddToLibraryAction implements ActionByType<typeof ACTION_ADD_TO_LIBRARY> {
|
export class AddToLibraryAction implements Action<AddToLibraryActionContext> {
|
||||||
public readonly type = ACTION_ADD_TO_LIBRARY;
|
public readonly type = ACTION_ADD_TO_LIBRARY;
|
||||||
public readonly id = ACTION_ADD_TO_LIBRARY;
|
public readonly id = ACTION_ADD_TO_LIBRARY;
|
||||||
public order = 15;
|
public order = 15;
|
||||||
|
|
|
@ -21,7 +21,7 @@ import _ from 'lodash';
|
||||||
import uuid from 'uuid';
|
import uuid from 'uuid';
|
||||||
|
|
||||||
import { CoreStart } from 'src/core/public';
|
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 { SavedObject } from '../../services/saved_objects';
|
||||||
import {
|
import {
|
||||||
ViewMode,
|
ViewMode,
|
||||||
|
@ -45,7 +45,7 @@ export interface ClonePanelActionContext {
|
||||||
embeddable: IEmbeddable;
|
embeddable: IEmbeddable;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ClonePanelAction implements ActionByType<typeof ACTION_CLONE_PANEL> {
|
export class ClonePanelAction implements Action<ClonePanelActionContext> {
|
||||||
public readonly type = ACTION_CLONE_PANEL;
|
public readonly type = ACTION_CLONE_PANEL;
|
||||||
public readonly id = ACTION_CLONE_PANEL;
|
public readonly id = ACTION_CLONE_PANEL;
|
||||||
public order = 45;
|
public order = 45;
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
import { dashboardExpandPanelAction } from '../../dashboard_strings';
|
import { dashboardExpandPanelAction } from '../../dashboard_strings';
|
||||||
import { IEmbeddable } from '../../services/embeddable';
|
import { IEmbeddable } from '../../services/embeddable';
|
||||||
import { ActionByType, IncompatibleActionError } from '../../services/ui_actions';
|
import { Action, IncompatibleActionError } from '../../services/ui_actions';
|
||||||
import {
|
import {
|
||||||
DASHBOARD_CONTAINER_TYPE,
|
DASHBOARD_CONTAINER_TYPE,
|
||||||
DashboardContainer,
|
DashboardContainer,
|
||||||
|
@ -46,7 +46,7 @@ export interface ExpandPanelActionContext {
|
||||||
embeddable: IEmbeddable;
|
embeddable: IEmbeddable;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ExpandPanelAction implements ActionByType<typeof ACTION_EXPAND_PANEL> {
|
export class ExpandPanelAction implements Action<ExpandPanelActionContext> {
|
||||||
public readonly type = ACTION_EXPAND_PANEL;
|
public readonly type = ACTION_EXPAND_PANEL;
|
||||||
public readonly id = ACTION_EXPAND_PANEL;
|
public readonly id = ACTION_EXPAND_PANEL;
|
||||||
public order = 7;
|
public order = 7;
|
||||||
|
|
|
@ -24,7 +24,7 @@ import { FormatFactory } from '../../../../data/common/field_formats/utils';
|
||||||
import { DataPublicPluginStart, exporters } from '../../services/data';
|
import { DataPublicPluginStart, exporters } from '../../services/data';
|
||||||
import { downloadMultipleAs } from '../../services/share';
|
import { downloadMultipleAs } from '../../services/share';
|
||||||
import { Adapters, IEmbeddable } from '../../services/embeddable';
|
import { Adapters, IEmbeddable } from '../../services/embeddable';
|
||||||
import { ActionByType } from '../../services/ui_actions';
|
import { Action } from '../../services/ui_actions';
|
||||||
import { dashboardExportCsvAction } from '../../dashboard_strings';
|
import { dashboardExportCsvAction } from '../../dashboard_strings';
|
||||||
|
|
||||||
export const ACTION_EXPORT_CSV = 'ACTION_EXPORT_CSV';
|
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
|
* This is "Export CSV" action which appears in the context
|
||||||
* menu of a dashboard panel.
|
* menu of a dashboard panel.
|
||||||
*/
|
*/
|
||||||
export class ExportCSVAction implements ActionByType<typeof ACTION_EXPORT_CSV> {
|
export class ExportCSVAction implements Action<ExportContext> {
|
||||||
public readonly id = ACTION_EXPORT_CSV;
|
public readonly id = ACTION_EXPORT_CSV;
|
||||||
|
|
||||||
public readonly type = ACTION_EXPORT_CSV;
|
public readonly type = ACTION_EXPORT_CSV;
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
import React from 'react';
|
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 { reactToUiComponent } from '../../services/kibana_react';
|
||||||
import {
|
import {
|
||||||
IEmbeddable,
|
IEmbeddable,
|
||||||
|
@ -38,7 +38,7 @@ export interface LibraryNotificationActionContext {
|
||||||
embeddable: IEmbeddable;
|
embeddable: IEmbeddable;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class LibraryNotificationAction implements ActionByType<typeof ACTION_LIBRARY_NOTIFICATION> {
|
export class LibraryNotificationAction implements Action<LibraryNotificationActionContext> {
|
||||||
public readonly id = ACTION_LIBRARY_NOTIFICATION;
|
public readonly id = ACTION_LIBRARY_NOTIFICATION;
|
||||||
public readonly type = ACTION_LIBRARY_NOTIFICATION;
|
public readonly type = ACTION_LIBRARY_NOTIFICATION;
|
||||||
public readonly order = 1;
|
public readonly order = 1;
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
import { CoreStart } from 'src/core/public';
|
import { CoreStart } from 'src/core/public';
|
||||||
import { IEmbeddable, ViewMode, EmbeddableStart } from '../../services/embeddable';
|
import { IEmbeddable, ViewMode, EmbeddableStart } from '../../services/embeddable';
|
||||||
import { DASHBOARD_CONTAINER_TYPE, DashboardContainer } from '../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 { openReplacePanelFlyout } from './open_replace_panel_flyout';
|
||||||
import { dashboardReplacePanelAction } from '../../dashboard_strings';
|
import { dashboardReplacePanelAction } from '../../dashboard_strings';
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ export interface ReplacePanelActionContext {
|
||||||
embeddable: IEmbeddable;
|
embeddable: IEmbeddable;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ReplacePanelAction implements ActionByType<typeof ACTION_REPLACE_PANEL> {
|
export class ReplacePanelAction implements Action<ReplacePanelActionContext> {
|
||||||
public readonly type = ACTION_REPLACE_PANEL;
|
public readonly type = ACTION_REPLACE_PANEL;
|
||||||
public readonly id = ACTION_REPLACE_PANEL;
|
public readonly id = ACTION_REPLACE_PANEL;
|
||||||
public order = 3;
|
public order = 3;
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import { ActionByType, IncompatibleActionError } from '../../services/ui_actions';
|
import { Action, IncompatibleActionError } from '../../services/ui_actions';
|
||||||
import {
|
import {
|
||||||
ViewMode,
|
ViewMode,
|
||||||
PanelState,
|
PanelState,
|
||||||
|
@ -38,7 +38,7 @@ export interface UnlinkFromLibraryActionContext {
|
||||||
embeddable: IEmbeddable;
|
embeddable: IEmbeddable;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class UnlinkFromLibraryAction implements ActionByType<typeof ACTION_UNLINK_FROM_LIBRARY> {
|
export class UnlinkFromLibraryAction implements Action<UnlinkFromLibraryActionContext> {
|
||||||
public readonly type = ACTION_UNLINK_FROM_LIBRARY;
|
public readonly type = ACTION_UNLINK_FROM_LIBRARY;
|
||||||
public readonly id = ACTION_UNLINK_FROM_LIBRARY;
|
public readonly id = ACTION_UNLINK_FROM_LIBRARY;
|
||||||
public order = 15;
|
public order = 15;
|
||||||
|
|
|
@ -62,27 +62,15 @@ import {
|
||||||
} from './services/kibana_react';
|
} from './services/kibana_react';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ACTION_CLONE_PANEL,
|
|
||||||
ACTION_EXPAND_PANEL,
|
|
||||||
ACTION_REPLACE_PANEL,
|
|
||||||
ClonePanelAction,
|
ClonePanelAction,
|
||||||
ClonePanelActionContext,
|
|
||||||
createDashboardContainerByValueRenderer,
|
createDashboardContainerByValueRenderer,
|
||||||
DASHBOARD_CONTAINER_TYPE,
|
DASHBOARD_CONTAINER_TYPE,
|
||||||
DashboardContainerFactory,
|
DashboardContainerFactory,
|
||||||
DashboardContainerFactoryDefinition,
|
DashboardContainerFactoryDefinition,
|
||||||
ExpandPanelAction,
|
ExpandPanelAction,
|
||||||
ExpandPanelActionContext,
|
|
||||||
ReplacePanelAction,
|
ReplacePanelAction,
|
||||||
ReplacePanelActionContext,
|
|
||||||
ACTION_UNLINK_FROM_LIBRARY,
|
|
||||||
UnlinkFromLibraryActionContext,
|
|
||||||
UnlinkFromLibraryAction,
|
UnlinkFromLibraryAction,
|
||||||
ACTION_ADD_TO_LIBRARY,
|
|
||||||
AddToLibraryActionContext,
|
|
||||||
AddToLibraryAction,
|
AddToLibraryAction,
|
||||||
ACTION_LIBRARY_NOTIFICATION,
|
|
||||||
LibraryNotificationActionContext,
|
|
||||||
LibraryNotificationAction,
|
LibraryNotificationAction,
|
||||||
} from './application';
|
} from './application';
|
||||||
import {
|
import {
|
||||||
|
@ -94,11 +82,7 @@ import { createSavedDashboardLoader } from './saved_dashboards';
|
||||||
import { DashboardConstants } from './dashboard_constants';
|
import { DashboardConstants } from './dashboard_constants';
|
||||||
import { PlaceholderEmbeddableFactory } from './application/embeddable/placeholder';
|
import { PlaceholderEmbeddableFactory } from './application/embeddable/placeholder';
|
||||||
import { UrlGeneratorState } from '../../share/public';
|
import { UrlGeneratorState } from '../../share/public';
|
||||||
import {
|
import { ExportCSVAction } from './application/actions/export_csv_action';
|
||||||
ACTION_EXPORT_CSV,
|
|
||||||
ExportContext,
|
|
||||||
ExportCSVAction,
|
|
||||||
} from './application/actions/export_csv_action';
|
|
||||||
import { dashboardFeatureCatalog } from './dashboard_strings';
|
import { dashboardFeatureCatalog } from './dashboard_strings';
|
||||||
|
|
||||||
declare module '../../share/public' {
|
declare module '../../share/public' {
|
||||||
|
@ -147,18 +131,6 @@ export interface DashboardStart {
|
||||||
DashboardContainerByValueRenderer: ReturnType<typeof createDashboardContainerByValueRenderer>;
|
DashboardContainerByValueRenderer: ReturnType<typeof createDashboardContainerByValueRenderer>;
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
export class DashboardPlugin
|
||||||
implements
|
implements
|
||||||
Plugin<DashboardSetup, DashboardStart, DashboardSetupDependencies, DashboardStartDependencies> {
|
Plugin<DashboardSetup, DashboardStart, DashboardSetupDependencies, DashboardStartDependencies> {
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export {
|
export {
|
||||||
ActionByType,
|
Action,
|
||||||
IncompatibleActionError,
|
IncompatibleActionError,
|
||||||
UiActionsSetup,
|
UiActionsSetup,
|
||||||
UiActionsStart,
|
UiActionsStart,
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
import { i18n } from '@kbn/i18n';
|
import { i18n } from '@kbn/i18n';
|
||||||
import { toMountPoint } from '../../../kibana_react/public';
|
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 { getOverlays, getIndexPatterns } from '../services';
|
||||||
import { applyFiltersPopover } from '../ui/apply_filters';
|
import { applyFiltersPopover } from '../ui/apply_filters';
|
||||||
import { Filter, FilterManager, TimefilterContract, esFilters } from '..';
|
import { Filter, FilterManager, TimefilterContract, esFilters } from '..';
|
||||||
|
@ -41,8 +41,8 @@ async function isCompatible(context: ApplyGlobalFilterActionContext) {
|
||||||
export function createFilterAction(
|
export function createFilterAction(
|
||||||
filterManager: FilterManager,
|
filterManager: FilterManager,
|
||||||
timeFilter: TimefilterContract
|
timeFilter: TimefilterContract
|
||||||
): ActionByType<typeof ACTION_GLOBAL_APPLY_FILTER> {
|
): Action {
|
||||||
return createAction<typeof ACTION_GLOBAL_APPLY_FILTER>({
|
return createAction({
|
||||||
type: ACTION_GLOBAL_APPLY_FILTER,
|
type: ACTION_GLOBAL_APPLY_FILTER,
|
||||||
id: ACTION_GLOBAL_APPLY_FILTER,
|
id: ACTION_GLOBAL_APPLY_FILTER,
|
||||||
order: 100,
|
order: 100,
|
||||||
|
|
|
@ -29,12 +29,16 @@ import {
|
||||||
} from '../../../public';
|
} from '../../../public';
|
||||||
import { dataPluginMock } from '../../../public/mocks';
|
import { dataPluginMock } from '../../../public/mocks';
|
||||||
import { setIndexPatterns, setSearchService } from '../../../public/services';
|
import { setIndexPatterns, setSearchService } from '../../../public/services';
|
||||||
import { TriggerContextMapping } from '../../../../ui_actions/public';
|
|
||||||
|
|
||||||
describe('brushEvent', () => {
|
describe('brushEvent', () => {
|
||||||
const DAY_IN_MS = 24 * 60 * 60 * 1000;
|
const DAY_IN_MS = 24 * 60 * 60 * 1000;
|
||||||
const JAN_01_2014 = 1388559600000;
|
const JAN_01_2014 = 1388559600000;
|
||||||
let baseEvent: TriggerContextMapping['SELECT_RANGE_TRIGGER']['data'];
|
let baseEvent: {
|
||||||
|
table: any;
|
||||||
|
column: number;
|
||||||
|
range: number[];
|
||||||
|
timeFieldName?: string;
|
||||||
|
};
|
||||||
|
|
||||||
const mockField = {
|
const mockField = {
|
||||||
name: 'time',
|
name: 'time',
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Datatable } from 'src/plugins/expressions/public';
|
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 { APPLY_FILTER_TRIGGER } from '../triggers';
|
||||||
import { createFiltersFromRangeSelectAction } from './filters/create_filters_from_range_select';
|
import { createFiltersFromRangeSelectAction } from './filters/create_filters_from_range_select';
|
||||||
|
|
||||||
|
@ -38,8 +38,8 @@ export const ACTION_SELECT_RANGE = 'ACTION_SELECT_RANGE';
|
||||||
|
|
||||||
export function createSelectRangeAction(
|
export function createSelectRangeAction(
|
||||||
getStartServices: () => { uiActions: UiActionsStart }
|
getStartServices: () => { uiActions: UiActionsStart }
|
||||||
): ActionByType<typeof ACTION_SELECT_RANGE> {
|
): Action {
|
||||||
return createAction<typeof ACTION_SELECT_RANGE>({
|
return createAction({
|
||||||
type: ACTION_SELECT_RANGE,
|
type: ACTION_SELECT_RANGE,
|
||||||
id: ACTION_SELECT_RANGE,
|
id: ACTION_SELECT_RANGE,
|
||||||
shouldAutoExecute: async () => true,
|
shouldAutoExecute: async () => true,
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Datatable } from 'src/plugins/expressions/public';
|
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 { APPLY_FILTER_TRIGGER } from '../triggers';
|
||||||
import { createFiltersFromValueClickAction } from './filters/create_filters_from_value_click';
|
import { createFiltersFromValueClickAction } from './filters/create_filters_from_value_click';
|
||||||
import type { Filter } from '../../common/es_query/filters';
|
import type { Filter } from '../../common/es_query/filters';
|
||||||
|
@ -44,8 +44,8 @@ export interface ValueClickContext {
|
||||||
|
|
||||||
export function createValueClickAction(
|
export function createValueClickAction(
|
||||||
getStartServices: () => { uiActions: UiActionsStart }
|
getStartServices: () => { uiActions: UiActionsStart }
|
||||||
): ActionByType<typeof ACTION_VALUE_CLICK> {
|
): Action {
|
||||||
return createAction<typeof ACTION_VALUE_CLICK>({
|
return createAction({
|
||||||
type: ACTION_VALUE_CLICK,
|
type: ACTION_VALUE_CLICK,
|
||||||
id: ACTION_VALUE_CLICK,
|
id: ACTION_VALUE_CLICK,
|
||||||
shouldAutoExecute: async () => true,
|
shouldAutoExecute: async () => true,
|
||||||
|
|
|
@ -54,11 +54,6 @@ import {
|
||||||
createFilterAction,
|
createFilterAction,
|
||||||
createFiltersFromValueClickAction,
|
createFiltersFromValueClickAction,
|
||||||
createFiltersFromRangeSelectAction,
|
createFiltersFromRangeSelectAction,
|
||||||
ApplyGlobalFilterActionContext,
|
|
||||||
ACTION_SELECT_RANGE,
|
|
||||||
ACTION_VALUE_CLICK,
|
|
||||||
SelectRangeActionContext,
|
|
||||||
ValueClickActionContext,
|
|
||||||
createValueClickAction,
|
createValueClickAction,
|
||||||
createSelectRangeAction,
|
createSelectRangeAction,
|
||||||
} from './actions';
|
} from './actions';
|
||||||
|
@ -67,19 +62,6 @@ import { SavedObjectsClientPublicToCommon } from './index_patterns';
|
||||||
import { getIndexPatternLoad } from './index_patterns/expressions';
|
import { getIndexPatternLoad } from './index_patterns/expressions';
|
||||||
import { UsageCollectionSetup } from '../../usage_collection/public';
|
import { UsageCollectionSetup } from '../../usage_collection/public';
|
||||||
import { getTableViewDescription } from './utils/table_inspector_view';
|
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
|
export class DataPublicPlugin
|
||||||
implements
|
implements
|
||||||
|
@ -126,14 +108,14 @@ export class DataPublicPlugin
|
||||||
);
|
);
|
||||||
|
|
||||||
uiActions.addTriggerAction(
|
uiActions.addTriggerAction(
|
||||||
'SELECT_RANGE_TRIGGER' as TriggerId,
|
'SELECT_RANGE_TRIGGER',
|
||||||
createSelectRangeAction(() => ({
|
createSelectRangeAction(() => ({
|
||||||
uiActions: startServices().plugins.uiActions,
|
uiActions: startServices().plugins.uiActions,
|
||||||
}))
|
}))
|
||||||
);
|
);
|
||||||
|
|
||||||
uiActions.addTriggerAction(
|
uiActions.addTriggerAction(
|
||||||
'VALUE_CLICK_TRIGGER' as TriggerId,
|
'VALUE_CLICK_TRIGGER',
|
||||||
createValueClickAction(() => ({
|
createValueClickAction(() => ({
|
||||||
uiActions: startServices().plugins.uiActions,
|
uiActions: startServices().plugins.uiActions,
|
||||||
}))
|
}))
|
||||||
|
|
|
@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n';
|
||||||
import { Trigger } from '../../../ui_actions/public';
|
import { Trigger } from '../../../ui_actions/public';
|
||||||
|
|
||||||
export const APPLY_FILTER_TRIGGER = 'FILTER_TRIGGER';
|
export const APPLY_FILTER_TRIGGER = 'FILTER_TRIGGER';
|
||||||
export const applyFilterTrigger: Trigger<'FILTER_TRIGGER'> = {
|
export const applyFilterTrigger: Trigger = {
|
||||||
id: APPLY_FILTER_TRIGGER,
|
id: APPLY_FILTER_TRIGGER,
|
||||||
title: i18n.translate('data.triggers.applyFilterTitle', {
|
title: i18n.translate('data.triggers.applyFilterTitle', {
|
||||||
defaultMessage: 'Apply filter',
|
defaultMessage: 'Apply filter',
|
||||||
|
|
|
@ -38,7 +38,7 @@ import { DataViewRow, DataViewColumn } from '../types';
|
||||||
import { IUiSettingsClient } from '../../../../../../core/public';
|
import { IUiSettingsClient } from '../../../../../../core/public';
|
||||||
import { Datatable, DatatableColumn } from '../../../../../expressions/public';
|
import { Datatable, DatatableColumn } from '../../../../../expressions/public';
|
||||||
import { FieldFormatsStart } from '../../../field_formats';
|
import { FieldFormatsStart } from '../../../field_formats';
|
||||||
import { TriggerId, UiActionsStart } from '../../../../../ui_actions/public';
|
import { UiActionsStart } from '../../../../../ui_actions/public';
|
||||||
|
|
||||||
interface DataTableFormatState {
|
interface DataTableFormatState {
|
||||||
columns: DataViewColumn[];
|
columns: DataViewColumn[];
|
||||||
|
@ -112,7 +112,7 @@ export class DataTableFormat extends Component<DataTableFormatProps, DataTableFo
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
const value = table.rows[rowIndex][column.id];
|
const value = table.rows[rowIndex][column.id];
|
||||||
const eventData = { table, column: columnIndex, row: rowIndex, value };
|
const eventData = { table, column: columnIndex, row: rowIndex, value };
|
||||||
uiActions.executeTriggerActions('VALUE_CLICK_TRIGGER' as TriggerId, {
|
uiActions.executeTriggerActions('VALUE_CLICK_TRIGGER', {
|
||||||
data: { data: [eventData] },
|
data: { data: [eventData] },
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
|
@ -145,7 +145,7 @@ export class DataTableFormat extends Component<DataTableFormatProps, DataTableFo
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
const value = table.rows[rowIndex][column.id];
|
const value = table.rows[rowIndex][column.id];
|
||||||
const eventData = { table, column: columnIndex, row: rowIndex, value };
|
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 },
|
data: { data: [eventData], negate: true },
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -18,44 +18,13 @@
|
||||||
*/
|
*/
|
||||||
import { UiActionsSetup } from '../../ui_actions/public';
|
import { UiActionsSetup } from '../../ui_actions/public';
|
||||||
import {
|
import {
|
||||||
ACTION_ADD_PANEL,
|
|
||||||
ACTION_CUSTOMIZE_PANEL,
|
|
||||||
ACTION_EDIT_PANEL,
|
|
||||||
ACTION_INSPECT_PANEL,
|
|
||||||
CONTEXT_MENU_TRIGGER,
|
|
||||||
contextMenuTrigger,
|
contextMenuTrigger,
|
||||||
EmbeddableContext,
|
|
||||||
PANEL_BADGE_TRIGGER,
|
|
||||||
PANEL_NOTIFICATION_TRIGGER,
|
|
||||||
panelBadgeTrigger,
|
panelBadgeTrigger,
|
||||||
panelNotificationTrigger,
|
panelNotificationTrigger,
|
||||||
RangeSelectContext,
|
|
||||||
REMOVE_PANEL_ACTION,
|
|
||||||
SELECT_RANGE_TRIGGER,
|
|
||||||
selectRangeTrigger,
|
selectRangeTrigger,
|
||||||
ValueClickContext,
|
|
||||||
VALUE_CLICK_TRIGGER,
|
|
||||||
valueClickTrigger,
|
valueClickTrigger,
|
||||||
} from './lib';
|
} 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
|
* This method initializes Embeddable plugin with initial set of
|
||||||
* triggers and actions.
|
* triggers and actions.
|
||||||
|
|
|
@ -25,7 +25,6 @@ import { RenderCompleteDispatcher } from '../../../../kibana_utils/public';
|
||||||
import { Adapters } from '../types';
|
import { Adapters } from '../types';
|
||||||
import { IContainer } from '../containers';
|
import { IContainer } from '../containers';
|
||||||
import { EmbeddableOutput, IEmbeddable } from './i_embeddable';
|
import { EmbeddableOutput, IEmbeddable } from './i_embeddable';
|
||||||
import { TriggerContextMapping } from '../ui_actions';
|
|
||||||
import { EmbeddableInput, ViewMode } from '../../../common/types';
|
import { EmbeddableInput, ViewMode } from '../../../common/types';
|
||||||
|
|
||||||
function getPanelTitle(input: EmbeddableInput, output: EmbeddableOutput) {
|
function getPanelTitle(input: EmbeddableInput, output: EmbeddableOutput) {
|
||||||
|
@ -248,7 +247,7 @@ export abstract class Embeddable<
|
||||||
this.onResetInput(newInput);
|
this.onResetInput(newInput);
|
||||||
}
|
}
|
||||||
|
|
||||||
public supportedTriggers(): Array<keyof TriggerContextMapping> {
|
public supportedTriggers(): string[] {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { Adapters } from '../types';
|
import { Adapters } from '../types';
|
||||||
import { IContainer } from '../containers/i_container';
|
import { IContainer } from '../containers/i_container';
|
||||||
import { TriggerContextMapping } from '../../../../ui_actions/public';
|
|
||||||
import { EmbeddableInput } from '../../../common/types';
|
import { EmbeddableInput } from '../../../common/types';
|
||||||
|
|
||||||
export interface EmbeddableError {
|
export interface EmbeddableError {
|
||||||
|
@ -173,5 +172,5 @@ export interface IEmbeddable<
|
||||||
/**
|
/**
|
||||||
* List of triggers that this embeddable will execute.
|
* List of triggers that this embeddable will execute.
|
||||||
*/
|
*/
|
||||||
supportedTriggers(): Array<keyof TriggerContextMapping>;
|
supportedTriggers(): string[];
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ import { mountWithIntl, nextTick } from '@kbn/test/jest';
|
||||||
import { findTestSubject } from '@elastic/eui/lib/test';
|
import { findTestSubject } from '@elastic/eui/lib/test';
|
||||||
import { I18nProvider } from '@kbn/i18n/react';
|
import { I18nProvider } from '@kbn/i18n/react';
|
||||||
import { CONTEXT_MENU_TRIGGER } from '../triggers';
|
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 { Trigger, ViewMode } from '../types';
|
||||||
import { isErrorEmbeddable } from '../embeddables';
|
import { isErrorEmbeddable } from '../embeddables';
|
||||||
import { EmbeddablePanel } from './embeddable_panel';
|
import { EmbeddablePanel } from './embeddable_panel';
|
||||||
|
@ -216,7 +216,7 @@ const renderInEditModeAndOpenContextMenu = async (
|
||||||
test('HelloWorldContainer in edit mode hides disabledActions', async () => {
|
test('HelloWorldContainer in edit mode hides disabledActions', async () => {
|
||||||
const action = {
|
const action = {
|
||||||
id: 'FOO',
|
id: 'FOO',
|
||||||
type: 'FOO' as ActionType,
|
type: 'FOO',
|
||||||
getIconType: () => undefined,
|
getIconType: () => undefined,
|
||||||
getDisplayName: () => 'foo',
|
getDisplayName: () => 'foo',
|
||||||
isCompatible: async () => true,
|
isCompatible: async () => true,
|
||||||
|
@ -252,7 +252,7 @@ test('HelloWorldContainer in edit mode hides disabledActions', async () => {
|
||||||
test('HelloWorldContainer hides disabled badges', async () => {
|
test('HelloWorldContainer hides disabled badges', async () => {
|
||||||
const action = {
|
const action = {
|
||||||
id: 'BAR',
|
id: 'BAR',
|
||||||
type: 'BAR' as ActionType,
|
type: 'BAR',
|
||||||
getIconType: () => undefined,
|
getIconType: () => undefined,
|
||||||
getDisplayName: () => 'bar',
|
getDisplayName: () => 'bar',
|
||||||
isCompatible: async () => true,
|
isCompatible: async () => true,
|
||||||
|
|
|
@ -17,16 +17,15 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { createAction, ActionType } from '../../ui_actions';
|
import { createAction } from '../../ui_actions';
|
||||||
import { ViewMode } from '../../types';
|
import { ViewMode } from '../../types';
|
||||||
import { IEmbeddable } from '../..';
|
import { IEmbeddable } from '../..';
|
||||||
|
|
||||||
// Casting to ActionType is a hack - in a real situation use
|
export const EDIT_MODE_ACTION = 'EDIT_MODE_ACTION';
|
||||||
// declare module and add this id to ActionContextMapping.
|
|
||||||
export const EDIT_MODE_ACTION = 'EDIT_MODE_ACTION' as ActionType;
|
|
||||||
|
|
||||||
export function createEditModeAction() {
|
export function createEditModeAction() {
|
||||||
return createAction<typeof EDIT_MODE_ACTION>({
|
return createAction({
|
||||||
|
id: EDIT_MODE_ACTION,
|
||||||
type: EDIT_MODE_ACTION,
|
type: EDIT_MODE_ACTION,
|
||||||
getDisplayName: () => 'I only show up in edit mode',
|
getDisplayName: () => 'I only show up in edit mode',
|
||||||
isCompatible: async (context: { embeddable: IEmbeddable }) =>
|
isCompatible: async (context: { embeddable: IEmbeddable }) =>
|
||||||
|
|
|
@ -17,12 +17,10 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { IncompatibleActionError, ActionType, ActionDefinitionByType } from '../../ui_actions';
|
import { IncompatibleActionError, Action } from '../../ui_actions';
|
||||||
import { EmbeddableInput, Embeddable, EmbeddableOutput, IEmbeddable } from '../../embeddables';
|
import { EmbeddableInput, Embeddable, EmbeddableOutput, IEmbeddable } from '../../embeddables';
|
||||||
|
|
||||||
// Casting to ActionType is a hack - in a real situation use
|
export const SAY_HELLO_ACTION = 'SAY_HELLO_ACTION';
|
||||||
// declare module and add this id to ActionContextMapping.
|
|
||||||
export const SAY_HELLO_ACTION = 'SAY_HELLO_ACTION' as ActionType;
|
|
||||||
|
|
||||||
export interface FullNameEmbeddableOutput extends EmbeddableOutput {
|
export interface FullNameEmbeddableOutput extends EmbeddableOutput {
|
||||||
fullName: string;
|
fullName: string;
|
||||||
|
@ -42,7 +40,7 @@ export interface SayHelloActionContext {
|
||||||
message?: string;
|
message?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SayHelloAction implements ActionDefinitionByType<typeof SAY_HELLO_ACTION> {
|
export class SayHelloAction implements Action<SayHelloActionContext> {
|
||||||
public readonly type = SAY_HELLO_ACTION;
|
public readonly type = SAY_HELLO_ACTION;
|
||||||
public readonly id = SAY_HELLO_ACTION;
|
public readonly id = SAY_HELLO_ACTION;
|
||||||
|
|
||||||
|
|
|
@ -18,16 +18,14 @@
|
||||||
*/
|
*/
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { EuiFlyoutBody } from '@elastic/eui';
|
import { EuiFlyoutBody } from '@elastic/eui';
|
||||||
import { createAction, IncompatibleActionError, ActionType } from '../../ui_actions';
|
import { createAction, IncompatibleActionError } from '../../ui_actions';
|
||||||
import { CoreStart } from '../../../../../../core/public';
|
import { CoreStart } from '../../../../../../core/public';
|
||||||
import { toMountPoint } from '../../../../../kibana_react/public';
|
import { toMountPoint } from '../../../../../kibana_react/public';
|
||||||
import { Embeddable, EmbeddableInput } from '../../embeddables';
|
import { Embeddable, EmbeddableInput } from '../../embeddables';
|
||||||
import { GetMessageModal } from './get_message_modal';
|
import { GetMessageModal } from './get_message_modal';
|
||||||
import { FullNameEmbeddableOutput, hasFullNameOutput } from './say_hello_action';
|
import { FullNameEmbeddableOutput, hasFullNameOutput } from './say_hello_action';
|
||||||
|
|
||||||
// Casting to ActionType is a hack - in a real situation use
|
export const ACTION_SEND_MESSAGE = 'ACTION_SEND_MESSAGE';
|
||||||
// declare module and add this id to ActionContextMapping.
|
|
||||||
export const ACTION_SEND_MESSAGE = 'ACTION_SEND_MESSAGE' as ActionType;
|
|
||||||
|
|
||||||
interface ActionContext {
|
interface ActionContext {
|
||||||
embeddable: Embeddable<EmbeddableInput, FullNameEmbeddableOutput>;
|
embeddable: Embeddable<EmbeddableInput, FullNameEmbeddableOutput>;
|
||||||
|
@ -44,7 +42,8 @@ export function createSendMessageAction(overlays: CoreStart['overlays']) {
|
||||||
overlays.openFlyout(toMountPoint(<EuiFlyoutBody>{content}</EuiFlyoutBody>));
|
overlays.openFlyout(toMountPoint(<EuiFlyoutBody>{content}</EuiFlyoutBody>));
|
||||||
};
|
};
|
||||||
|
|
||||||
return createAction<typeof ACTION_SEND_MESSAGE>({
|
return createAction<ActionContext>({
|
||||||
|
id: ACTION_SEND_MESSAGE,
|
||||||
type: ACTION_SEND_MESSAGE,
|
type: ACTION_SEND_MESSAGE,
|
||||||
getDisplayName: () => 'Send message',
|
getDisplayName: () => 'Send message',
|
||||||
isCompatible,
|
isCompatible,
|
||||||
|
|
|
@ -24,13 +24,6 @@ import { EuiButton } from '@elastic/eui';
|
||||||
import * as Rx from 'rxjs';
|
import * as Rx from 'rxjs';
|
||||||
import { UiActionsStart } from '../../../../../../ui_actions/public';
|
import { UiActionsStart } from '../../../../../../ui_actions/public';
|
||||||
import { ContactCardEmbeddable, CONTACT_USER_TRIGGER } from './contact_card_embeddable';
|
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 {
|
interface Props {
|
||||||
embeddable: ContactCardEmbeddable;
|
embeddable: ContactCardEmbeddable;
|
||||||
|
|
|
@ -56,7 +56,7 @@ export type ChartActionContext<T extends IEmbeddable = IEmbeddable> =
|
||||||
| RowClickContext;
|
| RowClickContext;
|
||||||
|
|
||||||
export const CONTEXT_MENU_TRIGGER = 'CONTEXT_MENU_TRIGGER';
|
export const CONTEXT_MENU_TRIGGER = 'CONTEXT_MENU_TRIGGER';
|
||||||
export const contextMenuTrigger: Trigger<'CONTEXT_MENU_TRIGGER'> = {
|
export const contextMenuTrigger: Trigger = {
|
||||||
id: CONTEXT_MENU_TRIGGER,
|
id: CONTEXT_MENU_TRIGGER,
|
||||||
title: i18n.translate('embeddableApi.contextMenuTrigger.title', {
|
title: i18n.translate('embeddableApi.contextMenuTrigger.title', {
|
||||||
defaultMessage: 'Context menu',
|
defaultMessage: 'Context menu',
|
||||||
|
@ -67,7 +67,7 @@ export const contextMenuTrigger: Trigger<'CONTEXT_MENU_TRIGGER'> = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const PANEL_BADGE_TRIGGER = 'PANEL_BADGE_TRIGGER';
|
export const PANEL_BADGE_TRIGGER = 'PANEL_BADGE_TRIGGER';
|
||||||
export const panelBadgeTrigger: Trigger<'PANEL_BADGE_TRIGGER'> = {
|
export const panelBadgeTrigger: Trigger = {
|
||||||
id: PANEL_BADGE_TRIGGER,
|
id: PANEL_BADGE_TRIGGER,
|
||||||
title: i18n.translate('embeddableApi.panelBadgeTrigger.title', {
|
title: i18n.translate('embeddableApi.panelBadgeTrigger.title', {
|
||||||
defaultMessage: 'Panel badges',
|
defaultMessage: 'Panel badges',
|
||||||
|
@ -78,7 +78,7 @@ export const panelBadgeTrigger: Trigger<'PANEL_BADGE_TRIGGER'> = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const PANEL_NOTIFICATION_TRIGGER = 'PANEL_NOTIFICATION_TRIGGER';
|
export const PANEL_NOTIFICATION_TRIGGER = 'PANEL_NOTIFICATION_TRIGGER';
|
||||||
export const panelNotificationTrigger: Trigger<'PANEL_NOTIFICATION_TRIGGER'> = {
|
export const panelNotificationTrigger: Trigger = {
|
||||||
id: PANEL_NOTIFICATION_TRIGGER,
|
id: PANEL_NOTIFICATION_TRIGGER,
|
||||||
title: i18n.translate('embeddableApi.panelNotificationTrigger.title', {
|
title: i18n.translate('embeddableApi.panelNotificationTrigger.title', {
|
||||||
defaultMessage: 'Panel notifications',
|
defaultMessage: 'Panel notifications',
|
||||||
|
@ -89,7 +89,7 @@ export const panelNotificationTrigger: Trigger<'PANEL_NOTIFICATION_TRIGGER'> = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const SELECT_RANGE_TRIGGER = 'SELECT_RANGE_TRIGGER';
|
export const SELECT_RANGE_TRIGGER = 'SELECT_RANGE_TRIGGER';
|
||||||
export const selectRangeTrigger: Trigger<'SELECT_RANGE_TRIGGER'> = {
|
export const selectRangeTrigger: Trigger = {
|
||||||
id: SELECT_RANGE_TRIGGER,
|
id: SELECT_RANGE_TRIGGER,
|
||||||
title: i18n.translate('embeddableApi.selectRangeTrigger.title', {
|
title: i18n.translate('embeddableApi.selectRangeTrigger.title', {
|
||||||
defaultMessage: 'Range selection',
|
defaultMessage: 'Range selection',
|
||||||
|
@ -100,7 +100,7 @@ export const selectRangeTrigger: Trigger<'SELECT_RANGE_TRIGGER'> = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const VALUE_CLICK_TRIGGER = 'VALUE_CLICK_TRIGGER';
|
export const VALUE_CLICK_TRIGGER = 'VALUE_CLICK_TRIGGER';
|
||||||
export const valueClickTrigger: Trigger<'VALUE_CLICK_TRIGGER'> = {
|
export const valueClickTrigger: Trigger = {
|
||||||
id: VALUE_CLICK_TRIGGER,
|
id: VALUE_CLICK_TRIGGER,
|
||||||
title: i18n.translate('embeddableApi.valueClickTrigger.title', {
|
title: i18n.translate('embeddableApi.valueClickTrigger.title', {
|
||||||
defaultMessage: 'Single click',
|
defaultMessage: 'Single click',
|
||||||
|
|
|
@ -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)
|
// 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)
|
// @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)
|
// 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<TEmbeddableInput extends EmbeddableInput = Embe
|
||||||
static runtimeId: number;
|
static runtimeId: number;
|
||||||
// (undocumented)
|
// (undocumented)
|
||||||
readonly runtimeId: number;
|
readonly runtimeId: number;
|
||||||
// Warning: (ae-forgotten-export) The symbol "TriggerContextMapping" needs to be exported by the entry point index.d.ts
|
|
||||||
//
|
|
||||||
// (undocumented)
|
// (undocumented)
|
||||||
supportedTriggers(): Array<keyof TriggerContextMapping>;
|
supportedTriggers(): string[];
|
||||||
// (undocumented)
|
// (undocumented)
|
||||||
abstract readonly type: string;
|
abstract readonly type: string;
|
||||||
// (undocumented)
|
// (undocumented)
|
||||||
|
@ -663,7 +661,7 @@ export interface IEmbeddable<I extends EmbeddableInput = EmbeddableInput, O exte
|
||||||
reload(): void;
|
reload(): void;
|
||||||
render(domNode: HTMLElement | Element): void;
|
render(domNode: HTMLElement | Element): void;
|
||||||
readonly runtimeId?: number;
|
readonly runtimeId?: number;
|
||||||
supportedTriggers(): Array<keyof TriggerContextMapping>;
|
supportedTriggers(): string[];
|
||||||
readonly type: string;
|
readonly type: string;
|
||||||
updateInput(changes: Partial<I>): void;
|
updateInput(changes: Partial<I>): 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)
|
// 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)
|
// @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)
|
// 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)
|
// 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)
|
// @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)
|
// Warning: (ae-missing-release-tag) "PanelState" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||||
//
|
//
|
||||||
|
|
|
@ -18,14 +18,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { ActionExecutionContext, createAction } from '../../../ui_actions/public';
|
import { ActionExecutionContext, createAction } from '../../../ui_actions/public';
|
||||||
import { ActionType } from '../types';
|
|
||||||
import { defaultTrigger } from '../triggers';
|
import { defaultTrigger } from '../triggers';
|
||||||
|
|
||||||
const sayHelloAction = createAction({
|
const sayHelloAction = createAction<{ amICompatible: boolean }>({
|
||||||
// Casting to ActionType is a hack - in a real situation use
|
id: 'test',
|
||||||
// declare module and add this id to ActionContextMapping.
|
type: 'test',
|
||||||
type: 'test' as ActionType,
|
isCompatible: ({ amICompatible }) => Promise.resolve(amICompatible),
|
||||||
isCompatible: ({ amICompatible }: { amICompatible: boolean }) => Promise.resolve(amICompatible),
|
|
||||||
execute: () => Promise.resolve(),
|
execute: () => Promise.resolve(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -33,7 +31,7 @@ test('action is not compatible based on context', async () => {
|
||||||
const isCompatible = await sayHelloAction.isCompatible({
|
const isCompatible = await sayHelloAction.isCompatible({
|
||||||
amICompatible: false,
|
amICompatible: false,
|
||||||
trigger: defaultTrigger,
|
trigger: defaultTrigger,
|
||||||
} as ActionExecutionContext);
|
} as ActionExecutionContext<{ amICompatible: boolean }>);
|
||||||
expect(isCompatible).toBe(false);
|
expect(isCompatible).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -41,6 +39,6 @@ test('action is compatible based on context', async () => {
|
||||||
const isCompatible = await sayHelloAction.isCompatible({
|
const isCompatible = await sayHelloAction.isCompatible({
|
||||||
amICompatible: true,
|
amICompatible: true,
|
||||||
trigger: defaultTrigger,
|
trigger: defaultTrigger,
|
||||||
} as ActionExecutionContext);
|
} as ActionExecutionContext<{ amICompatible: boolean }>);
|
||||||
expect(isCompatible).toBe(true);
|
expect(isCompatible).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
|
@ -18,15 +18,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { UiComponent } from 'src/plugins/kibana_utils/public';
|
import { UiComponent } from 'src/plugins/kibana_utils/public';
|
||||||
import { ActionType, ActionContextMapping, BaseContext } from '../types';
|
|
||||||
import { Presentable } from '../util/presentable';
|
import { Presentable } from '../util/presentable';
|
||||||
import { Trigger } from '../triggers';
|
import { Trigger } from '../triggers';
|
||||||
|
|
||||||
export type ActionByType<T extends ActionType> = Action<ActionContextMapping[T], T>;
|
|
||||||
export type ActionDefinitionByType<T extends ActionType> = ActionDefinition<
|
|
||||||
ActionContextMapping[T]
|
|
||||||
>;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* During action execution we can provide additional information,
|
* During action execution we can provide additional information,
|
||||||
* for example, trigger, that caused the action execution
|
* 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}
|
* Action methods are executed with Context from trigger + {@link ActionExecutionMeta}
|
||||||
*/
|
*/
|
||||||
export type ActionExecutionContext<Context extends BaseContext = BaseContext> = Context &
|
export type ActionExecutionContext<Context extends object = object> = Context & ActionExecutionMeta;
|
||||||
ActionExecutionMeta;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simplified action context for {@link ActionDefinition}
|
* Simplified action context for {@link ActionDefinition}
|
||||||
* When defining action consumer may use either it's own Context
|
* When defining action consumer may use either it's own Context
|
||||||
* or an ActionExecutionContext<Context> to get access to {@link ActionExecutionMeta} params
|
* or an ActionExecutionContext<Context> to get access to {@link ActionExecutionMeta} params
|
||||||
*/
|
*/
|
||||||
export type ActionDefinitionContext<Context extends BaseContext = BaseContext> =
|
export type ActionDefinitionContext<Context extends object = object> =
|
||||||
| Context
|
| Context
|
||||||
| ActionExecutionContext<Context>;
|
| ActionExecutionContext<Context>;
|
||||||
|
|
||||||
export interface Action<Context extends BaseContext = {}, T = ActionType>
|
export interface Action<Context extends object = object>
|
||||||
extends Partial<Presentable<ActionExecutionContext<Context>>> {
|
extends Partial<Presentable<ActionExecutionContext<Context>>> {
|
||||||
/**
|
/**
|
||||||
* Determined the order when there is more than one action matched to a trigger.
|
* Determined the order when there is more than one action matched to a trigger.
|
||||||
|
@ -69,7 +62,7 @@ export interface Action<Context extends BaseContext = {}, T = ActionType>
|
||||||
/**
|
/**
|
||||||
* The action type is what determines the context shape.
|
* 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.
|
* Optional EUI icon type that can be displayed along with the title.
|
||||||
|
@ -117,7 +110,7 @@ export interface Action<Context extends BaseContext = {}, T = ActionType>
|
||||||
/**
|
/**
|
||||||
* A convenience interface used to register an action.
|
* A convenience interface used to register an action.
|
||||||
*/
|
*/
|
||||||
export interface ActionDefinition<Context extends BaseContext = {}>
|
export interface ActionDefinition<Context extends object = object>
|
||||||
extends Partial<Presentable<ActionDefinitionContext<Context>>> {
|
extends Partial<Presentable<ActionDefinitionContext<Context>>> {
|
||||||
/**
|
/**
|
||||||
* ID of the action that uniquely identifies this action in the actions registry.
|
* ID of the action that uniquely identifies this action in the actions registry.
|
||||||
|
@ -127,7 +120,7 @@ export interface ActionDefinition<Context extends BaseContext = {}>
|
||||||
/**
|
/**
|
||||||
* ID of the factory for this action. Used to construct dynamic actions.
|
* 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
|
* Returns a promise that resolves to true if this item is compatible given
|
||||||
|
|
|
@ -22,7 +22,6 @@ import React from 'react';
|
||||||
import { Action, ActionContext as Context, ActionDefinition } from './action';
|
import { Action, ActionContext as Context, ActionDefinition } from './action';
|
||||||
import { Presentable, PresentableGrouping } from '../util/presentable';
|
import { Presentable, PresentableGrouping } from '../util/presentable';
|
||||||
import { uiToReactComponent } from '../../../kibana_react/public';
|
import { uiToReactComponent } from '../../../kibana_react/public';
|
||||||
import { ActionType } from '../types';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
|
@ -32,7 +31,7 @@ export class ActionInternal<A extends ActionDefinition = ActionDefinition>
|
||||||
constructor(public readonly definition: A) {}
|
constructor(public readonly definition: A) {}
|
||||||
|
|
||||||
public readonly id: string = this.definition.id;
|
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 order: number = this.definition.order || 0;
|
||||||
public readonly MenuItem? = this.definition.MenuItem;
|
public readonly MenuItem? = this.definition.MenuItem;
|
||||||
public readonly ReactMenuItem? = this.MenuItem ? uiToReactComponent(this.MenuItem) : undefined;
|
public readonly ReactMenuItem? = this.MenuItem ? uiToReactComponent(this.MenuItem) : undefined;
|
||||||
|
|
|
@ -17,25 +17,16 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { ActionContextMapping } from '../types';
|
import { ActionDefinition, Action } from './action';
|
||||||
import { ActionByType } from './action';
|
|
||||||
import { ActionType } from '../types';
|
|
||||||
import { ActionDefinition } from './action';
|
|
||||||
|
|
||||||
interface ActionDefinitionByType<T extends ActionType>
|
export function createAction<Context extends object = object>(
|
||||||
extends Omit<ActionDefinition<ActionContextMapping[T]>, 'id'> {
|
action: ActionDefinition<Context>
|
||||||
id?: string;
|
): Action<Context> {
|
||||||
}
|
|
||||||
|
|
||||||
export function createAction<T extends ActionType>(
|
|
||||||
action: ActionDefinitionByType<T>
|
|
||||||
): ActionByType<T> {
|
|
||||||
return {
|
return {
|
||||||
getIconType: () => undefined,
|
getIconType: () => undefined,
|
||||||
order: 0,
|
order: 0,
|
||||||
id: action.type,
|
|
||||||
isCompatible: () => Promise.resolve(true),
|
isCompatible: () => Promise.resolve(true),
|
||||||
getDisplayName: () => '',
|
getDisplayName: () => '',
|
||||||
...action,
|
...action,
|
||||||
} as ActionByType<T>;
|
} as Action<Context>;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ const createTestAction = ({
|
||||||
grouping?: PresentableGrouping;
|
grouping?: PresentableGrouping;
|
||||||
}) =>
|
}) =>
|
||||||
createAction({
|
createAction({
|
||||||
|
id: type as any, // mapping doesn't matter for this test
|
||||||
type: type as any, // mapping doesn't matter for this test
|
type: type as any, // mapping doesn't matter for this test
|
||||||
getDisplayName: () => dispayName,
|
getDisplayName: () => dispayName,
|
||||||
order,
|
order,
|
||||||
|
|
|
@ -24,7 +24,6 @@ import { i18n } from '@kbn/i18n';
|
||||||
import { uiToReactComponent } from '../../../kibana_react/public';
|
import { uiToReactComponent } from '../../../kibana_react/public';
|
||||||
import { Action, ActionExecutionContext } from '../actions';
|
import { Action, ActionExecutionContext } from '../actions';
|
||||||
import { Trigger } from '../triggers';
|
import { Trigger } from '../triggers';
|
||||||
import { BaseContext } from '../types';
|
|
||||||
|
|
||||||
export const defaultTitle = i18n.translate('uiActions.actionPanel.title', {
|
export const defaultTitle = i18n.translate('uiActions.actionPanel.title', {
|
||||||
defaultMessage: 'Options',
|
defaultMessage: 'Options',
|
||||||
|
@ -34,7 +33,7 @@ export const txtMore = i18n.translate('uiActions.actionPanel.more', {
|
||||||
defaultMessage: 'More',
|
defaultMessage: 'More',
|
||||||
});
|
});
|
||||||
|
|
||||||
interface ActionWithContext<Context extends BaseContext = BaseContext> {
|
interface ActionWithContext<Context extends object = object> {
|
||||||
action: Action<Context>;
|
action: Action<Context>;
|
||||||
context: Context;
|
context: Context;
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,6 @@ export {
|
||||||
} from './util';
|
} from './util';
|
||||||
export {
|
export {
|
||||||
Trigger,
|
Trigger,
|
||||||
TriggerContext,
|
|
||||||
VISUALIZE_FIELD_TRIGGER,
|
VISUALIZE_FIELD_TRIGGER,
|
||||||
visualizeFieldTrigger,
|
visualizeFieldTrigger,
|
||||||
VISUALIZE_GEO_FIELD_TRIGGER,
|
VISUALIZE_GEO_FIELD_TRIGGER,
|
||||||
|
@ -49,18 +48,9 @@ export {
|
||||||
RowClickContext,
|
RowClickContext,
|
||||||
} from './triggers';
|
} from './triggers';
|
||||||
export {
|
export {
|
||||||
TriggerContextMapping,
|
|
||||||
TriggerId,
|
|
||||||
ActionContextMapping,
|
|
||||||
ActionType,
|
|
||||||
VisualizeFieldContext,
|
VisualizeFieldContext,
|
||||||
ACTION_VISUALIZE_FIELD,
|
ACTION_VISUALIZE_FIELD,
|
||||||
ACTION_VISUALIZE_GEO_FIELD,
|
ACTION_VISUALIZE_GEO_FIELD,
|
||||||
ACTION_VISUALIZE_LENS_FIELD,
|
ACTION_VISUALIZE_LENS_FIELD,
|
||||||
} from './types';
|
} from './types';
|
||||||
export {
|
export { ActionExecutionContext, ActionExecutionMeta } from './actions';
|
||||||
ActionByType,
|
|
||||||
ActionDefinitionByType,
|
|
||||||
ActionExecutionContext,
|
|
||||||
ActionExecutionMeta,
|
|
||||||
} from './actions';
|
|
||||||
|
|
|
@ -21,7 +21,6 @@ import { CoreSetup, CoreStart } from 'src/core/public';
|
||||||
import { UiActionsSetup, UiActionsStart } from '.';
|
import { UiActionsSetup, UiActionsStart } from '.';
|
||||||
import { plugin as pluginInitializer } from '.';
|
import { plugin as pluginInitializer } from '.';
|
||||||
import { coreMock } from '../../../core/public/mocks';
|
import { coreMock } from '../../../core/public/mocks';
|
||||||
import { TriggerId } from './types';
|
|
||||||
|
|
||||||
export type Setup = jest.Mocked<UiActionsSetup>;
|
export type Setup = jest.Mocked<UiActionsSetup>;
|
||||||
export type Start = jest.Mocked<UiActionsStart>;
|
export type Start = jest.Mocked<UiActionsStart>;
|
||||||
|
@ -50,7 +49,7 @@ const createStartContract = (): Start => {
|
||||||
getAction: jest.fn(),
|
getAction: jest.fn(),
|
||||||
hasAction: jest.fn(),
|
hasAction: jest.fn(),
|
||||||
getTrigger: jest.fn(),
|
getTrigger: jest.fn(),
|
||||||
getTriggerActions: jest.fn((id: TriggerId) => []),
|
getTriggerActions: jest.fn((id: string) => []),
|
||||||
getTriggerCompatibleActions: jest.fn(),
|
getTriggerCompatibleActions: jest.fn(),
|
||||||
registerAction: jest.fn(),
|
registerAction: jest.fn(),
|
||||||
registerTrigger: jest.fn(),
|
registerTrigger: jest.fn(),
|
||||||
|
|
|
@ -15,11 +15,10 @@ import { PublicMethodsOf } from '@kbn/utility-types';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { UiComponent } from 'src/plugins/kibana_utils/public';
|
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)
|
// 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)
|
// @public (undocumented)
|
||||||
export interface Action<Context extends BaseContext = {}, T = ActionType> extends Partial<UiActionsPresentable<ActionExecutionContext<Context>>> {
|
export interface Action<Context extends object = object> extends Partial<UiActionsPresentable<ActionExecutionContext<Context>>> {
|
||||||
execute(context: ActionExecutionContext<Context>): Promise<void>;
|
execute(context: ActionExecutionContext<Context>): Promise<void>;
|
||||||
getDisplayName(context: ActionExecutionContext<Context>): string;
|
getDisplayName(context: ActionExecutionContext<Context>): string;
|
||||||
getHref?(context: ActionExecutionContext<Context>): Promise<string | undefined>;
|
getHref?(context: ActionExecutionContext<Context>): Promise<string | undefined>;
|
||||||
|
@ -31,7 +30,7 @@ export interface Action<Context extends BaseContext = {}, T = ActionType> extend
|
||||||
}>;
|
}>;
|
||||||
order?: number;
|
order?: number;
|
||||||
shouldAutoExecute?(context: ActionExecutionContext<Context>): Promise<boolean>;
|
shouldAutoExecute?(context: ActionExecutionContext<Context>): Promise<boolean>;
|
||||||
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)
|
// 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)
|
// @public (undocumented)
|
||||||
export const ACTION_VISUALIZE_LENS_FIELD = "ACTION_VISUALIZE_LENS_FIELD";
|
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<T extends ActionType> = Action<ActionContextMapping[T], T>;
|
|
||||||
|
|
||||||
// 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<T extends ActionType> = UiActionsActionDefinition<ActionContextMapping[T]>;
|
|
||||||
|
|
||||||
// Warning: (ae-missing-release-tag) "ActionExecutionContext" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
// Warning: (ae-missing-release-tag) "ActionExecutionContext" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||||
//
|
//
|
||||||
// @public
|
// @public
|
||||||
export type ActionExecutionContext<Context extends BaseContext = BaseContext> = Context & ActionExecutionMeta;
|
export type ActionExecutionContext<Context extends object = object> = 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)
|
// 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;
|
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-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)
|
// Warning: (ae-missing-release-tag) "buildContextMenuForActions" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||||
//
|
//
|
||||||
// @public
|
// @public
|
||||||
export function buildContextMenuForActions({ actions, title, closeMenu, }: BuildContextMenuParams): Promise<EuiContextMenuPanelDescriptor[]>;
|
export function buildContextMenuForActions({ actions, title, closeMenu, }: BuildContextMenuParams): Promise<EuiContextMenuPanelDescriptor[]>;
|
||||||
|
|
||||||
// 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)
|
// 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)
|
// @public (undocumented)
|
||||||
export function createAction<T extends ActionType>(action: ActionDefinitionByType_2<T>): ActionByType<T>;
|
export function createAction<Context extends object = object>(action: UiActionsActionDefinition<Context>): Action<Context>;
|
||||||
|
|
||||||
// Warning: (ae-missing-release-tag) "IncompatibleActionError" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
// 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)
|
// 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)
|
// @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)
|
// Warning: (ae-missing-release-tag) "Trigger" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||||
//
|
//
|
||||||
// @public
|
// @public
|
||||||
export interface Trigger<ID extends TriggerId = TriggerId> {
|
export interface Trigger {
|
||||||
description?: string;
|
description?: string;
|
||||||
id: ID;
|
id: string;
|
||||||
title?: 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> = 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-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)
|
// Warning: (ae-missing-release-tag) "ActionDefinition" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||||
//
|
//
|
||||||
// @public
|
// @public
|
||||||
export interface UiActionsActionDefinition<Context extends BaseContext = {}> extends Partial<UiActionsPresentable<ActionDefinitionContext<Context>>> {
|
export interface UiActionsActionDefinition<Context extends object = object> extends Partial<UiActionsPresentable<ActionDefinitionContext<Context>>> {
|
||||||
execute(context: ActionDefinitionContext<Context>): Promise<void>;
|
execute(context: ActionDefinitionContext<Context>): Promise<void>;
|
||||||
getHref?(context: ActionDefinitionContext<Context>): Promise<string | undefined>;
|
getHref?(context: ActionDefinitionContext<Context>): Promise<string | undefined>;
|
||||||
readonly id: string;
|
readonly id: string;
|
||||||
isCompatible?(context: ActionDefinitionContext<Context>): Promise<boolean>;
|
isCompatible?(context: ActionDefinitionContext<Context>): Promise<boolean>;
|
||||||
shouldAutoExecute?(context: ActionDefinitionContext<Context>): Promise<boolean>;
|
shouldAutoExecute?(context: ActionDefinitionContext<Context>): Promise<boolean>;
|
||||||
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)
|
// Warning: (ae-missing-release-tag) "Presentable" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||||
//
|
//
|
||||||
// @public
|
// @public
|
||||||
export interface UiActionsPresentable<Context extends object = object> {
|
export interface UiActionsPresentable<Context = unknown> {
|
||||||
getDisplayName(context: Context): string;
|
getDisplayName(context: Context): string;
|
||||||
getDisplayNameTooltip(context: Context): string;
|
getDisplayNameTooltip(context: Context): string;
|
||||||
getHref?(context: Context): Promise<string | undefined>;
|
getHref?(context: Context): Promise<string | undefined>;
|
||||||
|
@ -214,7 +154,7 @@ export interface UiActionsPresentable<Context extends object = object> {
|
||||||
// Warning: (ae-missing-release-tag) "PresentableGrouping" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
// 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)
|
// @public (undocumented)
|
||||||
export type UiActionsPresentableGrouping<Context extends object = object> = Array<PresentableGroup<Context>>;
|
export type UiActionsPresentableGrouping<Context = unknown> = Array<PresentableGroup<Context>>;
|
||||||
|
|
||||||
// Warning: (ae-missing-release-tag) "UiActionsService" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
// 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)
|
// (undocumented)
|
||||||
protected readonly actions: ActionRegistry;
|
protected readonly actions: ActionRegistry;
|
||||||
readonly addTriggerAction: <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: UiActionsActionDefinition<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;
|
readonly addTriggerAction: (triggerId: string, action: UiActionsActionDefinition) => void;
|
||||||
// (undocumented)
|
// (undocumented)
|
||||||
readonly attachAction: <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;
|
readonly attachAction: (triggerId: string, actionId: string) => void;
|
||||||
readonly clear: () => void;
|
readonly clear: () => void;
|
||||||
// (undocumented)
|
// (undocumented)
|
||||||
readonly detachAction: (triggerId: TriggerId, actionId: string) => void;
|
readonly detachAction: (triggerId: string, actionId: string) => void;
|
||||||
// @deprecated (undocumented)
|
// @deprecated (undocumented)
|
||||||
readonly executeTriggerActions: <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>;
|
readonly executeTriggerActions: (triggerId: string, context: object) => Promise<void>;
|
||||||
// Warning: (ae-forgotten-export) The symbol "UiActionsExecutionService" needs to be exported by the entry point index.d.ts
|
// Warning: (ae-forgotten-export) The symbol "UiActionsExecutionService" needs to be exported by the entry point index.d.ts
|
||||||
//
|
//
|
||||||
// (undocumented)
|
// (undocumented)
|
||||||
readonly executionService: UiActionsExecutionService;
|
readonly executionService: UiActionsExecutionService;
|
||||||
readonly fork: () => UiActionsService;
|
readonly fork: () => UiActionsService;
|
||||||
// (undocumented)
|
// (undocumented)
|
||||||
readonly getAction: <T extends UiActionsActionDefinition<{}>>(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">;
|
readonly getAction: <T extends UiActionsActionDefinition<object>>(id: string) => Action<ActionContext<T>>;
|
||||||
// Warning: (ae-forgotten-export) The symbol "TriggerContract" needs to be exported by the entry point index.d.ts
|
// Warning: (ae-forgotten-export) The symbol "TriggerContract" needs to be exported by the entry point index.d.ts
|
||||||
//
|
//
|
||||||
// (undocumented)
|
// (undocumented)
|
||||||
readonly getTrigger: <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>;
|
readonly getTrigger: (triggerId: string) => TriggerContract;
|
||||||
// (undocumented)
|
// (undocumented)
|
||||||
readonly getTriggerActions: <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">[];
|
readonly getTriggerActions: (triggerId: string) => Action[];
|
||||||
// (undocumented)
|
// (undocumented)
|
||||||
readonly getTriggerCompatibleActions: <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">[]>;
|
readonly getTriggerCompatibleActions: (triggerId: string, context: object) => Promise<Action[]>;
|
||||||
// (undocumented)
|
// (undocumented)
|
||||||
readonly hasAction: (actionId: string) => boolean;
|
readonly hasAction: (actionId: string) => boolean;
|
||||||
// Warning: (ae-forgotten-export) The symbol "ActionContext" needs to be exported by the entry point index.d.ts
|
// Warning: (ae-forgotten-export) The symbol "ActionContext" needs to be exported by the entry point index.d.ts
|
||||||
//
|
//
|
||||||
// (undocumented)
|
// (undocumented)
|
||||||
readonly registerAction: <A extends UiActionsActionDefinition<{}>>(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">;
|
readonly registerAction: <A extends UiActionsActionDefinition<object>>(definition: A) => Action<ActionContext<A>>;
|
||||||
// (undocumented)
|
// (undocumented)
|
||||||
readonly registerTrigger: (trigger: Trigger) => void;
|
readonly registerTrigger: (trigger: Trigger) => void;
|
||||||
// Warning: (ae-forgotten-export) The symbol "TriggerRegistry" needs to be exported by the entry point index.d.ts
|
// 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)
|
// 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)
|
// @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)
|
// 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)
|
// @public (undocumented)
|
||||||
export const visualizeGeoFieldTrigger: Trigger<'VISUALIZE_GEO_FIELD_TRIGGER'>;
|
export const visualizeGeoFieldTrigger: Trigger;
|
||||||
|
|
||||||
|
|
||||||
// Warnings were encountered during analysis:
|
// Warnings were encountered during analysis:
|
||||||
|
|
|
@ -19,14 +19,13 @@
|
||||||
|
|
||||||
import { uniqBy } from 'lodash';
|
import { uniqBy } from 'lodash';
|
||||||
import { Action } from '../actions';
|
import { Action } from '../actions';
|
||||||
import { BaseContext } from '../types';
|
|
||||||
import { defer as createDefer, Defer } from '../../../kibana_utils/public';
|
import { defer as createDefer, Defer } from '../../../kibana_utils/public';
|
||||||
import { buildContextMenuForActions, openContextMenu } from '../context_menu';
|
import { buildContextMenuForActions, openContextMenu } from '../context_menu';
|
||||||
import { Trigger } from '../triggers';
|
import { Trigger } from '../triggers';
|
||||||
|
|
||||||
interface ExecuteActionTask {
|
interface ExecuteActionTask {
|
||||||
action: Action;
|
action: Action;
|
||||||
context: BaseContext;
|
context: object;
|
||||||
trigger: Trigger;
|
trigger: Trigger;
|
||||||
defer: Defer<void>;
|
defer: Defer<void>;
|
||||||
alwaysShowPopup?: boolean;
|
alwaysShowPopup?: boolean;
|
||||||
|
@ -44,8 +43,8 @@ export class UiActionsExecutionService {
|
||||||
context,
|
context,
|
||||||
trigger,
|
trigger,
|
||||||
}: {
|
}: {
|
||||||
action: Action<BaseContext>;
|
action: Action;
|
||||||
context: BaseContext;
|
context: object;
|
||||||
trigger: Trigger;
|
trigger: Trigger;
|
||||||
},
|
},
|
||||||
alwaysShowPopup?: boolean
|
alwaysShowPopup?: boolean
|
||||||
|
|
|
@ -20,19 +20,17 @@
|
||||||
import { UiActionsService } from './ui_actions_service';
|
import { UiActionsService } from './ui_actions_service';
|
||||||
import { Action, ActionInternal, createAction } from '../actions';
|
import { Action, ActionInternal, createAction } from '../actions';
|
||||||
import { createHelloWorldAction } from '../tests/test_samples';
|
import { createHelloWorldAction } from '../tests/test_samples';
|
||||||
import { TriggerRegistry, TriggerId, ActionType, ActionRegistry } from '../types';
|
import { TriggerRegistry, ActionRegistry } from '../types';
|
||||||
import { Trigger } from '../triggers';
|
import { Trigger } from '../triggers';
|
||||||
|
|
||||||
// Casting to ActionType or TriggerId is a hack - in a real situation use
|
const FOO_TRIGGER = 'FOO_TRIGGER';
|
||||||
// declare module and add this id to the appropriate context mapping.
|
const BAR_TRIGGER = 'BAR_TRIGGER';
|
||||||
const FOO_TRIGGER: TriggerId = 'FOO_TRIGGER' as TriggerId;
|
const MY_TRIGGER = 'MY_TRIGGER';
|
||||||
const BAR_TRIGGER: TriggerId = 'BAR_TRIGGER' as TriggerId;
|
|
||||||
const MY_TRIGGER: TriggerId = 'MY_TRIGGER' as TriggerId;
|
|
||||||
|
|
||||||
const testAction1: Action = {
|
const testAction1: Action = {
|
||||||
id: 'action1',
|
id: 'action1',
|
||||||
order: 1,
|
order: 1,
|
||||||
type: 'type1' as ActionType,
|
type: 'type1',
|
||||||
execute: async () => {},
|
execute: async () => {},
|
||||||
getDisplayName: () => 'test1',
|
getDisplayName: () => 'test1',
|
||||||
getIconType: () => '',
|
getIconType: () => '',
|
||||||
|
@ -42,7 +40,7 @@ const testAction1: Action = {
|
||||||
const testAction2: Action = {
|
const testAction2: Action = {
|
||||||
id: 'action2',
|
id: 'action2',
|
||||||
order: 2,
|
order: 2,
|
||||||
type: 'type2' as ActionType,
|
type: 'type2',
|
||||||
execute: async () => {},
|
execute: async () => {},
|
||||||
getDisplayName: () => 'test2',
|
getDisplayName: () => 'test2',
|
||||||
getIconType: () => '',
|
getIconType: () => '',
|
||||||
|
@ -99,7 +97,7 @@ describe('UiActionsService', () => {
|
||||||
getDisplayName: () => 'test',
|
getDisplayName: () => 'test',
|
||||||
getIconType: () => '',
|
getIconType: () => '',
|
||||||
isCompatible: async () => true,
|
isCompatible: async () => true,
|
||||||
type: 'test' as ActionType,
|
type: 'test',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -111,7 +109,7 @@ describe('UiActionsService', () => {
|
||||||
getDisplayName: () => 'test',
|
getDisplayName: () => 'test',
|
||||||
getIconType: () => '',
|
getIconType: () => '',
|
||||||
isCompatible: async () => true,
|
isCompatible: async () => true,
|
||||||
type: 'test' as ActionType,
|
type: 'test',
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(action).toBeInstanceOf(ActionInternal);
|
expect(action).toBeInstanceOf(ActionInternal);
|
||||||
|
@ -123,7 +121,7 @@ describe('UiActionsService', () => {
|
||||||
const action1: Action = {
|
const action1: Action = {
|
||||||
id: 'action1',
|
id: 'action1',
|
||||||
order: 1,
|
order: 1,
|
||||||
type: 'type1' as ActionType,
|
type: 'type1',
|
||||||
execute: async () => {},
|
execute: async () => {},
|
||||||
getDisplayName: () => 'test',
|
getDisplayName: () => 'test',
|
||||||
getIconType: () => '',
|
getIconType: () => '',
|
||||||
|
@ -132,7 +130,7 @@ describe('UiActionsService', () => {
|
||||||
const action2: Action = {
|
const action2: Action = {
|
||||||
id: 'action2',
|
id: 'action2',
|
||||||
order: 2,
|
order: 2,
|
||||||
type: 'type2' as ActionType,
|
type: 'type2',
|
||||||
execute: async () => {},
|
execute: async () => {},
|
||||||
getDisplayName: () => 'test',
|
getDisplayName: () => 'test',
|
||||||
getIconType: () => '',
|
getIconType: () => '',
|
||||||
|
@ -207,7 +205,8 @@ describe('UiActionsService', () => {
|
||||||
test('filters out actions not applicable based on the context', async () => {
|
test('filters out actions not applicable based on the context', async () => {
|
||||||
const service = new UiActionsService();
|
const service = new UiActionsService();
|
||||||
const action = createAction({
|
const action = createAction({
|
||||||
type: 'test' as ActionType,
|
id: 'test',
|
||||||
|
type: 'test',
|
||||||
isCompatible: ({ accept }: { accept: boolean }) => Promise.resolve(accept),
|
isCompatible: ({ accept }: { accept: boolean }) => Promise.resolve(accept),
|
||||||
execute: () => Promise.resolve(),
|
execute: () => Promise.resolve(),
|
||||||
});
|
});
|
||||||
|
@ -238,16 +237,15 @@ describe('UiActionsService', () => {
|
||||||
test(`throws an error with an invalid trigger ID`, async () => {
|
test(`throws an error with an invalid trigger ID`, async () => {
|
||||||
const service = new UiActionsService();
|
const service = new UiActionsService();
|
||||||
|
|
||||||
// Without the cast "as TriggerId" typescript will happily throw an error!
|
await expect(service.getTriggerCompatibleActions('I do not exist', {})).rejects.toMatchObject(
|
||||||
await expect(
|
new Error('Trigger [triggerId = I do not exist] does not exist.')
|
||||||
service.getTriggerCompatibleActions('I do not exist' as TriggerId, {})
|
);
|
||||||
).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 () => {
|
test('returns empty list if trigger not attached to any action', async () => {
|
||||||
const service = new UiActionsService();
|
const service = new UiActionsService();
|
||||||
const testTrigger: Trigger = {
|
const testTrigger: Trigger = {
|
||||||
id: '123' as TriggerId,
|
id: '123',
|
||||||
title: '123',
|
title: '123',
|
||||||
};
|
};
|
||||||
service.registerTrigger(testTrigger);
|
service.registerTrigger(testTrigger);
|
||||||
|
@ -445,9 +443,7 @@ describe('UiActionsService', () => {
|
||||||
} as any;
|
} as any;
|
||||||
|
|
||||||
service.registerAction(action);
|
service.registerAction(action);
|
||||||
expect(() =>
|
expect(() => service.detachAction('i do not exist', ACTION_HELLO_WORLD)).toThrowError(
|
||||||
service.detachAction('i do not exist' as TriggerId, ACTION_HELLO_WORLD)
|
|
||||||
).toThrowError(
|
|
||||||
'No trigger [triggerId = i do not exist] exists, for detaching action [actionId = ACTION_HELLO_WORLD].'
|
'No trigger [triggerId = i do not exist] exists, for detaching action [actionId = ACTION_HELLO_WORLD].'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -461,7 +457,7 @@ describe('UiActionsService', () => {
|
||||||
} as any;
|
} as any;
|
||||||
|
|
||||||
service.registerAction(action);
|
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].'
|
'No trigger [triggerId = i do not exist] exists, for attaching action [actionId = ACTION_HELLO_WORLD].'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
@ -17,15 +17,9 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import { TriggerRegistry, ActionRegistry, TriggerToActionsRegistry } from '../types';
|
||||||
TriggerRegistry,
|
|
||||||
ActionRegistry,
|
|
||||||
TriggerToActionsRegistry,
|
|
||||||
TriggerId,
|
|
||||||
TriggerContextMapping,
|
|
||||||
} from '../types';
|
|
||||||
import { ActionInternal, Action, ActionDefinition, ActionContext } from '../actions';
|
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 { TriggerInternal } from '../triggers/trigger_internal';
|
||||||
import { TriggerContract } from '../triggers/trigger_contract';
|
import { TriggerContract } from '../triggers/trigger_contract';
|
||||||
import { UiActionsExecutionService } from './ui_actions_execution_service';
|
import { UiActionsExecutionService } from './ui_actions_execution_service';
|
||||||
|
@ -67,7 +61,7 @@ export class UiActionsService {
|
||||||
this.triggerToActions.set(trigger.id, []);
|
this.triggerToActions.set(trigger.id, []);
|
||||||
};
|
};
|
||||||
|
|
||||||
public readonly getTrigger = <T extends TriggerId>(triggerId: T): TriggerContract<T> => {
|
public readonly getTrigger = (triggerId: string): TriggerContract => {
|
||||||
const trigger = this.triggers.get(triggerId);
|
const trigger = this.triggers.get(triggerId);
|
||||||
|
|
||||||
if (!trigger) {
|
if (!trigger) {
|
||||||
|
@ -103,7 +97,7 @@ export class UiActionsService {
|
||||||
return this.actions.has(actionId);
|
return this.actions.has(actionId);
|
||||||
};
|
};
|
||||||
|
|
||||||
public readonly attachAction = <T extends TriggerId>(triggerId: T, actionId: string): void => {
|
public readonly attachAction = (triggerId: string, actionId: string): void => {
|
||||||
const trigger = this.triggers.get(triggerId);
|
const trigger = this.triggers.get(triggerId);
|
||||||
|
|
||||||
if (!trigger) {
|
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);
|
const trigger = this.triggers.get(triggerId);
|
||||||
|
|
||||||
if (!trigger) {
|
if (!trigger) {
|
||||||
|
@ -139,14 +133,10 @@ export class UiActionsService {
|
||||||
/**
|
/**
|
||||||
* `addTriggerAction` is similar to `attachAction` as it attaches action to a
|
* `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.
|
* 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 = <T extends TriggerId>(
|
public readonly addTriggerAction = (
|
||||||
triggerId: T,
|
triggerId: string,
|
||||||
// The action can accept partial or no context, but if it needs context not provided
|
action: ActionDefinition // TODO: remove `Action` https://github.com/elastic/kibana/issues/74501
|
||||||
// by this type of trigger, typescript will complain. yay!
|
|
||||||
action: ActionDefinition<TriggerContextMapping[T]> | Action<TriggerContextMapping[T]> // TODO: remove `Action` https://github.com/elastic/kibana/issues/74501
|
|
||||||
): void => {
|
): void => {
|
||||||
if (!this.actions.has(action.id)) this.registerAction(action);
|
if (!this.actions.has(action.id)) this.registerAction(action);
|
||||||
this.attachAction(triggerId, action.id);
|
this.attachAction(triggerId, action.id);
|
||||||
|
@ -162,9 +152,7 @@ export class UiActionsService {
|
||||||
return this.actions.get(id) as ActionInternal<T>;
|
return this.actions.get(id) as ActionInternal<T>;
|
||||||
};
|
};
|
||||||
|
|
||||||
public readonly getTriggerActions = <T extends TriggerId>(
|
public readonly getTriggerActions = (triggerId: string): Action[] => {
|
||||||
triggerId: T
|
|
||||||
): Array<Action<TriggerContextMapping[T]>> => {
|
|
||||||
// This line checks if trigger exists, otherwise throws.
|
// This line checks if trigger exists, otherwise throws.
|
||||||
this.getTrigger!(triggerId);
|
this.getTrigger!(triggerId);
|
||||||
|
|
||||||
|
@ -174,13 +162,13 @@ export class UiActionsService {
|
||||||
.map((actionId) => this.actions.get(actionId) as ActionInternal)
|
.map((actionId) => this.actions.get(actionId) as ActionInternal)
|
||||||
.filter(Boolean);
|
.filter(Boolean);
|
||||||
|
|
||||||
return actions as Array<Action<TriggerContext<T>>>;
|
return actions as Action[];
|
||||||
};
|
};
|
||||||
|
|
||||||
public readonly getTriggerCompatibleActions = async <T extends TriggerId>(
|
public readonly getTriggerCompatibleActions = async (
|
||||||
triggerId: T,
|
triggerId: string,
|
||||||
context: TriggerContextMapping[T]
|
context: object
|
||||||
): Promise<Array<Action<TriggerContextMapping[T]>>> => {
|
): Promise<Action[]> => {
|
||||||
const actions = this.getTriggerActions!(triggerId);
|
const actions = this.getTriggerActions!(triggerId);
|
||||||
const isCompatibles = await Promise.all(
|
const isCompatibles = await Promise.all(
|
||||||
actions.map((action) =>
|
actions.map((action) =>
|
||||||
|
@ -191,8 +179,7 @@ export class UiActionsService {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
return actions.reduce(
|
return actions.reduce(
|
||||||
(acc: Array<Action<TriggerContextMapping[T]>>, action, i) =>
|
(acc: Action[], action, i) => (isCompatibles[i] ? [...acc, action] : acc),
|
||||||
isCompatibles[i] ? [...acc, action] : acc,
|
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -202,11 +189,8 @@ export class UiActionsService {
|
||||||
*
|
*
|
||||||
* Use `plugins.uiActions.getTrigger(triggerId).exec(params)` instead.
|
* Use `plugins.uiActions.getTrigger(triggerId).exec(params)` instead.
|
||||||
*/
|
*/
|
||||||
public readonly executeTriggerActions = async <T extends TriggerId>(
|
public readonly executeTriggerActions = async (triggerId: string, context: object) => {
|
||||||
triggerId: T,
|
const trigger = this.getTrigger(triggerId);
|
||||||
context: TriggerContext<T>
|
|
||||||
) => {
|
|
||||||
const trigger = this.getTrigger<T>(triggerId);
|
|
||||||
await trigger.exec(context);
|
await trigger.exec(context);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,6 @@ import { Action, createAction } from '../actions';
|
||||||
import { openContextMenu } from '../context_menu';
|
import { openContextMenu } from '../context_menu';
|
||||||
import { uiActionsPluginMock } from '../mocks';
|
import { uiActionsPluginMock } from '../mocks';
|
||||||
import { Trigger } from '../triggers';
|
import { Trigger } from '../triggers';
|
||||||
import { TriggerId, ActionType } from '../types';
|
|
||||||
import { waitFor } from '@testing-library/dom';
|
import { waitFor } from '@testing-library/dom';
|
||||||
|
|
||||||
jest.mock('../context_menu');
|
jest.mock('../context_menu');
|
||||||
|
@ -31,17 +30,13 @@ const openContextMenuSpy = (openContextMenu as any) as jest.SpyInstance;
|
||||||
|
|
||||||
const CONTACT_USER_TRIGGER = 'CONTACT_USER_TRIGGER';
|
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<C extends object>(
|
function createTestAction<C extends object>(
|
||||||
type: string,
|
type: string,
|
||||||
checkCompatibility: (context: C) => boolean,
|
checkCompatibility: (context: C) => boolean,
|
||||||
autoExecutable = false
|
autoExecutable = false
|
||||||
): Action<object> {
|
): Action<object> {
|
||||||
return createAction<typeof TEST_ACTION_TYPE>({
|
return createAction({
|
||||||
type: type as ActionType,
|
type,
|
||||||
id: type,
|
id: type,
|
||||||
isCompatible: (context: C) => Promise.resolve(checkCompatibility(context)),
|
isCompatible: (context: C) => Promise.resolve(checkCompatibility(context)),
|
||||||
execute: (context) => executeFn(context),
|
execute: (context) => executeFn(context),
|
||||||
|
@ -67,7 +62,7 @@ beforeEach(reset);
|
||||||
test('executes a single action mapped to a trigger', async () => {
|
test('executes a single action mapped to a trigger', async () => {
|
||||||
const { setup, doStart } = uiActions;
|
const { setup, doStart } = uiActions;
|
||||||
const trigger: Trigger = {
|
const trigger: Trigger = {
|
||||||
id: 'MY-TRIGGER' as TriggerId,
|
id: 'MY-TRIGGER',
|
||||||
title: 'My trigger',
|
title: 'My trigger',
|
||||||
};
|
};
|
||||||
const action = createTestAction('test1', () => true);
|
const action = createTestAction('test1', () => true);
|
||||||
|
@ -77,7 +72,7 @@ test('executes a single action mapped to a trigger', async () => {
|
||||||
|
|
||||||
const context = {};
|
const context = {};
|
||||||
const start = doStart();
|
const start = doStart();
|
||||||
await start.executeTriggerActions('MY-TRIGGER' as TriggerId, context);
|
await start.executeTriggerActions('MY-TRIGGER', context);
|
||||||
|
|
||||||
jest.runAllTimers();
|
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 () => {
|
test("doesn't throw an error if there are no compatible actions to execute", async () => {
|
||||||
const { setup, doStart } = uiActions;
|
const { setup, doStart } = uiActions;
|
||||||
const trigger: Trigger = {
|
const trigger: Trigger = {
|
||||||
id: 'MY-TRIGGER' as TriggerId,
|
id: 'MY-TRIGGER',
|
||||||
title: '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 context = {};
|
||||||
const start = doStart();
|
const start = doStart();
|
||||||
await expect(
|
await expect(start.executeTriggerActions('MY-TRIGGER', context)).resolves.toBeUndefined();
|
||||||
start.executeTriggerActions('MY-TRIGGER' as TriggerId, context)
|
|
||||||
).resolves.toBeUndefined();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('does not execute an incompatible action', async () => {
|
test('does not execute an incompatible action', async () => {
|
||||||
const { setup, doStart } = uiActions;
|
const { setup, doStart } = uiActions;
|
||||||
const trigger: Trigger = {
|
const trigger: Trigger = {
|
||||||
id: 'MY-TRIGGER' as TriggerId,
|
id: 'MY-TRIGGER',
|
||||||
title: 'My trigger',
|
title: 'My trigger',
|
||||||
};
|
};
|
||||||
const action = createTestAction<{ name: string }>(
|
const action = createTestAction<{ name: string }>(
|
||||||
|
@ -119,7 +112,7 @@ test('does not execute an incompatible action', async () => {
|
||||||
const context = {
|
const context = {
|
||||||
name: 'executeme',
|
name: 'executeme',
|
||||||
};
|
};
|
||||||
await start.executeTriggerActions('MY-TRIGGER' as TriggerId, context);
|
await start.executeTriggerActions('MY-TRIGGER', context);
|
||||||
|
|
||||||
jest.runAllTimers();
|
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 () => {
|
test('shows a context menu when more than one action is mapped to a trigger', async () => {
|
||||||
const { setup, doStart } = uiActions;
|
const { setup, doStart } = uiActions;
|
||||||
const trigger: Trigger = {
|
const trigger: Trigger = {
|
||||||
id: 'MY-TRIGGER' as TriggerId,
|
id: 'MY-TRIGGER',
|
||||||
title: 'My trigger',
|
title: 'My trigger',
|
||||||
};
|
};
|
||||||
const action1 = createTestAction('test1', () => true);
|
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 start = doStart();
|
||||||
const context = {};
|
const context = {};
|
||||||
await start.getTrigger('MY-TRIGGER' as TriggerId)!.exec(context);
|
await start.getTrigger('MY-TRIGGER')!.exec(context);
|
||||||
|
|
||||||
jest.runAllTimers();
|
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 () => {
|
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 { setup, doStart } = uiActions;
|
||||||
const trigger: Trigger = {
|
const trigger: Trigger = {
|
||||||
id: 'MY-TRIGGER' as TriggerId,
|
id: 'MY-TRIGGER',
|
||||||
title: 'My trigger',
|
title: 'My trigger',
|
||||||
};
|
};
|
||||||
const action1 = createTestAction('test1', () => true);
|
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 start = doStart();
|
||||||
const context = {};
|
const context = {};
|
||||||
await start.getTrigger('MY-TRIGGER' as TriggerId)!.exec(context, true);
|
await start.getTrigger('MY-TRIGGER')!.exec(context, true);
|
||||||
|
|
||||||
jest.runAllTimers();
|
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 () => {
|
test('passes whole action context to isCompatible()', async () => {
|
||||||
const { setup, doStart } = uiActions;
|
const { setup, doStart } = uiActions;
|
||||||
const trigger = {
|
const trigger = {
|
||||||
id: 'MY-TRIGGER' as TriggerId,
|
id: 'MY-TRIGGER',
|
||||||
title: 'My trigger',
|
title: 'My trigger',
|
||||||
};
|
};
|
||||||
const action = createTestAction<{ foo: string }>('test', ({ foo }) => {
|
const action = createTestAction<{ foo: string }>('test', ({ foo }) => {
|
||||||
|
@ -195,14 +188,14 @@ test('passes whole action context to isCompatible()', async () => {
|
||||||
const start = doStart();
|
const start = doStart();
|
||||||
|
|
||||||
const context = { foo: 'bar' };
|
const context = { foo: 'bar' };
|
||||||
await start.executeTriggerActions('MY-TRIGGER' as TriggerId, context);
|
await start.executeTriggerActions('MY-TRIGGER', context);
|
||||||
jest.runAllTimers();
|
jest.runAllTimers();
|
||||||
});
|
});
|
||||||
|
|
||||||
test("doesn't show a context menu for auto executable actions", async () => {
|
test("doesn't show a context menu for auto executable actions", async () => {
|
||||||
const { setup, doStart } = uiActions;
|
const { setup, doStart } = uiActions;
|
||||||
const trigger: Trigger = {
|
const trigger: Trigger = {
|
||||||
id: 'MY-TRIGGER' as TriggerId,
|
id: 'MY-TRIGGER',
|
||||||
title: 'My trigger',
|
title: 'My trigger',
|
||||||
};
|
};
|
||||||
const action1 = createTestAction('test1', () => true, true);
|
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 start = doStart();
|
||||||
const context = {};
|
const context = {};
|
||||||
await start.executeTriggerActions('MY-TRIGGER' as TriggerId, context);
|
await start.executeTriggerActions('MY-TRIGGER', context);
|
||||||
|
|
||||||
jest.runAllTimers();
|
jest.runAllTimers();
|
||||||
|
|
||||||
|
@ -229,7 +222,7 @@ test("doesn't show a context menu for auto executable actions", async () => {
|
||||||
test('passes trigger into execute', async () => {
|
test('passes trigger into execute', async () => {
|
||||||
const { setup, doStart } = uiActions;
|
const { setup, doStart } = uiActions;
|
||||||
const trigger = {
|
const trigger = {
|
||||||
id: 'MY-TRIGGER' as TriggerId,
|
id: 'MY-TRIGGER',
|
||||||
title: 'My trigger',
|
title: 'My trigger',
|
||||||
};
|
};
|
||||||
const action = createTestAction<{ foo: string }>('test', () => true);
|
const action = createTestAction<{ foo: string }>('test', () => true);
|
||||||
|
@ -240,7 +233,7 @@ test('passes trigger into execute', async () => {
|
||||||
const start = doStart();
|
const start = doStart();
|
||||||
|
|
||||||
const context = { foo: 'bar' };
|
const context = { foo: 'bar' };
|
||||||
await start.executeTriggerActions('MY-TRIGGER' as TriggerId, context);
|
await start.executeTriggerActions('MY-TRIGGER', context);
|
||||||
jest.runAllTimers();
|
jest.runAllTimers();
|
||||||
expect(executeFn).toBeCalledWith({
|
expect(executeFn).toBeCalledWith({
|
||||||
...context,
|
...context,
|
||||||
|
|
|
@ -19,17 +19,16 @@
|
||||||
|
|
||||||
import { ActionInternal, Action } from '../actions';
|
import { ActionInternal, Action } from '../actions';
|
||||||
import { uiActionsPluginMock } from '../mocks';
|
import { uiActionsPluginMock } from '../mocks';
|
||||||
import { TriggerId, ActionType } from '../types';
|
|
||||||
|
|
||||||
const action1: Action = {
|
const action1: Action = {
|
||||||
id: 'action1',
|
id: 'action1',
|
||||||
order: 1,
|
order: 1,
|
||||||
type: 'type1' as ActionType,
|
type: 'type1',
|
||||||
} as any;
|
} as any;
|
||||||
const action2: Action = {
|
const action2: Action = {
|
||||||
id: 'action2',
|
id: 'action2',
|
||||||
order: 2,
|
order: 2,
|
||||||
type: 'type2' as ActionType,
|
type: 'type2',
|
||||||
} as any;
|
} as any;
|
||||||
|
|
||||||
test('returns actions set on trigger', () => {
|
test('returns actions set on trigger', () => {
|
||||||
|
@ -38,24 +37,24 @@ test('returns actions set on trigger', () => {
|
||||||
setup.registerAction(action2);
|
setup.registerAction(action2);
|
||||||
setup.registerTrigger({
|
setup.registerTrigger({
|
||||||
description: 'foo',
|
description: 'foo',
|
||||||
id: 'trigger' as TriggerId,
|
id: 'trigger',
|
||||||
title: 'baz',
|
title: 'baz',
|
||||||
});
|
});
|
||||||
|
|
||||||
const start = doStart();
|
const start = doStart();
|
||||||
const list0 = start.getTriggerActions('trigger' as TriggerId);
|
const list0 = start.getTriggerActions('trigger');
|
||||||
|
|
||||||
expect(list0).toHaveLength(0);
|
expect(list0).toHaveLength(0);
|
||||||
|
|
||||||
setup.addTriggerAction('trigger' as TriggerId, action1);
|
setup.addTriggerAction('trigger', action1);
|
||||||
const list1 = start.getTriggerActions('trigger' as TriggerId);
|
const list1 = start.getTriggerActions('trigger');
|
||||||
|
|
||||||
expect(list1).toHaveLength(1);
|
expect(list1).toHaveLength(1);
|
||||||
expect(list1[0]).toBeInstanceOf(ActionInternal);
|
expect(list1[0]).toBeInstanceOf(ActionInternal);
|
||||||
expect(list1[0].id).toBe(action1.id);
|
expect(list1[0].id).toBe(action1.id);
|
||||||
|
|
||||||
setup.addTriggerAction('trigger' as TriggerId, action2);
|
setup.addTriggerAction('trigger', action2);
|
||||||
const list2 = start.getTriggerActions('trigger' as TriggerId);
|
const list2 = start.getTriggerActions('trigger');
|
||||||
|
|
||||||
expect(list2).toHaveLength(2);
|
expect(list2).toHaveLength(2);
|
||||||
expect(!!list2.find(({ id }: any) => id === 'action1')).toBe(true);
|
expect(!!list2.find(({ id }: any) => id === 'action1')).toBe(true);
|
||||||
|
|
|
@ -21,23 +21,23 @@ import { uiActionsPluginMock } from '../mocks';
|
||||||
import { createHelloWorldAction } from '../tests/test_samples';
|
import { createHelloWorldAction } from '../tests/test_samples';
|
||||||
import { Action, createAction } from '../actions';
|
import { Action, createAction } from '../actions';
|
||||||
import { Trigger } from '../triggers';
|
import { Trigger } from '../triggers';
|
||||||
import { TriggerId, ActionType } from '../types';
|
|
||||||
|
|
||||||
let action: Action<{ name: string }, ActionType>;
|
let action: Action<{ name: string }>;
|
||||||
let uiActions: ReturnType<typeof uiActionsPluginMock.createPlugin>;
|
let uiActions: ReturnType<typeof uiActionsPluginMock.createPlugin>;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
uiActions = uiActionsPluginMock.createPlugin();
|
uiActions = uiActionsPluginMock.createPlugin();
|
||||||
action = createAction({
|
action = createAction({
|
||||||
type: 'test' as ActionType,
|
id: 'test',
|
||||||
|
type: 'test',
|
||||||
execute: () => Promise.resolve(),
|
execute: () => Promise.resolve(),
|
||||||
});
|
});
|
||||||
|
|
||||||
uiActions.setup.registerAction(action);
|
uiActions.setup.registerAction(action);
|
||||||
uiActions.setup.registerTrigger({
|
uiActions.setup.registerTrigger({
|
||||||
id: 'trigger' as TriggerId,
|
id: 'trigger',
|
||||||
title: 'trigger',
|
title: 'trigger',
|
||||||
});
|
});
|
||||||
uiActions.setup.addTriggerAction('trigger' as TriggerId, action);
|
uiActions.setup.addTriggerAction('trigger', action);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('can register action', async () => {
|
test('can register action', async () => {
|
||||||
|
@ -54,14 +54,14 @@ test('getTriggerCompatibleActions returns attached actions', async () => {
|
||||||
setup.registerAction(helloWorldAction);
|
setup.registerAction(helloWorldAction);
|
||||||
|
|
||||||
const testTrigger: Trigger = {
|
const testTrigger: Trigger = {
|
||||||
id: 'MY-TRIGGER' as TriggerId,
|
id: 'MY-TRIGGER',
|
||||||
title: 'My trigger',
|
title: 'My trigger',
|
||||||
};
|
};
|
||||||
setup.registerTrigger(testTrigger);
|
setup.registerTrigger(testTrigger);
|
||||||
setup.addTriggerAction('MY-TRIGGER' as TriggerId, helloWorldAction);
|
setup.addTriggerAction('MY-TRIGGER', helloWorldAction);
|
||||||
|
|
||||||
const start = doStart();
|
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.length).toBe(1);
|
||||||
expect(actions[0].id).toBe(helloWorldAction.id);
|
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 () => {
|
test('filters out actions not applicable based on the context', async () => {
|
||||||
const { setup, doStart } = uiActions;
|
const { setup, doStart } = uiActions;
|
||||||
const action1 = createAction({
|
const action1 = createAction({
|
||||||
type: 'test1' as ActionType,
|
id: 'test1',
|
||||||
|
type: 'test1',
|
||||||
isCompatible: async (context: { accept: boolean }) => {
|
isCompatible: async (context: { accept: boolean }) => {
|
||||||
return Promise.resolve(context.accept);
|
return Promise.resolve(context.accept);
|
||||||
},
|
},
|
||||||
|
@ -78,7 +79,7 @@ test('filters out actions not applicable based on the context', async () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const testTrigger: Trigger = {
|
const testTrigger: Trigger = {
|
||||||
id: 'MY-TRIGGER2' as TriggerId,
|
id: 'MY-TRIGGER2',
|
||||||
title: 'My trigger',
|
title: 'My trigger',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -100,15 +101,15 @@ test(`throws an error with an invalid trigger ID`, async () => {
|
||||||
const { doStart } = uiActions;
|
const { doStart } = uiActions;
|
||||||
const start = doStart();
|
const start = doStart();
|
||||||
|
|
||||||
await expect(
|
await expect(start.getTriggerCompatibleActions('I do not exist', {})).rejects.toMatchObject(
|
||||||
start.getTriggerCompatibleActions('I do not exist' as TriggerId, {})
|
new Error('Trigger [triggerId = I do not exist] does 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 () => {
|
test(`with a trigger mapping that maps to an non-existing action returns empty list`, async () => {
|
||||||
const { setup, doStart } = uiActions;
|
const { setup, doStart } = uiActions;
|
||||||
const testTrigger: Trigger = {
|
const testTrigger: Trigger = {
|
||||||
id: '123' as TriggerId,
|
id: '123',
|
||||||
title: '123',
|
title: '123',
|
||||||
};
|
};
|
||||||
setup.registerTrigger(testTrigger);
|
setup.registerTrigger(testTrigger);
|
||||||
|
|
|
@ -20,9 +20,8 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { EuiFlexGroup, EuiFlexItem, EuiBadge, EuiFlyoutBody } from '@elastic/eui';
|
import { EuiFlexGroup, EuiFlexItem, EuiBadge, EuiFlyoutBody } from '@elastic/eui';
|
||||||
import { CoreStart } from 'src/core/public';
|
import { CoreStart } from 'src/core/public';
|
||||||
import { createAction, ActionByType } from '../../actions';
|
import { createAction, Action } from '../../actions';
|
||||||
import { toMountPoint, reactToUiComponent } from '../../../../kibana_react/public';
|
import { toMountPoint, reactToUiComponent } from '../../../../kibana_react/public';
|
||||||
import { ActionType } from '../../types';
|
|
||||||
|
|
||||||
const ReactMenuItem: React.FC = () => {
|
const ReactMenuItem: React.FC = () => {
|
||||||
return (
|
return (
|
||||||
|
@ -37,14 +36,11 @@ const ReactMenuItem: React.FC = () => {
|
||||||
|
|
||||||
const UiMenuItem = reactToUiComponent(ReactMenuItem);
|
const UiMenuItem = reactToUiComponent(ReactMenuItem);
|
||||||
|
|
||||||
// Casting to ActionType is a hack - in a real situation use
|
export const ACTION_HELLO_WORLD = 'ACTION_HELLO_WORLD';
|
||||||
// declare module and add this id to ActionContextMapping.
|
|
||||||
export const ACTION_HELLO_WORLD = 'ACTION_HELLO_WORLD' as ActionType;
|
|
||||||
|
|
||||||
export function createHelloWorldAction(
|
export function createHelloWorldAction(overlays: CoreStart['overlays']): Action {
|
||||||
overlays: CoreStart['overlays']
|
return createAction({
|
||||||
): ActionByType<typeof ACTION_HELLO_WORLD> {
|
id: ACTION_HELLO_WORLD,
|
||||||
return createAction<typeof ACTION_HELLO_WORLD>({
|
|
||||||
type: ACTION_HELLO_WORLD,
|
type: ACTION_HELLO_WORLD,
|
||||||
getIconType: () => 'lock',
|
getIconType: () => 'lock',
|
||||||
MenuItem: UiMenuItem,
|
MenuItem: UiMenuItem,
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
import { Trigger } from '.';
|
import { Trigger } from '.';
|
||||||
|
|
||||||
export const DEFAULT_TRIGGER = '';
|
export const DEFAULT_TRIGGER = '';
|
||||||
export const defaultTrigger: Trigger<''> = {
|
export const defaultTrigger: Trigger = {
|
||||||
id: DEFAULT_TRIGGER,
|
id: DEFAULT_TRIGGER,
|
||||||
title: 'Unknown',
|
title: 'Unknown',
|
||||||
description: 'Unknown trigger.',
|
description: 'Unknown trigger.',
|
||||||
|
|
|
@ -23,7 +23,7 @@ import { Datatable } from '../../../expressions';
|
||||||
|
|
||||||
export const ROW_CLICK_TRIGGER = 'ROW_CLICK_TRIGGER';
|
export const ROW_CLICK_TRIGGER = 'ROW_CLICK_TRIGGER';
|
||||||
|
|
||||||
export const rowClickTrigger: Trigger<'ROW_CLICK_TRIGGER'> = {
|
export const rowClickTrigger: Trigger = {
|
||||||
id: ROW_CLICK_TRIGGER,
|
id: ROW_CLICK_TRIGGER,
|
||||||
title: i18n.translate('uiActions.triggers.rowClickTitle', {
|
title: i18n.translate('uiActions.triggers.rowClickTitle', {
|
||||||
defaultMessage: 'Table row click',
|
defaultMessage: 'Table row click',
|
||||||
|
|
|
@ -17,8 +17,6 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { TriggerContextMapping, TriggerId } from '../types';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a convenience interface used to register a *trigger*.
|
* 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
|
* trigger is *called* it first displays a context menu for user to pick a
|
||||||
* single action to execute.
|
* single action to execute.
|
||||||
*/
|
*/
|
||||||
export interface Trigger<ID extends TriggerId = TriggerId> {
|
export interface Trigger {
|
||||||
/**
|
/**
|
||||||
* Unique name of the trigger as identified in `ui_actions` plugin trigger registry.
|
* Unique name of the trigger as identified in `ui_actions` plugin trigger registry.
|
||||||
*/
|
*/
|
||||||
id: ID;
|
id: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User friendly name of the trigger.
|
* User friendly name of the trigger.
|
||||||
|
@ -46,5 +44,3 @@ export interface Trigger<ID extends TriggerId = TriggerId> {
|
||||||
*/
|
*/
|
||||||
description?: string;
|
description?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type TriggerContext<T> = T extends TriggerId ? TriggerContextMapping[T] : never;
|
|
||||||
|
|
|
@ -18,16 +18,15 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { TriggerInternal } from './trigger_internal';
|
import { TriggerInternal } from './trigger_internal';
|
||||||
import { TriggerId, TriggerContextMapping } from '../types';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a public representation of a trigger that is provided to other plugins.
|
* This is a public representation of a trigger that is provided to other plugins.
|
||||||
*/
|
*/
|
||||||
export class TriggerContract<T extends TriggerId> {
|
export class TriggerContract<Context extends object = object> {
|
||||||
/**
|
/**
|
||||||
* Unique name of the trigger as identified in `ui_actions` plugin trigger registry.
|
* 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.
|
* User friendly name of the trigger.
|
||||||
|
@ -39,7 +38,7 @@ export class TriggerContract<T extends TriggerId> {
|
||||||
*/
|
*/
|
||||||
public readonly description?: string;
|
public readonly description?: string;
|
||||||
|
|
||||||
constructor(private readonly internal: TriggerInternal<T>) {
|
constructor(private readonly internal: TriggerInternal<Context>) {
|
||||||
this.id = this.internal.trigger.id;
|
this.id = this.internal.trigger.id;
|
||||||
this.title = this.internal.trigger.title;
|
this.title = this.internal.trigger.title;
|
||||||
this.description = this.internal.trigger.description;
|
this.description = this.internal.trigger.description;
|
||||||
|
@ -48,7 +47,7 @@ export class TriggerContract<T extends TriggerId> {
|
||||||
/**
|
/**
|
||||||
* Use this method to execute action attached to this trigger.
|
* 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);
|
await this.internal.execute(context, alwaysShowPopup);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,18 +20,17 @@
|
||||||
import { Trigger } from './trigger';
|
import { Trigger } from './trigger';
|
||||||
import { TriggerContract } from './trigger_contract';
|
import { TriggerContract } from './trigger_contract';
|
||||||
import { UiActionsService } from '../service';
|
import { UiActionsService } from '../service';
|
||||||
import { TriggerId, TriggerContextMapping } from '../types';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal representation of a trigger kept for consumption only internally
|
* Internal representation of a trigger kept for consumption only internally
|
||||||
* within `ui_actions` plugin.
|
* within `ui_actions` plugin.
|
||||||
*/
|
*/
|
||||||
export class TriggerInternal<T extends TriggerId> {
|
export class TriggerInternal<Context extends object = object> {
|
||||||
public readonly contract = new TriggerContract<T>(this);
|
public readonly contract: TriggerContract<Context> = new TriggerContract<Context>(this);
|
||||||
|
|
||||||
constructor(public readonly service: UiActionsService, public readonly trigger: Trigger<T>) {}
|
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 triggerId = this.trigger.id;
|
||||||
const actions = await this.service.getTriggerCompatibleActions!(triggerId, context);
|
const actions = await this.service.getTriggerCompatibleActions!(triggerId, context);
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue