You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1006 B
46 lines
1006 B
import { handleActions } from 'redux-actions';
|
|
import * as types from 'Store/Actions/actionTypes';
|
|
import createSetReducer from './Creators/createSetReducer';
|
|
|
|
export const defaultState = {
|
|
currentPath: '',
|
|
isPopulated: false,
|
|
isFetching: false,
|
|
error: null,
|
|
directories: [],
|
|
files: [],
|
|
parent: null
|
|
};
|
|
|
|
const reducerSection = 'paths';
|
|
|
|
const pathReducers = handleActions({
|
|
|
|
[types.SET]: createSetReducer(reducerSection),
|
|
|
|
[types.UPDATE_PATHS]: (state, { payload }) => {
|
|
const newState = Object.assign({}, state);
|
|
|
|
newState.currentPath = payload.path;
|
|
newState.directories = payload.directories;
|
|
newState.files = payload.files;
|
|
newState.parent = payload.parent;
|
|
|
|
return newState;
|
|
},
|
|
|
|
[types.CLEAR_PATHS]: (state, { payload }) => {
|
|
const newState = Object.assign({}, state);
|
|
|
|
newState.path = '';
|
|
newState.directories = [];
|
|
newState.files = [];
|
|
newState.parent = '';
|
|
|
|
return newState;
|
|
}
|
|
|
|
}, defaultState);
|
|
|
|
export default pathReducers;
|