Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Nav block permissions variable naming accuracy #59882

Merged
merged 6 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions packages/block-library/src/navigation/edit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,9 @@ function Navigation( {
hasResolvedCanUserUpdateNavigationMenu,
canUserDeleteNavigationMenu,
hasResolvedCanUserDeleteNavigationMenu,
canUserCreateNavigationMenu,
isResolvingCanUserCreateNavigationMenu,
hasResolvedCanUserCreateNavigationMenu,
canUserCreateNavigationMenus,
isResolvingCanUserCreateNavigationMenus,
hasResolvedCanUserCreateNavigationMenus,
} = useNavigationMenu( ref );

const navMenuResolvedButMissing =
Expand Down Expand Up @@ -467,8 +467,8 @@ function Navigation( {

if (
! ref &&
hasResolvedCanUserCreateNavigationMenu &&
! canUserCreateNavigationMenu
hasResolvedCanUserCreateNavigationMenus &&
! canUserCreateNavigationMenus
) {
showNavigationMenuPermissionsNotice(
__(
Expand All @@ -482,16 +482,16 @@ function Navigation( {
isInnerBlockSelected,
canUserUpdateNavigationMenu,
hasResolvedCanUserUpdateNavigationMenu,
canUserCreateNavigationMenu,
hasResolvedCanUserCreateNavigationMenu,
canUserCreateNavigationMenus,
hasResolvedCanUserCreateNavigationMenus,
ref,
hideNavigationMenuPermissionsNotice,
showNavigationMenuPermissionsNotice,
navMenuResolvedButMissing,
] );

const hasManagePermissions =
canUserCreateNavigationMenu || canUserUpdateNavigationMenu;
canUserCreateNavigationMenus || canUserUpdateNavigationMenu;

const overlayMenuPreviewClasses = classnames(
'wp-block-navigation__overlay-menu-preview',
Expand Down Expand Up @@ -801,9 +801,11 @@ function Navigation( {
isSelected={ isSelected }
currentMenuId={ ref }
clientId={ clientId }
canUserCreateNavigationMenu={ canUserCreateNavigationMenu }
isResolvingCanUserCreateNavigationMenu={
isResolvingCanUserCreateNavigationMenu
canUserCreateNavigationMenus={
canUserCreateNavigationMenus
}
isResolvingCanUserCreateNavigationMenus={
isResolvingCanUserCreateNavigationMenus
}
onSelectNavigationMenu={ onSelectNavigationMenu }
onSelectClassicMenu={ onSelectClassicMenu }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function NavigationMenuSelector( {
navigationMenus,
isResolvingNavigationMenus,
hasResolvedNavigationMenus,
canUserCreateNavigationMenu,
canUserCreateNavigationMenus,
canSwitchNavigationMenu,
} = useNavigationMenu();

Expand Down Expand Up @@ -100,7 +100,7 @@ function NavigationMenuSelector( {
const hasNavigationMenus = !! navigationMenus?.length;
const hasClassicMenus = !! classicMenus?.length;
const showNavigationMenus = !! canSwitchNavigationMenu;
const showClassicMenus = !! canUserCreateNavigationMenu;
const showClassicMenus = !! canUserCreateNavigationMenus;

const noMenuSelected = hasNavigationMenus && ! currentMenuId;
const noBlockMenus = ! hasNavigationMenus && hasResolvedNavigationMenus;
Expand Down Expand Up @@ -129,7 +129,7 @@ function NavigationMenuSelector( {
}, [
hasResolvedNavigationMenus,
createNavigationMenuIsSuccess,
canUserCreateNavigationMenu,
canUserCreateNavigationMenus,
createNavigationMenuIsError,
isUpdatingMenuRef,
menuUnavailable,
Expand Down Expand Up @@ -187,7 +187,7 @@ function NavigationMenuSelector( {
</MenuGroup>
) }

{ canUserCreateNavigationMenu && (
{ canUserCreateNavigationMenus && (
<MenuGroup label={ __( 'Tools' ) }>
<MenuItem
onClick={ async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export default function NavigationPlaceholder( {
isSelected,
currentMenuId,
clientId,
canUserCreateNavigationMenu = false,
isResolvingCanUserCreateNavigationMenu,
canUserCreateNavigationMenus = false,
isResolvingCanUserCreateNavigationMenus,
onSelectNavigationMenu,
onSelectClassicMenu,
onCreateEmpty,
Expand All @@ -41,7 +41,7 @@ export default function NavigationPlaceholder( {
}, [ hasResolvedMenus, isResolvingMenus, isSelected ] );

const isResolvingActions =
isResolvingMenus && isResolvingCanUserCreateNavigationMenu;
isResolvingMenus && isResolvingCanUserCreateNavigationMenus;

return (
<>
Expand Down Expand Up @@ -74,7 +74,7 @@ export default function NavigationPlaceholder( {

<hr />

{ canUserCreateNavigationMenu && (
{ canUserCreateNavigationMenus && (
<Button
variant="tertiary"
onClick={ onCreateEmpty }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ describe( 'NavigationMenuSelector', () => {
useNavigationMenu.mockReturnValue( {
navigationMenus: [],
hasResolvedNavigationMenus: true,
canUserCreateNavigationMenu: true,
canUserCreateNavigationMenus: true,
canSwitchNavigationMenu: true,
} );

Expand All @@ -115,7 +115,7 @@ describe( 'NavigationMenuSelector', () => {
navigationMenus: [],
isResolvingNavigationMenus: true,
hasResolvedNavigationMenus: false,
canUserCreateNavigationMenu: false,
canUserCreateNavigationMenus: false,
canSwitchNavigationMenu: true,
} );

Expand Down Expand Up @@ -152,7 +152,7 @@ describe( 'NavigationMenuSelector', () => {
useNavigationMenu.mockReturnValue( {
navigationMenus: [],
hasResolvedNavigationMenus: true,
canUserCreateNavigationMenu: true,
canUserCreateNavigationMenus: true,
canSwitchNavigationMenu: true,
} );

Expand Down Expand Up @@ -203,7 +203,7 @@ describe( 'NavigationMenuSelector', () => {
useNavigationMenu.mockReturnValue( {
navigationMenus: [],
hasResolvedNavigationMenus: true,
canUserCreateNavigationMenu: false,
canUserCreateNavigationMenus: false,
canSwitchNavigationMenu: true,
} );

Expand All @@ -226,7 +226,7 @@ describe( 'NavigationMenuSelector', () => {
useNavigationMenu.mockReturnValue( {
navigationMenus: [],
hasResolvedNavigationMenus: true,
canUserCreateNavigationMenu: true,
canUserCreateNavigationMenus: true,
canSwitchNavigationMenu: true,
} );

Expand Down Expand Up @@ -254,7 +254,7 @@ describe( 'NavigationMenuSelector', () => {
useNavigationMenu.mockReturnValue( {
navigationMenus: [],
hasResolvedNavigationMenus: true,
canUserCreateNavigationMenu: true,
canUserCreateNavigationMenus: true,
canSwitchNavigationMenu: true,
} );

Expand All @@ -278,7 +278,7 @@ describe( 'NavigationMenuSelector', () => {
navigationMenus: [],
hasResolvedNavigationMenus: false,
isResolvingNavigationMenus: true,
canUserCreateNavigationMenu: true,
canUserCreateNavigationMenus: true,
canSwitchNavigationMenu: true,
} );

Expand All @@ -303,7 +303,7 @@ describe( 'NavigationMenuSelector', () => {
navigationMenus: [],
hasResolvedNavigationMenus: true,
isResolvingNavigationMenus: false,
canUserCreateNavigationMenu: true,
canUserCreateNavigationMenus: true,
canSwitchNavigationMenu: true,
} );

Expand Down Expand Up @@ -331,7 +331,7 @@ describe( 'NavigationMenuSelector', () => {
useNavigationMenu.mockReturnValue( {
navigationMenus: navigationMenusFixture,
hasResolvedNavigationMenus: true,
canUserCreateNavigationMenu: true,
canUserCreateNavigationMenus: true,
canSwitchNavigationMenu: false,
} );

Expand All @@ -352,7 +352,7 @@ describe( 'NavigationMenuSelector', () => {
useNavigationMenu.mockReturnValue( {
navigationMenus: navigationMenusFixture,
hasResolvedNavigationMenus: true,
canUserCreateNavigationMenu: false,
canUserCreateNavigationMenus: false,
canSwitchNavigationMenu: true,
} );

Expand Down Expand Up @@ -391,7 +391,7 @@ describe( 'NavigationMenuSelector', () => {
useNavigationMenu.mockReturnValue( {
navigationMenus: menusWithNoTitle,
hasResolvedNavigationMenus: true,
canUserCreateNavigationMenu: true,
canUserCreateNavigationMenus: true,
canSwitchNavigationMenu: true,
} );

Expand Down Expand Up @@ -425,7 +425,7 @@ describe( 'NavigationMenuSelector', () => {
useNavigationMenu.mockReturnValue( {
navigationMenus: navigationMenusFixture,
hasResolvedNavigationMenus: true,
canUserCreateNavigationMenu: true,
canUserCreateNavigationMenus: true,
canSwitchNavigationMenu: true,
} );

Expand Down Expand Up @@ -453,7 +453,7 @@ describe( 'NavigationMenuSelector', () => {
useNavigationMenu.mockReturnValue( {
navigationMenus: navigationMenusFixture,
hasResolvedNavigationMenus: true,
canUserCreateNavigationMenu: true,
canUserCreateNavigationMenus: true,
canSwitchNavigationMenu: true,
} );

Expand Down Expand Up @@ -504,7 +504,7 @@ describe( 'NavigationMenuSelector', () => {
const user = userEvent.setup();

useNavigationMenu.mockReturnValue( {
canUserCreateNavigationMenu: false,
canUserCreateNavigationMenus: false,
} );

useNavigationEntities.mockReturnValue( {
Expand All @@ -526,7 +526,7 @@ describe( 'NavigationMenuSelector', () => {
const user = userEvent.setup();

useNavigationMenu.mockReturnValue( {
canUserCreateNavigationMenu: true,
canUserCreateNavigationMenus: true,
} );

useNavigationEntities.mockReturnValue( {
Expand Down Expand Up @@ -563,7 +563,7 @@ describe( 'NavigationMenuSelector', () => {
isResolvingNavigationMenus: false,
hasResolvedNavigationMenus: true,
canSwitchNavigationMenu: true,
canUserCreateNavigationMenu: true,
canUserCreateNavigationMenus: true,
} );

useNavigationEntities.mockReturnValue( {
Expand Down Expand Up @@ -595,7 +595,7 @@ describe( 'NavigationMenuSelector', () => {
navigationMenus: [],
isResolvingNavigationMenus: true,
hasResolvedNavigationMenus: false,
canUserCreateNavigationMenu: true,
canUserCreateNavigationMenus: true,
} );

useNavigationEntities.mockReturnValue( {
Expand Down Expand Up @@ -628,7 +628,7 @@ describe( 'NavigationMenuSelector', () => {
navigationMenus: [],
isResolvingNavigationMenus: false,
hasResolvedNavigationMenus: true,
canUserCreateNavigationMenu: true,
canUserCreateNavigationMenus: true,
} );

useNavigationEntities.mockReturnValue( {
Expand Down
Loading
Loading