-
Notifications
You must be signed in to change notification settings - Fork 4.1k
/
panel.js
57 lines (49 loc) · 1.42 KB
/
panel.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { PanelBody, PanelRow } from '@wordpress/components';
import { useDispatch, useSelect } from '@wordpress/data';
/**
* Internal dependencies
*/
import { store as editorStore } from '../../store';
import PostTypeSupportCheck from '../post-type-support-check';
import PostComments from '../post-comments';
import PostPingbacks from '../post-pingbacks';
const PANEL_NAME = 'discussion-panel';
function PostDiscussionPanel() {
const { isEnabled, isOpened } = useSelect( ( select ) => {
const { isEditorPanelEnabled, isEditorPanelOpened } =
select( editorStore );
return {
isEnabled: isEditorPanelEnabled( PANEL_NAME ),
isOpened: isEditorPanelOpened( PANEL_NAME ),
};
}, [] );
const { toggleEditorPanelOpened } = useDispatch( editorStore );
if ( ! isEnabled ) {
return null;
}
return (
<PostTypeSupportCheck supportKeys={ [ 'comments', 'trackbacks' ] }>
<PanelBody
title={ __( 'Discussion' ) }
opened={ isOpened }
onToggle={ () => toggleEditorPanelOpened( PANEL_NAME ) }
>
<PostTypeSupportCheck supportKeys="comments">
<PanelRow>
<PostComments />
</PanelRow>
</PostTypeSupportCheck>
<PostTypeSupportCheck supportKeys="trackbacks">
<PanelRow>
<PostPingbacks />
</PanelRow>
</PostTypeSupportCheck>
</PanelBody>
</PostTypeSupportCheck>
);
}
export default PostDiscussionPanel;