reducers.ts 718 B

1234567891011121314151617181920212223242526
  1. import { DataSourcePermission, DataSourcePermissionState } from '../../types';
  2. import { Action, ActionTypes } from './actions';
  3. const initialState: DataSourcePermissionState = {
  4. permissions: [] as DataSourcePermission[],
  5. enabled: false,
  6. datasourceId: 0,
  7. };
  8. export const dataSourcePermissionReducers = (state = initialState, action: Action): DataSourcePermissionState => {
  9. switch (action.type) {
  10. case ActionTypes.LoadDataSourcePermissions:
  11. return {
  12. enabled: action.payload.enabled,
  13. permissions: action.payload.permissions,
  14. datasourceId: action.payload.datasourceId,
  15. };
  16. }
  17. return state;
  18. };
  19. export default {
  20. dataSourcePermission: dataSourcePermissionReducers,
  21. };