Skip to content

Commit

Permalink
It looks like hasManagePermissions is not cached between API calls …
Browse files Browse the repository at this point in the history
…so we refresh this quite often when switching between menus. For a more consistent UI experience we disabe the menu management link untill `hasManagePermissions` is refreshed.

Another option would be to cache this at a component level. But, this could be more accurate?
  • Loading branch information
draganescu committed Aug 29, 2022
1 parent 0ede795 commit b0bc044
Showing 1 changed file with 27 additions and 30 deletions.
57 changes: 27 additions & 30 deletions packages/block-library/src/navigation/edit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -608,16 +608,15 @@ function Navigation( {
/* translators: %s: The name of a menu. */
actionLabel={ __( "Switch to '%s'" ) }
/>
{ hasManagePermissions && (
<Button
variant="link"
href={ addQueryArgs( 'edit.php', {
post_type: 'wp_navigation',
} ) }
>
{ __( 'Manage menus' ) }
</Button>
) }
<Button
variant="link"
disabled={ ! hasManagePermissions }
href={ addQueryArgs( 'edit.php', {
post_type: 'wp_navigation',
} ) }
>
{ __( 'Manage menus' ) }
</Button>
</PanelBody>
</InspectorControls>
{ stylingInspectorControls }
Expand Down Expand Up @@ -680,16 +679,15 @@ function Navigation( {
/* translators: %s: The name of a menu. */
actionLabel={ __( "Switch to '%s'" ) }
/>
{ hasManagePermissions && (
<Button
variant="link"
href={ addQueryArgs( 'edit.php', {
post_type: 'wp_navigation',
} ) }
>
{ __( 'Manage menus' ) }
</Button>
) }
<Button
variant="link"
disabled={ ! hasManagePermissions }
href={ addQueryArgs( 'edit.php', {
post_type: 'wp_navigation',
} ) }
>
{ __( 'Manage menus' ) }
</Button>
</PanelBody>
</InspectorControls>
<Warning>
Expand Down Expand Up @@ -784,16 +782,15 @@ function Navigation( {
/* translators: %s: The name of a menu. */
actionLabel={ __( "Switch to '%s'" ) }
/>
{ hasManagePermissions && (
<Button
variant="link"
href={ addQueryArgs( 'edit.php', {
post_type: 'wp_navigation',
} ) }
>
{ __( 'Manage menus' ) }
</Button>
) }
<Button
variant="link"
disabled={ ! hasManagePermissions }
href={ addQueryArgs( 'edit.php', {
post_type: 'wp_navigation',
} ) }
>
{ __( 'Manage menus' ) }
</Button>
</PanelBody>
</InspectorControls>
{ stylingInspectorControls }
Expand Down

0 comments on commit b0bc044

Please sign in to comment.