removing datasource permissions states from grafana
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { DataSource, DataSourcePermission } from 'app/types';
|
||||
import { DataSource } from 'app/types';
|
||||
|
||||
export const getMockDataSources = (amount: number): DataSource[] => {
|
||||
const dataSources = [];
|
||||
@@ -43,32 +43,3 @@ export const getMockDataSource = (): DataSource => {
|
||||
user: '',
|
||||
};
|
||||
};
|
||||
|
||||
export const getMockDataSourcePermissionsUser = (): DataSourcePermission => {
|
||||
return {
|
||||
created: '2018-10-10T16:50:45+02:00',
|
||||
datasourceId: 1,
|
||||
id: 2,
|
||||
permission: 1,
|
||||
permissionName: 'Query',
|
||||
updated: '2018-10-10T16:50:45+02:00',
|
||||
userAvatarUrl: '/avatar/926aa85c6bcefa0b4deca3223f337ae1',
|
||||
userEmail: 'test@test.com',
|
||||
userId: 3,
|
||||
userLogin: 'testUser',
|
||||
};
|
||||
};
|
||||
|
||||
export const getMockDataSourcePermissionsTeam = (): DataSourcePermission => {
|
||||
return {
|
||||
created: '2018-10-10T16:57:09+02:00',
|
||||
datasourceId: 1,
|
||||
id: 6,
|
||||
permission: 1,
|
||||
permissionName: 'Query',
|
||||
team: 'A-team',
|
||||
teamAvatarUrl: '/avatar/93c0801b955cbd443a8cfa91a401d7bc',
|
||||
teamId: 1,
|
||||
updated: '2018-10-10T16:57:09+02:00',
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
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 { LayoutMode } from '../../../core/components/LayoutSelector/LayoutSelector';
|
||||
import { updateLocation, updateNavIndex, UpdateNavIndexAction } from '../../../core/actions';
|
||||
@@ -11,7 +11,6 @@ export enum ActionTypes {
|
||||
LoadDataSourceTypes = 'LOAD_DATA_SOURCE_TYPES',
|
||||
LoadDataSource = 'LOAD_DATA_SOURCE',
|
||||
LoadDataSourceMeta = 'LOAD_DATA_SOURCE_META',
|
||||
LoadDataSourcePermissions = 'LOAD_DATA_SOURCE_PERMISSIONS',
|
||||
SetDataSourcesSearchQuery = 'SET_DATA_SOURCES_SEARCH_QUERY',
|
||||
SetDataSourcesLayoutMode = 'SET_DATA_SOURCES_LAYOUT_MODE',
|
||||
SetDataSourceTypeSearchQuery = 'SET_DATA_SOURCE_TYPE_SEARCH_QUERY',
|
||||
@@ -52,11 +51,6 @@ export interface LoadDataSourceMetaAction {
|
||||
payload: Plugin;
|
||||
}
|
||||
|
||||
export interface LoadDataSourcePermissionsAction {
|
||||
type: ActionTypes.LoadDataSourcePermissions;
|
||||
payload: DataSourcePermissionDTO;
|
||||
}
|
||||
|
||||
const dataSourcesLoaded = (dataSources: DataSource[]): LoadDataSourcesAction => ({
|
||||
type: ActionTypes.LoadDataSources,
|
||||
payload: dataSources,
|
||||
@@ -77,13 +71,6 @@ const dataSourceTypesLoaded = (dataSourceTypes: Plugin[]): LoadDataSourceTypesAc
|
||||
payload: dataSourceTypes,
|
||||
});
|
||||
|
||||
const dataSourcePermissionsLoaded = (
|
||||
dataSourcePermission: DataSourcePermissionDTO
|
||||
): LoadDataSourcePermissionsAction => ({
|
||||
type: ActionTypes.LoadDataSourcePermissions,
|
||||
payload: dataSourcePermission,
|
||||
});
|
||||
|
||||
export const setDataSourcesSearchQuery = (searchQuery: string): SetDataSourcesSearchQueryAction => ({
|
||||
type: ActionTypes.SetDataSourcesSearchQuery,
|
||||
payload: searchQuery,
|
||||
@@ -108,8 +95,7 @@ export type Action =
|
||||
| SetDataSourceTypeSearchQueryAction
|
||||
| LoadDataSourceAction
|
||||
| UpdateNavIndexAction
|
||||
| LoadDataSourceMetaAction
|
||||
| LoadDataSourcePermissionsAction;
|
||||
| LoadDataSourceMetaAction;
|
||||
|
||||
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) {
|
||||
return (
|
||||
dataSources.filter(dataSource => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { DataSource, DataSourcePermissionDTO, DataSourcesState, Plugin } from 'app/types';
|
||||
import { DataSource, DataSourcesState, Plugin } from 'app/types';
|
||||
import { Action, ActionTypes } from './actions';
|
||||
import { LayoutModes } from '../../../core/components/LayoutSelector/LayoutSelector';
|
||||
|
||||
@@ -11,7 +11,6 @@ const initialState: DataSourcesState = {
|
||||
dataSourceTypes: [] as Plugin[],
|
||||
dataSourceTypeSearchQuery: '',
|
||||
dataSourceMeta: {} as Plugin,
|
||||
dataSourcePermission: {} as DataSourcePermissionDTO,
|
||||
hasFetched: false,
|
||||
};
|
||||
|
||||
@@ -37,9 +36,6 @@ export const dataSourcesReducer = (state = initialState, action: Action): DataSo
|
||||
|
||||
case ActionTypes.LoadDataSourceMeta:
|
||||
return { ...state, dataSourceMeta: action.payload };
|
||||
|
||||
case ActionTypes.LoadDataSourcePermissions:
|
||||
return { ...state, dataSourcePermission: action.payload };
|
||||
}
|
||||
|
||||
return state;
|
||||
|
||||
@@ -11,7 +11,7 @@ import pluginReducers from 'app/features/plugins/state/reducers';
|
||||
import dataSourcesReducers from 'app/features/datasources/state/reducers';
|
||||
import usersReducers from 'app/features/users/state/reducers';
|
||||
|
||||
const rootReducer = combineReducers({
|
||||
const rootReducers = {
|
||||
...sharedReducers,
|
||||
...alertingReducers,
|
||||
...teamsReducers,
|
||||
@@ -21,13 +21,19 @@ const rootReducer = combineReducers({
|
||||
...pluginReducers,
|
||||
...dataSourcesReducers,
|
||||
...usersReducers,
|
||||
});
|
||||
};
|
||||
|
||||
export let store;
|
||||
|
||||
export function addRootReducer(reducers) {
|
||||
Object.assign(rootReducers, ...reducers);
|
||||
}
|
||||
|
||||
export function configureStore() {
|
||||
const composeEnhancers = (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
|
||||
|
||||
const rootReducer = combineReducers(rootReducers);
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
// DEV builds we had the logger middleware
|
||||
store = createStore(rootReducer, {}, composeEnhancers(applyMiddleware(thunk, createLogger())));
|
||||
|
||||
@@ -1,28 +1,6 @@
|
||||
import { LayoutMode } from '../core/components/LayoutSelector/LayoutSelector';
|
||||
import { Plugin } from './plugins';
|
||||
|
||||
export interface DataSourcePermission {
|
||||
id: number;
|
||||
datasourceId: number;
|
||||
permission: number;
|
||||
permissionName: string;
|
||||
created: string;
|
||||
updated: string;
|
||||
userId?: number;
|
||||
userLogin?: string;
|
||||
userEmail?: string;
|
||||
userAvatarUrl?: string;
|
||||
teamId?: number;
|
||||
teamAvatarUrl?: string;
|
||||
team?: string;
|
||||
}
|
||||
|
||||
export interface DataSourcePermissionDTO {
|
||||
datasourceId: number;
|
||||
enabled: boolean;
|
||||
permissions: DataSourcePermission[];
|
||||
}
|
||||
|
||||
export interface DataSource {
|
||||
id: number;
|
||||
orgId: number;
|
||||
@@ -49,6 +27,5 @@ export interface DataSourcesState {
|
||||
dataSourceTypes: Plugin[];
|
||||
dataSource: DataSource;
|
||||
dataSourceMeta: Plugin;
|
||||
dataSourcePermission: DataSourcePermissionDTO;
|
||||
hasFetched: boolean;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import { DashboardState } from './dashboard';
|
||||
import { DashboardAcl, OrgRole, PermissionLevel } from './acl';
|
||||
import { ApiKey, ApiKeysState, NewApiKey } from './apiKeys';
|
||||
import { Invitee, OrgUser, User, UsersState } from './user';
|
||||
import { DataSource, DataSourcePermissionDTO, DataSourcePermission, DataSourcesState } from './datasources';
|
||||
import { DataSource, DataSourcesState } from './datasources';
|
||||
import { PluginMeta, Plugin, PluginsState } from './plugins';
|
||||
|
||||
export {
|
||||
@@ -41,8 +41,6 @@ export {
|
||||
Plugin,
|
||||
PluginsState,
|
||||
DataSourcesState,
|
||||
DataSourcePermissionDTO,
|
||||
DataSourcePermission,
|
||||
Invitee,
|
||||
OrgUser,
|
||||
User,
|
||||
|
||||
Reference in New Issue
Block a user