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 and priethor committed Jun 26, 2023
1 parent 971a26c commit d7dae8a
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

0 comments on commit d7dae8a

Please sign in to comment.