mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Fix: Update badges on PanelEditor tabs when adding a query/transformation/alert (#27729)
* minor nits in paneleditor * add events for queries and transformations * fix spelling * add event to alertctrl * revert alert changes * re add force update * reduce events
This commit is contained in:
@@ -6,6 +6,7 @@ import { getNextRefIdChar } from 'app/core/utils/query';
|
||||
import templateSrv from 'app/features/templating/template_srv';
|
||||
// Types
|
||||
import {
|
||||
AppEvent,
|
||||
DataConfigSource,
|
||||
DataLink,
|
||||
DataQuery,
|
||||
@@ -23,6 +24,7 @@ import { EDIT_PANEL_ID } from 'app/core/constants';
|
||||
import config from 'app/core/config';
|
||||
import { PanelQueryRunner } from './PanelQueryRunner';
|
||||
import { getDatasourceSrv } from '../../plugins/datasource_srv';
|
||||
import { CoreEvents } from '../../../types';
|
||||
|
||||
export const panelAdded = eventFactory<PanelModel | undefined>('panel-added');
|
||||
export const panelRemoved = eventFactory<PanelModel | undefined>('panel-removed');
|
||||
@@ -382,6 +384,11 @@ export class PanelModel implements DataConfigSource {
|
||||
}
|
||||
}
|
||||
|
||||
updateQueries(queries: DataQuery[]) {
|
||||
this.events.emit(CoreEvents.queryChanged);
|
||||
this.targets = queries;
|
||||
}
|
||||
|
||||
addQuery(query?: Partial<DataQuery>) {
|
||||
query = query || { refId: 'A' };
|
||||
query.refId = getNextRefIdChar(this.targets);
|
||||
@@ -461,6 +468,7 @@ export class PanelModel implements DataConfigSource {
|
||||
}
|
||||
|
||||
setTransformations(transformations: DataTransformerConfig[]) {
|
||||
this.events.emit(CoreEvents.transformationChanged);
|
||||
this.transformations = transformations;
|
||||
this.resendLastResult();
|
||||
}
|
||||
@@ -488,6 +496,14 @@ export class PanelModel implements DataConfigSource {
|
||||
getSavedId(): number {
|
||||
return this.editSourceId ?? this.id;
|
||||
}
|
||||
|
||||
on<T>(event: AppEvent<T>, callback: (payload?: T) => void) {
|
||||
this.events.on(event, callback);
|
||||
}
|
||||
|
||||
off<T>(event: AppEvent<T>, callback: (payload?: T) => void) {
|
||||
this.events.off(event, callback);
|
||||
}
|
||||
}
|
||||
|
||||
function applyFieldConfigDefaults(fieldConfig: FieldConfigSource, defaults: FieldConfigSource): FieldConfigSource {
|
||||
|
||||
Reference in New Issue
Block a user