From 8f4b9a46c82ca765300b38fc92954643ebf8b79e Mon Sep 17 00:00:00 2001 From: Aki Hamano <54422211+t-hamano@users.noreply.github.com> Date: Thu, 31 Oct 2024 17:03:16 +0900 Subject: [PATCH] Disable device preview in pattern/template part/navitation editor (#65970) Co-authored-by: t-hamano Co-authored-by: tellthemachines Co-authored-by: andrewserong Co-authored-by: draganescu --- packages/editor/src/components/header/index.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/editor/src/components/header/index.js b/packages/editor/src/components/header/index.js index 1bd1114852fd6c..07a5e9ddee5911 100644 --- a/packages/editor/src/components/header/index.js +++ b/packages/editor/src/components/header/index.js @@ -25,6 +25,11 @@ import PostViewLink from '../post-view-link'; import PreviewDropdown from '../preview-dropdown'; import ZoomOutToggle from '../zoom-out-toggle'; import { store as editorStore } from '../../store'; +import { + TEMPLATE_PART_POST_TYPE, + PATTERN_POST_TYPE, + NAVIGATION_POST_TYPE, +} from '../../store/constants'; const toolbarVariations = { distractionFreeDisabled: { y: '-50px' }, @@ -60,12 +65,10 @@ function Header( { showIconLabels, hasFixedToolbar, hasBlockSelection, - isNestedEntity, } = useSelect( ( select ) => { const { get: getPreference } = select( preferencesStore ); const { getEditorMode, - getEditorSettings, getCurrentPostType, isPublishSidebarOpened: _isPublishSidebarOpened, } = select( editorStore ); @@ -78,8 +81,6 @@ function Header( { hasFixedToolbar: getPreference( 'core', 'fixedToolbar' ), hasBlockSelection: !! select( blockEditorStore ).getBlockSelectionStart(), - isNestedEntity: - !! getEditorSettings().onNavigateToPreviousEntityRecord, }; }, [] ); @@ -87,6 +88,12 @@ function Header( { postType ); + const disablePreviewOption = [ + NAVIGATION_POST_TYPE, + TEMPLATE_PART_POST_TYPE, + PATTERN_POST_TYPE, + ].includes( postType ); + const [ isBlockToolsCollapsed, setIsBlockToolsCollapsed ] = useState( true ); @@ -155,7 +162,7 @@ function Header( {