feat setup: Setup Redux, Immutable.js and React

feat FileList: Implement File List + changedir action
This commit is contained in:
Mahdi Dibaiee
2015-08-31 11:19:22 +04:30
parent 86113d017d
commit ee6f5d6ffb
32 changed files with 8558 additions and 1755 deletions

10
src/js/reducers/all.js Normal file
View File

@ -0,0 +1,10 @@
import Immutable from 'immutable';
import cwd from './cwd';
import files from './files';
export default function(state = new Immutable.Map(), action) {
return new Immutable.Map({
cwd: cwd(state.get('cwd'), action),
files: files(state.get('files'), action)
});
}

16
src/js/reducers/cwd.js Normal file
View File

@ -0,0 +1,16 @@
import { CHANGE_DIRECTORY } from 'actions/types';
import listFiles from 'actions/list-files';
import { children } from 'api/files';
import store from 'store';
export default function(state = '/', action) {
switch (action.type) {
case CHANGE_DIRECTORY:
children(action.dir).then(files => {
store.dispatch(listFiles(files));
});
return action.dir;
default:
return state;
}
}

10
src/js/reducers/files.js Normal file
View File

@ -0,0 +1,10 @@
import { LIST_FILES } from 'actions/types';
export default function(state = [], action) {
switch (action.type) {
case LIST_FILES:
return action.files;
default:
return state;
}
}