Test repo can now be used to list entries

This commit is contained in:
Mathias Biilmann Christensen
2016-02-25 20:40:35 -08:00
parent 67cdd92bfb
commit 978b7290c5
17 changed files with 363 additions and 41 deletions

View File

@ -1,15 +1,20 @@
import Immutable from 'immutable';
import { OrderedMap, fromJS } from 'immutable';
import { CONFIG_SUCCESS } from '../actions/config';
import { ENTRIES_REQUEST, ENTRIES_SUCCESS } from '../actions/entries';
export function collections(state = null, action) {
switch (action.type) {
case CONFIG_SUCCESS:
const collections = action.payload && action.payload.collections;
return Immutable.OrderedMap().withMutations((map) => {
return OrderedMap().withMutations((map) => {
(collections || []).forEach(function(collection) {
map.set(collection.name, Immutable.fromJS(collection));
map.set(collection.name, fromJS(collection));
});
});
case ENTRIES_REQUEST:
return state && state.setIn([action.payload.collection, 'isFetching'], true);
case ENTRIES_SUCCESS:
return state && state.setIn([action.payload.collection, 'entries'], fromJS(action.payload.entries));
default:
return state;
}