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

Improve post locking modal #10886

Merged
merged 7 commits into from Nov 19, 2018
36 changes: 21 additions & 15 deletions packages/editor/src/components/post-locked-modal/index.js
Expand Up @@ -2,6 +2,7 @@
* External dependencies
*/
import jQuery from 'jquery';
import { get } from 'lodash';

/**
* WordPress dependencies
Expand Down Expand Up @@ -118,7 +119,7 @@ class PostLockedModal extends Component {
}

render() {
const { user, postId, isLocked, isTakeover, postLockUtils } = this.props;
const { user, postId, isLocked, isTakeover, postLockUtils, postType } = this.props;
if ( ! isLocked ) {
return null;
}
Expand All @@ -133,7 +134,10 @@ class PostLockedModal extends Component {
action: 'edit',
_wpnonce: postLockUtils.nonce,
} );
const allPosts = getWPAdminURL( 'edit.php' );
const allPostsUrl = getWPAdminURL( 'edit.php', {
post_type: get( postType, [ 'slug' ] ),
} );
const allPostsLabel = get( postType, [ 'labels', 'all_items' ] );
return (
<Modal
title={ isTakeover ? __( 'Someone else has taken over this post.' ) : __( 'This post is already being edited.' ) }
Expand All @@ -155,38 +159,37 @@ class PostLockedModal extends Component {
<div>
{ userDisplayName ?
sprintf(
/* translators: 'post' is generic and may be of any type (post, page, etc.). */
__( '%s now has editing control of this post. Don\'t worry, your changes up to this moment have been saved.' ),
/* translators: %s: user's display name */
__( '%s now has editing control of this post. Dont worry, your changes up to this moment have been saved.' ),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want to keep the slashed single quote, the there a reason that was changed here?

Suggested change
__( '%s now has editing control of this post. Dont worry, your changes up to this moment have been saved.' ),
__( '%s now has editing control of this post. Don\'t worry, your changes up to this moment have been saved.' ),

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An apostrophe is the correct character to use in English here, not a single quote. It's certainly typographically better; that said, we should just be consistent and use one or the other everywhere. See: #7555.

userDisplayName
) :
/* translators: 'post' is generic and may be of any type (post, page, etc.). */
__( 'Another user now has editing control of this post. Don\'t worry, your changes up to this moment have been saved.' )
__( 'Another user now has editing control of this post. Don’t worry, your changes up to this moment have been saved.' )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
__( 'Another user now has editing control of this post. Dont worry, your changes up to this moment have been saved.' )
__( 'Another user now has editing control of this post. Don\'t worry, your changes up to this moment have been saved.' )

}
</div>
<p>
<a href={ allPosts }>
{ __( 'View all posts' ) }
</a>
</p>

<div className="editor-post-locked-modal__buttons">
<Button isPrimary isLarge href={ allPostsUrl }>
{ allPostsLabel }
</Button>
</div>
</div>
) }
{ ! isTakeover && (
<div>
<div>
{ userDisplayName ?
sprintf(
/* translators: 'post' is generic and may be of any type (post, page, etc.). */
/* translators: %s: user's display name */
__( '%s is currently working on this post, which means you cannot make changes, unless you take over.' ),
userDisplayName
) :
/* translators: 'post' is generic and may be of any type (post, page, etc.). */
__( 'Another user is currently working on this post, which means you cannot make changes, unless you take over.' )
}
</div>

<div className="editor-post-locked-modal__buttons">
<Button isDefault isLarge href={ allPosts }>
{ __( 'All Posts' ) }
<Button isDefault isLarge href={ allPostsUrl }>
{ allPostsLabel }
</Button>
<PostPreviewButton />
<Button isPrimary isLarge href={ unlockUrl }>
Expand All @@ -209,14 +212,17 @@ export default compose(
getPostLockUser,
getCurrentPostId,
getActivePostLock,
getEditedPostAttribute,
} = select( 'core/editor' );
const { getPostType } = select( 'core' );
return {
isLocked: isPostLocked(),
isTakeover: isPostLockTakeover(),
user: getPostLockUser(),
postId: getCurrentPostId(),
postLockUtils: getEditorSettings().postLockUtils,
activePostLock: getActivePostLock(),
postType: getPostType( getEditedPostAttribute( 'type' ) ),
};
} ),
withDispatch( ( dispatch ) => {
Expand Down