UNPKG

@wordpress/edit-post

Version:
29 lines (26 loc) 763 B
/** * WordPress dependencies */ import { compose, ifCondition } from '@wordpress/compose'; import { withSelect, withDispatch } from '@wordpress/data'; /** * Internal dependencies */ import BaseOption from './base'; import { store as editPostStore } from '../../../store'; export default compose( withSelect( ( select, { panelName } ) => { const { isEditorPanelEnabled, isEditorPanelRemoved } = select( editPostStore ); return { isRemoved: isEditorPanelRemoved( panelName ), isChecked: isEditorPanelEnabled( panelName ), }; } ), ifCondition( ( { isRemoved } ) => ! isRemoved ), withDispatch( ( dispatch, { panelName } ) => ( { onChange: () => dispatch( editPostStore ).toggleEditorPanelEnabled( panelName ), } ) ) )( BaseOption );