Skip to content

Commit

Permalink
Template Part: Hide Advanced panel for non-admin users
Browse files Browse the repository at this point in the history
  • Loading branch information
t-hamano committed Aug 22, 2024
1 parent 2a7c3e6 commit 0d2f566
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 35 deletions.
44 changes: 19 additions & 25 deletions packages/block-library/src/template-part/edit/advanced-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ const htmlElementMessages = {
export function TemplatePartAdvancedControls( {
tagName,
setAttributes,
isEntityAvailable,
templatePartId,
defaultWrapper,
hasInnerBlocks,
Expand Down Expand Up @@ -70,30 +69,25 @@ export function TemplatePartAdvancedControls( {

return (
<>
{ isEntityAvailable && (
<>
<TextControl
__next40pxDefaultSize
__nextHasNoMarginBottom
label={ __( 'Title' ) }
value={ title }
onChange={ ( value ) => {
setTitle( value );
} }
onFocus={ ( event ) => event.target.select() }
/>

<SelectControl
__next40pxDefaultSize
__nextHasNoMarginBottom
label={ __( 'Area' ) }
labelPosition="top"
options={ areaOptions }
value={ area }
onChange={ setArea }
/>
</>
) }
<TextControl
__next40pxDefaultSize
__nextHasNoMarginBottom
label={ __( 'Title' ) }
value={ title }
onChange={ ( value ) => {
setTitle( value );
} }
onFocus={ ( event ) => event.target.select() }
/>
<SelectControl
__next40pxDefaultSize
__nextHasNoMarginBottom
label={ __( 'Area' ) }
labelPosition="top"
options={ areaOptions }
value={ area }
onChange={ setArea }
/>
<SelectControl
__nextHasNoMarginBottom
__next40pxDefaultSize
Expand Down
21 changes: 11 additions & 10 deletions packages/block-library/src/template-part/edit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,16 +254,17 @@ export default function TemplatePartEdit( {
</ToolbarButton>
</BlockControls>
) }
<InspectorControls group="advanced">
<TemplatePartAdvancedControls
tagName={ tagName }
setAttributes={ setAttributes }
isEntityAvailable={ isEntityAvailable }
templatePartId={ templatePartId }
defaultWrapper={ areaObject.tagName }
hasInnerBlocks={ hasInnerBlocks }
/>
</InspectorControls>
{ isEntityAvailable && canUserEdit && (
<InspectorControls group="advanced">
<TemplatePartAdvancedControls
tagName={ tagName }
setAttributes={ setAttributes }
templatePartId={ templatePartId }
defaultWrapper={ areaObject.tagName }
hasInnerBlocks={ hasInnerBlocks }
/>
</InspectorControls>
) }
{ isPlaceholder && (
<TagName { ...blockProps }>
<TemplatePartPlaceholder
Expand Down

0 comments on commit 0d2f566

Please sign in to comment.