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

Editor: Unify the show block breadcrumbs preference #57506

Merged
merged 1 commit into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions packages/edit-post/src/components/layout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import { useState, useEffect, useCallback, useMemo } from '@wordpress/element';
import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
import { store as noticesStore } from '@wordpress/notices';
import { store as preferencesStore } from '@wordpress/preferences';

import { privateApis as commandsPrivateApis } from '@wordpress/commands';
import { privateApis as coreCommandsPrivateApis } from '@wordpress/core-commands';

Expand Down Expand Up @@ -194,9 +193,7 @@ function Layout() {
showIconLabels: get( 'core', 'showIconLabels' ),
isDistractionFree:
select( editPostStore ).isFeatureActive( 'distractionFree' ),
showBlockBreadcrumbs: select( editPostStore ).isFeatureActive(
'showBlockBreadcrumbs'
),
showBlockBreadcrumbs: get( 'core', 'showBlockBreadcrumbs' ),
showMostUsedBlocks:
select( editPostStore ).isFeatureActive( 'mostUsedBlocks' ),
// translators: Default label for the Document in the Block Breadcrumb.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export default function EditPostPreferencesModal() {
/>
{ showBlockBreadcrumbsOption && (
<EnableFeature
scope="core"
featureName="showBlockBreadcrumbs"
help={ __(
'Display the block hierarchy trail at the bottom of the editor.'
Expand Down
12 changes: 5 additions & 7 deletions packages/edit-post/src/hooks/commands/use-common-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ export default function useCommonCommands() {
showBlockBreadcrumbs,
isDistractionFree,
} = useSelect( ( select ) => {
const { getEditorMode, isFeatureActive } = select( editPostStore );
const { get } = select( preferencesStore );
const { getEditorMode } = select( editPostStore );
const { isListViewOpened } = select( editorStore );
return {
activeSidebar: select( interfaceStore ).getActiveComplementaryArea(
Expand All @@ -53,11 +54,8 @@ export default function useCommonCommands() {
isListViewOpen: isListViewOpened(),
isPublishSidebarEnabled:
select( editorStore ).isPublishSidebarEnabled(),
showBlockBreadcrumbs: isFeatureActive( 'showBlockBreadcrumbs' ),
isDistractionFree: select( preferencesStore ).get(
editPostStore.name,
'distractionFree'
),
showBlockBreadcrumbs: get( 'core', 'showBlockBreadcrumbs' ),
isDistractionFree: get( editPostStore.name, 'distractionFree' ),
};
}, [] );
const { toggle } = useDispatch( preferencesStore );
Expand Down Expand Up @@ -177,7 +175,7 @@ export default function useCommonCommands() {
? __( 'Hide block breadcrumbs' )
: __( 'Show block breadcrumbs' ),
callback: ( { close } ) => {
toggle( 'core/edit-post', 'showBlockBreadcrumbs' );
toggle( 'core', 'showBlockBreadcrumbs' );
close();
createInfoNotice(
showBlockBreadcrumbs
Expand Down
2 changes: 1 addition & 1 deletion packages/edit-post/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ export function initializeEditor(
isPublishSidebarEnabled: true,
openPanels: [ 'post-status' ],
preferredStyleVariations: {},
showBlockBreadcrumbs: true,
showListViewByDefault: false,
themeStyles: true,
welcomeGuide: true,
Expand All @@ -71,6 +70,7 @@ export function initializeEditor(

dispatch( preferencesStore ).setDefaults( 'core', {
allowRightClickOverrides: true,
showBlockBreadcrumbs: true,
showIconLabels: false,
} );

Expand Down
7 changes: 2 additions & 5 deletions packages/edit-site/src/components/editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export default function Editor( { isLoading } ) {
showIconLabels,
showBlockBreadcrumbs,
} = useSelect( ( select ) => {
const { get } = select( preferencesStore );
const { getEditedPostContext, getEditorMode, getCanvasMode } = unlock(
select( editSiteStore )
);
Expand All @@ -118,7 +119,6 @@ export default function Editor( { isLoading } ) {
const { getEntityRecord } = select( coreDataStore );
const { getRenderingMode, isInserterOpened, isListViewOpened } =
select( editorStore );
const { get } = select( preferencesStore );
const _context = getEditedPostContext();

// The currently selected entity to display.
Expand All @@ -141,11 +141,8 @@ export default function Editor( { isLoading } ) {
isRightSidebarOpen: getActiveComplementaryArea(
editSiteStore.name
),
showBlockBreadcrumbs: get( 'core', 'showBlockBreadcrumbs' ),
showIconLabels: get( 'core', 'showIconLabels' ),
showBlockBreadcrumbs: get(
'core/edit-site',
'showBlockBreadcrumbs'
),
};
}, [] );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export default function EditSitePreferencesModal() {
label={ __( 'Always open list view' ) }
/>
<EnableFeature
scope="core"
featureName="showBlockBreadcrumbs"
help={ __(
'Shows block breadcrumbs at the bottom of the editor.'
Expand Down
13 changes: 4 additions & 9 deletions packages/edit-site/src/hooks/commands/use-edit-mode-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ function useEditUICommands() {
isListViewOpen,
isDistractionFree,
} = useSelect( ( select ) => {
const { get } = select( preferencesStore );
const { getEditorMode } = select( editSiteStore );
const { isListViewOpened } = select( editorStore );
return {
Expand All @@ -225,15 +226,9 @@ function useEditUICommands() {
activeSidebar: select( interfaceStore ).getActiveComplementaryArea(
editSiteStore.name
),
showBlockBreadcrumbs: select( preferencesStore ).get(
'core/edit-site',
'showBlockBreadcrumbs'
),
showBlockBreadcrumbs: get( 'core', 'showBlockBreadcrumbs' ),
isListViewOpen: isListViewOpened(),
isDistractionFree: select( preferencesStore ).get(
editSiteStore.name,
'distractionFree'
),
isDistractionFree: get( editSiteStore.name, 'distractionFree' ),
};
}, [] );
const { openModal } = useDispatch( interfaceStore );
Expand Down Expand Up @@ -339,7 +334,7 @@ function useEditUICommands() {
? __( 'Hide block breadcrumbs' )
: __( 'Show block breadcrumbs' ),
callback: ( { close } ) => {
toggle( 'core/edit-site', 'showBlockBreadcrumbs' );
toggle( 'core', 'showBlockBreadcrumbs' );
close();
createInfoNotice(
showBlockBreadcrumbs
Expand Down
2 changes: 1 addition & 1 deletion packages/edit-site/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ export function initializeEditor( id, settings ) {
welcomeGuidePage: true,
welcomeGuideTemplate: true,
showListViewByDefault: false,
showBlockBreadcrumbs: true,
} );

dispatch( preferencesStore ).setDefaults( 'core', {
allowRightClickOverrides: true,
keepCaretInsideBlock: false,
showBlockBreadcrumbs: true,
} );

dispatch( interfaceStore ).setDefaultComplementaryArea(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export default function convertEditorSettings( data ) {
const settingsToMoveToCore = [
'allowRightClickOverrides',
'keepCaretInsideBlock',
'showBlockBreadcrumbs',
'showIconLabels',
];

Expand Down
Loading