forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
/
drilldown_definition.ts
162 lines (144 loc) · 5.35 KB
/
drilldown_definition.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import type { LicenseType } from '@kbn/licensing-plugin/public';
import type { ActionExecutionContext } from '@kbn/ui-actions-plugin/public';
import type { PersistableStateDefinition, UiComponent } from '@kbn/kibana-utils-plugin/common';
import type {
ActionFactoryDefinition,
BaseActionConfig,
BaseActionFactoryContext,
SerializedAction,
SerializedEvent,
} from '../dynamic_actions';
/**
* This is a convenience interface to register a drilldown. Drilldown has
* ability to collect configuration from user. Once drilldown is executed it
* receives the collected information together with the context of the
* user's interaction.
*
* `Config` is a serializable object containing the configuration that the
* drilldown is able to collect using UI.
*
* `ExecutionContext` is an object created in response to user's interaction
* and provided to the `execute` function of the drilldown. This object contains
* information about the action user performed.
*/
export interface DrilldownDefinition<
Config extends BaseActionConfig = BaseActionConfig,
ExecutionContext extends object = object,
FactoryContext extends BaseActionFactoryContext = BaseActionFactoryContext
> extends PersistableStateDefinition<SerializedEvent> {
/**
* Globally unique identifier for this drilldown.
*/
id: string;
/**
* Is this action factory not GA?
* Adds a beta badge on a list item representing this ActionFactory
*/
readonly isBeta?: boolean;
/**
* Minimal license level
* Empty means no restrictions
*/
minimalLicense?: LicenseType;
/**
* Required when `minimalLicense` is used.
* Is a user-facing string. Has to be unique. Doesn't need i18n.
* The feature's name will be displayed to Cloud end-users when they're billed based on their feature usage.
*/
licenseFeatureName?: string;
/**
* Determines the display order of the drilldowns in the flyout picker.
* Higher numbers are displayed first.
*/
order?: number;
/**
* Function that returns default config for this drilldown.
*/
createConfig: ActionFactoryDefinition<Config, ExecutionContext, FactoryContext>['createConfig'];
/**
* `UiComponent` that collects config for this drilldown. You can create
* a React component and transform it `UiComponent` using `uiToReactComponent`
* helper from `kibana_utils` plugin.
*
* ```tsx
* import React from 'react';
* import { uiToReactComponent } from 'src/plugins/kibana_utils';
* import { CollectConfigProps } from 'src/plugins/kibana_utils/public';
*
* type Props = CollectConfigProps<Config>;
*
* const ReactCollectConfig: React.FC<Props> = () => {
* return <div>Collecting config...'</div>;
* };
*
* export const CollectConfig = uiToReactComponent(ReactCollectConfig);
* ```
*/
CollectConfig: ActionFactoryDefinition<Config, ExecutionContext, FactoryContext>['CollectConfig'];
/**
* A validator function for the config object. Should always return a boolean.
*/
isConfigValid: ActionFactoryDefinition<Config, ExecutionContext, FactoryContext>['isConfigValid'];
/**
* Compatibility check during drilldown creation.
* Could be used to filter out a drilldown if it's not compatible with the current context.
*/
isConfigurable?(context: FactoryContext): boolean;
/**
* Name of EUI icon to display when showing this drilldown to user.
*/
euiIcon?: string;
/**
* Should return an internationalized name of the drilldown, which will be
* displayed to the user as the name of drilldown factory when configuring a drilldown.
*/
getDisplayName: () => string;
/**
* Name of the drilldown instance displayed to the user at the moment of
* drilldown execution. Should be internationalized.
*/
readonly actionMenuItem?: UiComponent<{
config: Omit<SerializedAction<Config>, 'factoryId'>;
context: ExecutionContext | ActionExecutionContext<ExecutionContext>;
}>;
/**
* isCompatible during execution
* Could be used to prevent drilldown from execution
*/
isCompatible?(
config: Config,
context: ExecutionContext | ActionExecutionContext<ExecutionContext>
): Promise<boolean>;
/**
* Implements the "navigation" action of the drilldown. This happens when
* user clicks something in the UI that executes a trigger to which this
* drilldown was attached.
*
* @param config Config object that user configured this drilldown with.
* @param context Object that represents context in which the underlying
* `UIAction` of this drilldown is being executed in.
*/
execute(
config: Config,
context: ExecutionContext | ActionExecutionContext<ExecutionContext>
): void;
/**
* A link where drilldown should navigate on middle click or Ctrl + click.
*/
getHref?(
config: Config,
context: ExecutionContext | ActionExecutionContext<ExecutionContext>
): Promise<string | undefined>;
/**
* List of triggers supported by this drilldown type
* This is used in trigger picker when configuring drilldown
*/
supportedTriggers(): string[];
}