From 6a93603d992bab45be20d90fc1c0bd434b9d47a5 Mon Sep 17 00:00:00 2001 From: Dave Smith Date: Mon, 14 Feb 2022 11:24:21 +0000 Subject: [PATCH 1/3] Rename to include "Menu" terminology Remove "entity" in favour of "menu" Attempt to fix failing e2e test --- .../src/navigation/use-navigation-menu.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/block-library/src/navigation/use-navigation-menu.js b/packages/block-library/src/navigation/use-navigation-menu.js index f647f814339f65..3ab7301a73e81c 100644 --- a/packages/block-library/src/navigation/use-navigation-menu.js +++ b/packages/block-library/src/navigation/use-navigation-menu.js @@ -65,22 +65,22 @@ export default function useNavigationMenu( ref ) { ), navigationMenu, navigationMenus, - canUserUpdateNavigationEntity: ref + canUserUpdateNavigationMenu: ref ? canUser( 'update', 'navigation', ref ) : undefined, - hasResolvedCanUserUpdateNavigationEntity: hasFinishedResolution( + hasResolvedCanUserUpdateNavigationMenu: hasFinishedResolution( 'canUser', [ 'update', 'navigation', ref ] ), - canUserDeleteNavigationEntity: ref + canUserDeleteNavigationMenu: ref ? canUser( 'delete', 'navigation', ref ) : undefined, - hasResolvedCanUserDeleteNavigationEntity: hasFinishedResolution( + hasResolvedCanUserDeleteNavigationMenu: hasFinishedResolution( 'canUser', [ 'delete', 'navigation', ref ] ), - canUserCreateNavigation: canUser( 'create', 'navigation' ), - hasResolvedCanUserCreateNavigation: hasFinishedResolution( + canUserCreateNavigationMenu: canUser( 'create', 'navigation' ), + hasResolvedCanUserCreateNavigationMenu: hasFinishedResolution( 'canUser', [ 'create', 'navigation' ] ), From dca6814fcfa08fa297e67ed27b128e2fc4209578 Mon Sep 17 00:00:00 2001 From: Dave Smith Date: Mon, 14 Feb 2022 13:37:38 +0000 Subject: [PATCH 2/3] Rename all instances --- .../src/navigation/edit/index.js | 42 ++++++++++--------- .../edit/navigation-menu-selector.js | 4 +- .../src/navigation/edit/placeholder/index.js | 8 ++-- 3 files changed, 28 insertions(+), 26 deletions(-) diff --git a/packages/block-library/src/navigation/edit/index.js b/packages/block-library/src/navigation/edit/index.js index e780ae7372aeba..28d4ae5ffa8b22 100644 --- a/packages/block-library/src/navigation/edit/index.js +++ b/packages/block-library/src/navigation/edit/index.js @@ -223,12 +223,12 @@ function Navigation( { hasResolvedNavigationMenus, navigationMenus, navigationMenu, - canUserUpdateNavigationEntity, - hasResolvedCanUserUpdateNavigationEntity, - canUserDeleteNavigationEntity, - hasResolvedCanUserDeleteNavigationEntity, - canUserCreateNavigation, - hasResolvedCanUserCreateNavigation, + canUserUpdateNavigationMenu, + hasResolvedCanUserUpdateNavigationMenu, + canUserDeleteNavigationMenu, + hasResolvedCanUserDeleteNavigationMenu, + canUserCreateNavigationMenu, + hasResolvedCanUserCreateNavigationMenu, } = useNavigationMenu( ref ); const navRef = useRef(); @@ -361,16 +361,16 @@ function Navigation( { if ( isSelected || isInnerBlockSelected ) { if ( - hasResolvedCanUserUpdateNavigationEntity && - ! canUserUpdateNavigationEntity + hasResolvedCanUserUpdateNavigationMenu && + ! canUserUpdateNavigationMenu ) { showCantEditNotice(); } if ( ! ref && - hasResolvedCanUserCreateNavigation && - ! canUserCreateNavigation + hasResolvedCanUserCreateNavigationMenu && + ! canUserCreateNavigationMenu ) { showCantCreateNotice(); } @@ -378,10 +378,10 @@ function Navigation( { }, [ isSelected, isInnerBlockSelected, - canUserUpdateNavigationEntity, - hasResolvedCanUserUpdateNavigationEntity, - canUserCreateNavigation, - hasResolvedCanUserCreateNavigation, + canUserUpdateNavigationMenu, + hasResolvedCanUserUpdateNavigationMenu, + canUserCreateNavigationMenu, + hasResolvedCanUserCreateNavigationMenu, ref, ] ); @@ -645,12 +645,12 @@ function Navigation( { { isEntityAvailable && ( - { hasResolvedCanUserUpdateNavigationEntity && - canUserUpdateNavigationEntity && ( + { hasResolvedCanUserUpdateNavigationMenu && + canUserUpdateNavigationMenu && ( ) } - { hasResolvedCanUserDeleteNavigationEntity && - canUserDeleteNavigationEntity && ( + { hasResolvedCanUserDeleteNavigationMenu && + canUserDeleteNavigationMenu && ( @@ -672,10 +672,12 @@ function Navigation( { hasResolvedNavigationMenus } clientId={ clientId } - canUserCreateNavigation={ canUserCreateNavigation } + canUserCreateNavigationMenu={ + canUserCreateNavigationMenu + } /> ) } - { ! hasResolvedCanUserCreateNavigation || + { ! hasResolvedCanUserCreateNavigationMenu || ( ! isEntityAvailable && ! isPlaceholderShown && ( ) ) } diff --git a/packages/block-library/src/navigation/edit/navigation-menu-selector.js b/packages/block-library/src/navigation/edit/navigation-menu-selector.js index 4f5b61e71f3ad6..443d0aa5ae9de1 100644 --- a/packages/block-library/src/navigation/edit/navigation-menu-selector.js +++ b/packages/block-library/src/navigation/edit/navigation-menu-selector.js @@ -30,8 +30,8 @@ export default function NavigationMenuSelector( { const { navigationMenus, - canUserCreateNavigation: canUserCreateNavigationMenu, - canUserUpdateNavigationEntity: canUserUpdateNavigationMenu, + canUserCreateNavigationMenu: canUserCreateNavigationMenu, + canUserUpdateNavigationMenu: canUserUpdateNavigationMenu, canSwitchNavigationMenu, } = useNavigationMenu(); diff --git a/packages/block-library/src/navigation/edit/placeholder/index.js b/packages/block-library/src/navigation/edit/placeholder/index.js index f7275091478c89..5de4dc4afac0ee 100644 --- a/packages/block-library/src/navigation/edit/placeholder/index.js +++ b/packages/block-library/src/navigation/edit/placeholder/index.js @@ -20,7 +20,7 @@ export default function NavigationPlaceholder( { onFinish, canSwitchNavigationMenu, hasResolvedNavigationMenus, - canUserCreateNavigation = false, + canUserCreateNavigationMenu = false, } ) { const createNavigationMenu = useCreateNavigationMenu( clientId ); @@ -28,7 +28,7 @@ export default function NavigationPlaceholder( { blocks, navigationMenuTitle = null ) => { - if ( ! canUserCreateNavigation ) { + if ( ! canUserCreateNavigationMenu ) { return; } @@ -56,7 +56,7 @@ export default function NavigationPlaceholder( { const hasNavigationMenus = !! navigationMenus?.length; const showSelectMenus = - ( canSwitchNavigationMenu || canUserCreateNavigation ) && + ( canSwitchNavigationMenu || canUserCreateNavigationMenu ) && ( hasNavigationMenus || hasMenus ); return ( @@ -100,7 +100,7 @@ export default function NavigationPlaceholder( { ) : undefined } - { canUserCreateNavigation && ( + { canUserCreateNavigationMenu && (