Merge pull request #507 from netlify/fix-post-save-error
Fix runtime error on saving post in editorial workflow
This commit is contained in:
commit
14be00be90
@ -225,7 +225,7 @@ export function persistUnpublishedEntry(collection, existingUnpublishedEntry) {
|
|||||||
const entryDraft = state.entryDraft;
|
const entryDraft = state.entryDraft;
|
||||||
|
|
||||||
// Early return if draft contains validation errors
|
// Early return if draft contains validation errors
|
||||||
if (!entryDraft.get('fieldsErrors').isEmpty()) return;
|
if (!entryDraft.get('fieldsErrors').isEmpty()) return Promise.resolve();
|
||||||
|
|
||||||
const backend = currentBackend(state.config);
|
const backend = currentBackend(state.config);
|
||||||
const assetProxies = entryDraft.get('mediaFiles').map(path => getAsset(state, path));
|
const assetProxies = entryDraft.get('mediaFiles').map(path => getAsset(state, path));
|
||||||
@ -234,15 +234,14 @@ export function persistUnpublishedEntry(collection, existingUnpublishedEntry) {
|
|||||||
|
|
||||||
dispatch(unpublishedEntryPersisting(collection, entry, transactionID));
|
dispatch(unpublishedEntryPersisting(collection, entry, transactionID));
|
||||||
const persistAction = existingUnpublishedEntry ? backend.persistUnpublishedEntry : backend.persistEntry;
|
const persistAction = existingUnpublishedEntry ? backend.persistUnpublishedEntry : backend.persistEntry;
|
||||||
persistAction.call(backend, state.config, collection, entryDraft, assetProxies.toJS())
|
return persistAction.call(backend, state.config, collection, entryDraft, assetProxies.toJS())
|
||||||
.then(() => {
|
.then(() => {
|
||||||
dispatch(notifSend({
|
dispatch(notifSend({
|
||||||
message: 'Entry saved',
|
message: 'Entry saved',
|
||||||
kind: 'success',
|
kind: 'success',
|
||||||
dismissAfter: 4000,
|
dismissAfter: 4000,
|
||||||
}));
|
}));
|
||||||
dispatch(unpublishedEntryPersisted(collection, entry, transactionID));
|
return dispatch(unpublishedEntryPersisted(collection, entry, transactionID));
|
||||||
dispatch(closeEntry());
|
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
dispatch(notifSend({
|
dispatch(notifSend({
|
||||||
@ -250,7 +249,7 @@ export function persistUnpublishedEntry(collection, existingUnpublishedEntry) {
|
|||||||
kind: 'danger',
|
kind: 'danger',
|
||||||
dismissAfter: 8000,
|
dismissAfter: 8000,
|
||||||
}));
|
}));
|
||||||
dispatch(unpublishedEntryPersistedFail(error, transactionID));
|
return dispatch(unpublishedEntryPersistedFail(error, transactionID));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user