Skip to content

Commit

Permalink
Move alert registration to setup function.
Browse files Browse the repository at this point in the history
  • Loading branch information
justinkambic committed May 14, 2020
1 parent 6bb5519 commit e5a1eb3
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions x-pack/plugins/uptime/public/apps/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ export interface ClientPluginsStart {

export class UptimePlugin implements Plugin<void, void, ClientPluginsSetup, ClientPluginsStart> {
private _store: Store<any, any>;
private _data: DataPublicPluginSetup | undefined;
private _triggersActionsUI: TriggersAndActionsUIPublicPluginSetup | undefined;

constructor(_context: PluginInitializerContext) {
this._store = initializeStore();
Expand All @@ -41,9 +39,6 @@ export class UptimePlugin implements Plugin<void, void, ClientPluginsSetup, Clie
core: CoreSetup<ClientPluginsStart, unknown>,
plugins: ClientPluginsSetup
): Promise<void> {
this._data = plugins.data;
this._triggersActionsUI = plugins.triggers_actions_ui;

if (plugins.home) {
plugins.home.featureCatalogue.register({
id: PLUGIN.ID,
Expand All @@ -56,6 +51,19 @@ export class UptimePlugin implements Plugin<void, void, ClientPluginsSetup, Clie
});
}

alertTypeInitializers.forEach(init => {
const alertInitializer = init({
autocomplete: plugins.data.autocomplete,
store: this._store,
});
if (
plugins.triggers_actions_ui &&
!plugins.triggers_actions_ui.alertTypeRegistry.has(alertInitializer.id)
) {
plugins.triggers_actions_ui.alertTypeRegistry.register(alertInitializer);
}
});

const self = this;
core.application.register({
appRoute: '/app/uptime#/',
Expand Down Expand Up @@ -83,19 +91,6 @@ export class UptimePlugin implements Plugin<void, void, ClientPluginsSetup, Clie

public start(start: CoreStart, _plugins: {}): void {
kibanaService.core = start;

alertTypeInitializers.forEach(init => {
const alertInitializer = init({
autocomplete: this._data!.autocomplete,
store: this._store,
});
if (
this._triggersActionsUI &&
!this._triggersActionsUI.alertTypeRegistry.has(alertInitializer.id)
) {
this._triggersActionsUI.alertTypeRegistry.register(alertInitializer);
}
});
}

public stop(): void {}
Expand Down

0 comments on commit e5a1eb3

Please sign in to comment.