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
|
* Contant Declarations
|
||||||
*/
|
*/
|
||||||
export const INIT = 'init';
|
|
||||||
|
|
||||||
export const UNPUBLISHED_ENTRY_REQUEST = 'UNPUBLISHED_ENTRY_REQUEST';
|
export const UNPUBLISHED_ENTRY_REQUEST = 'UNPUBLISHED_ENTRY_REQUEST';
|
||||||
export const UNPUBLISHED_ENTRY_SUCCESS = 'UNPUBLISHED_ENTRY_SUCCESS';
|
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
|
* Exported Thunk Action Creators
|
||||||
*/
|
*/
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import React, { PropTypes } from 'react';
|
import React, { PropTypes } from 'react';
|
||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
import { OrderedMap } from 'immutable';
|
import { OrderedMap } from 'immutable';
|
||||||
import { init, loadUnpublishedEntries } from '../../actions/editorialWorkflow';
|
import { loadUnpublishedEntries } from '../../actions/editorialWorkflow';
|
||||||
import { selectUnpublishedEntries } from '../../reducers';
|
import { selectUnpublishedEntries } from '../../reducers';
|
||||||
import { EDITORIAL_WORKFLOW, status } from '../../constants/publishModes';
|
import { EDITORIAL_WORKFLOW, status } from '../../constants/publishModes';
|
||||||
import UnpublishedListing from '../../components/UnpublishedListing';
|
import UnpublishedListing from '../../components/UnpublishedListing';
|
||||||
@ -13,7 +13,6 @@ export default function CollectionPageHOC(CollectionPage) {
|
|||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const { dispatch, isEditorialWorkflow } = this.props;
|
const { dispatch, isEditorialWorkflow } = this.props;
|
||||||
if (isEditorialWorkflow) {
|
if (isEditorialWorkflow) {
|
||||||
dispatch(init());
|
|
||||||
dispatch(loadUnpublishedEntries());
|
dispatch(loadUnpublishedEntries());
|
||||||
}
|
}
|
||||||
super.componentDidMount();
|
super.componentDidMount();
|
||||||
|
@ -1,14 +1,20 @@
|
|||||||
import { Map, List, fromJS } from 'immutable';
|
import { Map, List, fromJS } from 'immutable';
|
||||||
|
import { EDITORIAL_WORKFLOW } from '../constants/publishModes';
|
||||||
import {
|
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';
|
} from '../actions/editorialWorkflow';
|
||||||
|
import { CONFIG_SUCCESS } from '../actions/config';
|
||||||
|
|
||||||
const unpublishedEntries = (state = null, action) => {
|
const unpublishedEntries = (state = null, action) => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case INIT:
|
case CONFIG_SUCCESS:
|
||||||
// Editorial workflow must be explicitly initiated.
|
const publish_mode = action.payload && action.payload.publish_mode;
|
||||||
return Map({ entities: Map(), pages: Map() });
|
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:
|
case UNPUBLISHED_ENTRY_REQUEST:
|
||||||
return state.setIn(['entities', `${action.payload.status}.${action.payload.slug}`, 'isFetching'], true);
|
return state.setIn(['entities', `${action.payload.status}.${action.payload.slug}`, 'isFetching'], true);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user