-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Enable post locking in Gutenberg #4217
Merged
Merged
Changes from 103 commits
Commits
Show all changes
119 commits
Select commit
Hold shift + click to select a range
4f38c60
Enable post locking via the heartbeat api, following core
8578fc7
remove interval change
b370721
Docblock updates
940f338
Merge branch 'master' of github.com:WordPress/gutenberg
18290b2
Merge branch 'master' of github.com:WordPress/gutenberg
aa301d2
Merge branch 'master' into feature/post-locking
fbf7d08
revert unintended changes
e387b39
remove nonce handling
3a3deb9
rename file & setup
6980a89
Ensure heartbeat interval is low enough to work for post locking
810119d
Unlock the post when the window is closed or exited.
c510e37
Fixes for eslint
a9d7922
Merge branch 'master' into feature/post-locking
60c6ccc
tabs not spaces
c611a7b
post locking WIP
7f35914
Merge branch 'master' of github.com:WordPress/gutenberg
ca38176
Merge branch 'master' into feature/post-locking
a5d1764
modal on load first pass
fd8e941
Merge branch 'master' of github.com:WordPress/gutenberg
3b500f9
Merge branch 'master' of github.com:WordPress/gutenberg
f4aa602
Merge branch 'master' into feature/post-locking
2c3aecc
Fixes for phpunit
68f2099
Enable a Modal showCloseIcon property
0905e1a
Add a post locked modal, first pass
f669682
Add an “isPostLocked” selector
5515ba1
Add a locked reducer
6fda398
action is ‘lockPost’ and takes a boolean
3157fc2
fixes for phpunit
413e75b
cleanup hearbeat post locking
d79f3ca
Show the post locked modal when the post is locked
825e0a5
spaces for phpcs
27f45dc
passed lock & user at initialization
5213a7c
Merge branch 'master' of github.com:WordPress/gutenberg
ca04b3d
Merge branch 'master' into feature/post-locking
d48e0f5
Merge branch 'master' of github.com:WordPress/gutenberg
9f8882d
Merge branch 'master' into feature/post-locking
ad0c4ae
update inline docs
c2e6d74
pass a unlocking lockNonce to settings if the post is locked
560222f
Lock modal actions, first pass; leverage existing PostPreviewButton
b5c1d48
Add some style
1514d06
improve modal string construction, nonce setup, linting fixes
ab79301
better setup, fix beforeunload
784d618
Merge branch 'master' of github.com:WordPress/gutenberg
c0a7b53
Merge branch 'master' into feature/post-locking
e5d10d9
Merge branch 'master' of github.com:WordPress/gutenberg
a8415e3
Merge branch 'master' into feature/post-locking
9b94b5d
Merge branch 'master' into feature/post-locking
3dfd55b
complete takeover action logic
434f9ff
update core data readme
836ba7a
Complete takeover action, reaction
28490b6
alignment for eslint
e37b9d5
Add the lock details to the lockPost dispatch
f168ed3
Ensure modal header can display an icon when passed its src
08f13e6
modal icon img styles
d7062a0
Improve post lock modal, improve all posts url construction
4efcff1
Add lockedDetails to the lockPost action
73c9bc5
add lockDetails to the locked reducer
d2a971e
new selector: getLockDetails
c15bddc
Add avatgar data for existing locks
30eb346
dispatch an autosave when the post is taken over
dcdcd5b
Merge branch 'master' of github.com:WordPress/gutenberg
4816d72
Merge branch 'master' into feature/post-locking
4d1437d
Fix for phpcs, also smaller gravatar size x2 display
c515d54
Add docs for getLockDetails
809a86b
improve post locking modal style to match designs
4436ec3
switch ajaxurl from global to editor settings
b674cf7
Don’t hide the modal title - display it above the existing content
31a5032
import { setupHearthbeatPostLocking } from '@wordpress/editor';
cc37e6a
complete move of setupHearthbeatPostLocking to editor package
6818df1
showCloseIcon -> isDismissable
2c1fcf0
post lock modal - switch to withSelect
7e2119e
Revert "post lock modal - switch to withSelect"
a7987b8
modal cleanup and withSelect rework
b9aac75
improve avatar image alignment
b7ff092
Use a href links instead of action handlers for buttons
0476023
no closing
ca9fa60
Try moving to editor package
95f5f5c
Revert "Try moving to editor package"
c03878f
remove inner buttons, not needed
7cdb082
clean up modal imports
42e45dc
improve heartbeat post locking setup
a0c57de
docs update
aad9b92
more docs cleanup
0534539
Fixes for phpcs
8d071c1
Remove specific Modal Header Icon
youknowriad 5d767cb
Move the PostLockedModal to the editor module
youknowriad 7e60a81
Styles cleaning for the post locked modal
youknowriad 17803ec
Post Lock: Clarifying the lock state
youknowriad 6f30da2
Move post locking setup to the post locked modal component
youknowriad 52cb1e6
Remove unnecessary exposed function
youknowriad 4b633d8
Merge branch 'master' of github.com:WordPress/gutenberg
8378bbe
Merge branch 'feature/post-locking' of github.com:WordPress/gutenberg…
f6bb6e9
Merge branch 'master' into feature/post-locking
e32ac81
cleanup after merge
72c15e3
Merge branch 'master' of github.com:WordPress/gutenberg
8090483
Merge branch 'master' into feature/post-locking
17a80e1
fixes for phpcs
9315785
docs cleanup
6744619
cleanup after merge
24d9aef
Adjust the modal display with latest language, formatting and post type
ef2a42c
spacing
dff9ec9
Merge branch 'master' of github.com:WordPress/gutenberg
5a7f787
Merge branch 'master' into feature/post-locking
93aa165
Merge branch 'master' into feature/post-locking
4f3e67d
restore heartbeat settings after merge
413458c
Merge remote-tracking branch 'origin/master' into feature/post-locking
youknowriad 1f53d95
Add e2e tests for the post locking modal
youknowriad f6d5fc1
Revert "Add e2e tests for the post locking modal"
youknowriad d22b48b
Fix i18n of the post lock modal message and tweak docs
youknowriad 10bd363
Merge remote-tracking branch 'origin/master' into feature/post-locking
youknowriad 008872b
Try fixing the release post issue
youknowriad 6afbc96
Merge branch 'master' of github.com:WordPress/gutenberg
3d84894
Merge branch 'feature/post-locking' of github.com:WordPress/gutenberg…
9611023
Merge branch 'master' into feature/post-locking
1fee125
include and use an unclock nonce
6bc1196
Remove the heartbeat interval tweak
youknowriad 240f3e7
Code style and documentation tweaks
youknowriad 719175b
i18n: Drop untranslatable `postType` interpolation.
mcsf f89696c
i18n: Separate strings for more versatile translation
mcsf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1432,6 +1432,52 @@ function gutenberg_editor_scripts_and_styles( $hook ) { | |
} | ||
} | ||
|
||
// Lock settings. | ||
$user_id = wp_check_post_lock( $post->ID ); | ||
if ( $user_id ) { | ||
/** | ||
* Filters whether to show the post locked dialog. | ||
* | ||
* Returning a falsey value to the filter will short-circuit displaying the dialog. | ||
* | ||
* @since 3.6.0 | ||
* | ||
* @param bool $display Whether to display the dialog. Default true. | ||
* @param WP_Post $post Post object. | ||
* @param WP_User|bool $user The user id currently editing the post. | ||
*/ | ||
if ( apply_filters( 'show_post_locked_dialog', true, $post, $user_id ) ) { | ||
$locked = true; | ||
} | ||
|
||
$user_details = null; | ||
if ( $locked ) { | ||
$user = get_userdata( $user_id ); | ||
youknowriad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
$user_details = array( | ||
'name' => $user->display_name, | ||
); | ||
$avatar = get_avatar( $user_id, 64 ); | ||
if ( $avatar ) { | ||
if ( preg_match( "|src='([^']+)'|", $avatar, $matches ) ) { | ||
$user_details['avatar'] = $matches[1]; | ||
} | ||
} | ||
} | ||
|
||
$lock_details = array( | ||
'isLocked' => $locked, | ||
youknowriad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
'user' => $user_details, | ||
); | ||
} else { | ||
|
||
// Lock the post. | ||
$active_post_lock = wp_set_post_lock( $post->ID ); | ||
$lock_details = array( | ||
'isLocked' => false, | ||
'activePostLock' => esc_attr( implode( ':', $active_post_lock ) ), | ||
); | ||
} | ||
|
||
$editor_settings = array( | ||
'alignWide' => $align_wide || ! empty( $gutenberg_theme_support[0]['wide-images'] ), // Backcompat. Use `align-wide` outside of `gutenberg` array. | ||
'availableTemplates' => $available_templates, | ||
|
@@ -1444,7 +1490,13 @@ function gutenberg_editor_scripts_and_styles( $hook ) { | |
'autosaveInterval' => 10, | ||
'maxUploadFileSize' => $max_upload_size, | ||
'allowedMimeTypes' => get_allowed_mime_types(), | ||
'styles' => $styles, | ||
'postLock' => $lock_details, | ||
|
||
// Ideally, we'd remove this and rely on a REST API endpoint. | ||
'postLockUtils' => array( | ||
'nonce' => wp_create_nonce( 'lock-post_' . $post->ID ), | ||
'ajaxUrl' => admin_url( 'admin-ajax.php' ), | ||
), | ||
); | ||
|
||
$post_autosave = get_autosave_newer_than_post_save( $post ); | ||
|
@@ -1471,8 +1523,8 @@ function gutenberg_editor_scripts_and_styles( $hook ) { | |
( function() { | ||
var editorSettings = %s; | ||
window._wpLoadGutenbergEditor = new Promise( function( resolve ) { | ||
wp.domReady( function() { | ||
resolve( wp.editPost.initializeEditor( 'editor', "%s", %d, editorSettings, window._wpGutenbergDefaultPost ) ); | ||
wp.domReady( function() { | ||
resolve( wp.editPost.initializeEditor( 'editor', "%s", %d, editorSettings, window._wpGutenbergDefaultPost ) ); | ||
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. Same here, probably a useless change du to rebases? |
||
} ); | ||
} ); | ||
} )(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably a useless change.