From 0d2f566dfb7fc209f5e624b07d5f82bb1d31f7fb Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Fri, 23 Aug 2024 01:00:55 +0900 Subject: [PATCH 1/2] Template Part: Hide Advanced panel for non-admin users --- .../template-part/edit/advanced-controls.js | 44 ++++++++----------- .../src/template-part/edit/index.js | 21 ++++----- 2 files changed, 30 insertions(+), 35 deletions(-) diff --git a/packages/block-library/src/template-part/edit/advanced-controls.js b/packages/block-library/src/template-part/edit/advanced-controls.js index 0a2b8bebbf4fc..fd6aba819e9c8 100644 --- a/packages/block-library/src/template-part/edit/advanced-controls.js +++ b/packages/block-library/src/template-part/edit/advanced-controls.js @@ -35,7 +35,6 @@ const htmlElementMessages = { export function TemplatePartAdvancedControls( { tagName, setAttributes, - isEntityAvailable, templatePartId, defaultWrapper, hasInnerBlocks, @@ -70,30 +69,25 @@ export function TemplatePartAdvancedControls( { return ( <> - { isEntityAvailable && ( - <> - { - setTitle( value ); - } } - onFocus={ ( event ) => event.target.select() } - /> - - - - ) } + { + setTitle( value ); + } } + onFocus={ ( event ) => event.target.select() } + /> + ) } - - - + { isEntityAvailable && canUserEdit && ( + + + + ) } { isPlaceholder && ( Date: Fri, 23 Aug 2024 10:24:35 +0900 Subject: [PATCH 2/2] Restore original conditional statement --- .../template-part/edit/advanced-controls.js | 43 +++++++++++-------- .../src/template-part/edit/index.js | 3 +- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/packages/block-library/src/template-part/edit/advanced-controls.js b/packages/block-library/src/template-part/edit/advanced-controls.js index fd6aba819e9c8..3c319a7ec0fe7 100644 --- a/packages/block-library/src/template-part/edit/advanced-controls.js +++ b/packages/block-library/src/template-part/edit/advanced-controls.js @@ -35,6 +35,7 @@ const htmlElementMessages = { export function TemplatePartAdvancedControls( { tagName, setAttributes, + isEntityAvailable, templatePartId, defaultWrapper, hasInnerBlocks, @@ -69,25 +70,29 @@ export function TemplatePartAdvancedControls( { return ( <> - { - setTitle( value ); - } } - onFocus={ ( event ) => event.target.select() } - /> - + { isEntityAvailable && ( + <> + { + setTitle( value ); + } } + onFocus={ ( event ) => event.target.select() } + /> + + + ) } ) } - { isEntityAvailable && canUserEdit && ( + { canUserEdit && (