UNPKG

@wordpress/edit-post

Version:
69 lines (62 loc) 1.51 kB
/** * WordPress dependencies */ import { __ } from '@wordpress/i18n'; import { PanelBody, PanelRow } from '@wordpress/components'; import { PostComments, PostPingbacks, PostTypeSupportCheck, } from '@wordpress/editor'; import { compose } from '@wordpress/compose'; import { withSelect, withDispatch } from '@wordpress/data'; /** * Internal dependencies */ import { store as editPostStore } from '../../../store'; /** * Module Constants */ const PANEL_NAME = 'discussion-panel'; function DiscussionPanel( { isEnabled, isOpened, onTogglePanel } ) { if ( ! isEnabled ) { return null; } return ( <PostTypeSupportCheck supportKeys={ [ 'comments', 'trackbacks' ] }> <PanelBody title={ __( 'Discussion' ) } opened={ isOpened } onToggle={ onTogglePanel } > <PostTypeSupportCheck supportKeys="comments"> <PanelRow> <PostComments /> </PanelRow> </PostTypeSupportCheck> <PostTypeSupportCheck supportKeys="trackbacks"> <PanelRow> <PostPingbacks /> </PanelRow> </PostTypeSupportCheck> </PanelBody> </PostTypeSupportCheck> ); } export default compose( [ withSelect( ( select ) => { return { isEnabled: select( editPostStore ).isEditorPanelEnabled( PANEL_NAME ), isOpened: select( editPostStore ).isEditorPanelOpened( PANEL_NAME ), }; } ), withDispatch( ( dispatch ) => ( { onTogglePanel() { return dispatch( editPostStore ).toggleEditorPanelOpened( PANEL_NAME ); }, } ) ), ] )( DiscussionPanel );