-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Expand file tree
/
Copy pathheader.js
More file actions
48 lines (43 loc) · 1.13 KB
/
header.js
File metadata and controls
48 lines (43 loc) · 1.13 KB
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
/**
* WordPress dependencies
*/
import { useSelect } from '@wordpress/data';
import { store as coreStore } from '@wordpress/core-data';
import { __experimentalHeading as Heading } from '@wordpress/components';
/**
* Internal dependencies
*/
import AddNewTemplate from '../add-new-template';
import { store as editSiteStore } from '../../store';
export default function Header( { templateType } ) {
const { canCreate, postType } = useSelect(
( select ) => {
const { supportsTemplatePartsMode } =
select( editSiteStore ).getSettings();
return {
postType: select( coreStore ).getPostType( templateType ),
canCreate: ! supportsTemplatePartsMode,
};
},
[ templateType ]
);
if ( ! postType ) {
return null;
}
return (
<header className="edit-site-list-header">
<Heading level={ 1 } className="edit-site-list-header__title">
{ postType.labels?.name }
</Heading>
{ canCreate && (
<div className="edit-site-list-header__right">
<AddNewTemplate
templateType={ templateType }
showIcon={ false }
toggleProps={ { variant: 'primary' } }
/>
</div>
) }
</header>
);
}