From ee1556e4fabfe1f83e4af6efc6905c70744e7dcf Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Thu, 26 Jan 2023 12:16:20 +0000 Subject: [PATCH] [v9.3.x] QueryEditorRow: Fixes issue loading query editor when data source variable selected (#62180) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QueryEditorRow: Fixes issue loading query editor when data source variable selected (#61927) * QueryEditorRow: Fixes issue loading query editor when data source variable selected * Fix func name * Removed wait * restore waiting for with better check * restore waiting for with better check (cherry picked from commit 9f7ddf1f0b5234a1fd82e1f92d1444f81a794e45) Co-authored-by: Torkel Ödegaard --- .../app/features/query/components/QueryEditorRow.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/public/app/features/query/components/QueryEditorRow.tsx b/public/app/features/query/components/QueryEditorRow.tsx index ac028cac25d..ccf32ab5d08 100644 --- a/public/app/features/query/components/QueryEditorRow.tsx +++ b/public/app/features/query/components/QueryEditorRow.tsx @@ -63,8 +63,10 @@ interface Props { } interface State { + /** DatasourceUid or ds variable expression used to resolve current datasource */ loadedDataSourceIdentifier?: string | null; datasource: DataSourceApi | null; + datasourceUid?: string | null; hasTextEditMode: boolean; data?: PanelData; isOpen?: boolean; @@ -238,17 +240,17 @@ export class QueryEditorRow extends PureComponent { + isWaitingForDatasourceToLoad(): boolean { // if we not yet have loaded the datasource in state the // ds in props and the ds in state will have different values. - return this.props.dataSource.uid !== this.state.datasource?.uid; - }; + return this.props.dataSource.uid !== this.state.loadedDataSourceIdentifier; + } renderPluginEditor = () => { const { query, onChange, queries, onRunQuery, onAddQuery, app = CoreApp.PanelEditor, history } = this.props; const { datasource, data } = this.state; - if (this.waitingForDatasourceToLoad()) { + if (this.isWaitingForDatasourceToLoad()) { return null; }