initialize editorialWorkflow state after config loaded & parsed
This commit is contained in:
parent
165c758bb9
commit
911e3f7077
@ -3,8 +3,6 @@ import { EDITORIAL_WORKFLOW } from '../constants/publishModes';
|
||||
/*
|
||||
* Contant Declarations
|
||||
*/
|
||||
export const INIT = 'init';
|
||||
|
||||
export const UNPUBLISHED_ENTRY_REQUEST = 'UNPUBLISHED_ENTRY_REQUEST';
|
||||
export const UNPUBLISHED_ENTRY_SUCCESS = 'UNPUBLISHED_ENTRY_SUCCESS';
|
||||
|
||||
@ -55,16 +53,6 @@ function unpublishedEntriesFailed(error) {
|
||||
};
|
||||
}
|
||||
|
||||
/*
|
||||
* Exported simple Action Creators
|
||||
*/
|
||||
export function init() {
|
||||
return {
|
||||
type: INIT
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Exported Thunk Action Creators
|
||||
*/
|
||||
|
@ -1,7 +1,7 @@
|
||||
import React, { PropTypes } from 'react';
|
||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||
import { OrderedMap } from 'immutable';
|
||||
import { init, loadUnpublishedEntries } from '../../actions/editorialWorkflow';
|
||||
import { loadUnpublishedEntries } from '../../actions/editorialWorkflow';
|
||||
import { selectUnpublishedEntries } from '../../reducers';
|
||||
import { EDITORIAL_WORKFLOW, status } from '../../constants/publishModes';
|
||||
import UnpublishedListing from '../../components/UnpublishedListing';
|
||||
@ -13,7 +13,6 @@ export default function CollectionPageHOC(CollectionPage) {
|
||||
componentDidMount() {
|
||||
const { dispatch, isEditorialWorkflow } = this.props;
|
||||
if (isEditorialWorkflow) {
|
||||
dispatch(init());
|
||||
dispatch(loadUnpublishedEntries());
|
||||
}
|
||||
super.componentDidMount();
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user