Skip to content

Commit

Permalink
Link to homeUrl from site editor view menu. (#45475)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterwilsoncc authored and Mamaduka committed Nov 10, 2022
1 parent 1d6e86f commit 5df9d42
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/edit-site/src/components/header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import classnames from 'classnames';
*/
import { useCallback, useRef } from '@wordpress/element';
import { useViewportMatch } from '@wordpress/compose';
import { store as coreStore } from '@wordpress/core-data';
import {
ToolSelector,
__experimentalPreviewOptions as PreviewOptions,
Expand Down Expand Up @@ -60,8 +61,8 @@ export default function Header( {
listViewShortcut,
isLoaded,
isVisualMode,
settings,
blockEditorMode,
homeUrl,
} = useSelect( ( select ) => {
const {
__experimentalGetPreviewDeviceType,
Expand All @@ -70,7 +71,6 @@ export default function Header( {
isInserterOpened,
isListViewOpened,
getEditorMode,
getSettings,
} = select( editSiteStore );
const { getEditedEntityRecord } = select( coreStore );
const { __experimentalGetTemplateInfo: getTemplateInfo } =
Expand All @@ -83,6 +83,10 @@ export default function Header( {
const record = getEditedEntityRecord( 'postType', postType, postId );
const _isLoaded = !! postId;

const {
getUnstableBase, // Site index.
} = select( coreStore );

return {
deviceType: __experimentalGetPreviewDeviceType(),
entityTitle: getTemplateInfo( record ).title,
Expand All @@ -95,8 +99,8 @@ export default function Header( {
'core/edit-site/toggle-list-view'
),
isVisualMode: getEditorMode() === 'visual',
settings: getSettings(),
blockEditorMode: __unstableGetEditorMode(),
homeUrl: getUnstableBase()?.home,
};
}, [] );

Expand Down Expand Up @@ -256,7 +260,7 @@ export default function Header( {
>
<MenuGroup>
<MenuItem
href={ settings?.siteUrl }
href={ homeUrl }
target="_blank"
icon={ external }
>
Expand Down

0 comments on commit 5df9d42

Please sign in to comment.