initialize editorialWorkflow state after config loaded & parsed

This commit is contained in:
Cássio Zen
2016-09-13 04:29:30 -03:00
parent 165c758bb9
commit 911e3f7077
3 changed files with 12 additions and 19 deletions

View File

@ -1,14 +1,20 @@
import { Map, List, fromJS } from 'immutable';
import { EDITORIAL_WORKFLOW } from '../constants/publishModes';
import {
INIT, UNPUBLISHED_ENTRY_REQUEST, UNPUBLISHED_ENTRY_SUCCESS, UNPUBLISHED_ENTRIES_REQUEST, UNPUBLISHED_ENTRIES_SUCCESS
UNPUBLISHED_ENTRY_REQUEST, UNPUBLISHED_ENTRY_SUCCESS, UNPUBLISHED_ENTRIES_REQUEST, UNPUBLISHED_ENTRIES_SUCCESS
} from '../actions/editorialWorkflow';
import { CONFIG_SUCCESS } from '../actions/config';
const unpublishedEntries = (state = null, action) => {
switch (action.type) {
case INIT:
// Editorial workflow must be explicitly initiated.
return Map({ entities: Map(), pages: Map() });
case CONFIG_SUCCESS:
const publish_mode = action.payload && action.payload.publish_mode;
if (publish_mode === EDITORIAL_WORKFLOW) {
// Editorial workflow state is explicetelly initiated after the config.
return Map({ entities: Map(), pages: Map() });
} else {
return state;
}
case UNPUBLISHED_ENTRY_REQUEST:
return state.setIn(['entities', `${action.payload.status}.${action.payload.slug}`, 'isFetching'], true);