-
Notifications
You must be signed in to change notification settings - Fork 4.3k
/
Copy pathindex.js
80 lines (74 loc) · 2.18 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
/**
* WordPress dependencies
*/
import { store as coreStore } from '@wordpress/core-data';
import { useSelect } from '@wordpress/data';
import { InterfaceSkeleton } from '@wordpress/interface';
import { __, sprintf } from '@wordpress/i18n';
import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
/**
* Internal dependencies
*/
import useRegisterShortcuts from './use-register-shortcuts';
import Header from './header';
import NavigationSidebar from '../navigation-sidebar';
import Table from './table';
export default function List( { templateType } ) {
useRegisterShortcuts();
const { previousShortcut, nextShortcut } = useSelect( ( select ) => {
return {
previousShortcut: select(
keyboardShortcutsStore
).getAllShortcutKeyCombinations( 'core/edit-site/previous-region' ),
nextShortcut: select(
keyboardShortcutsStore
).getAllShortcutKeyCombinations( 'core/edit-site/next-region' ),
};
}, [] );
const postType = useSelect(
( select ) => select( coreStore ).getPostType( templateType ),
[ templateType ]
);
// `postType` could load in asynchronously. Only provide the detailed region labels if
// the postType has loaded, otherwise `InterfaceSkeleton` will fallback to the defaults.
const itemsListLabel = postType?.labels?.items_list;
const detailedRegionLabels = postType
? {
header: sprintf(
// translators: %s - the name of the page, 'Header' as in the header area of that page.
__( '%s - Header' ),
itemsListLabel
),
body: sprintf(
// translators: %s - the name of the page, 'Content' as in the content area of that page.
__( '%s - Content' ),
itemsListLabel
),
}
: undefined;
return (
<InterfaceSkeleton
className="edit-site-list"
labels={ {
drawer: __( 'Navigation Sidebar' ),
...detailedRegionLabels,
} }
header={ <Header templateType={ templateType } /> }
drawer={
<NavigationSidebar
activeTemplateType={ templateType }
isDefaultOpen
/>
}
content={
<main className="edit-site-list-main">
<Table templateType={ templateType } />
</main>
}
shortcuts={ {
previous: previousShortcut,
next: nextShortcut,
} }
/>
);
}