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) => {
|
return (dispatch, getState) => {
|
||||||
const state = getState();
|
const state = getState();
|
||||||
if (state.config.get('publish_mode') !== EDITORIAL_WORKFLOW) return;
|
if (state.config.get('publish_mode') !== EDITORIAL_WORKFLOW) return;
|
||||||
const backend = currentBackend(state.config);
|
const backend = currentBackend(state.config);
|
||||||
dispatch(unpublishedEntriesLoading());
|
dispatch(unpublishedEntriesLoading());
|
||||||
backend.unpublishedEntries().then(
|
backend.unpublishedEntries(collections).then(
|
||||||
response => dispatch(unpublishedEntriesLoaded(response.entries, response.pagination)),
|
response => dispatch(unpublishedEntriesLoaded(response.entries, response.pagination)),
|
||||||
error => dispatch(unpublishedEntriesFailed(error))
|
error => dispatch(unpublishedEntriesFailed(error))
|
||||||
);
|
);
|
||||||
|
@ -164,8 +164,8 @@ class Backend {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
unpublishedEntries(page, perPage) {
|
unpublishedEntries(collections) {
|
||||||
return this.implementation.unpublishedEntries(page, perPage)
|
return this.implementation.unpublishedEntries()
|
||||||
.then(loadedEntries => loadedEntries.filter(entry => entry !== null))
|
.then(loadedEntries => loadedEntries.filter(entry => entry !== null))
|
||||||
.then(entries => (
|
.then(entries => (
|
||||||
entries.map((loadedEntry) => {
|
entries.map((loadedEntry) => {
|
||||||
@ -184,7 +184,10 @@ class Backend {
|
|||||||
))
|
))
|
||||||
.then(entries => ({
|
.then(entries => ({
|
||||||
pagination: 0,
|
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 {
|
class unpublishedEntriesPanel extends Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
|
collections: ImmutablePropTypes.orderedMap,
|
||||||
isEditorialWorkflow: PropTypes.bool.isRequired,
|
isEditorialWorkflow: PropTypes.bool.isRequired,
|
||||||
isFetching: PropTypes.bool,
|
isFetching: PropTypes.bool,
|
||||||
unpublishedEntries: ImmutablePropTypes.map,
|
unpublishedEntries: ImmutablePropTypes.map,
|
||||||
@ -26,9 +27,9 @@ class unpublishedEntriesPanel extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const { loadUnpublishedEntries, isEditorialWorkflow } = this.props;
|
const { loadUnpublishedEntries, isEditorialWorkflow, collections } = this.props;
|
||||||
if (isEditorialWorkflow) {
|
if (isEditorialWorkflow) {
|
||||||
loadUnpublishedEntries();
|
loadUnpublishedEntries(collections);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,8 +50,9 @@ class unpublishedEntriesPanel extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function mapStateToProps(state) {
|
function mapStateToProps(state) {
|
||||||
|
const { collections } = state;
|
||||||
const isEditorialWorkflow = (state.config.get('publish_mode') === EDITORIAL_WORKFLOW);
|
const isEditorialWorkflow = (state.config.get('publish_mode') === EDITORIAL_WORKFLOW);
|
||||||
const returnObj = { isEditorialWorkflow };
|
const returnObj = { collections, isEditorialWorkflow };
|
||||||
|
|
||||||
if (isEditorialWorkflow) {
|
if (isEditorialWorkflow) {
|
||||||
returnObj.isFetching = state.editorialWorkflow.getIn(['pages', 'isFetching'], false);
|
returnObj.isFetching = state.editorialWorkflow.getIn(['pages', 'isFetching'], false);
|
||||||
|
@ -11,12 +11,6 @@ export const formatToExtension = format => ({
|
|||||||
html: 'html',
|
html: 'html',
|
||||||
}[format]);
|
}[format]);
|
||||||
|
|
||||||
function formatByType(type) {
|
|
||||||
// Right now the only type is "editorialWorkflow" and
|
|
||||||
// we always returns the same format
|
|
||||||
return FrontmatterFormatter;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function formatByExtension(extension) {
|
export function formatByExtension(extension) {
|
||||||
return {
|
return {
|
||||||
yml: yamlFormatter,
|
yml: yamlFormatter,
|
||||||
@ -39,9 +33,6 @@ function formatByName(name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function resolveFormat(collectionOrEntity, entry) {
|
export function resolveFormat(collectionOrEntity, entry) {
|
||||||
if (typeof collectionOrEntity === 'string') {
|
|
||||||
return formatByType(collectionOrEntity);
|
|
||||||
}
|
|
||||||
const path = entry && entry.path;
|
const path = entry && entry.path;
|
||||||
if (path) {
|
if (path) {
|
||||||
return formatByExtension(path.split('.').pop());
|
return formatByExtension(path.split('.').pop());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user