From 2fb3c57bcadc675f9c6745a99d957b3924e39b71 Mon Sep 17 00:00:00 2001 From: Ramon Date: Thu, 14 Dec 2023 14:23:05 +1100 Subject: [PATCH] The revisions button is a permanent member of the global styles sidebar, so it doesn't need to be included via fill. (#57034) This commit moves the button from ui.js to the sidebar component in the hope that it will make both maintenance and working with parallel states, e.g., style book visibility easier later. --- .../src/components/global-styles/ui.js | 56 +------------------ .../global-styles-sidebar.js | 48 +++++++++++++++- 2 files changed, 46 insertions(+), 58 deletions(-) diff --git a/packages/edit-site/src/components/global-styles/ui.js b/packages/edit-site/src/components/global-styles/ui.js index c8d72205c3bed..8f602b1abb393 100644 --- a/packages/edit-site/src/components/global-styles/ui.js +++ b/packages/edit-site/src/components/global-styles/ui.js @@ -6,7 +6,6 @@ import { __experimentalNavigatorScreen as NavigatorScreen, __experimentalUseNavigator as useNavigator, createSlotFill, - Button, DropdownMenu, MenuGroup, MenuItem, @@ -19,7 +18,7 @@ import { } from '@wordpress/block-editor'; import { __ } from '@wordpress/i18n'; import { store as preferencesStore } from '@wordpress/preferences'; -import { backup, moreVertical } from '@wordpress/icons'; +import { moreVertical } from '@wordpress/icons'; import { store as coreStore } from '@wordpress/core-data'; import { useEffect } from '@wordpress/element'; @@ -115,58 +114,6 @@ function GlobalStylesActionMenu() { ); } -function GlobalStylesRevisionsMenu() { - const { setIsListViewOpened } = useDispatch( editSiteStore ); - const { revisionsCount } = useSelect( ( select ) => { - const { getEntityRecord, __experimentalGetCurrentGlobalStylesId } = - select( coreStore ); - - const globalStylesId = __experimentalGetCurrentGlobalStylesId(); - const globalStyles = globalStylesId - ? getEntityRecord( 'root', 'globalStyles', globalStylesId ) - : undefined; - - return { - revisionsCount: - globalStyles?._links?.[ 'version-history' ]?.[ 0 ]?.count ?? 0, - }; - }, [] ); - const { goTo } = useNavigator(); - const { setEditorCanvasContainerView } = unlock( - useDispatch( editSiteStore ) - ); - const isRevisionsOpened = useSelect( - ( select ) => - 'global-styles-revisions' === - unlock( select( editSiteStore ) ).getEditorCanvasContainerView(), - [] - ); - const loadRevisions = () => { - setIsListViewOpened( false ); - - if ( ! isRevisionsOpened ) { - goTo( '/revisions' ); - setEditorCanvasContainerView( 'global-styles-revisions' ); - } else { - goTo( '/' ); - setEditorCanvasContainerView( undefined ); - } - }; - const hasRevisions = revisionsCount > 0; - - return ( - -