@wordpress/edit-post
Version:
Edit Post module for WordPress.
29 lines (26 loc) • 763 B
JavaScript
/**
* 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 );