From 1ee97457946c84c00c6d7ade5e9981081a6f573f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Thu, 17 Dec 2020 11:45:28 +0100 Subject: [PATCH] PanelEdit: Need new data after plugin change (#29874) * PanelEdit: Need new data after plugin change * Updated --- .../features/dashboard/dashgrid/PanelChrome.tsx | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/public/app/features/dashboard/dashgrid/PanelChrome.tsx b/public/app/features/dashboard/dashgrid/PanelChrome.tsx index 8c7d0453dce..a625e429ab8 100644 --- a/public/app/features/dashboard/dashgrid/PanelChrome.tsx +++ b/public/app/features/dashboard/dashgrid/PanelChrome.tsx @@ -1,5 +1,5 @@ // Libraries -import React, { PureComponent } from 'react'; +import React, { Component } from 'react'; import classNames from 'classnames'; import { Unsubscribable } from 'rxjs'; // Components @@ -51,7 +51,7 @@ export interface State { data: PanelData; } -export class PanelChrome extends PureComponent { +export class PanelChrome extends Component { readonly timeSrv: TimeSrv = getTimeSrv(); querySubscription?: Unsubscribable; @@ -124,6 +124,19 @@ export class PanelChrome extends PureComponent { } } + shouldComponentUpdate(prevProps: Props, prevState: State) { + const { plugin, panel } = this.props; + + // If plugin changed we need to process fieldOverrides again + // We do this by asking panel query runner to resend last result + if (prevProps.plugin !== plugin) { + panel.getQueryRunner().resendLastResult(); + return false; + } + + return true; + } + // Updates the response with information from the stream // The next is outside a react synthetic event so setState is not batched // So in this context we can only do a single call to setState