mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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:
@@ -19094,6 +19094,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"receiver": {
|
"receiver": {
|
||||||
|
"description": "Receiver receiver",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
"active",
|
"active",
|
||||||
|
|||||||
@@ -6,9 +6,15 @@ import { Provider } from 'react-redux';
|
|||||||
import { Route, Router } from 'react-router-dom';
|
import { Route, Router } from 'react-router-dom';
|
||||||
import { getGrafanaContextMock } from 'test/mocks/getGrafanaContextMock';
|
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 { locationSearchToObject, locationService, setDataSourceSrv, setEchoSrv, config } from '@grafana/runtime';
|
||||||
import { DataSourceRef } from '@grafana/schema';
|
|
||||||
import { GrafanaContext } from 'app/core/context/GrafanaContext';
|
import { GrafanaContext } from 'app/core/context/GrafanaContext';
|
||||||
import { GrafanaRoute } from 'app/core/navigation/GrafanaRoute';
|
import { GrafanaRoute } from 'app/core/navigation/GrafanaRoute';
|
||||||
import { Echo } from 'app/core/services/echo/Echo';
|
import { Echo } from 'app/core/services/echo/Echo';
|
||||||
|
|||||||
@@ -63,8 +63,10 @@ interface Props<TQuery extends DataQuery> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface State<TQuery extends DataQuery> {
|
interface State<TQuery extends DataQuery> {
|
||||||
|
/** DatasourceUid or ds variable expression used to resolve current datasource */
|
||||||
loadedDataSourceIdentifier?: string | null;
|
loadedDataSourceIdentifier?: string | null;
|
||||||
datasource: DataSourceApi<TQuery> | null;
|
datasource: DataSourceApi<TQuery> | null;
|
||||||
|
datasourceUid?: string | null;
|
||||||
hasTextEditMode: boolean;
|
hasTextEditMode: boolean;
|
||||||
data?: PanelData;
|
data?: PanelData;
|
||||||
isOpen?: boolean;
|
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
|
// if we not yet have loaded the datasource in state the
|
||||||
// ds in props and the ds in state will have different values.
|
// 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 = () => {
|
renderPluginEditor = () => {
|
||||||
const { query, onChange, queries, onRunQuery, onAddQuery, app = CoreApp.PanelEditor, history } = this.props;
|
const { query, onChange, queries, onRunQuery, onAddQuery, app = CoreApp.PanelEditor, history } = this.props;
|
||||||
const { datasource, data } = this.state;
|
const { datasource, data } = this.state;
|
||||||
|
|
||||||
if (this.waitingForDatasourceToLoad()) {
|
if (this.isWaitingForDatasourceToLoad()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user