Ghost/ghost/admin/app/components/modals/delete-post.hbs
Chris Raible a10b13916a
🐛 Fixed admin error when deleting an unsaved or imported post (#20053)
ref
https://linear.app/tryghost/issue/ENG-845/error-attempted-to-set-lexical-on-the-deleted-record
ref
[https://linear.app/tryghost/issue/ENG-854/🐛-deleting-imported-posts-makes-ghost-unresponsive](https://linear.app/tryghost/issue/ENG-854/%F0%9F%90%9B-deleting-imported-posts-makes-ghost-unresponsive)

- When deleting a post in the editor's Post Settings Menu, if the post
has unsaved changes (indicated by the hasDirtyAttributes property in the
editor), Admin will crash because it tries to save a post revision
before leaving the editor, but the post has already been deleted so
saving fails.
- This can occur when editing a post and quickly deleting it from the
Post Settings Menu before saving is completed.
- It can also occur when attempting to delete an imported post, as the
editor will parse the lexical from the server and may make some minor,
invisible-to-the-user changes to the lexical string locally (e.g. JSON
formatting, or updating the JSON to use extended version of base lexical
nodes), which triggers the same error.
- This fix bypasses the attempt to save a post revision when leaving the
editor if the post is already deleted, which allows the transition back
to the Posts route to succeed.
2024-04-18 10:02:02 -07:00

24 lines
926 B
Handlebars

<div class="modal-content" {{on-key "Enter" (perform this.deletePostTask)}}>
<header class="modal-header">
<h1>Are you sure you want to delete this {{@data.post.displayName}}?</h1>
</header>
<button type="button" class="close" title="Close" {{on "click" @close}}>{{svg-jar "close"}}<span class="hidden">Close</span></button>
<div class="modal-body">
<p>
You're about to delete "<strong>{{@data.post.title}}</strong>".
This is permanent! We warned you, k?
</p>
</div>
<div class="modal-footer">
<button type="button" class="gh-btn" {{on "click" @close}}><span>Cancel</span></button>
<GhTaskButton
@buttonText="Delete"
@successText="Deleted"
@task={{this.deletePostTask}}
@class="gh-btn gh-btn-red gh-btn-icon"
data-test-button="delete-post-confirm"
/>
</div>
</div>