Skip to content

Commit

Permalink
fix lost unsaved changes when updating status or publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
erquhart committed Jan 5, 2018
1 parent b927c8a commit f0a169c
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/components/Editor/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,11 @@ class Editor extends React.Component {
};

handleChangeStatus = (newStatusName) => {
const { updateUnpublishedEntryStatus, collection, slug, currentStatus } = this.props;
const { entryDraft, updateUnpublishedEntryStatus, collection, slug, currentStatus } = this.props;
if (entryDraft.get('hasChanged')) {
window.alert('You have unsaved changes, please save before updating status.');
return;
}
const newStatus = status.get(newStatusName);
this.props.updateUnpublishedEntryStatus(collection.get('name'), slug, currentStatus, newStatus);
}
Expand All @@ -206,14 +210,11 @@ class Editor extends React.Component {
if (currentStatus !== status.last()) {
window.alert('Please update status to "Ready" before publishing.');
return;
} else if (entryDraft.get('hasChanged')) {
window.alert('You have unsaved changes, please save before publishing.');
return;
} else if (!window.confirm('Are you sure you want to publish this entry?')) {
return;
} else if (entryDraft.get('hasChanged')) {
if (window.confirm('Your unsaved changes will be saved before publishing. Are you sure you want to publish?')) {
await persistEntry(collection);
} else {
return;
}
}

await publishUnpublishedEntry(collection.get('name'), slug);
Expand Down

0 comments on commit f0a169c

Please sign in to comment.