Skip to content

Commit

Permalink
Site Editor: Disable the revision button if there is no clickable menu (
Browse files Browse the repository at this point in the history
  • Loading branch information
t-hamano authored Jun 25, 2023
1 parent 600d1b0 commit 2a69e42
Showing 1 changed file with 34 additions and 24 deletions.
58 changes: 34 additions & 24 deletions packages/edit-site/src/components/global-styles/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
__experimentalNavigatorScreen as NavigatorScreen,
__experimentalUseNavigator as useNavigator,
createSlotFill,
Button,
DropdownMenu,
MenuGroup,
MenuItem,
Expand Down Expand Up @@ -142,33 +143,42 @@ function GlobalStylesRevisionsMenu() {

return (
<GlobalStylesMenuFill>
<DropdownMenu icon={ backup } label={ __( 'Revisions' ) }>
{ ( { onClose } ) => (
<MenuGroup>
{ hasRevisions && (
{ canReset || hasRevisions ? (
<DropdownMenu icon={ backup } label={ __( 'Revisions' ) }>
{ ( { onClose } ) => (
<MenuGroup>
{ hasRevisions && (
<MenuItem
onClick={ loadRevisions }
icon={
<RevisionsCountBadge>
{ revisionsCount }
</RevisionsCountBadge>
}
>
{ __( 'Revision history' ) }
</MenuItem>
) }
<MenuItem
onClick={ loadRevisions }
icon={
<RevisionsCountBadge>
{ revisionsCount }
</RevisionsCountBadge>
}
onClick={ () => {
onReset();
onClose();
} }
disabled={ ! canReset }
>
{ __( 'Revision history' ) }
{ __( 'Reset to defaults' ) }
</MenuItem>
) }
<MenuItem
onClick={ () => {
onReset();
onClose();
} }
disabled={ ! canReset }
>
{ __( 'Reset to defaults' ) }
</MenuItem>
</MenuGroup>
) }
</DropdownMenu>
</MenuGroup>
) }
</DropdownMenu>
) : (
<Button
label={ __( 'Revisions' ) }
icon={ backup }
disabled
__experimentalIsFocusable
/>
) }
</GlobalStylesMenuFill>
);
}
Expand Down

1 comment on commit 2a69e42

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 2a69e42.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5367573388
📝 Reported issues:

Please sign in to comment.