mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
DataSourceSettings: Hide caching settings for non-backend datasources (#34083)
* add field to plugin meta * only show cache settings if pluginMeta has "isBackend" Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
This commit is contained in:
@@ -1,12 +1,16 @@
|
||||
import config from '../../../core/config';
|
||||
import { DataSourcePluginMeta, DataSourceSettings, locationUtil } from '@grafana/data';
|
||||
import { DataSourceWithBackend, getDataSourceSrv, locationService } from '@grafana/runtime';
|
||||
import { updateNavIndex } from 'app/core/actions';
|
||||
import { getBackendSrv } from 'app/core/services/backend_srv';
|
||||
import { getDatasourceSrv } from 'app/features/plugins/datasource_srv';
|
||||
import { updateNavIndex } from 'app/core/actions';
|
||||
import { buildNavModel } from './navModel';
|
||||
import { DataSourcePluginMeta, DataSourceSettings, locationUtil } from '@grafana/data';
|
||||
import { DataSourcePluginCategory, ThunkResult, ThunkDispatch } from 'app/types';
|
||||
import { getPluginSettings } from 'app/features/plugins/PluginSettingsCache';
|
||||
import { importDataSourcePlugin } from 'app/features/plugins/plugin_loader';
|
||||
import { getPluginSettings } from 'app/features/plugins/PluginSettingsCache';
|
||||
import { DataSourcePluginCategory, ThunkDispatch, ThunkResult } from 'app/types';
|
||||
|
||||
import config from '../../../core/config';
|
||||
|
||||
import { buildCategories } from './buildCategories';
|
||||
import { buildNavModel } from './navModel';
|
||||
import {
|
||||
dataSourceLoaded,
|
||||
dataSourceMetaLoaded,
|
||||
@@ -15,13 +19,11 @@ import {
|
||||
dataSourcesLoaded,
|
||||
initDataSourceSettingsFailed,
|
||||
initDataSourceSettingsSucceeded,
|
||||
testDataSourceFailed,
|
||||
testDataSourceStarting,
|
||||
testDataSourceSucceeded,
|
||||
testDataSourceFailed,
|
||||
} from './reducers';
|
||||
import { buildCategories } from './buildCategories';
|
||||
import { getDataSource, getDataSourceMeta } from './selectors';
|
||||
import { getDataSourceSrv, locationService } from '@grafana/runtime';
|
||||
|
||||
export interface DataSourceTypesLoadedPayload {
|
||||
plugins: DataSourcePluginMeta[];
|
||||
@@ -118,9 +120,15 @@ export function loadDataSource(uid: string): ThunkResult<void> {
|
||||
const dataSource = await getDataSourceUsingUidOrId(uid);
|
||||
const pluginInfo = (await getPluginSettings(dataSource.type)) as DataSourcePluginMeta;
|
||||
const plugin = await importDataSourcePlugin(pluginInfo);
|
||||
|
||||
const isBackend = plugin.DataSourceClass.prototype instanceof DataSourceWithBackend;
|
||||
const meta = {
|
||||
...pluginInfo,
|
||||
isBackend: isBackend,
|
||||
};
|
||||
dispatch(dataSourceLoaded(dataSource));
|
||||
dispatch(dataSourceMetaLoaded(pluginInfo));
|
||||
dispatch(dataSourceMetaLoaded(meta));
|
||||
|
||||
plugin.meta = meta;
|
||||
dispatch(updateNavIndex(buildNavModel(dataSource, plugin)));
|
||||
};
|
||||
}
|
||||
@@ -157,9 +165,11 @@ async function getDataSourceUsingUidOrId(uid: string): Promise<DataSourceSetting
|
||||
})
|
||||
.toPromise();
|
||||
|
||||
// Not ideal to do a full page reload here but so tricky to handle this otherwise
|
||||
// We can update the location using react router, but need to fully reload the route as the nav model
|
||||
// page index is not matching with the url in that case. And react router has no way to unmount remount a route
|
||||
// Not ideal to do a full page reload here but so tricky to handle this
|
||||
// otherwise We can update the location using react router, but need to
|
||||
// fully reload the route as the nav model page index is not matching with
|
||||
// the url in that case. And react router has no way to unmount remount a
|
||||
// route
|
||||
if (response.ok && response.data.id.toString() === uid) {
|
||||
window.location.href = locationUtil.assureBaseUrl(`/datasources/edit/${response.data.uid}`);
|
||||
return {} as DataSourceSettings; // avoids flashing an error
|
||||
|
||||
Reference in New Issue
Block a user