Skip to content

Commit

Permalink
When clicking on templates in manage templates list go direct to edit…
Browse files Browse the repository at this point in the history
… mode rather than via the view only screen
  • Loading branch information
glendaviesnz committed Mar 6, 2023
1 parent 208e3e2 commit d48192b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/edit-site/src/components/list/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ export default function Table( { templateType } ) {
params={ {
postId: template.id,
postType: template.type,
canvas: 'edit',
fromTemplateList: true,
} }
>
{ decodeEntities(
Expand Down
12 changes: 12 additions & 0 deletions packages/edit-site/src/components/site-hub/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,21 @@ import { __ } from '@wordpress/i18n';
import { store as blockEditorStore } from '@wordpress/block-editor';
import { store as coreStore } from '@wordpress/core-data';
import { forwardRef } from '@wordpress/element';
import { getQueryArgs } from '@wordpress/url';

/**
* Internal dependencies
*/
import { store as editSiteStore } from '../../store';
import SiteIcon from '../site-icon';
import { unlock } from '../../private-apis';
import { useHistory } from '../routes';

const HUB_ANIMATION_DURATION = 0.3;

const SiteHub = forwardRef( ( props, ref ) => {
const history = useHistory();
const { fromTemplateList } = getQueryArgs( window.location.href );
const { canvasMode, dashboardLink } = useSelect( ( select ) => {
select( editSiteStore ).getEditedPostType();
const { getCanvasMode, getSettings } = unlock(
Expand All @@ -52,6 +56,14 @@ const SiteHub = forwardRef( ( props, ref ) => {
label: __( 'Open Navigation Sidebar' ),
onClick: () => {
clearSelectedBlock();
if ( fromTemplateList ) {
history.push( {
path: '/wp_template/all',
postType: 'wp_template',
postId: undefined,
fromTemplateList: undefined,
} );
}
setCanvasMode( 'view' );
},
};
Expand Down

0 comments on commit d48192b

Please sign in to comment.