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
This commit is contained in:
Torkel Ödegaard 2023-01-26 11:07:17 +01:00 committed by GitHub
parent a3b396854a
commit 9f7ddf1f0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 6 deletions

View File

@ -19094,6 +19094,7 @@
}
},
"receiver": {
"description": "Receiver receiver",
"type": "object",
"required": [
"active",

View File

@ -6,9 +6,15 @@ import { Provider } from 'react-redux';
import { Route, Router } from 'react-router-dom';
import { getGrafanaContextMock } from 'test/mocks/getGrafanaContextMock';
import { DataSourceApi, DataSourceInstanceSettings, QueryEditorProps, ScopedVars, UrlQueryValue } from '@grafana/data';
import {
DataSourceApi,
DataSourceInstanceSettings,
DataSourceRef,
QueryEditorProps,
ScopedVars,
UrlQueryValue,
} from '@grafana/data';
import { locationSearchToObject, locationService, setDataSourceSrv, setEchoSrv, config } from '@grafana/runtime';
import { DataSourceRef } from '@grafana/schema';
import { GrafanaContext } from 'app/core/context/GrafanaContext';
import { GrafanaRoute } from 'app/core/navigation/GrafanaRoute';
import { Echo } from 'app/core/services/echo/Echo';

View File

@ -63,8 +63,10 @@ interface Props<TQuery extends DataQuery> {
}
interface State<TQuery extends DataQuery> {
/** DatasourceUid or ds variable expression used to resolve current datasource */
loadedDataSourceIdentifier?: string | null;
datasource: DataSourceApi<TQuery> | null;
datasourceUid?: string | null;
hasTextEditMode: boolean;
data?: PanelData;
isOpen?: boolean;
@ -238,17 +240,17 @@ export class QueryEditorRow<TQuery extends DataQuery> extends PureComponent<Prop
}
}
waitingForDatasourceToLoad = (): boolean => {
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;
}