diff --git a/public/app/features/dashboard/state/PanelModel.ts b/public/app/features/dashboard/state/PanelModel.ts index ed6abe527f9..f20eee3cc53 100644 --- a/public/app/features/dashboard/state/PanelModel.ts +++ b/public/app/features/dashboard/state/PanelModel.ts @@ -14,12 +14,10 @@ import { fieldColorModeRegistry, FieldConfigProperty, FieldConfigSource, - PanelEvents, PanelPlugin, ScopedVars, ThresholdsConfig, ThresholdsMode, - EventBusExtended, EventBusSrv, DataFrameDTO, urlUtil, @@ -154,7 +152,7 @@ export class PanelModel implements DataConfigSource { isInView: boolean; hasRefreshed: boolean; - events: EventBusExtended; + events: EventBusSrv; cacheTimeout?: any; cachedPluginOptions?: any; legend?: { show: boolean; sort?: string; sortDesc?: boolean }; @@ -479,7 +477,6 @@ export class PanelModel implements DataConfigSource { } destroy() { - this.events.emit(PanelEvents.panelTeardown); this.events.removeAllListeners(); if (this.queryRunner) { diff --git a/public/app/features/query/components/QueryEditorRow.tsx b/public/app/features/query/components/QueryEditorRow.tsx index 6e228dd2f01..261a785e6ba 100644 --- a/public/app/features/query/components/QueryEditorRow.tsx +++ b/public/app/features/query/components/QueryEditorRow.tsx @@ -17,6 +17,7 @@ import { toLegacyResponseData, EventBusExtended, DataSourceInstanceSettings, + EventBusSrv, } from '@grafana/data'; import { QueryEditorRowTitle } from './QueryEditorRowTitle'; import { @@ -88,7 +89,7 @@ export class QueryEditorRow extends PureComponent { onRunQuery(); }, render: () => () => console.log('legacy render function called, it does nothing'), - events: panel.events, + events: new EventBusSrv(), range: getTimeSrv().timeRange(), }; } @@ -128,7 +129,7 @@ export class QueryEditorRow extends PureComponent { } if (this.angularQueryEditor) { - notifyAngularQueryEditorsOfData(this.angularScope?.panel!, data, this.angularQueryEditor); + notifyAngularQueryEditorsOfData(this.angularScope!, data, this.angularQueryEditor); } } @@ -322,7 +323,7 @@ export class QueryEditorRow extends PureComponent { // So we can check if we already emitted this legacy data event let globalLastPanelDataCache: PanelData | null = null; -function notifyAngularQueryEditorsOfData(panel: PanelModel, data: PanelData, editor: AngularComponent) { +function notifyAngularQueryEditorsOfData(scope: AngularQueryComponentScope, data: PanelData, editor: AngularComponent) { if (data === globalLastPanelDataCache) { return; } @@ -331,9 +332,9 @@ function notifyAngularQueryEditorsOfData(panel: PanelModel, data: PanelData, edi if (data.state === LoadingState.Done) { const legacy = data.series.map(v => toLegacyResponseData(v)); - panel.events.emit(PanelEvents.dataReceived, legacy); + scope.events.emit(PanelEvents.dataReceived, legacy); } else if (data.state === LoadingState.Error) { - panel.events.emit(PanelEvents.dataError, data.error); + scope.events.emit(PanelEvents.dataError, data.error); } // Some query controllers listen to data error events and need a digest