Skip to content
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
Next Next commit
Link to homeUrl from site editor view menu.
  • Loading branch information
peterwilsoncc committed Nov 2, 2022
commit 6740369ae044240063a70b5021abe566e02d6e17
12 changes: 8 additions & 4 deletions packages/edit-site/src/components/header-edit-mode/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 @@ -50,22 +51,25 @@ export default function Header( { showIconLabels } ) {
isListViewOpen,
listViewShortcut,
isVisualMode,
settings,
blockEditorMode,
homeUrl,
} = useSelect( ( select ) => {
const {
__experimentalGetPreviewDeviceType,
getEditedPostType,
isInserterOpened,
isListViewOpened,
getEditorMode,
getSettings,
} = select( editSiteStore );
const { getShortcutRepresentation } = select( keyboardShortcutsStore );
const { __unstableGetEditorMode } = select( blockEditorStore );

const postType = getEditedPostType();

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

Comment on lines +69 to +72
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a 100% copy-paste from packages/block-library/src/home-link/edit.js -- let me know if there is a better way. I am sure there is.

return {
deviceType: __experimentalGetPreviewDeviceType(),
templateType: postType,
Expand All @@ -75,8 +79,8 @@ export default function Header( { showIconLabels } ) {
'core/edit-site/toggle-list-view'
),
isVisualMode: getEditorMode() === 'visual',
settings: getSettings(),
blockEditorMode: __unstableGetEditorMode(),
homeUrl: getUnstableBase()?.home,
Copy link
Member

Choose a reason for hiding this comment

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

This is much better. We were only using the URL setting, so there was no need to return the whole object.

};
}, [] );

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