diff --git a/packages/edit-post/src/components/header/index.js b/packages/edit-post/src/components/header/index.js index a7bdccbfe44d9..09a93424f6903 100644 --- a/packages/edit-post/src/components/header/index.js +++ b/packages/edit-post/src/components/header/index.js @@ -15,6 +15,7 @@ import HeaderToolbar from './header-toolbar'; import MoreMenu from './more-menu'; import PostPublishButtonOrToggle from './post-publish-button-or-toggle'; import { default as DevicePreview } from '../device-preview'; +import ViewLink from '../view-link'; import MainDashboardButton from './main-dashboard-button'; import { store as editPostStore } from '../../store'; import TemplateTitle from './template-title'; @@ -88,6 +89,7 @@ function Header( { setEntitiesSavedStatesCallback } ) { showIconLabels={ showIconLabels } /> ) } + { + // Grab post type to retrieve the view_item label. + const postTypeSlug = select( editorStore ).getCurrentPostType(); + const postType = select( coreStore ).getPostType( postTypeSlug ); + + return { + permalink: select( editorStore ).getPermalink(), + isPublished: select( editorStore ).isCurrentPostPublished(), + label: postType?.labels.view_item, + }; + }, [] ); + + // Only render the view button if the post is published and has a permalink. + if ( ! isPublished || ! permalink ) { + return null; + } + + return ( +