editorial workflow HoC

This commit is contained in:
Cássio Zen
2016-09-08 16:18:38 -03:00
parent 90d4b39fc1
commit 04c50d8def
6 changed files with 97 additions and 9 deletions

View File

@ -2,15 +2,14 @@ import React, { PropTypes } from 'react';
import ImmutablePropTypes from 'react-immutable-proptypes';
import { connect } from 'react-redux';
import { loadEntries } from '../actions/entries';
import { loadUnpublishedEntries } from '../actions/editorialWorkflow';
import { selectEntries } from '../reducers';
import { Loader } from '../components/UI';
import EntryListing from '../components/EntryListing';
import EditorialWorkflow from './EditorialWorkflowHoC';
class DashboardPage extends React.Component {
componentDidMount() {
const { collection, dispatch } = this.props;
dispatch(loadUnpublishedEntries());
if (collection) {
dispatch(loadEntries(collection));
}
@ -38,7 +37,6 @@ class DashboardPage extends React.Component {
</div>;
}
}
DashboardPage.propTypes = {
collection: ImmutablePropTypes.map.isRequired,
collections: ImmutablePropTypes.orderedMap.isRequired,
@ -46,6 +44,13 @@ DashboardPage.propTypes = {
entries: ImmutablePropTypes.list,
};
/*
* Instead of checking the publish mode everywhere to dispatch & render the additional editorial workflow stuff,
* We delegate it to a Higher Order Component
*/
DashboardPage = EditorialWorkflow(DashboardPage);
function mapStateToProps(state, ownProps) {
const { collections } = state;
const { name, slug } = ownProps.params;