mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Explore: Fixed default data source loading (#37059)
Co-authored-by: Andrej Ocenas <mr.ocenas@gmail.com>
This commit is contained in:
parent
02f9564607
commit
64f898c5f6
@ -31,7 +31,7 @@ type Props = OwnProps & ConnectedProps<typeof connector>;
|
||||
|
||||
export class UnConnectedExploreToolbar extends PureComponent<Props> {
|
||||
onChangeDatasource = async (dsSettings: DataSourceInstanceSettings) => {
|
||||
this.props.changeDatasource(this.props.exploreId, dsSettings.name, { importQueries: true });
|
||||
this.props.changeDatasource(this.props.exploreId, dsSettings.uid, { importQueries: true });
|
||||
};
|
||||
|
||||
onClearAll = () => {
|
||||
|
@ -35,12 +35,12 @@ export const updateDatasourceInstanceAction = createAction<UpdateDatasourceInsta
|
||||
*/
|
||||
export function changeDatasource(
|
||||
exploreId: ExploreId,
|
||||
datasourceName: string,
|
||||
datasourceUid: string,
|
||||
options?: { importQueries: boolean }
|
||||
): ThunkResult<void> {
|
||||
return async (dispatch, getState) => {
|
||||
const orgId = getState().user.orgId;
|
||||
const { history, instance } = await loadAndInitDatasource(orgId, datasourceName);
|
||||
const { history, instance } = await loadAndInitDatasource(orgId, datasourceUid);
|
||||
const currentDataSourceInstance = getState().explore[exploreId]!.datasourceInstance;
|
||||
|
||||
dispatch(
|
||||
|
@ -60,11 +60,11 @@ export const createEmptyQueryResponse = (): PanelData => ({
|
||||
|
||||
export async function loadAndInitDatasource(
|
||||
orgId: number,
|
||||
datasourceName?: string
|
||||
datasourceUid?: string
|
||||
): Promise<{ history: HistoryItem[]; instance: DataSourceApi }> {
|
||||
let instance;
|
||||
try {
|
||||
instance = await getDatasourceSrv().get(datasourceName);
|
||||
instance = await getDatasourceSrv().get(datasourceUid);
|
||||
} catch (error) {
|
||||
// Falling back to the default data source in case the provided data source was not found.
|
||||
// It may happen if last used data source or the data source provided in the URL has been
|
||||
|
Loading…
Reference in New Issue
Block a user