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; }