From c5a425c5d23f8cd209414de60a31ee7fedf51c98 Mon Sep 17 00:00:00 2001 From: Ella Date: Wed, 21 Feb 2024 15:21:34 +0100 Subject: [PATCH] Move legacy meta boxes to toggle --- .../data/data-core-edit-post.md | 8 +++++ .../edit-post/src/components/header/index.js | 17 ++++++++-- .../edit-post/src/components/layout/index.js | 3 +- .../src/components/layout/style.scss | 9 ++++++ .../src/components/visual-editor/index.js | 32 ++----------------- packages/edit-post/src/store/actions.js | 4 +++ packages/edit-post/src/store/reducer.js | 9 ++++++ packages/edit-post/src/store/selectors.js | 4 +++ 8 files changed, 54 insertions(+), 32 deletions(-) diff --git a/docs/reference-guides/data/data-core-edit-post.md b/docs/reference-guides/data/data-core-edit-post.md index 0401734597d248..e5dd8917e6167c 100644 --- a/docs/reference-guides/data/data-core-edit-post.md +++ b/docs/reference-guides/data/data-core-edit-post.md @@ -328,6 +328,10 @@ _Returns_ - `boolean`: Whether the metaboxes are being saved. +### showMetaBoxes + +Undocumented declaration. + ## Actions @@ -522,6 +526,10 @@ _Parameters_ - _feature_ `string`: Feature name. +### toggleMetaBoxes + +Undocumented declaration. + ### togglePinnedPluginItem Triggers an action object used to toggle a plugin name flag. diff --git a/packages/edit-post/src/components/header/index.js b/packages/edit-post/src/components/header/index.js index b7e42d0217eefc..9b4d0a6e0ebf1d 100644 --- a/packages/edit-post/src/components/header/index.js +++ b/packages/edit-post/src/components/header/index.js @@ -18,9 +18,9 @@ import { privateApis as editorPrivateApis, } from '@wordpress/editor'; import { useEffect, useRef, useState } from '@wordpress/element'; -import { useSelect } from '@wordpress/data'; +import { useSelect, useDispatch } from '@wordpress/data'; import { __ } from '@wordpress/i18n'; -import { next, previous } from '@wordpress/icons'; +import { next, previous, box } from '@wordpress/icons'; import { PinnedItems } from '@wordpress/interface'; import { useViewportMatch } from '@wordpress/compose'; import { @@ -63,6 +63,7 @@ function Header( { setEntitiesSavedStatesCallback, initialPost } ) { isTextEditor, hasBlockSelection, hasActiveMetaboxes, + showMetaBoxes, hasFixedToolbar, isPublishSidebarOpened, showIconLabels, @@ -76,6 +77,7 @@ function Header( { setEntitiesSavedStatesCallback, initialPost } ) { hasBlockSelection: !! select( blockEditorStore ).getBlockSelectionStart(), hasActiveMetaboxes: select( editPostStore ).hasMetaBoxes(), + showMetaBoxes: select( editPostStore ).showMetaBoxes(), hasHistory: !! select( editorStore ).getEditorSettings() .onNavigateToPreviousEntityRecord, @@ -85,6 +87,7 @@ function Header( { setEntitiesSavedStatesCallback, initialPost } ) { showIconLabels: getPreference( 'core', 'showIconLabels' ), }; }, [] ); + const { toggleMetaBoxes } = useDispatch( editPostStore ); const [ isBlockToolsCollapsed, setIsBlockToolsCollapsed ] = useState( true ); @@ -187,6 +190,16 @@ function Header( { setEntitiesSavedStatesCallback, initialPost } ) { setEntitiesSavedStatesCallback } /> + { hasActiveMetaboxes && ( +