-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Prevent saving the post before previewing in locked/read-only mode. #32341
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -159,9 +159,14 @@ export class PostPreviewButton extends Component { | |
| // https://html.spec.whatwg.org/multipage/interaction.html#dom-window-focus | ||
| this.previewWindow.focus(); | ||
|
|
||
| // If we don't need to autosave the post before previewing, then we simply | ||
| // load the Preview URL in the Preview tab. | ||
| if ( ! this.props.isAutosaveable ) { | ||
| if ( | ||
| // If we don't need to autosave the post before previewing, then we simply | ||
| // load the Preview URL in the Preview tab. | ||
| ! this.props.isAutosaveable || | ||
| // Also, save the post only if user has the post lock. | ||
| // Do not save or overwrite the post, if the post is already locked. | ||
| this.props.isPostLocked | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: @joemcgill suggested to expose this boolean as a component prop to |
||
| ) { | ||
| this.setPreviewWindowLink( event.target.href ); | ||
| return; | ||
| } | ||
|
|
@@ -232,6 +237,7 @@ export default compose( [ | |
| isEditedPostSaveable, | ||
| isEditedPostAutosaveable, | ||
| getEditedPostPreviewLink, | ||
| isPostLocked, | ||
| } = select( 'core/editor' ); | ||
| const { getPostType } = select( 'core' ); | ||
|
|
||
|
|
@@ -250,6 +256,7 @@ export default compose( [ | |
| [ 'draft', 'auto-draft' ].indexOf( | ||
| getEditedPostAttribute( 'status' ) | ||
| ) !== -1, | ||
| isPostLocked: isPostLocked(), | ||
| }; | ||
| } ), | ||
| withDispatch( ( dispatch ) => ( { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.