Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "show template" to preview dropdown. #66514

Merged
merged 8 commits into from
Nov 5, 2024
Prev Previous commit
Next Next commit
Check that there's an actual template.
  • Loading branch information
tellthemachines committed Oct 30, 2024
commit 553af4d28605cea119bc84681452b23bf4157867
7 changes: 5 additions & 2 deletions packages/editor/src/components/preview-dropdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ export default function PreviewDropdown( { forceIsAutosaveable, disabled } ) {
isViewable,
showIconLabels,
isTemplateHidden,
templateId,
} = useSelect( ( select ) => {
const { getDeviceType, getCurrentPostType } = select( editorStore );
const { getDeviceType, getCurrentPostType, getCurrentTemplateId } =
select( editorStore );
const { getRenderingMode } = unlock( select( editorStore ) );
const { getEntityRecord, getPostType } = select( coreStore );
const { get } = select( preferencesStore );
Expand All @@ -51,6 +53,7 @@ export default function PreviewDropdown( { forceIsAutosaveable, disabled } ) {
isViewable: getPostType( _currentPostType )?.viewable ?? false,
showIconLabels: get( 'core', 'showIconLabels' ),
isTemplateHidden: getRenderingMode() === 'post-only',
templateId: getCurrentTemplateId(),
};
}, [] );
const { setDeviceType, setRenderingMode } = useDispatch( editorStore );
Expand Down Expand Up @@ -150,7 +153,7 @@ export default function PreviewDropdown( { forceIsAutosaveable, disabled } ) {
</MenuItem>
</MenuGroup>
) }
{ ! isTemplate && (
{ ! isTemplate && !! templateId && (
<MenuGroup>
<MenuItem
icon={ ! isTemplateHidden ? check : undefined }
Expand Down
Loading