forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathi_embeddable.ts
178 lines (154 loc) · 5.11 KB
/
i_embeddable.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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { Observable } from 'rxjs';
import { Adapters } from '../types';
import { IContainer } from '../containers/i_container';
import { ViewMode } from '../types';
import { TriggerContextMapping } from '../../../../ui_actions/public';
export interface EmbeddableInput {
viewMode?: ViewMode;
title?: string;
/**
* Note this is not a saved object id. It is used to uniquely identify this
* Embeddable instance from others (e.g. inside a container). It's possible to
* have two Embeddables where everything else is the same but the id.
*/
id: string;
lastReloadRequestTime?: number;
hidePanelTitles?: boolean;
/**
* Reserved key for `ui_actions` events.
*/
events?: unknown;
/**
* List of action IDs that this embeddable should not render.
*/
disabledActions?: string[];
/**
* Whether this embeddable should not execute triggers.
*/
disableTriggers?: boolean;
[key: string]: unknown;
}
export interface EmbeddableOutput {
editUrl?: string;
editApp?: string;
editPath?: string;
defaultTitle?: string;
title?: string;
editable?: boolean;
savedObjectId?: string;
}
export interface IEmbeddable<
I extends EmbeddableInput = EmbeddableInput,
O extends EmbeddableOutput = EmbeddableOutput
> {
/**
* Is this embeddable an instance of a Container class, can it contain
* nested embeddables?
**/
readonly isContainer: boolean;
/**
* If this embeddable is nested inside a container, this will contain
* a reference to its parent.
**/
readonly parent?: IContainer;
/**
* The type of embeddable, this is what will be used to take a serialized
* embeddable and find the correct factory for which to create an instance of it.
**/
readonly type: string;
/**
* A unique identifier for this embeddable. Mainly only used by containers to map their
* Panel States to a child embeddable instance.
**/
readonly id: string;
/**
* A functional representation of the isContainer variable, but helpful for typescript to
* know the shape if this returns true
*/
getIsContainer(): this is IContainer;
/**
* Get the input used to instantiate this embeddable. The input is a serialized representation of
* this embeddable instance and can be used to clone or re-instantiate it. Input state:
*
* - Can be updated externally
* - Can change multiple times for a single embeddable instance.
*
* Examples: title, pie slice colors, custom search columns and sort order.
**/
getInput(): Readonly<I>;
/**
* Output state is:
*
* - State that should not change once the embeddable is instantiated, or
* - State that is derived from the input state, or
* - State that only the embeddable instance itself knows about, or the factory.
*
* Examples: editUrl, title taken from a saved object, if your input state was first name and
* last name, your output state could be greeting.
**/
getOutput(): Readonly<O>;
/**
* Updates input state with the given changes.
* @param changes
*/
updateInput(changes: Partial<I>): void;
/**
* Returns an observable which will be notified when input state changes.
*/
getInput$(): Readonly<Observable<I>>;
/**
* Returns an observable which will be notified when output state changes.
*/
getOutput$(): Readonly<Observable<O>>;
/**
* Returns the title of this embeddable.
*/
getTitle(): string | undefined;
/**
* Returns the top most parent embeddable, or itself if this embeddable
* is not within a parent.
*/
getRoot(): IEmbeddable | IContainer;
/**
* Renders the embeddable at the given node.
* @param domNode
*/
render(domNode: HTMLElement | Element): void;
/**
* Reload the embeddable so output and rendering is up to date. Especially relevant
* if the embeddable takes relative time as input (e.g. now to now-15)
*/
reload(): void;
/**
* An embeddable can return inspector adapters if it wants the inspector to be
* available via the context menu of that panel.
* @return Inspector adapters that will be used to open an inspector for.
*/
getInspectorAdapters(): Adapters | undefined;
/**
* Cleans up subscriptions, destroy nodes mounted from calls to render.
*/
destroy(): void;
/**
* List of triggers that this embeddable will execute.
*/
supportedTriggers(): Array<keyof TriggerContextMapping>;
}