Skip to content

Commit

Permalink
Permalink: Hide edit field for users without publishing capabilities (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka authored Dec 8, 2022
1 parent f720a26 commit 55a06a5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/editor/src/components/post-url/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,20 @@ export default function PostURL( { onClose } ) {
permalinkPrefix,
permalinkSuffix,
} = useSelect( ( select ) => {
const post = select( editorStore ).getCurrentPost();
const postTypeSlug = select( editorStore ).getCurrentPostType();
const postType = select( coreStore ).getPostType( postTypeSlug );
const permalinkParts = select( editorStore ).getPermalinkParts();
const hasPublishAction = post?._links?.[ 'wp:action-publish' ] ?? false;

return {
isEditable: select( editorStore ).isPermalinkEditable(),
isEditable:
select( editorStore ).isPermalinkEditable() && hasPublishAction,
postSlug: safeDecodeURIComponent(
select( editorStore ).getEditedPostSlug()
),
viewPostLabel: postType?.labels.view_item,
postLink: select( editorStore ).getCurrentPost().link,
postLink: post.link,
permalinkPrefix: permalinkParts?.prefix,
permalinkSuffix: permalinkParts?.suffix,
};
Expand Down

0 comments on commit 55a06a5

Please sign in to comment.