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

Site Editor: Update back button URL #36313

Merged
merged 2 commits into from
Nov 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions lib/full-site-editing/template-parts.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function gutenberg_register_template_part_post_type() {
'new_item' => __( 'New Template Part', 'gutenberg' ),
'edit_item' => __( 'Edit Template Part', 'gutenberg' ),
'view_item' => __( 'View Template Part', 'gutenberg' ),
'view_items' => __( 'View Template Parts', 'gutenberg' ),
'all_items' => __( 'All Template Parts', 'gutenberg' ),
'search_items' => __( 'Search Template Parts', 'gutenberg' ),
'parent_item_colon' => __( 'Parent Template Part:', 'gutenberg' ),
Expand Down
1 change: 1 addition & 0 deletions lib/full-site-editing/templates.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function gutenberg_register_template_post_type() {
'new_item' => __( 'New Template', 'gutenberg' ),
'edit_item' => __( 'Edit Template', 'gutenberg' ),
'view_item' => __( 'View Template', 'gutenberg' ),
'view_items' => __( 'View Templates', 'gutenberg' ),
'all_items' => __( 'All Templates', 'gutenberg' ),
'search_items' => __( 'Search Templates', 'gutenberg' ),
'parent_item_colon' => __( 'Parent Template:', 'gutenberg' ),
Expand Down
54 changes: 39 additions & 15 deletions packages/edit-site/src/components/header/navigation-link/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* External dependencies
*/
import { get } from 'lodash';

/**
* WordPress dependencies
*/
Expand All @@ -11,22 +16,35 @@ import { __ } from '@wordpress/i18n';
import { wordpress } from '@wordpress/icons';
import { store as coreDataStore } from '@wordpress/core-data';
import { useReducedMotion } from '@wordpress/compose';
import { addQueryArgs } from '@wordpress/url';

/**
* Internal dependencies
*/
import { store as editSiteStore } from '../../../store';

function NavigationLink( { icon } ) {
const { isRequestingSiteIcon, siteIconUrl } = useSelect( ( select ) => {
const { getEntityRecord, isResolving } = select( coreDataStore );
const siteData =
getEntityRecord( 'root', '__unstableBase', undefined ) || {};
const { isRequestingSiteIcon, templateType, siteIconUrl } = useSelect(
( select ) => {
const { getEditedPostType } = select( editSiteStore );
const { getEntityRecord, getPostType, isResolving } = select(
coreDataStore
);
const siteData =
getEntityRecord( 'root', '__unstableBase', undefined ) || {};

return {
isRequestingSiteIcon: isResolving( 'core', 'getEntityRecord', [
'root',
'__unstableBase',
undefined,
] ),
siteIconUrl: siteData.site_icon_url,
};
}, [] );
return {
isRequestingSiteIcon: isResolving( 'core', 'getEntityRecord', [
'root',
'__unstableBase',
undefined,
] ),
templateType: getPostType( getEditedPostType() ),
siteIconUrl: siteData.site_icon_url,
};
},
[]
);

const disableMotion = useReducedMotion();

Expand Down Expand Up @@ -59,8 +77,14 @@ function NavigationLink( { icon } ) {
<motion.div className="edit-site-navigation-link" whileHover="expand">
<Button
className="edit-site-navigation-link__button has-icon"
label={ __( 'Dashboard' ) }
href="index.php"
href={ addQueryArgs( 'edit.php', {
post_type: templateType?.slug,
} ) }
label={ get(
templateType,
[ 'labels', 'view_items' ],
__( 'Back' )
) }
>
{ buttonIcon }
</Button>
Expand Down