@wordpress/edit-site 6.42.0 → 6.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/components/page-patterns/index.cjs +7 -27
- package/build/components/page-patterns/index.cjs.map +2 -2
- package/build/components/page-templates/index-legacy.cjs +13 -6
- package/build/components/page-templates/index-legacy.cjs.map +2 -2
- package/build/components/post-list/index.cjs +15 -6
- package/build/components/post-list/index.cjs.map +2 -2
- package/build/components/post-list/quick-edit-modal.cjs +16 -48
- package/build/components/post-list/quick-edit-modal.cjs.map +2 -2
- package/build/components/sidebar-dataviews/index.cjs +37 -25
- package/build/components/sidebar-dataviews/index.cjs.map +3 -3
- package/build/components/sidebar-navigation-screen-patterns/index.cjs +55 -47
- package/build/components/sidebar-navigation-screen-patterns/index.cjs.map +2 -2
- package/build/components/sidebar-navigation-screen-templates-browse/content-legacy.cjs +33 -56
- package/build/components/sidebar-navigation-screen-templates-browse/content-legacy.cjs.map +3 -3
- package/build/components/site-editor-routes/home.cjs +8 -4
- package/build/components/site-editor-routes/home.cjs.map +2 -2
- package/build/components/site-editor-routes/navigation-item.cjs +13 -6
- package/build/components/site-editor-routes/navigation-item.cjs.map +2 -2
- package/build/components/site-editor-routes/navigation.cjs +9 -4
- package/build/components/site-editor-routes/navigation.cjs.map +2 -2
- package/build/components/site-editor-routes/page-item.cjs +13 -6
- package/build/components/site-editor-routes/page-item.cjs.map +2 -2
- package/build/components/site-editor-routes/pages.cjs +21 -7
- package/build/components/site-editor-routes/pages.cjs.map +3 -3
- package/build/components/site-editor-routes/stylebook.cjs +17 -2
- package/build/components/site-editor-routes/stylebook.cjs.map +2 -2
- package/build/components/site-editor-routes/template-item.cjs +13 -6
- package/build/components/site-editor-routes/template-item.cjs.map +2 -2
- package/build/components/site-editor-routes/templates.cjs +20 -7
- package/build/components/site-editor-routes/templates.cjs.map +3 -3
- package/build/components/site-editor-routes/utils.cjs +7 -2
- package/build/components/site-editor-routes/utils.cjs.map +2 -2
- package/build-module/components/page-patterns/index.mjs +8 -30
- package/build-module/components/page-patterns/index.mjs.map +2 -2
- package/build-module/components/page-templates/index-legacy.mjs +14 -11
- package/build-module/components/page-templates/index-legacy.mjs.map +2 -2
- package/build-module/components/post-list/index.mjs +16 -11
- package/build-module/components/post-list/index.mjs.map +2 -2
- package/build-module/components/post-list/quick-edit-modal.mjs +16 -48
- package/build-module/components/post-list/quick-edit-modal.mjs.map +2 -2
- package/build-module/components/sidebar-dataviews/index.mjs +45 -25
- package/build-module/components/sidebar-dataviews/index.mjs.map +2 -2
- package/build-module/components/sidebar-navigation-screen-patterns/index.mjs +55 -47
- package/build-module/components/sidebar-navigation-screen-patterns/index.mjs.map +2 -2
- package/build-module/components/sidebar-navigation-screen-templates-browse/content-legacy.mjs +41 -59
- package/build-module/components/sidebar-navigation-screen-templates-browse/content-legacy.mjs.map +2 -2
- package/build-module/components/site-editor-routes/home.mjs +10 -6
- package/build-module/components/site-editor-routes/home.mjs.map +2 -2
- package/build-module/components/site-editor-routes/navigation-item.mjs +14 -7
- package/build-module/components/site-editor-routes/navigation-item.mjs.map +2 -2
- package/build-module/components/site-editor-routes/navigation.mjs +10 -5
- package/build-module/components/site-editor-routes/navigation.mjs.map +2 -2
- package/build-module/components/site-editor-routes/page-item.mjs +14 -7
- package/build-module/components/site-editor-routes/page-item.mjs.map +2 -2
- package/build-module/components/site-editor-routes/pages.mjs +22 -11
- package/build-module/components/site-editor-routes/pages.mjs.map +2 -2
- package/build-module/components/site-editor-routes/stylebook.mjs +18 -3
- package/build-module/components/site-editor-routes/stylebook.mjs.map +2 -2
- package/build-module/components/site-editor-routes/template-item.mjs +14 -7
- package/build-module/components/site-editor-routes/template-item.mjs.map +2 -2
- package/build-module/components/site-editor-routes/templates.mjs +21 -11
- package/build-module/components/site-editor-routes/templates.mjs.map +2 -2
- package/build-module/components/site-editor-routes/utils.mjs +5 -1
- package/build-module/components/site-editor-routes/utils.mjs.map +2 -2
- package/build-style/style-rtl.css +60 -49
- package/build-style/style.css +60 -49
- package/package.json +46 -46
- package/src/components/page-patterns/index.js +9 -30
- package/src/components/page-templates/index-legacy.js +14 -11
- package/src/components/post-list/index.js +16 -10
- package/src/components/post-list/quick-edit-modal.js +19 -54
- package/src/components/post-list/style.scss +2 -0
- package/src/components/sidebar-dataviews/index.js +48 -26
- package/src/components/sidebar-dataviews/style.scss +0 -16
- package/src/components/sidebar-navigation-screen-patterns/index.js +62 -55
- package/src/components/sidebar-navigation-screen-templates-browse/content-legacy.js +44 -64
- package/src/components/site-editor-routes/home.js +9 -5
- package/src/components/site-editor-routes/navigation-item.js +13 -6
- package/src/components/site-editor-routes/navigation.js +9 -4
- package/src/components/site-editor-routes/page-item.js +13 -6
- package/src/components/site-editor-routes/pages.js +21 -10
- package/src/components/site-editor-routes/stylebook.js +12 -3
- package/src/components/site-editor-routes/template-item.js +13 -6
- package/src/components/site-editor-routes/templates.js +21 -10
- package/src/components/site-editor-routes/utils.js +12 -0
- package/build/components/post-list/view-utils.cjs +0 -202
- package/build/components/post-list/view-utils.cjs.map +0 -7
- package/build/components/sidebar-dataviews/dataview-item.cjs +0 -82
- package/build/components/sidebar-dataviews/dataview-item.cjs.map +0 -7
- package/build-module/components/post-list/view-utils.mjs +0 -182
- package/build-module/components/post-list/view-utils.mjs.map +0 -7
- package/build-module/components/sidebar-dataviews/dataview-item.mjs +0 -51
- package/build-module/components/sidebar-dataviews/dataview-item.mjs.map +0 -7
- package/src/components/post-list/view-utils.js +0 -187
- package/src/components/sidebar-dataviews/dataview-item.js +0 -56
|
@@ -6,9 +6,11 @@ import {
|
|
|
6
6
|
__experimentalItem as Item,
|
|
7
7
|
} from '@wordpress/components';
|
|
8
8
|
import { getTemplatePartIcon } from '@wordpress/editor';
|
|
9
|
+
import { useMemo } from '@wordpress/element';
|
|
9
10
|
import { __ } from '@wordpress/i18n';
|
|
10
11
|
import { file } from '@wordpress/icons';
|
|
11
12
|
import { privateApis as routerPrivateApis } from '@wordpress/router';
|
|
13
|
+
import { useViewConfig } from '@wordpress/views';
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
* Internal dependencies
|
|
@@ -28,70 +30,44 @@ import { unlock } from '../../lock-unlock';
|
|
|
28
30
|
const { useLocation } = unlock( routerPrivateApis );
|
|
29
31
|
|
|
30
32
|
function CategoriesGroup( {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
templatePartViews,
|
|
34
|
+
patternViews,
|
|
35
|
+
templatePartCounts,
|
|
36
|
+
patternCounts,
|
|
33
37
|
currentCategory,
|
|
34
38
|
currentType,
|
|
35
39
|
} ) {
|
|
36
|
-
const [ allPatterns, ...otherPatterns ] = patternCategories;
|
|
37
|
-
|
|
38
40
|
return (
|
|
39
41
|
<ItemGroup className="edit-site-sidebar-navigation-screen-patterns__group">
|
|
40
|
-
|
|
41
|
-
key="all"
|
|
42
|
-
count={ Object.values( templatePartAreas )
|
|
43
|
-
.map( ( { templateParts } ) => templateParts?.length || 0 )
|
|
44
|
-
.reduce( ( acc, val ) => acc + val, 0 ) }
|
|
45
|
-
icon={ getTemplatePartIcon() } /* no name, so it provides the fallback icon */
|
|
46
|
-
label={ __( 'All template parts' ) }
|
|
47
|
-
id={ TEMPLATE_PART_ALL_AREAS_CATEGORY }
|
|
48
|
-
type={ TEMPLATE_PART_POST_TYPE }
|
|
49
|
-
isActive={
|
|
50
|
-
currentCategory === TEMPLATE_PART_ALL_AREAS_CATEGORY &&
|
|
51
|
-
currentType === TEMPLATE_PART_POST_TYPE
|
|
52
|
-
}
|
|
53
|
-
/>
|
|
54
|
-
{ Object.entries( templatePartAreas ).map(
|
|
55
|
-
( [ area, { label, templateParts, icon } ] ) => (
|
|
56
|
-
<CategoryItem
|
|
57
|
-
key={ area }
|
|
58
|
-
count={ templateParts?.length }
|
|
59
|
-
icon={ getTemplatePartIcon( icon ) }
|
|
60
|
-
label={ label }
|
|
61
|
-
id={ area }
|
|
62
|
-
type={ TEMPLATE_PART_POST_TYPE }
|
|
63
|
-
isActive={
|
|
64
|
-
currentCategory === area &&
|
|
65
|
-
currentType === TEMPLATE_PART_POST_TYPE
|
|
66
|
-
}
|
|
67
|
-
/>
|
|
68
|
-
)
|
|
69
|
-
) }
|
|
70
|
-
<div className="edit-site-sidebar-navigation-screen-patterns__divider" />
|
|
71
|
-
{ allPatterns && (
|
|
42
|
+
{ templatePartViews?.map( ( view ) => (
|
|
72
43
|
<CategoryItem
|
|
73
|
-
key={
|
|
74
|
-
count={
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
44
|
+
key={ view.slug }
|
|
45
|
+
count={ templatePartCounts[ view.slug ] }
|
|
46
|
+
icon={ getTemplatePartIcon(
|
|
47
|
+
view.slug === TEMPLATE_PART_ALL_AREAS_CATEGORY
|
|
48
|
+
? undefined
|
|
49
|
+
: view.slug
|
|
50
|
+
) }
|
|
51
|
+
label={ view.title }
|
|
52
|
+
id={ view.slug }
|
|
53
|
+
type={ TEMPLATE_PART_POST_TYPE }
|
|
79
54
|
isActive={
|
|
80
|
-
currentCategory ===
|
|
81
|
-
currentType ===
|
|
55
|
+
currentCategory === view.slug &&
|
|
56
|
+
currentType === TEMPLATE_PART_POST_TYPE
|
|
82
57
|
}
|
|
83
58
|
/>
|
|
84
|
-
) }
|
|
85
|
-
|
|
59
|
+
) ) }
|
|
60
|
+
<div className="edit-site-sidebar-navigation-screen-patterns__divider" />
|
|
61
|
+
{ patternViews?.map( ( view ) => (
|
|
86
62
|
<CategoryItem
|
|
87
|
-
key={
|
|
88
|
-
count={
|
|
89
|
-
label={
|
|
63
|
+
key={ view.slug }
|
|
64
|
+
count={ patternCounts[ view.slug ] }
|
|
65
|
+
label={ view.title }
|
|
90
66
|
icon={ file }
|
|
91
|
-
id={
|
|
67
|
+
id={ view.slug }
|
|
92
68
|
type={ PATTERN_TYPES.user }
|
|
93
69
|
isActive={
|
|
94
|
-
currentCategory === `${
|
|
70
|
+
currentCategory === `${ view.slug }` &&
|
|
95
71
|
currentType === PATTERN_TYPES.user
|
|
96
72
|
}
|
|
97
73
|
/>
|
|
@@ -110,9 +86,38 @@ export default function SidebarNavigationScreenPatterns( { backPath } ) {
|
|
|
110
86
|
? PATTERN_DEFAULT_CATEGORY
|
|
111
87
|
: TEMPLATE_PART_ALL_AREAS_CATEGORY );
|
|
112
88
|
|
|
113
|
-
const {
|
|
89
|
+
const { view_list: templatePartViews } = useViewConfig( {
|
|
90
|
+
kind: 'postType',
|
|
91
|
+
name: TEMPLATE_PART_POST_TYPE,
|
|
92
|
+
} );
|
|
93
|
+
const { view_list: patternViews } = useViewConfig( {
|
|
94
|
+
kind: 'postType',
|
|
95
|
+
name: PATTERN_TYPES.user,
|
|
96
|
+
} );
|
|
97
|
+
|
|
98
|
+
const { templatePartAreas, isLoading, hasTemplateParts } =
|
|
114
99
|
useTemplatePartAreas();
|
|
115
|
-
const
|
|
100
|
+
const templatePartCounts = useMemo( () => {
|
|
101
|
+
const counts = { [ TEMPLATE_PART_ALL_AREAS_CATEGORY ]: 0 };
|
|
102
|
+
Object.entries( templatePartAreas ).forEach(
|
|
103
|
+
( [ area, { templateParts } ] ) => {
|
|
104
|
+
const count = templateParts?.length || 0;
|
|
105
|
+
counts[ area ] = count;
|
|
106
|
+
counts[ TEMPLATE_PART_ALL_AREAS_CATEGORY ] += count;
|
|
107
|
+
}
|
|
108
|
+
);
|
|
109
|
+
return counts;
|
|
110
|
+
}, [ templatePartAreas ] );
|
|
111
|
+
const { patternCategories } = usePatternCategories();
|
|
112
|
+
const patternCounts = useMemo( () => {
|
|
113
|
+
const counts = {};
|
|
114
|
+
patternCategories.forEach( ( cat ) => {
|
|
115
|
+
counts[ cat.name ] = cat.count;
|
|
116
|
+
} );
|
|
117
|
+
return counts;
|
|
118
|
+
}, [ patternCategories ] );
|
|
119
|
+
|
|
120
|
+
const hasPatterns = patternCounts[ PATTERN_DEFAULT_CATEGORY ] > 0;
|
|
116
121
|
|
|
117
122
|
return (
|
|
118
123
|
<SidebarNavigationScreen
|
|
@@ -133,8 +138,10 @@ export default function SidebarNavigationScreenPatterns( { backPath } ) {
|
|
|
133
138
|
</ItemGroup>
|
|
134
139
|
) }
|
|
135
140
|
<CategoriesGroup
|
|
136
|
-
|
|
137
|
-
|
|
141
|
+
templatePartViews={ templatePartViews }
|
|
142
|
+
patternViews={ patternViews }
|
|
143
|
+
templatePartCounts={ templatePartCounts }
|
|
144
|
+
patternCounts={ patternCounts }
|
|
138
145
|
currentCategory={ currentCategory }
|
|
139
146
|
currentType={ postType }
|
|
140
147
|
/>
|
|
@@ -1,79 +1,59 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
5
|
+
import { useSelect } from '@wordpress/data';
|
|
6
|
+
import {
|
|
7
|
+
commentAuthorAvatar,
|
|
8
|
+
layout,
|
|
9
|
+
plugins as pluginIcon,
|
|
10
|
+
globe,
|
|
11
|
+
} from '@wordpress/icons';
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
14
|
* Internal dependencies
|
|
13
15
|
*/
|
|
14
|
-
import SidebarNavigationItem from '../sidebar-navigation-item';
|
|
15
|
-
import { useAddedBy } from '../page-templates/hooks';
|
|
16
|
-
import { layout } from '@wordpress/icons';
|
|
17
16
|
import { TEMPLATE_POST_TYPE } from '../../utils/constants';
|
|
18
|
-
import
|
|
19
|
-
|
|
20
|
-
const { useLocation } = unlock( routerPrivateApis );
|
|
21
|
-
|
|
22
|
-
const EMPTY_ARRAY = [];
|
|
23
|
-
|
|
24
|
-
function TemplateDataviewItem( { template, isActive } ) {
|
|
25
|
-
const { text, icon } = useAddedBy( template.type, template.id );
|
|
26
|
-
|
|
27
|
-
return (
|
|
28
|
-
<SidebarNavigationItem
|
|
29
|
-
to={ addQueryArgs( '/template', { activeView: text } ) }
|
|
30
|
-
icon={ icon }
|
|
31
|
-
aria-current={ isActive }
|
|
32
|
-
>
|
|
33
|
-
{ text }
|
|
34
|
-
</SidebarNavigationItem>
|
|
35
|
-
);
|
|
36
|
-
}
|
|
17
|
+
import DataViewsSidebarContent from '../sidebar-dataviews';
|
|
37
18
|
|
|
19
|
+
const SOURCE_TO_ICON = {
|
|
20
|
+
user: commentAuthorAvatar,
|
|
21
|
+
theme: layout,
|
|
22
|
+
plugin: pluginIcon,
|
|
23
|
+
site: globe,
|
|
24
|
+
};
|
|
38
25
|
export default function DataviewsTemplatesSidebarContent() {
|
|
39
|
-
const {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
} );
|
|
45
|
-
const firstItemPerAuthorText = useMemo( () => {
|
|
46
|
-
const firstItemPerAuthor = records?.reduce( ( acc, template ) => {
|
|
47
|
-
const author = template.author_text;
|
|
48
|
-
if ( author && ! acc[ author ] ) {
|
|
49
|
-
acc[ author ] = template;
|
|
50
|
-
}
|
|
51
|
-
return acc;
|
|
52
|
-
}, {} );
|
|
53
|
-
return (
|
|
54
|
-
( firstItemPerAuthor && Object.values( firstItemPerAuthor ) ) ??
|
|
55
|
-
EMPTY_ARRAY
|
|
26
|
+
const authorSourceMap = useSelect( ( select ) => {
|
|
27
|
+
const templates = select( coreStore ).getEntityRecords(
|
|
28
|
+
'postType',
|
|
29
|
+
TEMPLATE_POST_TYPE,
|
|
30
|
+
{ per_page: -1 }
|
|
56
31
|
);
|
|
57
|
-
|
|
32
|
+
if ( ! templates ) {
|
|
33
|
+
return {};
|
|
34
|
+
}
|
|
35
|
+
const map = {};
|
|
36
|
+
for ( const template of templates ) {
|
|
37
|
+
if (
|
|
38
|
+
template.author_text &&
|
|
39
|
+
template.original_source &&
|
|
40
|
+
! map[ template.author_text ]
|
|
41
|
+
) {
|
|
42
|
+
map[ template.author_text ] = template.original_source;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return map;
|
|
46
|
+
}, [] );
|
|
47
|
+
|
|
48
|
+
const resolveIcon = ( view ) => {
|
|
49
|
+
const source = authorSourceMap[ view.slug ];
|
|
50
|
+
return SOURCE_TO_ICON[ source ] ?? layout;
|
|
51
|
+
};
|
|
58
52
|
|
|
59
53
|
return (
|
|
60
|
-
<
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
aria-current={ activeView === 'all' }
|
|
65
|
-
>
|
|
66
|
-
{ __( 'All templates' ) }
|
|
67
|
-
</SidebarNavigationItem>
|
|
68
|
-
{ firstItemPerAuthorText.map( ( template ) => {
|
|
69
|
-
return (
|
|
70
|
-
<TemplateDataviewItem
|
|
71
|
-
key={ template.author_text }
|
|
72
|
-
template={ template }
|
|
73
|
-
isActive={ activeView === template.author_text }
|
|
74
|
-
/>
|
|
75
|
-
);
|
|
76
|
-
} ) }
|
|
77
|
-
</ItemGroup>
|
|
54
|
+
<DataViewsSidebarContent
|
|
55
|
+
postType={ TEMPLATE_POST_TYPE }
|
|
56
|
+
resolveIcon={ resolveIcon }
|
|
57
|
+
/>
|
|
78
58
|
);
|
|
79
59
|
}
|
|
@@ -4,15 +4,17 @@
|
|
|
4
4
|
import SidebarNavigationScreenMain from '../sidebar-navigation-screen-main';
|
|
5
5
|
import SidebarNavigationScreenUnsupported from '../sidebar-navigation-screen-unsupported';
|
|
6
6
|
import Editor from '../editor';
|
|
7
|
-
import { isClassicThemeWithStyleBookSupport } from './utils';
|
|
7
|
+
import { isClassicThemeWithStyleBookSupport, isThemeDataLoaded } from './utils';
|
|
8
8
|
|
|
9
9
|
export const homeRoute = {
|
|
10
10
|
name: 'home',
|
|
11
11
|
path: '/',
|
|
12
12
|
areas: {
|
|
13
13
|
sidebar( { siteData } ) {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
if ( ! isThemeDataLoaded( siteData ) ) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
return siteData.currentTheme.is_block_theme ||
|
|
16
18
|
isClassicThemeWithStyleBookSupport( siteData ) ? (
|
|
17
19
|
<SidebarNavigationScreenMain />
|
|
18
20
|
) : (
|
|
@@ -27,8 +29,10 @@ export const homeRoute = {
|
|
|
27
29
|
) : undefined;
|
|
28
30
|
},
|
|
29
31
|
mobile( { siteData } ) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
if ( ! isThemeDataLoaded( siteData ) ) {
|
|
33
|
+
return <></>;
|
|
34
|
+
}
|
|
35
|
+
return siteData.currentTheme.is_block_theme ||
|
|
32
36
|
isClassicThemeWithStyleBookSupport( siteData ) ? (
|
|
33
37
|
<SidebarNavigationScreenMain />
|
|
34
38
|
) : (
|
|
@@ -10,6 +10,7 @@ import Editor from '../editor';
|
|
|
10
10
|
import SidebarNavigationScreenNavigationMenu from '../sidebar-navigation-screen-navigation-menu';
|
|
11
11
|
import SidebarNavigationScreenUnsupported from '../sidebar-navigation-screen-unsupported';
|
|
12
12
|
import { unlock } from '../../lock-unlock';
|
|
13
|
+
import { isThemeDataLoaded } from './utils';
|
|
13
14
|
|
|
14
15
|
const { useLocation } = unlock( routerPrivateApis );
|
|
15
16
|
|
|
@@ -29,24 +30,30 @@ export const navigationItemRoute = {
|
|
|
29
30
|
path: '/wp_navigation/:postId',
|
|
30
31
|
areas: {
|
|
31
32
|
sidebar( { siteData } ) {
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
if ( ! isThemeDataLoaded( siteData ) ) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
return siteData.currentTheme.is_block_theme ? (
|
|
34
37
|
<SidebarNavigationScreenNavigationMenu backPath="/navigation" />
|
|
35
38
|
) : (
|
|
36
39
|
<SidebarNavigationScreenUnsupported />
|
|
37
40
|
);
|
|
38
41
|
},
|
|
39
42
|
preview( { siteData } ) {
|
|
40
|
-
|
|
41
|
-
|
|
43
|
+
if ( ! isThemeDataLoaded( siteData ) ) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
return siteData.currentTheme.is_block_theme ? (
|
|
42
47
|
<Editor />
|
|
43
48
|
) : (
|
|
44
49
|
<SidebarNavigationScreenUnsupported />
|
|
45
50
|
);
|
|
46
51
|
},
|
|
47
52
|
mobile( { siteData } ) {
|
|
48
|
-
|
|
49
|
-
|
|
53
|
+
if ( ! isThemeDataLoaded( siteData ) ) {
|
|
54
|
+
return <></>;
|
|
55
|
+
}
|
|
56
|
+
return siteData.currentTheme.is_block_theme ? (
|
|
50
57
|
<MobileNavigationItemView />
|
|
51
58
|
) : (
|
|
52
59
|
<SidebarNavigationScreenUnsupported />
|
|
@@ -10,6 +10,7 @@ import Editor from '../editor';
|
|
|
10
10
|
import SidebarNavigationScreenNavigationMenus from '../sidebar-navigation-screen-navigation-menus';
|
|
11
11
|
import SidebarNavigationScreenUnsupported from '../sidebar-navigation-screen-unsupported';
|
|
12
12
|
import { unlock } from '../../lock-unlock';
|
|
13
|
+
import { isThemeDataLoaded } from './utils';
|
|
13
14
|
|
|
14
15
|
const { useLocation } = unlock( routerPrivateApis );
|
|
15
16
|
|
|
@@ -29,8 +30,10 @@ export const navigationRoute = {
|
|
|
29
30
|
path: '/navigation',
|
|
30
31
|
areas: {
|
|
31
32
|
sidebar( { siteData } ) {
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
if ( ! isThemeDataLoaded( siteData ) ) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
return siteData.currentTheme.is_block_theme ? (
|
|
34
37
|
<SidebarNavigationScreenNavigationMenus backPath="/" />
|
|
35
38
|
) : (
|
|
36
39
|
<SidebarNavigationScreenUnsupported />
|
|
@@ -41,8 +44,10 @@ export const navigationRoute = {
|
|
|
41
44
|
return isBlockTheme ? <Editor /> : undefined;
|
|
42
45
|
},
|
|
43
46
|
mobile( { siteData } ) {
|
|
44
|
-
|
|
45
|
-
|
|
47
|
+
if ( ! isThemeDataLoaded( siteData ) ) {
|
|
48
|
+
return <></>;
|
|
49
|
+
}
|
|
50
|
+
return siteData.currentTheme.is_block_theme ? (
|
|
46
51
|
<MobileNavigationView />
|
|
47
52
|
) : (
|
|
48
53
|
<SidebarNavigationScreenUnsupported />
|
|
@@ -10,14 +10,17 @@ import Editor from '../editor';
|
|
|
10
10
|
import DataViewsSidebarContent from '../sidebar-dataviews';
|
|
11
11
|
import SidebarNavigationScreen from '../sidebar-navigation-screen';
|
|
12
12
|
import SidebarNavigationScreenUnsupported from '../sidebar-navigation-screen-unsupported';
|
|
13
|
+
import { isThemeDataLoaded } from './utils';
|
|
13
14
|
|
|
14
15
|
export const pageItemRoute = {
|
|
15
16
|
name: 'page-item',
|
|
16
17
|
path: '/page/:postId',
|
|
17
18
|
areas: {
|
|
18
19
|
sidebar( { siteData } ) {
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
if ( ! isThemeDataLoaded( siteData ) ) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
return siteData.currentTheme.is_block_theme ? (
|
|
21
24
|
<SidebarNavigationScreen
|
|
22
25
|
title={ __( 'Pages' ) }
|
|
23
26
|
backPath="/"
|
|
@@ -28,16 +31,20 @@ export const pageItemRoute = {
|
|
|
28
31
|
);
|
|
29
32
|
},
|
|
30
33
|
mobile( { siteData } ) {
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
if ( ! isThemeDataLoaded( siteData ) ) {
|
|
35
|
+
return <></>;
|
|
36
|
+
}
|
|
37
|
+
return siteData.currentTheme.is_block_theme ? (
|
|
33
38
|
<Editor />
|
|
34
39
|
) : (
|
|
35
40
|
<SidebarNavigationScreenUnsupported />
|
|
36
41
|
);
|
|
37
42
|
},
|
|
38
43
|
preview( { siteData } ) {
|
|
39
|
-
|
|
40
|
-
|
|
44
|
+
if ( ! isThemeDataLoaded( siteData ) ) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
return siteData.currentTheme.is_block_theme ? (
|
|
41
48
|
<Editor />
|
|
42
49
|
) : (
|
|
43
50
|
<SidebarNavigationScreenUnsupported />
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { privateApis as routerPrivateApis } from '@wordpress/router';
|
|
5
5
|
import { __ } from '@wordpress/i18n';
|
|
6
|
+
import { resolveSelect } from '@wordpress/data';
|
|
7
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
6
8
|
import { loadView } from '@wordpress/views';
|
|
7
9
|
|
|
8
10
|
/**
|
|
@@ -14,21 +16,26 @@ import SidebarNavigationScreenUnsupported from '../sidebar-navigation-screen-uns
|
|
|
14
16
|
import DataViewsSidebarContent from '../sidebar-dataviews';
|
|
15
17
|
import PostList from '../post-list';
|
|
16
18
|
import { unlock } from '../../lock-unlock';
|
|
17
|
-
import {
|
|
18
|
-
DEFAULT_VIEW,
|
|
19
|
-
getActiveViewOverridesForTab,
|
|
20
|
-
} from '../post-list/view-utils';
|
|
19
|
+
import { isThemeDataLoaded } from './utils';
|
|
21
20
|
|
|
22
21
|
const { useLocation } = unlock( routerPrivateApis );
|
|
23
22
|
|
|
24
23
|
async function isListView( query ) {
|
|
25
24
|
const { activeView = 'all' } = query;
|
|
25
|
+
const config = await unlock( resolveSelect( coreStore ) ).getViewConfig(
|
|
26
|
+
'postType',
|
|
27
|
+
'page'
|
|
28
|
+
);
|
|
29
|
+
const defaultView = config?.default_view;
|
|
30
|
+
const defaultLayouts = config?.default_layouts;
|
|
31
|
+
const viewEntry = config?.view_list?.find( ( v ) => v.slug === activeView );
|
|
26
32
|
const view = await loadView( {
|
|
27
33
|
kind: 'postType',
|
|
28
34
|
name: 'page',
|
|
29
35
|
slug: 'default',
|
|
30
|
-
defaultView
|
|
31
|
-
|
|
36
|
+
defaultView,
|
|
37
|
+
defaultLayouts,
|
|
38
|
+
activeViewOverrides: viewEntry?.view ?? {},
|
|
32
39
|
} );
|
|
33
40
|
return view.type === 'list';
|
|
34
41
|
}
|
|
@@ -45,8 +52,10 @@ export const pagesRoute = {
|
|
|
45
52
|
path: '/page',
|
|
46
53
|
areas: {
|
|
47
54
|
sidebar( { siteData } ) {
|
|
48
|
-
|
|
49
|
-
|
|
55
|
+
if ( ! isThemeDataLoaded( siteData ) ) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
return siteData.currentTheme.is_block_theme ? (
|
|
50
59
|
<SidebarNavigationScreen
|
|
51
60
|
title={ __( 'Pages' ) }
|
|
52
61
|
backPath="/"
|
|
@@ -69,8 +78,10 @@ export const pagesRoute = {
|
|
|
69
78
|
return isList ? <Editor /> : undefined;
|
|
70
79
|
},
|
|
71
80
|
mobile( { siteData } ) {
|
|
72
|
-
|
|
73
|
-
|
|
81
|
+
if ( ! isThemeDataLoaded( siteData ) ) {
|
|
82
|
+
return <></>;
|
|
83
|
+
}
|
|
84
|
+
return siteData.currentTheme.is_block_theme ? (
|
|
74
85
|
<MobilePagesView />
|
|
75
86
|
) : (
|
|
76
87
|
<SidebarNavigationScreenUnsupported />
|
|
@@ -10,7 +10,7 @@ import { privateApis as editorPrivateApis } from '@wordpress/editor';
|
|
|
10
10
|
import SidebarNavigationScreen from '../sidebar-navigation-screen';
|
|
11
11
|
import SidebarNavigationScreenUnsupported from '../sidebar-navigation-screen-unsupported';
|
|
12
12
|
import { unlock } from '../../lock-unlock';
|
|
13
|
-
import { isClassicThemeWithStyleBookSupport } from './utils';
|
|
13
|
+
import { isClassicThemeWithStyleBookSupport, isThemeDataLoaded } from './utils';
|
|
14
14
|
|
|
15
15
|
const { StyleBookPreview } = unlock( editorPrivateApis );
|
|
16
16
|
|
|
@@ -19,6 +19,9 @@ export const stylebookRoute = {
|
|
|
19
19
|
path: '/stylebook',
|
|
20
20
|
areas: {
|
|
21
21
|
sidebar( { siteData } ) {
|
|
22
|
+
if ( ! isThemeDataLoaded( siteData ) ) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
22
25
|
return isClassicThemeWithStyleBookSupport( siteData ) ? (
|
|
23
26
|
<SidebarNavigationScreen
|
|
24
27
|
title={ __( 'Styles' ) }
|
|
@@ -33,12 +36,18 @@ export const stylebookRoute = {
|
|
|
33
36
|
},
|
|
34
37
|
preview( { siteData } ) {
|
|
35
38
|
return isClassicThemeWithStyleBookSupport( siteData ) ? (
|
|
36
|
-
<StyleBookPreview
|
|
39
|
+
<StyleBookPreview
|
|
40
|
+
isStatic
|
|
41
|
+
settings={ siteData.editorSettings }
|
|
42
|
+
/>
|
|
37
43
|
) : undefined;
|
|
38
44
|
},
|
|
39
45
|
mobile( { siteData } ) {
|
|
40
46
|
return isClassicThemeWithStyleBookSupport( siteData ) ? (
|
|
41
|
-
<StyleBookPreview
|
|
47
|
+
<StyleBookPreview
|
|
48
|
+
isStatic
|
|
49
|
+
settings={ siteData.editorSettings }
|
|
50
|
+
/>
|
|
42
51
|
) : undefined;
|
|
43
52
|
},
|
|
44
53
|
},
|
|
@@ -4,27 +4,34 @@
|
|
|
4
4
|
import Editor from '../editor';
|
|
5
5
|
import SidebarNavigationScreenTemplatesBrowse from '../sidebar-navigation-screen-templates-browse';
|
|
6
6
|
import SidebarNavigationScreenUnsupported from '../sidebar-navigation-screen-unsupported';
|
|
7
|
+
import { isThemeDataLoaded } from './utils';
|
|
7
8
|
|
|
8
9
|
const areas = {
|
|
9
10
|
sidebar( { siteData } ) {
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
if ( ! isThemeDataLoaded( siteData ) ) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
return siteData.currentTheme.is_block_theme ? (
|
|
12
15
|
<SidebarNavigationScreenTemplatesBrowse backPath="/" />
|
|
13
16
|
) : (
|
|
14
17
|
<SidebarNavigationScreenUnsupported />
|
|
15
18
|
);
|
|
16
19
|
},
|
|
17
20
|
mobile( { siteData } ) {
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
if ( ! isThemeDataLoaded( siteData ) ) {
|
|
22
|
+
return <></>;
|
|
23
|
+
}
|
|
24
|
+
return siteData.currentTheme.is_block_theme ? (
|
|
20
25
|
<Editor />
|
|
21
26
|
) : (
|
|
22
27
|
<SidebarNavigationScreenUnsupported />
|
|
23
28
|
);
|
|
24
29
|
},
|
|
25
30
|
preview( { siteData } ) {
|
|
26
|
-
|
|
27
|
-
|
|
31
|
+
if ( ! isThemeDataLoaded( siteData ) ) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
return siteData.currentTheme.is_block_theme ? (
|
|
28
35
|
<Editor />
|
|
29
36
|
) : (
|
|
30
37
|
<SidebarNavigationScreenUnsupported />
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
+
import { resolveSelect } from '@wordpress/data';
|
|
5
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
4
6
|
import { loadView } from '@wordpress/views';
|
|
5
7
|
|
|
6
8
|
/**
|
|
@@ -11,19 +13,24 @@ import SidebarNavigationScreenTemplatesBrowse from '../sidebar-navigation-screen
|
|
|
11
13
|
import SidebarNavigationScreenUnsupported from '../sidebar-navigation-screen-unsupported';
|
|
12
14
|
import PageTemplates from '../page-templates';
|
|
13
15
|
import PageTemplatesLegacy from '../page-templates/index-legacy';
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
getActiveViewOverridesForTab,
|
|
17
|
-
} from '../page-templates/view-utils';
|
|
16
|
+
import { unlock } from '../../lock-unlock';
|
|
17
|
+
import { isThemeDataLoaded } from './utils';
|
|
18
18
|
|
|
19
19
|
async function isTemplateListView( query ) {
|
|
20
20
|
const { activeView = 'active' } = query;
|
|
21
|
+
const config = await unlock( resolveSelect( coreStore ) ).getViewConfig(
|
|
22
|
+
'postType',
|
|
23
|
+
'wp_template'
|
|
24
|
+
);
|
|
25
|
+
const defaultView = config?.default_view;
|
|
26
|
+
const activeViewOverrides =
|
|
27
|
+
config?.view_list?.find( ( v ) => v.slug === activeView )?.view ?? {};
|
|
21
28
|
const view = await loadView( {
|
|
22
29
|
kind: 'postType',
|
|
23
30
|
name: 'wp_template',
|
|
24
31
|
slug: 'default',
|
|
25
|
-
defaultView
|
|
26
|
-
activeViewOverrides
|
|
32
|
+
defaultView,
|
|
33
|
+
activeViewOverrides,
|
|
27
34
|
} );
|
|
28
35
|
return view.type === 'list';
|
|
29
36
|
}
|
|
@@ -33,8 +40,10 @@ export const templatesRoute = {
|
|
|
33
40
|
path: '/template',
|
|
34
41
|
areas: {
|
|
35
42
|
sidebar( { siteData } ) {
|
|
36
|
-
|
|
37
|
-
|
|
43
|
+
if ( ! isThemeDataLoaded( siteData ) ) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
return siteData.currentTheme.is_block_theme ? (
|
|
38
47
|
<SidebarNavigationScreenTemplatesBrowse backPath="/" />
|
|
39
48
|
) : (
|
|
40
49
|
<SidebarNavigationScreenUnsupported />
|
|
@@ -62,8 +71,10 @@ export const templatesRoute = {
|
|
|
62
71
|
return isListView ? <Editor /> : undefined;
|
|
63
72
|
},
|
|
64
73
|
mobile( { siteData } ) {
|
|
65
|
-
|
|
66
|
-
|
|
74
|
+
if ( ! isThemeDataLoaded( siteData ) ) {
|
|
75
|
+
return <></>;
|
|
76
|
+
}
|
|
77
|
+
if ( ! siteData.currentTheme.is_block_theme ) {
|
|
67
78
|
return <SidebarNavigationScreenUnsupported />;
|
|
68
79
|
}
|
|
69
80
|
// Check if the template activation experiment is enabled.
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if the current theme data has been loaded from the REST API.
|
|
3
|
+
*
|
|
4
|
+
* @param {Object} siteData - The site data provided by the site editor route area resolvers.
|
|
5
|
+
* @return {boolean} True if the theme data is available, false otherwise.
|
|
6
|
+
*/
|
|
7
|
+
export function isThemeDataLoaded( siteData ) {
|
|
8
|
+
return (
|
|
9
|
+
siteData.currentTheme !== undefined && siteData.currentTheme !== null
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
|
|
1
13
|
/**
|
|
2
14
|
* Check if the classic theme supports the stylebook.
|
|
3
15
|
*
|