diff --git a/public/app/features/dashboard/panel_editor/QueriesTab.tsx b/public/app/features/dashboard/panel_editor/QueriesTab.tsx index ca06098debd..28d822e3ad5 100644 --- a/public/app/features/dashboard/panel_editor/QueriesTab.tsx +++ b/public/app/features/dashboard/panel_editor/QueriesTab.tsx @@ -197,7 +197,7 @@ export class QueriesTab extends PureComponent {
{panel.targets.map((query, index) => ( void; onRemoveQuery: (query: DataQuery) => void; onMoveQuery: (query: DataQuery, direction: number) => void; - datasourceName: string | null; + dataSourceValue: string | null; inMixedMode: boolean; } interface State { + loadedDataSourceValue: string | null | undefined; datasource: DataSourceApi | null; isCollapsed: boolean; angularScope: AngularQueryComponentScope | null; @@ -36,6 +37,7 @@ export class QueryEditorRow extends PureComponent { datasource: null, isCollapsed: false, angularScope: null, + loadedDataSourceValue: undefined, }; componentDidMount() { @@ -61,14 +63,14 @@ export class QueryEditorRow extends PureComponent { const dataSourceSrv = getDatasourceSrv(); const datasource = await dataSourceSrv.get(query.datasource || panel.datasource); - this.setState({ datasource }); + this.setState({ datasource, loadedDataSourceValue: this.props.dataSourceValue }); } componentDidUpdate() { - const { datasource } = this.state; + const { loadedDataSourceValue } = this.state; // check if we need to load another datasource - if (datasource && datasource.name !== this.props.datasourceName) { + if (loadedDataSourceValue !== this.props.dataSourceValue) { if (this.angularQueryEditor) { this.angularQueryEditor.destroy(); this.angularQueryEditor = null; @@ -178,7 +180,7 @@ export class QueryEditorRow extends PureComponent { } render() { - const { query, datasourceName, inMixedMode } = this.props; + const { query, inMixedMode } = this.props; const { datasource, isCollapsed } = this.state; const isDisabled = query.hide; @@ -202,7 +204,7 @@ export class QueryEditorRow extends PureComponent { {isCollapsed && } {!isCollapsed && } {query.refId} - {inMixedMode && ({datasourceName})} + {inMixedMode && ({datasource.name})} {isDisabled && Disabled}