Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to navigate to section: /revisions from the revisions button #67660

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
First commit. try to navigate to section: /revisions from the revisio…
…ns button
  • Loading branch information
ramonjd committed Dec 8, 2024
commit 0775f64f6b9d3f5ea003d3d0b05f0c9a85b76218
6 changes: 5 additions & 1 deletion packages/edit-site/src/components/global-styles/ui.js
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@ import { moreVertical } from '@wordpress/icons';
import { store as coreStore } from '@wordpress/core-data';
import { useEffect } from '@wordpress/element';
import { usePrevious } from '@wordpress/compose';
import { privateApis as routerPrivateApis } from '@wordpress/router';

/**
* Internal dependencies
@@ -52,6 +53,7 @@ const SLOT_FILL_NAME = 'GlobalStylesMenu';
const { useGlobalStylesReset } = unlock( blockEditorPrivateApis );
const { Slot: GlobalStylesMenuSlot, Fill: GlobalStylesMenuFill } =
createSlotFill( SLOT_FILL_NAME );
const { useLocation } = unlock( routerPrivateApis );

function GlobalStylesActionMenu() {
const [ canReset, onReset ] = useGlobalStylesReset();
@@ -329,6 +331,8 @@ function NavigationSync( { path: parentPath, onPathChange, children } ) {

function GlobalStylesUI( { path, onPathChange } ) {
const blocks = getBlockTypes();
const { query } = useLocation();
const { canvas } = query;
const editorCanvasContainerView = useSelect(
( select ) =>
unlock( select( editSiteStore ) ).getEditorCanvasContainerView(),
@@ -440,7 +444,7 @@ function GlobalStylesUI( { path, onPathChange } ) {

<GlobalStylesActionMenu />
<GlobalStylesBlockLink />
<GlobalStylesEditorCanvasContainerLink />
{ 'edit' === canvas && <GlobalStylesEditorCanvasContainerLink /> }
</Navigator>
);
}
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
*/
import { __ } from '@wordpress/i18n';
import { useMemo, useState } from '@wordpress/element';
import { useDispatch } from '@wordpress/data';
import { privateApis as routerPrivateApis } from '@wordpress/router';
import { useViewportMatch } from '@wordpress/compose';
import {
@@ -19,13 +20,15 @@ import Page from '../page';
import { unlock } from '../../lock-unlock';
import StyleBook from '../style-book';
import { STYLE_BOOK_COLOR_GROUPS } from '../style-book/constants';
import { store as editSiteStore } from '../../store';

const { useLocation, useHistory } = unlock( routerPrivateApis );
const { Menu } = unlock( componentsPrivateApis );

const GlobalStylesPageActions = ( {
isStyleBookOpened,
setIsStyleBookOpened,
setIsStyleBookClosed,
} ) => {
return (
<Menu
@@ -68,6 +71,9 @@ export default function GlobalStylesUIWrapper() {
const { canvas = 'view' } = query;
const [ isStyleBookOpened, setIsStyleBookOpened ] = useState( false );
const isMobileViewport = useViewportMatch( 'medium', '<' );
const { setEditorCanvasContainerView } = unlock(
useDispatch( editSiteStore )
);
const [ section, onChangeSection ] = useMemo( () => {
return [
query.section ?? '/',
@@ -80,6 +86,26 @@ export default function GlobalStylesUIWrapper() {
},
];
}, [ path, query.section, history ] );
console.log( { isStyleBookOpened, section, canvas } );

/*
@TODO This needs refactoring. Or at least ScreenRevision needs to be refactored/abstracted
so that it doesn't know about the editorCanvasContainerView.

*/
/* const turnOn = () => {
setEditorCanvasContainerView(
section === '/revisions'
? 'global-styles-revisions:style-book'
: 'style-book'
);
setIsStyleBookOpened( true );
};

const turnOff = () => {
setEditorCanvasContainerView( 'style-book' );
setIsStyleBookOpened( false );
};*/

return (
<>
Original file line number Diff line number Diff line change
@@ -30,20 +30,20 @@ export function SidebarNavigationItemGlobalStyles( props ) {

export default function SidebarNavigationScreenGlobalStyles() {
const history = useHistory();
const { path, query } = useLocation();
const { path } = useLocation();
const {
revisions,
isLoading: isLoadingRevisions,
revisionsCount,
} = useGlobalStylesRevisions();
const openRevisions = useCallback(
async () =>
() =>
history.navigate(
addQueryArgs( path, {
section: '/revisions',
} )
),
[ path, query.section, history ]
[ path, history ]
);

// If there are no revisions, do not render a footer.