diff --git a/src/actions/editorialWorkflow.js b/src/actions/editorialWorkflow.js index 8daa68579c93..9446187a6e28 100644 --- a/src/actions/editorialWorkflow.js +++ b/src/actions/editorialWorkflow.js @@ -474,3 +474,21 @@ export function getUnpublishedEntryDependencies(collection, slug) { .catch(err => dispatch(unpublishedEntryDependenciesError(collection, slug, err))); }; } + +export function publishUnpublishedEntryAndDependencies(collection, slug) { + return (dispatch, getState) => dispatch(getUnpublishedEntryDependencies(collection, slug)) + .then(({ payload }) => { + if (payload.dependencies.size === 1) { + return dispatch(publishUnpublishedEntry(collection, slug)); + } + + const confirmationMessage = `\ +Thisntry has dependencies, and cannot be published on its own. Publish all the following posts? +${ payload.dependencies.join("\n") }`; + + if (window.confirm(confirmationMessage)) { + return dispatch(publishUnpublishedEntries(payload.dependencies.map( + dep => dep.split(".")))); + } + }); +} diff --git a/src/containers/editorialWorkflow/UnpublishedEntriesPanel.js b/src/containers/editorialWorkflow/UnpublishedEntriesPanel.js index 8d0220e65070..21cf8ab78628 100644 --- a/src/containers/editorialWorkflow/UnpublishedEntriesPanel.js +++ b/src/containers/editorialWorkflow/UnpublishedEntriesPanel.js @@ -2,7 +2,8 @@ import React, { Component, PropTypes } from 'react'; import ImmutablePropTypes from 'react-immutable-proptypes'; import { OrderedMap } from 'immutable'; import { connect } from 'react-redux'; -import { loadUnpublishedEntries, updateUnpublishedEntryStatus, publishUnpublishedEntry } from '../../actions/editorialWorkflow'; +import { loadUnpublishedEntries, updateUnpublishedEntryStatus, + publishUnpublishedEntryAndDependencies } from '../../actions/editorialWorkflow'; import { selectUnpublishedEntriesByStatus } from '../../reducers'; import { EDITORIAL_WORKFLOW, status } from '../../constants/publishModes'; import UnpublishedListing from '../../components/UnpublishedListing/UnpublishedListing'; @@ -61,5 +62,5 @@ function mapStateToProps(state) { export default connect(mapStateToProps, { loadUnpublishedEntries, updateUnpublishedEntryStatus, - publishUnpublishedEntry, + publishUnpublishedEntry: publishUnpublishedEntryAndDependencies, })(unpublishedEntriesPanel);