Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix lost unsaved changes when updating status or publishing #987

Merged
merged 1 commit into from
Feb 28, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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