File tree Expand file tree Collapse file tree 7 files changed +205
-152
lines changed
e2e-tests/specs/experiments Expand file tree Collapse file tree 7 files changed +205
-152
lines changed Original file line number Diff line number Diff line change @@ -207,8 +207,11 @@ describe( 'Multi-entity editor states', () => {
207
207
'.wp-block-template-part .block-editor-block-list__layout'
208
208
) ;
209
209
210
- // Our custom template shows up in the " templates > all" menu; let's use it.
211
- await clickTemplateItem ( [ 'Templates' , 'All' ] , templateName ) ;
210
+ // Our custom template shows up in the "Templates > General" menu; let's use it.
211
+ await clickTemplateItem (
212
+ [ 'Templates' , 'General templates' ] ,
213
+ templateName
214
+ ) ;
212
215
await page . waitForXPath (
213
216
`//h1[contains(@class, "edit-site-document-actions__title") and contains(text(), '${ templateName } ')]`
214
217
) ;
Original file line number Diff line number Diff line change 3
3
*/
4
4
import { __ } from '@wordpress/i18n' ;
5
5
6
- export const TEMPLATES_GENERAL = [
7
- 'front-page' ,
8
- 'archive' ,
9
- 'singular' ,
6
+ export const TEMPLATES_PRIMARY = [
10
7
'index' ,
11
- 'search' ,
8
+ 'singular' ,
9
+ 'archive' ,
10
+ 'single' ,
11
+ 'page' ,
12
+ 'home' ,
12
13
'404' ,
14
+ 'search' ,
15
+ ] ;
16
+
17
+ export const TEMPLATES_SECONDARY = [
18
+ 'author' ,
19
+ 'category' ,
20
+ 'taxonomy' ,
21
+ 'date' ,
22
+ 'tag' ,
23
+ 'attachment' ,
24
+ 'single-post' ,
25
+ 'front-page' ,
26
+ ] ;
27
+
28
+ export const TEMPLATES_TOP_LEVEL = [
29
+ ...TEMPLATES_PRIMARY ,
30
+ ...TEMPLATES_SECONDARY ,
31
+ ] ;
32
+
33
+ export const TEMPLATES_GENERAL = [ 'page-home' ] ;
34
+
35
+ export const TEMPLATES_POSTS_PREFIXES = [
36
+ 'post-' ,
37
+ 'author-' ,
38
+ 'single-post-' ,
39
+ 'tag-' ,
13
40
] ;
14
41
15
- export const TEMPLATES_POSTS = [ 'home' , 'single' , 'single-post ' ] ;
42
+ export const TEMPLATES_PAGES_PREFIXES = [ 'page- ' ] ;
16
43
17
44
export const TEMPLATES_NEW_OPTIONS = [
18
45
'front-page' ,
@@ -30,9 +57,10 @@ export const MENU_CONTENT_PAGES = 'content-pages';
30
57
export const MENU_CONTENT_POSTS = 'content-posts' ;
31
58
export const MENU_TEMPLATE_PARTS = 'template-parts' ;
32
59
export const MENU_TEMPLATES = 'templates' ;
33
- export const MENU_TEMPLATES_ALL = 'templates-all ' ;
60
+ export const MENU_TEMPLATES_GENERAL = 'templates-general ' ;
34
61
export const MENU_TEMPLATES_PAGES = 'templates-pages' ;
35
62
export const MENU_TEMPLATES_POSTS = 'templates-posts' ;
63
+ export const MENU_TEMPLATES_UNUSED = 'templates-unused' ;
36
64
37
65
export const SEARCH_DEBOUNCE_IN_MS = 75 ;
38
66
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -7,22 +7,31 @@ import { map } from 'lodash';
7
7
* WordPress dependencies
8
8
*/
9
9
import { __experimentalNavigationMenu as NavigationMenu } from '@wordpress/components' ;
10
- import { __ } from '@wordpress/i18n ' ;
10
+ import { useMemo } from '@wordpress/element ' ;
11
11
12
12
/**
13
13
* Internal dependencies
14
14
*/
15
15
import TemplateNavigationItem from '../template-navigation-item' ;
16
- import { MENU_TEMPLATES , MENU_TEMPLATES_ALL } from '../constants' ;
16
+ import { MENU_TEMPLATES } from '../constants' ;
17
+
18
+ export default function TemplatesSubMenu ( { menu, title, templates } ) {
19
+ const templatesFiltered = useMemo (
20
+ ( ) =>
21
+ templates
22
+ ?. filter ( ( { location } ) => location === menu )
23
+ ?. map ( ( { template } ) => template ) ?? [ ] ,
24
+ [ menu , templates ]
25
+ ) ;
17
26
18
- export default function TemplatesAllMenu ( { templates } ) {
19
27
return (
20
28
< NavigationMenu
21
- menu = { MENU_TEMPLATES_ALL }
22
- title = { __ ( 'All Templates' ) }
29
+ menu = { menu }
30
+ title = { title }
23
31
parentMenu = { MENU_TEMPLATES }
32
+ isEmpty = { templatesFiltered . length === 0 }
24
33
>
25
- { map ( templates , ( template ) => (
34
+ { map ( templatesFiltered , ( template ) => (
26
35
< TemplateNavigationItem
27
36
item = { template }
28
37
key = { `wp_template-${ template . id } ` }
You can’t perform that action at this time.
0 commit comments