Skip to content

Commit

Permalink
Site Editor: Update back button URL
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka committed Nov 8, 2021
1 parent e5c5b82 commit 8762082
Showing 1 changed file with 28 additions and 15 deletions.
43 changes: 28 additions & 15 deletions packages/edit-site/src/components/header/navigation-link/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,33 @@ 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, postType, siteIconUrl } = useSelect(
( select ) => {
const { getEditedPostType } = select( editSiteStore );
const { getEntityRecord, 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,
] ),
postType: getEditedPostType(),
siteIconUrl: siteData.site_icon_url,
};
},
[]
);

const disableMotion = useReducedMotion();

Expand Down Expand Up @@ -59,8 +70,10 @@ 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"
label={ __( 'Back' ) }
href={ addQueryArgs( 'edit.php', {
post_type: postType,
} ) }
>
{ buttonIcon }
</Button>
Expand Down

0 comments on commit 8762082

Please sign in to comment.