diff --git a/packages/edit-post/src/components/preferences-modal/test/__snapshots__/meta-boxes-section.js.snap b/packages/edit-post/src/components/preferences-modal/test/__snapshots__/meta-boxes-section.js.snap index 2246e0f12fdef..c39f90d4aa0e5 100644 --- a/packages/edit-post/src/components/preferences-modal/test/__snapshots__/meta-boxes-section.js.snap +++ b/packages/edit-post/src/components/preferences-modal/test/__snapshots__/meta-boxes-section.js.snap @@ -65,42 +65,46 @@ exports[`MetaBoxesSection renders a Custom Fields option 1`] = `
- - - - - - + + + + + + +
@@ -173,126 +177,130 @@ exports[`MetaBoxesSection renders a Custom Fields option and meta box options 1`
- - - - - - + + + + + + +
- -
- - - - - - + + + + + + +
- -
- - - - - - + + + + + + +
@@ -365,85 +373,89 @@ exports[`MetaBoxesSection renders meta box options 1`] = `
- - - - - - + + + + + + +
- -
- - - - - - + + + + + + +
diff --git a/packages/edit-post/src/index.js b/packages/edit-post/src/index.js index 0395c1f4beefa..6a84ce20978f6 100644 --- a/packages/edit-post/src/index.js +++ b/packages/edit-post/src/index.js @@ -57,9 +57,7 @@ export function initializeEditor( editorMode: 'visual', fullscreenMode: true, hiddenBlockTypes: [], - inactivePanels: [], isPublishSidebarEnabled: true, - openPanels: [ 'post-status' ], preferredStyleVariations: {}, themeStyles: true, welcomeGuide: true, @@ -69,6 +67,8 @@ export function initializeEditor( dispatch( preferencesStore ).setDefaults( 'core', { allowRightClickOverrides: true, fixedToolbar: false, + inactivePanels: [], + openPanels: [ 'post-status' ], showBlockBreadcrumbs: true, showIconLabels: false, showListViewByDefault: false, diff --git a/packages/edit-post/src/index.native.js b/packages/edit-post/src/index.native.js index 2828d5317d232..974f617d609f2 100644 --- a/packages/edit-post/src/index.native.js +++ b/packages/edit-post/src/index.native.js @@ -31,6 +31,10 @@ export function initializeEditor( id, postType, postId ) { preferredStyleVariations: {}, welcomeGuide: true, } ); + dispatch( preferencesStore ).setDefaults( 'core', { + inactivePanels: [], + openPanels: [ 'post-status' ], + } ); dispatch( preferencesStore ).setDefaults( 'core', { fixedToolbar: false, diff --git a/packages/edit-post/src/store/selectors.js b/packages/edit-post/src/store/selectors.js index dff5f27c8918a..0d879493f995b 100644 --- a/packages/edit-post/src/store/selectors.js +++ b/packages/edit-post/src/store/selectors.js @@ -186,13 +186,10 @@ export const getPreferences = createRegistrySelector( ( select ) => () => { // the new preferences store format to old format to ensure no breaking // changes for plugins. const inactivePanels = select( preferencesStore ).get( - 'core/edit-post', + 'core', 'inactivePanels' ); - const openPanels = select( preferencesStore ).get( - 'core/edit-post', - 'openPanels' - ); + const openPanels = select( preferencesStore ).get( 'core', 'openPanels' ); const panels = convertPanelsToOldFormat( inactivePanels, openPanels ); return { diff --git a/packages/edit-site/src/components/preferences-modal/enable-panel-option.js b/packages/edit-site/src/components/preferences-modal/enable-panel-option.js new file mode 100644 index 0000000000000..6c9ea22b7f17d --- /dev/null +++ b/packages/edit-site/src/components/preferences-modal/enable-panel-option.js @@ -0,0 +1,23 @@ +/** + * WordPress dependencies + */ +import { compose, ifCondition } from '@wordpress/compose'; +import { withSelect, withDispatch } from '@wordpress/data'; +import { ___unstablePreferencesModalBaseOption as BaseOption } from '@wordpress/interface'; +import { store as editorStore } from '@wordpress/editor'; + +export default compose( + withSelect( ( select, { panelName } ) => { + const { isEditorPanelEnabled, isEditorPanelRemoved } = + select( editorStore ); + return { + isRemoved: isEditorPanelRemoved( panelName ), + isChecked: isEditorPanelEnabled( panelName ), + }; + } ), + ifCondition( ( { isRemoved } ) => ! isRemoved ), + withDispatch( ( dispatch, { panelName } ) => ( { + onChange: () => + dispatch( editorStore ).toggleEditorPanelEnabled( panelName ), + } ) ) +)( BaseOption ); diff --git a/packages/edit-site/src/components/preferences-modal/index.js b/packages/edit-site/src/components/preferences-modal/index.js index 39e6f289bbd54..7960e23d2023f 100644 --- a/packages/edit-site/src/components/preferences-modal/index.js +++ b/packages/edit-site/src/components/preferences-modal/index.js @@ -11,12 +11,20 @@ import { useMemo } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; import { useSelect, useDispatch, useRegistry } from '@wordpress/data'; import { store as preferencesStore } from '@wordpress/preferences'; -import { store as editorStore } from '@wordpress/editor'; +import { + PostTaxonomies, + PostExcerptCheck, + PageAttributesCheck, + PostFeaturedImageCheck, + PostTypeSupportCheck, + store as editorStore, +} from '@wordpress/editor'; /** * Internal dependencies */ import EnableFeature from './enable-feature'; +import EnablePanelOption from './enable-panel-option'; import { store as editSiteStore } from '../../store'; export const PREFERENCES_MODAL_NAME = 'edit-site/preferences'; @@ -52,32 +60,75 @@ export default function EditSitePreferencesModal() { name: 'general', tabLabel: __( 'General' ), content: ( - - - - + + + + + + - + > + ( + + ) } + /> + + + + + + + + + + + + + + ), }, { diff --git a/packages/edit-site/src/index.js b/packages/edit-site/src/index.js index 0ac3558d5740a..c145147b5e2ef 100644 --- a/packages/edit-site/src/index.js +++ b/packages/edit-site/src/index.js @@ -64,7 +64,9 @@ export function initializeEditor( id, settings ) { allowRightClickOverrides: true, fixedToolbar: false, focusMode: false, + inactivePanels: [], keepCaretInsideBlock: false, + openPanels: [ 'post-status' ], showBlockBreadcrumbs: true, showListViewByDefault: false, } ); diff --git a/packages/editor/src/store/actions.js b/packages/editor/src/store/actions.js index 49f49a5d06da5..a0330321bac8f 100644 --- a/packages/editor/src/store/actions.js +++ b/packages/editor/src/store/actions.js @@ -624,7 +624,7 @@ export const toggleEditorPanelEnabled = const inactivePanels = registry .select( preferencesStore ) - .get( 'core/edit-post', 'inactivePanels' ) ?? []; + .get( 'core', 'inactivePanels' ) ?? []; const isPanelInactive = !! inactivePanels?.includes( panelName ); @@ -641,7 +641,7 @@ export const toggleEditorPanelEnabled = registry .dispatch( preferencesStore ) - .set( 'core/edit-post', 'inactivePanels', updatedInactivePanels ); + .set( 'core', 'inactivePanels', updatedInactivePanels ); }; /** @@ -653,9 +653,8 @@ export const toggleEditorPanelOpened = ( panelName ) => ( { registry } ) => { const openPanels = - registry - .select( preferencesStore ) - .get( 'core/edit-post', 'openPanels' ) ?? []; + registry.select( preferencesStore ).get( 'core', 'openPanels' ) ?? + []; const isPanelOpen = !! openPanels?.includes( panelName ); @@ -672,7 +671,7 @@ export const toggleEditorPanelOpened = registry .dispatch( preferencesStore ) - .set( 'core/edit-post', 'openPanels', updatedOpenPanels ); + .set( 'core', 'openPanels', updatedOpenPanels ); }; /** diff --git a/packages/editor/src/store/selectors.js b/packages/editor/src/store/selectors.js index 70d726638a094..107ffe4dd4625 100644 --- a/packages/editor/src/store/selectors.js +++ b/packages/editor/src/store/selectors.js @@ -1152,7 +1152,7 @@ export const isEditorPanelEnabled = createRegistrySelector( // For backward compatibility, we check edit-post // even though now this is in "editor" package. const inactivePanels = select( preferencesStore ).get( - 'core/edit-post', + 'core', 'inactivePanels' ); return ( @@ -1176,7 +1176,7 @@ export const isEditorPanelOpened = createRegistrySelector( // For backward compatibility, we check edit-post // even though now this is in "editor" package. const openPanels = select( preferencesStore ).get( - 'core/edit-post', + 'core', 'openPanels' ); return !! openPanels?.includes( panelName ); diff --git a/packages/interface/src/components/preferences-modal-section/index.js b/packages/interface/src/components/preferences-modal-section/index.js index ea164128ea54c..8ea2ca2652d6d 100644 --- a/packages/interface/src/components/preferences-modal-section/index.js +++ b/packages/interface/src/components/preferences-modal-section/index.js @@ -10,7 +10,9 @@ const Section = ( { description, title, children } ) => (

) } - { children } +
+ { children } +
); diff --git a/packages/interface/src/components/preferences-modal-section/style.scss b/packages/interface/src/components/preferences-modal-section/style.scss index 1a45642a8b7af..a1259af3430d5 100644 --- a/packages/interface/src/components/preferences-modal-section/style.scss +++ b/packages/interface/src/components/preferences-modal-section/style.scss @@ -22,3 +22,7 @@ font-style: normal; color: $gray-700; } + +.interface-preferences-modal__section:has(.interface-preferences-modal__section-content:empty) { + display: none; +} diff --git a/packages/preferences-persistence/src/migrations/preferences-package-data/convert-editor-settings.js b/packages/preferences-persistence/src/migrations/preferences-package-data/convert-editor-settings.js index e5be380a309c3..b245fb958571f 100644 --- a/packages/preferences-persistence/src/migrations/preferences-package-data/convert-editor-settings.js +++ b/packages/preferences-persistence/src/migrations/preferences-package-data/convert-editor-settings.js @@ -8,7 +8,9 @@ export default function convertEditorSettings( data ) { 'allowRightClickOverrides', 'fixedToolbar', 'focusMode', + 'inactivePanels', 'keepCaretInsideBlock', + 'openPanels', 'showBlockBreadcrumbs', 'showIconLabels', 'showListViewByDefault', diff --git a/packages/preferences-persistence/src/migrations/preferences-package-data/test/index.js b/packages/preferences-persistence/src/migrations/preferences-package-data/test/index.js index 693d9586af5e4..ffa39e630f509 100644 --- a/packages/preferences-persistence/src/migrations/preferences-package-data/test/index.js +++ b/packages/preferences-persistence/src/migrations/preferences-package-data/test/index.js @@ -44,6 +44,10 @@ describe( 'convertPreferencesPackageData', () => { { "core": { "fixedToolbar": true, + "inactivePanels": [], + "openPanels": [ + "post-status", + ], }, "core/customize-widgets": { "fixedToolbar": true, @@ -56,10 +60,6 @@ describe( 'convertPreferencesPackageData', () => { "core/audio", "core/cover", ], - "inactivePanels": [], - "openPanels": [ - "post-status", - ], "pinnedItems": { "my-sidebar-plugin/title-sidebar": false, },