|
@@ -1,5 +1,5 @@
|
|
|
import { ThunkAction } from 'redux-thunk';
|
|
import { ThunkAction } from 'redux-thunk';
|
|
|
-import { DataSource, DataSourcePermissionDTO, Plugin, StoreState } from 'app/types';
|
|
|
|
|
|
|
+import { DataSource, Plugin, StoreState } from 'app/types';
|
|
|
import { getBackendSrv } from '../../../core/services/backend_srv';
|
|
import { getBackendSrv } from '../../../core/services/backend_srv';
|
|
|
import { LayoutMode } from '../../../core/components/LayoutSelector/LayoutSelector';
|
|
import { LayoutMode } from '../../../core/components/LayoutSelector/LayoutSelector';
|
|
|
import { updateLocation, updateNavIndex, UpdateNavIndexAction } from '../../../core/actions';
|
|
import { updateLocation, updateNavIndex, UpdateNavIndexAction } from '../../../core/actions';
|
|
@@ -11,7 +11,6 @@ export enum ActionTypes {
|
|
|
LoadDataSourceTypes = 'LOAD_DATA_SOURCE_TYPES',
|
|
LoadDataSourceTypes = 'LOAD_DATA_SOURCE_TYPES',
|
|
|
LoadDataSource = 'LOAD_DATA_SOURCE',
|
|
LoadDataSource = 'LOAD_DATA_SOURCE',
|
|
|
LoadDataSourceMeta = 'LOAD_DATA_SOURCE_META',
|
|
LoadDataSourceMeta = 'LOAD_DATA_SOURCE_META',
|
|
|
- LoadDataSourcePermissions = 'LOAD_DATA_SOURCE_PERMISSIONS',
|
|
|
|
|
SetDataSourcesSearchQuery = 'SET_DATA_SOURCES_SEARCH_QUERY',
|
|
SetDataSourcesSearchQuery = 'SET_DATA_SOURCES_SEARCH_QUERY',
|
|
|
SetDataSourcesLayoutMode = 'SET_DATA_SOURCES_LAYOUT_MODE',
|
|
SetDataSourcesLayoutMode = 'SET_DATA_SOURCES_LAYOUT_MODE',
|
|
|
SetDataSourceTypeSearchQuery = 'SET_DATA_SOURCE_TYPE_SEARCH_QUERY',
|
|
SetDataSourceTypeSearchQuery = 'SET_DATA_SOURCE_TYPE_SEARCH_QUERY',
|
|
@@ -52,11 +51,6 @@ export interface LoadDataSourceMetaAction {
|
|
|
payload: Plugin;
|
|
payload: Plugin;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-export interface LoadDataSourcePermissionsAction {
|
|
|
|
|
- type: ActionTypes.LoadDataSourcePermissions;
|
|
|
|
|
- payload: DataSourcePermissionDTO;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
const dataSourcesLoaded = (dataSources: DataSource[]): LoadDataSourcesAction => ({
|
|
const dataSourcesLoaded = (dataSources: DataSource[]): LoadDataSourcesAction => ({
|
|
|
type: ActionTypes.LoadDataSources,
|
|
type: ActionTypes.LoadDataSources,
|
|
|
payload: dataSources,
|
|
payload: dataSources,
|
|
@@ -77,13 +71,6 @@ const dataSourceTypesLoaded = (dataSourceTypes: Plugin[]): LoadDataSourceTypesAc
|
|
|
payload: dataSourceTypes,
|
|
payload: dataSourceTypes,
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
-const dataSourcePermissionsLoaded = (
|
|
|
|
|
- dataSourcePermission: DataSourcePermissionDTO
|
|
|
|
|
-): LoadDataSourcePermissionsAction => ({
|
|
|
|
|
- type: ActionTypes.LoadDataSourcePermissions,
|
|
|
|
|
- payload: dataSourcePermission,
|
|
|
|
|
-});
|
|
|
|
|
-
|
|
|
|
|
export const setDataSourcesSearchQuery = (searchQuery: string): SetDataSourcesSearchQueryAction => ({
|
|
export const setDataSourcesSearchQuery = (searchQuery: string): SetDataSourcesSearchQueryAction => ({
|
|
|
type: ActionTypes.SetDataSourcesSearchQuery,
|
|
type: ActionTypes.SetDataSourcesSearchQuery,
|
|
|
payload: searchQuery,
|
|
payload: searchQuery,
|
|
@@ -108,8 +95,7 @@ export type Action =
|
|
|
| SetDataSourceTypeSearchQueryAction
|
|
| SetDataSourceTypeSearchQueryAction
|
|
|
| LoadDataSourceAction
|
|
| LoadDataSourceAction
|
|
|
| UpdateNavIndexAction
|
|
| UpdateNavIndexAction
|
|
|
- | LoadDataSourceMetaAction
|
|
|
|
|
- | LoadDataSourcePermissionsAction;
|
|
|
|
|
|
|
+ | LoadDataSourceMetaAction;
|
|
|
|
|
|
|
|
type ThunkResult<R> = ThunkAction<R, StoreState, undefined, Action>;
|
|
type ThunkResult<R> = ThunkAction<R, StoreState, undefined, Action>;
|
|
|
|
|
|
|
@@ -159,42 +145,6 @@ export function loadDataSourceTypes(): ThunkResult<void> {
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-export function loadDataSourcePermissions(id: number): ThunkResult<void> {
|
|
|
|
|
- return async dispatch => {
|
|
|
|
|
- const response = await getBackendSrv().get(`/api/datasources/${id}/permissions`);
|
|
|
|
|
- dispatch(dataSourcePermissionsLoaded(response));
|
|
|
|
|
- };
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-export function enableDataSourcePermissions(id: number): ThunkResult<void> {
|
|
|
|
|
- return async dispatch => {
|
|
|
|
|
- await getBackendSrv().post(`/api/datasources/${id}/enable-permissions`, {});
|
|
|
|
|
- dispatch(loadDataSourcePermissions(id));
|
|
|
|
|
- };
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-export function disableDataSourcePermissions(id: number): ThunkResult<void> {
|
|
|
|
|
- return async dispatch => {
|
|
|
|
|
- await getBackendSrv().post(`/api/datasources/${id}/disable-permissions`, {});
|
|
|
|
|
- dispatch(loadDataSourcePermissions(id));
|
|
|
|
|
- };
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-export function addDataSourcePermission(id: number, data: object): ThunkResult<void> {
|
|
|
|
|
- return async dispatch => {
|
|
|
|
|
- await getBackendSrv().post(`/api/datasources/${id}/permissions`, data);
|
|
|
|
|
-
|
|
|
|
|
- dispatch(loadDataSourcePermissions(id));
|
|
|
|
|
- };
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-export function removeDataSourcePermission(id: number, permissionId: number): ThunkResult<void> {
|
|
|
|
|
- return async dispatch => {
|
|
|
|
|
- await getBackendSrv().delete(`/api/datasources/${id}/permissions/${permissionId}`);
|
|
|
|
|
- dispatch(loadDataSourcePermissions(id));
|
|
|
|
|
- };
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
export function nameExits(dataSources, name) {
|
|
export function nameExits(dataSources, name) {
|
|
|
return (
|
|
return (
|
|
|
dataSources.filter(dataSource => {
|
|
dataSources.filter(dataSource => {
|