diff --git a/packages/editor/src/components/post-actions/actions.js b/packages/editor/src/components/post-actions/actions.js index a6ff1f77486c9..b1857f4fc3f89 100644 --- a/packages/editor/src/components/post-actions/actions.js +++ b/packages/editor/src/components/post-actions/actions.js @@ -21,7 +21,13 @@ import { /** * Internal dependencies */ -import { TEMPLATE_ORIGINS, TEMPLATE_POST_TYPE } from '../../store/constants'; +import { + TEMPLATE_ORIGINS, + TEMPLATE_POST_TYPE, + TEMPLATE_PART_POST_TYPE, + PATTERN_POST_TYPE, + NAVIGATION_POST_TYPE, +} from '../../store/constants'; import { store as editorStore } from '../../store'; import { unlock } from '../../lock-unlock'; import isTemplateRevertable from '../../store/utils/is-template-revertable'; @@ -365,13 +371,20 @@ function useRestorePostAction() { ); } -const viewPostAction = { +export const viewPostAction = { id: 'view-post', label: __( 'View' ), isPrimary: true, icon: external, isEligible( post ) { - return post.status !== 'trash'; + return ( + ! [ + TEMPLATE_POST_TYPE, + TEMPLATE_PART_POST_TYPE, + PATTERN_POST_TYPE, + NAVIGATION_POST_TYPE, + ].includes( post.type ) && post.status !== 'trash' + ); }, callback( posts, onActionPerformed ) { const post = posts[ 0 ]; diff --git a/packages/editor/src/components/post-card-panel/index.js b/packages/editor/src/components/post-card-panel/index.js index a8419c0feb8c2..82d190f9f258c 100644 --- a/packages/editor/src/components/post-card-panel/index.js +++ b/packages/editor/src/components/post-card-panel/index.js @@ -12,6 +12,7 @@ import { __experimentalVStack as VStack, __experimentalText as Text, PanelBody, + Button, } from '@wordpress/components'; import { store as coreStore } from '@wordpress/core-data'; import { useSelect } from '@wordpress/data'; @@ -31,15 +32,34 @@ import { } from '../../store/constants'; import { unlock } from '../../lock-unlock'; import TemplateAreas from '../template-areas'; +import { viewPostAction } from '../post-actions/actions'; + +function ViewPostLink( { post } ) { + if ( ! viewPostAction.isEligible( post ) ) { + return null; + } + return ( +