From 93c66f9be616ea32e8796653e81ff9690fec70cf Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Thu, 4 Jan 2024 08:13:48 +0100 Subject: [PATCH 1/2] Editor: Unify the top toolbar preference --- .../src/editor/set-is-fixed-toolbar.ts | 2 +- packages/edit-post/src/components/header/index.js | 2 +- .../src/components/header/writing-menu/index.js | 4 ++-- .../src/components/preferences-modal/index.js | 3 ++- packages/edit-post/src/editor.js | 9 +-------- packages/edit-post/src/editor.native.js | 14 ++------------ .../src/hooks/commands/use-common-commands.js | 2 +- packages/edit-post/src/index.js | 2 +- packages/edit-post/src/index.native.js | 5 ++++- packages/edit-post/src/store/actions.js | 2 +- packages/edit-post/src/store/test/actions.js | 4 ++-- .../block-editor/use-site-editor-settings.js | 6 ------ .../src/components/header-edit-mode/index.js | 5 +---- .../components/header-edit-mode/more-menu/index.js | 4 ++-- packages/edit-site/src/components/layout/index.js | 2 +- .../src/components/preferences-modal/index.js | 2 +- .../src/hooks/commands/use-edit-mode-commands.js | 2 +- packages/edit-site/src/index.js | 2 +- packages/edit-site/src/store/actions.js | 2 +- packages/edit-site/src/store/test/actions.js | 4 ++-- .../provider/use-block-editor-settings.js | 5 ++++- .../convert-editor-settings.js | 1 + .../preferences-package-data/test/index.js | 5 +++-- test/e2e/specs/editor/blocks/links.spec.js | 4 ++-- 24 files changed, 38 insertions(+), 55 deletions(-) diff --git a/packages/e2e-test-utils-playwright/src/editor/set-is-fixed-toolbar.ts b/packages/e2e-test-utils-playwright/src/editor/set-is-fixed-toolbar.ts index 93c2cd14e1ebc5..ab7baef5967f0f 100644 --- a/packages/e2e-test-utils-playwright/src/editor/set-is-fixed-toolbar.ts +++ b/packages/e2e-test-utils-playwright/src/editor/set-is-fixed-toolbar.ts @@ -15,6 +15,6 @@ export async function setIsFixedToolbar( this: Editor, isFixed: boolean ) { await this.page.evaluate( ( _isFixed ) => { window.wp.data .dispatch( 'core/preferences' ) - .set( 'core/edit-post', 'fixedToolbar', _isFixed ); + .set( 'core', 'fixedToolbar', _isFixed ); }, isFixed ); } diff --git a/packages/edit-post/src/components/header/index.js b/packages/edit-post/src/components/header/index.js index 82705424175f35..b76b89ff7673db 100644 --- a/packages/edit-post/src/components/header/index.js +++ b/packages/edit-post/src/components/header/index.js @@ -82,7 +82,7 @@ function Header( { setEntitiesSavedStatesCallback } ) { select( editorStore ).getRenderingMode() === 'template-only', isPublishSidebarOpened: select( editPostStore ).isPublishSidebarOpened(), - hasFixedToolbar: getPreference( 'core/edit-post', 'fixedToolbar' ), + hasFixedToolbar: getPreference( 'core', 'fixedToolbar' ), showIconLabels: getPreference( 'core', 'showIconLabels' ), }; }, [] ); diff --git a/packages/edit-post/src/components/header/writing-menu/index.js b/packages/edit-post/src/components/header/writing-menu/index.js index f0a4dc762ac5c0..0c01a4df24f3a5 100644 --- a/packages/edit-post/src/components/header/writing-menu/index.js +++ b/packages/edit-post/src/components/header/writing-menu/index.js @@ -27,7 +27,7 @@ function WritingMenu() { const toggleDistractionFree = () => { registry.batch( () => { - setPreference( 'core/edit-post', 'fixedToolbar', true ); + setPreference( 'core', 'fixedToolbar', true ); setIsInserterOpened( false ); setIsListViewOpened( false ); closeGeneralSidebar(); @@ -46,7 +46,7 @@ function WritingMenu() { return ( { - setPreference( 'core/edit-post', 'fixedToolbar', true ); + setPreference( 'core', 'fixedToolbar', true ); setIsInserterOpened( false ); setIsListViewOpened( false ); closeGeneralSidebar(); @@ -186,6 +186,7 @@ export default function EditPostPreferencesModal() { ) } >