mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
Datasources: Add the props for the "add datasource" event (#62227)
chore: pass editLink to the add datasource user event
This commit is contained in:
parent
a54d18c1f5
commit
83ff974b86
@ -6,6 +6,7 @@ import { ThunkResult, ThunkDispatch } from 'app/types';
|
||||
|
||||
import { getMockDataSource } from '../__mocks__';
|
||||
import * as api from '../api';
|
||||
import { DATASOURCES_ROUTES } from '../constants';
|
||||
import { trackDataSourceCreated, trackDataSourceTested } from '../tracking';
|
||||
import { GenericDataSourcePlugin } from '../types';
|
||||
|
||||
@ -357,6 +358,7 @@ describe('addDataSource', () => {
|
||||
plugin_version: '1.2.3',
|
||||
datasource_uid: 'azure23',
|
||||
grafana_version: '1.0',
|
||||
editLink: DATASOURCES_ROUTES.Edit.replace(':uid', 'azure23'),
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -189,7 +189,7 @@ export function loadDataSourceMeta(dataSource: DataSourceSettings): ThunkResult<
|
||||
};
|
||||
}
|
||||
|
||||
export function addDataSource(plugin: DataSourcePluginMeta, editLink = DATASOURCES_ROUTES.Edit): ThunkResult<void> {
|
||||
export function addDataSource(plugin: DataSourcePluginMeta, editRoute = DATASOURCES_ROUTES.Edit): ThunkResult<void> {
|
||||
return async (dispatch, getStore) => {
|
||||
await dispatch(loadDataSources());
|
||||
|
||||
@ -207,6 +207,7 @@ export function addDataSource(plugin: DataSourcePluginMeta, editLink = DATASOURC
|
||||
}
|
||||
|
||||
const result = await api.createDataSource(newInstance);
|
||||
const editLink = editRoute.replace(/:uid/gi, result.datasource.uid);
|
||||
|
||||
await getDatasourceSrv().reload();
|
||||
await contextSrv.fetchUserPermissions();
|
||||
@ -216,9 +217,10 @@ export function addDataSource(plugin: DataSourcePluginMeta, editLink = DATASOURC
|
||||
plugin_id: plugin.id,
|
||||
datasource_uid: result.datasource.uid,
|
||||
plugin_version: result.meta?.info?.version,
|
||||
editLink,
|
||||
});
|
||||
|
||||
locationService.push(editLink.replace(/:uid/gi, result.datasource.uid));
|
||||
locationService.push(editLink);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,8 @@ type DataSourceCreatedProps = {
|
||||
plugin_id: string;
|
||||
/** The plugin version (especially interesting in external plugins - core plugins are aligned with grafana version) */
|
||||
plugin_version?: string;
|
||||
/** The URL that points to the edit page for the datasoruce. We are using this to be able to distinguish between the performance of different datasource edit locations. */
|
||||
editLink?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user