Fix other than markdown editorial workflow entries on dashboard.
When entries were loaded for the editorial workflow dashboard, they were all assumed to be FrontMatter/MarkDown files. This PR allows them to be any supported format.
This commit is contained in:
parent
4d33d67798
commit
37a36ffed4
@ -209,13 +209,13 @@ export function loadUnpublishedEntry(collection, slug) {
|
||||
};
|
||||
}
|
||||
|
||||
export function loadUnpublishedEntries() {
|
||||
export function loadUnpublishedEntries(collections) {
|
||||
return (dispatch, getState) => {
|
||||
const state = getState();
|
||||
if (state.config.get('publish_mode') !== EDITORIAL_WORKFLOW) return;
|
||||
const backend = currentBackend(state.config);
|
||||
dispatch(unpublishedEntriesLoading());
|
||||
backend.unpublishedEntries().then(
|
||||
backend.unpublishedEntries(collections).then(
|
||||
response => dispatch(unpublishedEntriesLoaded(response.entries, response.pagination)),
|
||||
error => dispatch(unpublishedEntriesFailed(error))
|
||||
);
|
||||
|
@ -164,8 +164,8 @@ class Backend {
|
||||
};
|
||||
}
|
||||
|
||||
unpublishedEntries(page, perPage) {
|
||||
return this.implementation.unpublishedEntries(page, perPage)
|
||||
unpublishedEntries(collections) {
|
||||
return this.implementation.unpublishedEntries()
|
||||
.then(loadedEntries => loadedEntries.filter(entry => entry !== null))
|
||||
.then(entries => (
|
||||
entries.map((loadedEntry) => {
|
||||
@ -184,7 +184,10 @@ class Backend {
|
||||
))
|
||||
.then(entries => ({
|
||||
pagination: 0,
|
||||
entries: entries.map(this.entryWithFormat("editorialWorkflow")),
|
||||
entries: entries.map(entry => {
|
||||
const collection = collections.get(entry.collection);
|
||||
return this.entryWithFormat(collection)(entry);
|
||||
}),
|
||||
}));
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,7 @@ import { Loader } from '../../components/UI';
|
||||
|
||||
class unpublishedEntriesPanel extends Component {
|
||||
static propTypes = {
|
||||
collections: ImmutablePropTypes.orderedMap,
|
||||
isEditorialWorkflow: PropTypes.bool.isRequired,
|
||||
isFetching: PropTypes.bool,
|
||||
unpublishedEntries: ImmutablePropTypes.map,
|
||||
@ -26,9 +27,9 @@ class unpublishedEntriesPanel extends Component {
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
const { loadUnpublishedEntries, isEditorialWorkflow } = this.props;
|
||||
const { loadUnpublishedEntries, isEditorialWorkflow, collections } = this.props;
|
||||
if (isEditorialWorkflow) {
|
||||
loadUnpublishedEntries();
|
||||
loadUnpublishedEntries(collections);
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,8 +50,9 @@ class unpublishedEntriesPanel extends Component {
|
||||
}
|
||||
|
||||
function mapStateToProps(state) {
|
||||
const { collections } = state;
|
||||
const isEditorialWorkflow = (state.config.get('publish_mode') === EDITORIAL_WORKFLOW);
|
||||
const returnObj = { isEditorialWorkflow };
|
||||
const returnObj = { collections, isEditorialWorkflow };
|
||||
|
||||
if (isEditorialWorkflow) {
|
||||
returnObj.isFetching = state.editorialWorkflow.getIn(['pages', 'isFetching'], false);
|
||||
|
@ -11,12 +11,6 @@ export const formatToExtension = format => ({
|
||||
html: 'html',
|
||||
}[format]);
|
||||
|
||||
function formatByType(type) {
|
||||
// Right now the only type is "editorialWorkflow" and
|
||||
// we always returns the same format
|
||||
return FrontmatterFormatter;
|
||||
}
|
||||
|
||||
export function formatByExtension(extension) {
|
||||
return {
|
||||
yml: yamlFormatter,
|
||||
@ -39,9 +33,6 @@ function formatByName(name) {
|
||||
}
|
||||
|
||||
export function resolveFormat(collectionOrEntity, entry) {
|
||||
if (typeof collectionOrEntity === 'string') {
|
||||
return formatByType(collectionOrEntity);
|
||||
}
|
||||
const path = entry && entry.path;
|
||||
if (path) {
|
||||
return formatByExtension(path.split('.').pop());
|
||||
|
Loading…
x
Reference in New Issue
Block a user