@wordpress/edit-site 6.42.0 → 6.43.1-next.v.202604091042.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/more-menu/site-export.cjs +1 -1
- package/build/components/more-menu/site-export.cjs.map +2 -2
- 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-identity/index.cjs +17 -1
- package/build/components/sidebar-identity/index.cjs.map +2 -2
- 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/more-menu/site-export.mjs +1 -1
- package/build-module/components/more-menu/site-export.mjs.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-identity/index.mjs +17 -1
- package/build-module/components/sidebar-identity/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 +68 -51
- package/build-style/style.css +68 -51
- package/package.json +46 -46
- package/src/components/more-menu/site-export.js +1 -1
- 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-identity/index.js +17 -1
- 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
|
@@ -22,7 +22,12 @@ const { usePostFields, PostCardPanel } = unlock( editorPrivateApis );
|
|
|
22
22
|
|
|
23
23
|
const fieldsWithBulkEditSupport = [ 'status', 'date', 'author', 'discussion' ];
|
|
24
24
|
|
|
25
|
-
export function QuickEditModal( {
|
|
25
|
+
export function QuickEditModal( {
|
|
26
|
+
postType,
|
|
27
|
+
postId,
|
|
28
|
+
closeModal,
|
|
29
|
+
quickEditForm,
|
|
30
|
+
} ) {
|
|
26
31
|
const isBulk = postId.length > 1;
|
|
27
32
|
|
|
28
33
|
const [ localEdits, setLocalEdits ] = useState( {} );
|
|
@@ -93,61 +98,21 @@ export function QuickEditModal( { postType, postId, closeModal } ) {
|
|
|
93
98
|
);
|
|
94
99
|
|
|
95
100
|
const form = useMemo( () => {
|
|
96
|
-
|
|
97
|
-
{
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
id: 'post-content-info',
|
|
106
|
-
layout: { type: 'regular', labelPosition: 'none' },
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
id: 'status',
|
|
110
|
-
label: __( 'Status' ),
|
|
111
|
-
children: [
|
|
112
|
-
{
|
|
113
|
-
id: 'status',
|
|
114
|
-
layout: { type: 'regular', labelPosition: 'none' },
|
|
115
|
-
},
|
|
116
|
-
'scheduled_date',
|
|
117
|
-
'password',
|
|
118
|
-
],
|
|
119
|
-
},
|
|
120
|
-
'author',
|
|
121
|
-
'date',
|
|
122
|
-
'slug',
|
|
123
|
-
'parent',
|
|
124
|
-
{
|
|
125
|
-
id: 'discussion',
|
|
126
|
-
label: __( 'Discussion' ),
|
|
127
|
-
children: [
|
|
128
|
-
{
|
|
129
|
-
id: 'comment_status',
|
|
130
|
-
layout: { type: 'regular', labelPosition: 'none' },
|
|
131
|
-
},
|
|
132
|
-
'ping_status',
|
|
133
|
-
],
|
|
134
|
-
},
|
|
135
|
-
'template',
|
|
136
|
-
];
|
|
137
|
-
|
|
101
|
+
if ( ! quickEditForm ) {
|
|
102
|
+
return { layout: { type: 'panel' }, fields: [] };
|
|
103
|
+
}
|
|
104
|
+
if ( ! isBulk ) {
|
|
105
|
+
return quickEditForm;
|
|
106
|
+
}
|
|
138
107
|
return {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
typeof field === 'string' ? field : field.id
|
|
146
|
-
)
|
|
147
|
-
)
|
|
148
|
-
: allFields,
|
|
108
|
+
...quickEditForm,
|
|
109
|
+
fields: ( quickEditForm.fields ?? [] ).filter( ( field ) =>
|
|
110
|
+
fieldsWithBulkEditSupport.includes(
|
|
111
|
+
typeof field === 'string' ? field : field.id
|
|
112
|
+
)
|
|
113
|
+
),
|
|
149
114
|
};
|
|
150
|
-
}, [ isBulk ] );
|
|
115
|
+
}, [ isBulk, quickEditForm ] );
|
|
151
116
|
|
|
152
117
|
const onChange = ( edits ) => {
|
|
153
118
|
const currentData = { ...record, ...localEdits };
|
|
@@ -3,34 +3,51 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { __experimentalItemGroup as ItemGroup } from '@wordpress/components';
|
|
5
5
|
import { privateApis as routerPrivateApis } from '@wordpress/router';
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
import {
|
|
7
|
+
trash,
|
|
8
|
+
pages,
|
|
9
|
+
drafts,
|
|
10
|
+
published,
|
|
11
|
+
scheduled,
|
|
12
|
+
pending,
|
|
13
|
+
notAllowed,
|
|
14
|
+
} from '@wordpress/icons';
|
|
15
|
+
import { useViewConfig } from '@wordpress/views';
|
|
16
|
+
import { addQueryArgs } from '@wordpress/url';
|
|
9
17
|
|
|
10
18
|
/**
|
|
11
19
|
* Internal dependencies
|
|
12
20
|
*/
|
|
13
21
|
import { unlock } from '../../lock-unlock';
|
|
14
|
-
import
|
|
15
|
-
import { getDefaultViews } from '../post-list/view-utils';
|
|
22
|
+
import SidebarNavigationItem from '../sidebar-navigation-item';
|
|
16
23
|
|
|
17
24
|
const { useLocation } = unlock( routerPrivateApis );
|
|
18
25
|
|
|
19
|
-
|
|
26
|
+
const SLUG_TO_ICON = {
|
|
27
|
+
all: pages,
|
|
28
|
+
published,
|
|
29
|
+
future: scheduled,
|
|
30
|
+
drafts,
|
|
31
|
+
pending,
|
|
32
|
+
private: notAllowed,
|
|
33
|
+
trash,
|
|
34
|
+
};
|
|
35
|
+
const defaultResolveIcon = ( view ) => {
|
|
36
|
+
return SLUG_TO_ICON[ view.slug ];
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export default function DataViewsSidebarContent( {
|
|
40
|
+
postType,
|
|
41
|
+
resolveIcon = defaultResolveIcon,
|
|
42
|
+
} ) {
|
|
20
43
|
const {
|
|
44
|
+
path,
|
|
21
45
|
query: { activeView = 'all' },
|
|
22
46
|
} = useLocation();
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
},
|
|
28
|
-
[ postType ]
|
|
29
|
-
);
|
|
30
|
-
const defaultViews = useMemo(
|
|
31
|
-
() => getDefaultViews( postTypeObject ),
|
|
32
|
-
[ postTypeObject ]
|
|
33
|
-
);
|
|
47
|
+
const { view_list: viewList } = useViewConfig( {
|
|
48
|
+
kind: 'postType',
|
|
49
|
+
name: postType,
|
|
50
|
+
} );
|
|
34
51
|
if ( ! postType ) {
|
|
35
52
|
return null;
|
|
36
53
|
}
|
|
@@ -38,16 +55,21 @@ export default function DataViewsSidebarContent( { postType } ) {
|
|
|
38
55
|
return (
|
|
39
56
|
<>
|
|
40
57
|
<ItemGroup className="edit-site-sidebar-dataviews">
|
|
41
|
-
{
|
|
58
|
+
{ viewList?.map( ( view ) => {
|
|
59
|
+
const isActive = view.slug === activeView;
|
|
60
|
+
const slug = view.slug === 'all' ? undefined : view.slug;
|
|
61
|
+
const icon = resolveIcon( view );
|
|
42
62
|
return (
|
|
43
|
-
<
|
|
44
|
-
key={
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
63
|
+
<SidebarNavigationItem
|
|
64
|
+
key={ view.slug }
|
|
65
|
+
icon={ icon }
|
|
66
|
+
to={ addQueryArgs( path, {
|
|
67
|
+
activeView: slug,
|
|
68
|
+
} ) }
|
|
69
|
+
aria-current={ isActive ? 'true' : undefined }
|
|
70
|
+
>
|
|
71
|
+
{ view.title }
|
|
72
|
+
</SidebarNavigationItem>
|
|
51
73
|
);
|
|
52
74
|
} ) }
|
|
53
75
|
</ItemGroup>
|
|
@@ -5,19 +5,3 @@
|
|
|
5
5
|
margin-left: -$grid-unit-20;
|
|
6
6
|
margin-right: -$grid-unit-20;
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
.edit-site-sidebar-dataviews-dataview-item {
|
|
10
|
-
border-radius: $radius-small;
|
|
11
|
-
|
|
12
|
-
&:hover,
|
|
13
|
-
&:focus,
|
|
14
|
-
&[aria-current] {
|
|
15
|
-
color: $gray-200;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
&.is-selected {
|
|
19
|
-
background: $gray-800;
|
|
20
|
-
font-weight: $font-weight-medium;
|
|
21
|
-
color: $white;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
@@ -9,6 +9,22 @@ import { DataForm } from '@wordpress/dataviews';
|
|
|
9
9
|
import { MediaEdit } from '@wordpress/fields';
|
|
10
10
|
|
|
11
11
|
const fields = [
|
|
12
|
+
{
|
|
13
|
+
id: 'title',
|
|
14
|
+
type: 'text',
|
|
15
|
+
label: __( 'Site Title' ),
|
|
16
|
+
description: __(
|
|
17
|
+
"Displays in your site's layout via the Site Title block."
|
|
18
|
+
),
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: 'description',
|
|
22
|
+
type: 'text',
|
|
23
|
+
label: __( 'Site Tagline' ),
|
|
24
|
+
description: __(
|
|
25
|
+
"In a few words, explain what this site is about. Displays in your site's layout via the Site Tagline block."
|
|
26
|
+
),
|
|
27
|
+
},
|
|
12
28
|
{
|
|
13
29
|
id: 'site_logo',
|
|
14
30
|
type: 'media',
|
|
@@ -42,7 +58,7 @@ const form = {
|
|
|
42
58
|
type: 'regular',
|
|
43
59
|
labelPosition: 'top',
|
|
44
60
|
},
|
|
45
|
-
fields: [ 'site_logo', 'site_icon' ],
|
|
61
|
+
fields: [ 'title', 'description', 'site_logo', 'site_icon' ],
|
|
46
62
|
};
|
|
47
63
|
|
|
48
64
|
export default function SidebarIdentity() {
|
|
@@ -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 />
|