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

Template parts: use the template actions component for template parts patterns #54173

Merged
merged 3 commits into from
Sep 8, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ import useInitEditedEntityFromURL from '../sync-state-with-url/use-init-edited-e
import usePatternDetails from './use-pattern-details';
import { store as editSiteStore } from '../../store';
import { unlock } from '../../lock-unlock';
import TemplateActions from '../template-actions';

export default function SidebarNavigationScreenPattern() {
const { params } = useNavigator();
const navigator = useNavigator();
const {
params: { postType, postId },
} = navigator;
const { categoryType } = getQueryArgs( window.location.href );
const { postType, postId } = params;
const { setCanvasMode } = unlock( useDispatch( editSiteStore ) );

useInitEditedEntityFromURL();
Expand All @@ -38,11 +41,21 @@ export default function SidebarNavigationScreenPattern() {
return (
<SidebarNavigationScreen
actions={
<SidebarButton
onClick={ () => setCanvasMode( 'edit' ) }
label={ __( 'Edit' ) }
icon={ pencil }
/>
<>
<TemplateActions
postType={ postType }
postId={ postId }
toggleProps={ { as: SidebarButton } }
onRemove={ () => {
navigator.goTo( `/${ postType }/all` );
} }
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably make the onRemove navigate back to the same location as the back button i.e. the category page when the user has come from there to edit the template part. The backPath value could be reused here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for picking up on this, and for the suggestion 🙇🏻

/>
<SidebarButton
onClick={ () => setCanvasMode( 'edit' ) }
label={ __( 'Edit' ) }
icon={ pencil }
/>
</>
}
backPath={ backPath }
{ ...patternDetails }
Expand Down
Loading