Skip to content

Commit

Permalink
Site Editor: Update back button URL (#36313)
Browse files Browse the repository at this point in the history
* Site Editor: Update back button URL
* Update labels
  • Loading branch information
Mamaduka authored Nov 10, 2021
1 parent 74f2490 commit f45a544
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 15 deletions.
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

0 comments on commit f45a544

Please sign in to comment.