mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
PanelEditor: Fixes issue changing panel type from graph to stat and thresholds not taking affect after going back to dashboard (#24144)
* PanelEditor: Fixes issue with panel type change and query result reuse * removed unused imports * removed unused imports
This commit is contained in:
parent
4f81125af0
commit
a00636b2ec
@ -88,6 +88,7 @@ describe('panelEditor actions', () => {
|
||||
|
||||
expect(dispatchedActions.length).toBe(3);
|
||||
expect(dispatchedActions[0].type).toBe(panelModelAndPluginReady.type);
|
||||
expect(sourcePanel.plugin).toEqual(panel.plugin);
|
||||
});
|
||||
|
||||
it('should discard changes when shouldDiscardChanges is true', async () => {
|
||||
|
@ -47,6 +47,10 @@ export function panelEditorCleanUp(): ThunkResult<void> {
|
||||
|
||||
sourcePanel.restoreModel(modifiedSaveModel);
|
||||
|
||||
// Loaded plugin is not included in the persisted properties
|
||||
// So is not handled by restoreModel
|
||||
sourcePanel.plugin = panel.plugin;
|
||||
|
||||
if (panelTypeChanged) {
|
||||
dispatch(panelModelAndPluginReady({ panelId: sourcePanel.id, plugin: panel.plugin! }));
|
||||
}
|
||||
|
@ -73,6 +73,7 @@ export class PanelChrome extends PureComponent<Props, State> {
|
||||
|
||||
panel.events.on(PanelEvents.refresh, this.onRefresh);
|
||||
panel.events.on(PanelEvents.render, this.onRender);
|
||||
|
||||
dashboard.panelInitialized(this.props.panel);
|
||||
|
||||
// Move snapshot data into the query response
|
||||
@ -99,6 +100,15 @@ export class PanelChrome extends PureComponent<Props, State> {
|
||||
this.setState({ isFirstLoad: false });
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.querySubscription) {
|
||||
this.querySubscription = panel
|
||||
.getQueryRunner()
|
||||
.getData()
|
||||
.subscribe({
|
||||
next: data => this.onDataUpdate(data),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
@ -184,15 +194,7 @@ export class PanelChrome extends PureComponent<Props, State> {
|
||||
return;
|
||||
}
|
||||
|
||||
const queryRunner = panel.getQueryRunner();
|
||||
|
||||
if (!this.querySubscription) {
|
||||
this.querySubscription = queryRunner.getData().subscribe({
|
||||
next: data => this.onDataUpdate(data),
|
||||
});
|
||||
}
|
||||
|
||||
queryRunner.run({
|
||||
panel.getQueryRunner().run({
|
||||
datasource: panel.datasource,
|
||||
queries: panel.targets,
|
||||
panelId: panel.id,
|
||||
|
@ -314,18 +314,10 @@ export class DashboardModel {
|
||||
panelInitialized(panel: PanelModel) {
|
||||
panel.initialized();
|
||||
|
||||
if (this.panelInEdit === panel) {
|
||||
if (this.panelInEdit.getQueryRunner().getLastResult()) {
|
||||
return;
|
||||
} else {
|
||||
// refresh if panel is in edit mode and there is no last result
|
||||
panel.refresh();
|
||||
}
|
||||
} else {
|
||||
// refresh new panels unless we are in fullscreen / edit mode
|
||||
if (!this.otherPanelInFullscreen(panel)) {
|
||||
panel.refresh();
|
||||
}
|
||||
const lastResult = panel.getQueryRunner().getLastResult();
|
||||
|
||||
if (!this.otherPanelInFullscreen(panel) && !lastResult) {
|
||||
panel.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user