Skip to content

Commit

Permalink
Disable device preview in pattern/template part/navitation editor (#6…
Browse files Browse the repository at this point in the history
…5970)

Co-authored-by: t-hamano <[email protected]>
Co-authored-by: tellthemachines <[email protected]>
Co-authored-by: andrewserong <[email protected]>
Co-authored-by: draganescu <[email protected]>
  • Loading branch information
5 people authored Oct 31, 2024
1 parent 37e8b9c commit fb511a6
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions packages/editor/src/components/header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
Expand Down Expand Up @@ -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 );
Expand All @@ -78,15 +81,19 @@ function Header( {
hasFixedToolbar: getPreference( 'core', 'fixedToolbar' ),
hasBlockSelection:
!! select( blockEditorStore ).getBlockSelectionStart(),
isNestedEntity:
!! getEditorSettings().onNavigateToPreviousEntityRecord,
};
}, [] );

const canBeZoomedOut = [ 'post', 'page', 'wp_template' ].includes(
postType
);

const disablePreviewOption = [
NAVIGATION_POST_TYPE,
TEMPLATE_PART_POST_TYPE,
PATTERN_POST_TYPE,
].includes( postType );

const [ isBlockToolsCollapsed, setIsBlockToolsCollapsed ] =
useState( true );

Expand Down Expand Up @@ -155,7 +162,7 @@ function Header( {

<PreviewDropdown
forceIsAutosaveable={ forceIsDirty }
disabled={ isNestedEntity }
disabled={ disablePreviewOption }
/>
<PostPreviewButton
className="editor-header__post-preview-button"
Expand Down

1 comment on commit fb511a6

@github-actions
Copy link

Choose a reason for hiding this comment

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

Flaky tests detected in fb511a6.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/11608184382
📝 Reported issues:

Please sign in to comment.