-
Notifications
You must be signed in to change notification settings - Fork 4k
/
index.js
86 lines (81 loc) · 2.21 KB
/
index.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import {
__experimentalHStack as HStack,
PanelBody,
} from '@wordpress/components';
import { useDispatch, useSelect } from '@wordpress/data';
import { PostSwitchToDraftButton, PostSyncStatus } from '@wordpress/editor';
/**
* Internal dependencies
*/
import PostVisibility from '../post-visibility';
import PostTrash from '../post-trash';
import PostSchedule from '../post-schedule';
import PostSticky from '../post-sticky';
import PostAuthor from '../post-author';
import PostSlug from '../post-slug';
import PostFormat from '../post-format';
import PostPendingStatus from '../post-pending-status';
import PluginPostStatusInfo from '../plugin-post-status-info';
import { store as editPostStore } from '../../../store';
import PostTemplate from '../post-template';
import PostURL from '../post-url';
/**
* Module Constants
*/
const PANEL_NAME = 'post-status';
export default function PostStatus() {
const { isOpened, isRemoved } = useSelect( ( select ) => {
// We use isEditorPanelRemoved to hide the panel if it was programatically removed. We do
// not use isEditorPanelEnabled since this panel should not be disabled through the UI.
const { isEditorPanelRemoved, isEditorPanelOpened } =
select( editPostStore );
return {
isRemoved: isEditorPanelRemoved( PANEL_NAME ),
isOpened: isEditorPanelOpened( PANEL_NAME ),
};
}, [] );
const { toggleEditorPanelOpened } = useDispatch( editPostStore );
if ( isRemoved ) {
return null;
}
return (
<PanelBody
className="edit-post-post-status"
title={ __( 'Summary' ) }
opened={ isOpened }
onToggle={ () => toggleEditorPanelOpened( PANEL_NAME ) }
>
<PluginPostStatusInfo.Slot>
{ ( fills ) => (
<>
<PostVisibility />
<PostSchedule />
<PostTemplate />
<PostURL />
<PostSticky />
<PostPendingStatus />
<PostFormat />
<PostSlug />
<PostAuthor />
<PostSyncStatus />
{ fills }
<HStack
style={ {
marginTop: '16px',
} }
spacing={ 4 }
wrap
>
<PostSwitchToDraftButton />
<PostTrash />
</HStack>
</>
) }
</PluginPostStatusInfo.Slot>
</PanelBody>
);
}