Skip to content

Commit

Permalink
Extract the manage menus button to a shared component to reduce dupli…
Browse files Browse the repository at this point in the history
…cate code (#45769)
  • Loading branch information
scruffian authored Nov 15, 2022
1 parent eb3faf6 commit 2572104
Showing 1 changed file with 17 additions and 49 deletions.
66 changes: 17 additions & 49 deletions packages/block-library/src/navigation/edit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,19 @@ function Navigation( {
</InspectorControls>
);

const ManageMenusButton = ( { buttonClassName = '' } ) => (
<Button
variant="link"
disabled={ ! hasManagePermissions || ! hasResolvedNavigationMenus }
className={ buttonClassName }
href={ addQueryArgs( 'edit.php', {
post_type: 'wp_navigation',
} ) }
>
{ __( 'Manage menus' ) }
</Button>
);

// If the block has inner blocks, but no menu id, then these blocks are either:
// - inserted via a pattern.
// - inserted directly via Code View (or otherwise).
Expand Down Expand Up @@ -725,18 +738,7 @@ function Navigation( {
<WrappedNavigationMenuSelector
currentMenuId={ ref }
/>
<Button
variant="link"
disabled={
! hasManagePermissions ||
! hasResolvedNavigationMenus
}
href={ addQueryArgs( 'edit.php', {
post_type: 'wp_navigation',
} ) }
>
{ __( 'Manage menus' ) }
</Button>
<ManageMenusButton />
</>
) }
</PanelBody>
Expand Down Expand Up @@ -798,18 +800,7 @@ function Navigation( {
<WrappedNavigationMenuSelector
currentMenuId={ null }
/>
<Button
variant="link"
disabled={
! hasManagePermissions ||
! hasResolvedNavigationMenus
}
href={ addQueryArgs( 'edit.php', {
post_type: 'wp_navigation',
} ) }
>
{ __( 'Manage menus' ) }
</Button>
<ManageMenusButton />
</>
) }
</PanelBody>
Expand Down Expand Up @@ -920,18 +911,7 @@ function Navigation( {
<WrappedNavigationMenuSelector
currentMenuId={ ref }
/>
<Button
variant="link"
disabled={
! hasManagePermissions ||
! hasResolvedNavigationMenus
}
href={ addQueryArgs( 'edit.php', {
post_type: 'wp_navigation',
} ) }
>
{ __( 'Manage menus' ) }
</Button>
<ManageMenusButton />
</>
) }
</PanelBody>
Expand Down Expand Up @@ -961,19 +941,7 @@ function Navigation( {
/>
) }
{ isOffCanvasNavigationEditorEnabled && (
<Button
variant="link"
className="wp-block-navigation-manage-menus-button"
disabled={
! hasManagePermissions ||
! hasResolvedNavigationMenus
}
href={ addQueryArgs( 'edit.php', {
post_type: 'wp_navigation',
} ) }
>
{ __( 'Manage menus' ) }
</Button>
<ManageMenusButton className="wp-block-navigation-manage-menus-button" />
) }
</InspectorControls>
) }
Expand Down

0 comments on commit 2572104

Please sign in to comment.