mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Adding reload to datasourceSrv (#44217)
This commit is contained in:
@@ -8,8 +8,6 @@ import { importDataSourcePlugin } from 'app/features/plugins/plugin_loader';
|
||||
import { getPluginSettings } from 'app/features/plugins/pluginSettings';
|
||||
import { DataSourcePluginCategory, ThunkDispatch, ThunkResult } from 'app/types';
|
||||
|
||||
import config from '../../../core/config';
|
||||
|
||||
import { buildCategories } from './buildCategories';
|
||||
import { buildNavModel } from './navModel';
|
||||
import {
|
||||
@@ -218,7 +216,7 @@ export function addDataSource(plugin: DataSourcePluginMeta): ThunkResult<void> {
|
||||
}
|
||||
|
||||
const result = await getBackendSrv().post('/api/datasources', newInstance);
|
||||
await updateFrontendSettings();
|
||||
await getDatasourceSrv().reload();
|
||||
locationService.push(`/datasources/edit/${result.datasource.uid}`);
|
||||
};
|
||||
}
|
||||
@@ -235,7 +233,7 @@ export function loadDataSourcePlugins(): ThunkResult<void> {
|
||||
export function updateDataSource(dataSource: DataSourceSettings): ThunkResult<void> {
|
||||
return async (dispatch) => {
|
||||
await getBackendSrv().put(`/api/datasources/${dataSource.id}`, dataSource); // by UID not yet supported
|
||||
await updateFrontendSettings();
|
||||
await getDatasourceSrv().reload();
|
||||
return dispatch(loadDataSource(dataSource.uid));
|
||||
};
|
||||
}
|
||||
@@ -245,7 +243,7 @@ export function deleteDataSource(): ThunkResult<void> {
|
||||
const dataSource = getStore().dataSources.dataSource;
|
||||
|
||||
await getBackendSrv().delete(`/api/datasources/${dataSource.id}`);
|
||||
await updateFrontendSettings();
|
||||
await getDatasourceSrv().reload();
|
||||
|
||||
locationService.push('/datasources');
|
||||
};
|
||||
@@ -283,16 +281,6 @@ export function findNewName(dataSources: ItemWithName[], name: string) {
|
||||
return name;
|
||||
}
|
||||
|
||||
function updateFrontendSettings() {
|
||||
return getBackendSrv()
|
||||
.get('/api/frontend/settings')
|
||||
.then((settings: any) => {
|
||||
config.datasources = settings.datasources;
|
||||
config.defaultDatasource = settings.defaultDatasource;
|
||||
getDatasourceSrv().init(config.datasources, settings.defaultDatasource);
|
||||
});
|
||||
}
|
||||
|
||||
function nameHasSuffix(name: string) {
|
||||
return name.endsWith('-', name.length - 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user