Skip to content

Commit dd60726

Browse files
committed
feat: 🎸 add .dynamicActions manager to Embeddable
1 parent 5134cdb commit dd60726

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

‎src/legacy/core_plugins/visualizations/public/np_ready/public/embeddable/visualize_embeddable.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ export class VisualizeEmbeddable extends Embeddable<VisualizeInput, VisualizeOut
304304
timeFieldName: this.vis.indexPattern.timeFieldName,
305305
data: event.data,
306306
};
307+
307308
getUiActions()
308309
.getTrigger(triggerId)
309310
.exec(context);

‎src/plugins/embeddable/public/lib/embeddables/embeddable.tsx‎

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ import { IContainer } from '../containers';
2323
import { IEmbeddable, EmbeddableInput, EmbeddableOutput } from './i_embeddable';
2424
import { ViewMode } from '../types';
2525
import { EmbeddableActionStorage } from './embeddable_action_storage';
26-
import { UiActionsStart } from '../ui_actions';
26+
import {
27+
UiActionsStart,
28+
UiActionsDynamicActionManager,
29+
} from '../../../../../plugins/ui_actions/public';
2730

2831
function getPanelTitle(input: EmbeddableInput, output: EmbeddableOutput) {
2932
return input.hidePanelTitles ? '' : input.title === undefined ? output.defaultTitle : input.title;
@@ -55,9 +58,18 @@ export abstract class Embeddable<
5558
// TODO: Rename to destroyed.
5659
private destoyed: boolean = false;
5760

58-
private __actionStorage?: EmbeddableActionStorage;
59-
public get actionStorage(): EmbeddableActionStorage {
60-
return this.__actionStorage || (this.__actionStorage = new EmbeddableActionStorage(this));
61+
private __dynamicActions?: UiActionsDynamicActionManager;
62+
public get dynamicActions(): UiActionsDynamicActionManager | undefined {
63+
if (!this.params.uiActions) return undefined;
64+
if (!this.__dynamicActions) {
65+
this.__dynamicActions = new UiActionsDynamicActionManager({
66+
isCompatible: async () => true,
67+
storage: new EmbeddableActionStorage(this),
68+
uiActions: this.params.uiActions,
69+
});
70+
}
71+
72+
return this.__dynamicActions;
6173
}
6274

6375
constructor(
@@ -66,6 +78,7 @@ export abstract class Embeddable<
6678
parent?: IContainer,
6779
public readonly params: EmbeddableParams = {}
6880
) {
81+
window.emb = this;
6982
this.id = input.id;
7083
this.output = {
7184
title: getPanelTitle(input, output),
@@ -89,6 +102,10 @@ export abstract class Embeddable<
89102
this.onResetInput(newInput);
90103
});
91104
}
105+
106+
if (this.dynamicActions) {
107+
this.dynamicActions.start();
108+
}
92109
}
93110

94111
public getIsContainer(): this is IContainer {

‎src/plugins/embeddable/public/lib/embeddables/i_embeddable.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919

2020
import { Observable } from 'rxjs';
21+
import { UiActionsDynamicActionManager } from '../../../../../plugins/ui_actions/public';
2122
import { Adapters } from '../types';
2223
import { IContainer } from '../containers/i_container';
2324
import { ViewMode } from '../types';
@@ -82,6 +83,11 @@ export interface IEmbeddable<
8283
**/
8384
readonly id: string;
8485

86+
/**
87+
* Default implementation of dynamic action API for embeddables.
88+
*/
89+
dynamicActions?: UiActionsDynamicActionManager;
90+
8591
/**
8692
* A functional representation of the isContainer variable, but helpful for typescript to
8793
* know the shape if this returns true

0 commit comments

Comments
 (0)