QueryEditor: handle query.hide changes in angular based query-editors (#31336) (#31385)

* handle query.hide changes in angular query-editors

* better comment

(cherry picked from commit 7ccba047c6)

Co-authored-by: Gábor Farkas <gabor.farkas@gmail.com>
This commit is contained in:
Grot (@grafanabot)
2021-02-22 16:48:35 +01:00
committed by GitHub
co-authored by Gábor Farkas
parent 59b730c372
commit d0f940c268
@@ -80,6 +80,8 @@ export class QueryEditorRow extends PureComponent<Props, State> {
const panel = new PanelModel({ targets: queries });
const dashboard = {} as DashboardModel;
const me = this;
return {
datasource: datasource,
target: query,
@@ -89,6 +91,14 @@ export class QueryEditorRow extends PureComponent<Props, State> {
// Old angular editors modify the query model and just call refresh
// Important that this use this.props here so that as this fuction is only created on mount and it's
// important not to capture old prop functions in this closure
// the "hide" attribute of the quries can be changed from the "outside",
// it will be applied to "this.props.query.hide", but not to "query.hide".
// so we have to apply it.
if (query.hide !== me.props.query.hide) {
query.hide = me.props.query.hide;
}
this.props.onChange(query);
this.props.onRunQuery();
},