Skip to content

Commit

Permalink
Add lock icon when user doesn't have permission to edit a pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
glendaviesnz committed Jan 24, 2024
1 parent 2171067 commit 67f116a
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions packages/block-library/src/block/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
Spinner,
ToolbarButton,
ToolbarGroup,
Tooltip,
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import {
Expand All @@ -29,6 +30,7 @@ import {
} from '@wordpress/block-editor';
import { privateApis as patternsPrivateApis } from '@wordpress/patterns';
import { parse, cloneBlock } from '@wordpress/blocks';
import { lock, Icon } from '@wordpress/icons';

/**
* Internal dependencies
Expand Down Expand Up @@ -348,18 +350,29 @@ export default function ReusableBlockEdit( {

return (
<RecursionProvider uniqueId={ ref }>
{ userCanEdit && editOriginalProps && (
<BlockControls>
<ToolbarGroup>
<BlockControls group="other">
<ToolbarGroup>
{ userCanEdit && editOriginalProps && (
<ToolbarButton
href={ editOriginalProps.href }
onClick={ handleEditOriginal }
>
{ __( 'Edit original' ) }
</ToolbarButton>
</ToolbarGroup>
</BlockControls>
) }
) }
{ ! userCanEdit && (
<Tooltip
text={ __(
'You do not have permission to edit the content of this block'
) }
>
<div className="components-button components-toolbar-button has-icon">
<Icon icon={ lock } />
</div>
</Tooltip>
) }
</ToolbarGroup>
</BlockControls>

{ hasOverridableBlocks && (
<BlockControls>
Expand Down

0 comments on commit 67f116a

Please sign in to comment.