Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
b860aa7
View config: Add pattern summary form
jorgefilipecosta Jun 23, 2026
48a2150
Editor: Register pattern summary fields
jorgefilipecosta Jun 23, 2026
040bdfb
Editor: Enable DataForm summary for patterns
jorgefilipecosta Jun 23, 2026
4ddb97e
E2E: Test DataForm pattern summary
jorgefilipecosta Jun 23, 2026
78ee800
Editor: Refine pattern DataForm summary
jorgefilipecosta Jun 23, 2026
a171945
Tests: Assert full pattern form config
jorgefilipecosta Jun 23, 2026
7b95d82
Tests: Cover pattern description edits
jorgefilipecosta Jun 23, 2026
2ad4fce
Fields: Reuse pattern sync constants
jorgefilipecosta Jun 23, 2026
6e643f0
Editor: Simplify post type field guards
jorgefilipecosta Jun 23, 2026
1b55ed7
Fields: Clarify pattern summary field behavior
jorgefilipecosta Jun 23, 2026
ceaeb92
Backport: Add Core changelog for pattern summary config
jorgefilipecosta Jun 23, 2026
86d540a
Tests: Cover pattern summary fields across editors
jorgefilipecosta Jun 24, 2026
396e4db
Fields: Share pattern sync status metadata
jorgefilipecosta Jun 24, 2026
2995493
Tests: Cover direct pattern creation summary
jorgefilipecosta Jun 24, 2026
cadd2e7
Tests: Tighten pattern summary assertions
jorgefilipecosta Jun 24, 2026
bfcdee6
Fields: Clarify pattern sync fallback flow
jorgefilipecosta Jun 24, 2026
f38e2fc
Tests: Group wp_block summary coverage
jorgefilipecosta Jun 24, 2026
14feff2
Tests: Scope wp_block summary helpers
jorgefilipecosta Jun 24, 2026
4705dbf
Tests: Use field-specific summary helpers
jorgefilipecosta Jun 24, 2026
2ed298f
Address pattern summary review feedback
jorgefilipecosta Jun 25, 2026
7a14b86
small tweaks
ntsekouras Jun 26, 2026
2cdea4c
`usePostFields` directly + update e2e tests
ntsekouras Jun 26, 2026
08b37ff
more tweaks
ntsekouras Jun 26, 2026
d55d025
Tests: Share pattern creation modal helper
jorgefilipecosta Jun 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions backport-changelog/7.1/12288.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
https://github.com/WordPress/wordpress-develop/pull/12288

* https://github.com/WordPress/gutenberg/pull/79452
22 changes: 22 additions & 0 deletions lib/compat/wordpress-7.1/view-config-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,28 @@ function _gutenberg_get_entity_view_config_post_type_wp_block( $config ) {

$config['view_list'] = $view_list;

$config['form'] = array(
'layout' => array( 'type' => 'panel' ),
'fields' => array(
array(
'id' => 'excerpt',
'layout' => array(
'type' => 'panel',
'labelPosition' => 'top',
),
),
array(
'id' => 'post-content-info',
'layout' => array(
'type' => 'regular',
'labelPosition' => 'none',
),
),
'sync-status',
'revisions',
),
);

return $config;
}

Expand Down
52 changes: 2 additions & 50 deletions packages/edit-site/src/components/page-patterns/fields.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* WordPress dependencies
*/
import { __, _x } from '@wordpress/i18n';
import { __ } from '@wordpress/i18n';
import { useMemo, useId } from '@wordpress/element';
import { BlockPreview } from '@wordpress/block-editor';
import { parse } from '@wordpress/blocks';
Expand All @@ -10,11 +10,7 @@ import { privateApis as editorPrivateApis } from '@wordpress/editor';
/**
* Internal dependencies
*/
import {
TEMPLATE_PART_POST_TYPE,
PATTERN_SYNC_TYPES,
OPERATOR_IS,
} from '../../utils/constants';
import { TEMPLATE_PART_POST_TYPE } from '../../utils/constants';
import { unlock } from '../../lock-unlock';

const { useStyle } = unlock( editorPrivateApis );
Expand Down Expand Up @@ -65,47 +61,3 @@ export const previewField = {
render: PreviewField,
enableSorting: false,
};

const SYNC_FILTERS = [
{
value: PATTERN_SYNC_TYPES.full,
label: _x( 'Synced', 'pattern (singular)' ),
description: __( 'Patterns that are kept in sync across the site.' ),
},
{
value: PATTERN_SYNC_TYPES.unsynced,
label: _x( 'Not synced', 'pattern (singular)' ),
description: __(
'Patterns that can be changed freely without affecting the site.'
),
},
];

export const patternStatusField = {
label: __( 'Sync status' ),
id: 'sync-status',
render: ( { item } ) => {
const syncStatus =
'wp_pattern_sync_status' in item
? item.wp_pattern_sync_status || PATTERN_SYNC_TYPES.full
: PATTERN_SYNC_TYPES.unsynced;
// User patterns can have their sync statuses checked directly.
// Non-user patterns are all unsynced for the time being.
return (
<span
className={ `edit-site-patterns__field-sync-status-${ syncStatus }` }
>
{
SYNC_FILTERS.find( ( { value } ) => value === syncStatus )
.label
}
</span>
);
},
elements: SYNC_FILTERS,
filterBy: {
operators: [ OPERATOR_IS ],
isPrimary: true,
},
enableSorting: false,
};
28 changes: 5 additions & 23 deletions packages/edit-site/src/components/page-patterns/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ import { unlock } from '../../lock-unlock';
import usePatterns, { useAugmentPatternsWithPermissions } from './use-patterns';
import PatternsActions from './actions';
import { useEditPostAction } from '../dataviews-actions';
import { patternStatusField, previewField } from './fields';
import { previewField } from './fields';
import usePatternCategories from '../sidebar-navigation-screen-patterns/use-pattern-categories';

const { ExperimentalBlockEditorProvider } = unlock( blockEditorPrivateApis );
const { usePostActions, usePostFields, patternTitleField } =
unlock( editorPrivateApis );
const { usePostActions, usePostFields } = unlock( editorPrivateApis );
const { useLocation, useHistory } = unlock( routerPrivateApis );

const EMPTY_ARRAY = [];
Expand Down Expand Up @@ -104,27 +103,10 @@ export default function DataviewsPatterns() {
syncStatus: viewSyncStatus,
} );

const templatePartFields = usePostFields( {
postType: TEMPLATE_PART_POST_TYPE,
} );
const templatePartAuthorField = templatePartFields.find(
( field ) => field.id === 'author'
);

const postTypeFields = usePostFields( { postType } );
const fields = useMemo( () => {
const _fields = [ previewField, patternTitleField ];

if ( postType === PATTERN_TYPES.user ) {
_fields.push( patternStatusField );
} else if (
postType === TEMPLATE_PART_POST_TYPE &&
templatePartAuthorField
) {
_fields.push( templatePartAuthorField );
}

return _fields;
}, [ postType, templatePartAuthorField ] );
return [ previewField, ...( postTypeFields || [] ) ];
}, [ postTypeFields ] );

const { data, paginationInfo } = useMemo( () => {
// Search is managed server-side as well as filters for patterns.
Expand Down
2 changes: 1 addition & 1 deletion packages/edit-site/src/components/page-patterns/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@

.edit-site-page-patterns-dataviews {
.dataviews-view-grid__badge-fields {
.dataviews-view-grid__field-value:has(.edit-site-patterns__field-sync-status-fully) {
.dataviews-view-grid__field-value:has(.fields-field__pattern-sync-status-fully) {
background: rgba(var(--wp-block-synced-color--rgb), 0.04);
color: var(--wp-block-synced-color);
}
Expand Down
10 changes: 7 additions & 3 deletions packages/editor/src/components/sidebar/post-summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,13 @@ export default function PostSummary( { onActionPerformed } ) {
);
if (
window?.__experimentalDataFormInspector &&
[ 'page', 'post', 'wp_template', 'wp_template_part' ].includes(
postType
)
[
'page',
'post',
'wp_block',
'wp_template',
'wp_template_part',
].includes( postType )
) {
return <DataFormPostSummary onActionPerformed={ onActionPerformed } />;
}
Expand Down
56 changes: 30 additions & 26 deletions packages/editor/src/dataviews/store/private-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ import {
templateTitleField,
pageTitleField,
patternTitleField,
patternDescriptionField,
patternSyncStatusField,
notesField,
scheduledDateField,
lastEditedDateField,
Expand Down Expand Up @@ -265,67 +267,69 @@ export const registerPostTypeSchema =
if ( postType === ATTACHMENT_POST_TYPE ) {
fields = ORDERED_MEDIA_FIELDS;
} else {
const postTypeSlug = postTypeConfig.slug;
const isDesignPostType = DESIGN_POST_TYPES.includes( postTypeSlug );
const isPattern = postTypeSlug === 'wp_block';

fields = [
postTypeConfig.supports?.thumbnail &&
currentTheme?.theme_supports?.[ 'post-thumbnails' ] &&
featuredImageField,
! DESIGN_POST_TYPES.includes( postTypeConfig.slug ) &&
! isDesignPostType &&
postTypeConfig.supports?.author &&
authorField,
postTypeConfig.slug === 'wp_template' && templateAuthorField,
postTypeConfig.slug === 'wp_template_part' &&
templatePartAuthorField,
! DESIGN_POST_TYPES.includes( postTypeConfig.slug ) &&
statusField,
! DESIGN_POST_TYPES.includes( postTypeConfig.slug ) &&
dateField,
! DESIGN_POST_TYPES.includes( postTypeConfig.slug ) &&
scheduledDateField,
postTypeSlug === 'wp_template' && templateAuthorField,
postTypeSlug === 'wp_template_part' && templatePartAuthorField,
! isDesignPostType && statusField,
! isDesignPostType && dateField,
! isDesignPostType && scheduledDateField,
lastEditedDateField,
! DESIGN_POST_TYPES.includes( postTypeConfig.slug ) &&
slugField,
! DESIGN_POST_TYPES.includes( postTypeConfig.slug ) &&
! isDesignPostType && slugField,
! isDesignPostType &&
postTypeConfig.supports?.excerpt &&
excerptField,
isPattern &&
postTypeConfig.supports?.excerpt &&
patternDescriptionField,
postTypeConfig.supports?.[ 'page-attributes' ] && parentField,
postTypeConfig.supports?.comments && commentStatusField,
postTypeConfig.supports?.trackbacks && pingStatusField,
( postTypeConfig.supports?.comments ||
postTypeConfig.supports?.trackbacks ) &&
discussionField,
! DESIGN_POST_TYPES.includes( postTypeConfig.slug ) &&
templateField,
! isDesignPostType && templateField,
postTypeConfig.supports?.[ 'post-formats' ] &&
! disablePostFormats &&
formatField,
! DESIGN_POST_TYPES.includes( postTypeConfig.slug ) &&
( ! isDesignPostType || isPattern ) &&
postTypeConfig.supports?.editor &&
postContentInfoField,
! DESIGN_POST_TYPES.includes( postTypeConfig.slug ) &&
passwordField,
postTypeConfig.slug === 'post' && stickyField,
postTypeConfig.slug === 'wp_template' && descriptionField,
postTypeConfig.slug === 'wp_template' &&
readOnlyDescriptionField,
! isDesignPostType && passwordField,
postTypeSlug === 'post' && stickyField,
postTypeSlug === 'wp_template' && descriptionField,
postTypeSlug === 'wp_template' && readOnlyDescriptionField,
// The `home`/`index` template summary exposes a few fields that
// target other entities (`root/site` and the posts page).
// `DataFormPostSummary` overrides them to read/write the right
// entity and to control their visibility.
postTypeConfig.slug === 'wp_template' && postsPageTitleField,
postTypeConfig.slug === 'wp_template' && postsPerPageField,
postTypeConfig.slug === 'wp_template' && siteDiscussionField,
postTypeSlug === 'wp_template' && postsPageTitleField,
postTypeSlug === 'wp_template' && postsPerPageField,
postTypeSlug === 'wp_template' && siteDiscussionField,
postTypeConfig.supports?.editor &&
postTypeConfig.viewable &&
postPreviewField,
hasEditorNotesSupport( postTypeConfig.supports ) && notesField,
isPattern && patternSyncStatusField,
].filter( Boolean );
if ( postTypeConfig.supports?.title ) {
let _titleField;
if ( postType === 'page' ) {
_titleField = pageTitleField;
} else if ( postType === 'wp_template' ) {
_titleField = templateTitleField;
} else if ( postType === 'wp_block' ) {
} else if (
[ 'wp_block', 'wp_template_part' ].includes( postType )
) {
_titleField = patternTitleField;
} else {
_titleField = titleField;
Expand Down
8 changes: 8 additions & 0 deletions packages/fields/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,14 @@ Password field for BasePost.

Undocumented declaration.

### patternDescriptionField

Description field for patterns.

### patternSyncStatusField

Sync status field for patterns.

### patternTitleField

Title for the pattern entity.
Expand Down
2 changes: 2 additions & 0 deletions packages/fields/src/fields/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ export { default as titleField } from './title';
export { default as pageTitleField } from './page-title';
export { default as templateTitleField } from './template-title';
export { default as patternTitleField } from './pattern-title';
export { default as patternDescriptionField } from './pattern-description';
export { default as patternSyncStatusField } from './pattern-sync-status';
export { default as orderField } from './order';
export { default as featuredImageField } from './featured-image';
export { default as templateField } from './template';
Expand Down
44 changes: 44 additions & 0 deletions packages/fields/src/fields/pattern-description/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* WordPress dependencies
*/
import type { Field } from '@wordpress/dataviews';
import { decodeEntities } from '@wordpress/html-entities';
import { __ } from '@wordpress/i18n';
import { Text } from '@wordpress/ui';

/**
* Internal dependencies
*/
import type { Pattern } from '../../types';

function getPatternDescription( item: Pattern ) {
if ( typeof item.excerpt === 'string' ) {
return decodeEntities( item.excerpt );
}
return decodeEntities( item.excerpt?.raw || '' );
}

const patternDescriptionField: Field< Pattern > = {
id: 'excerpt',
type: 'text',
label: __( 'Description' ),
placeholder: __( 'Add a description' ),
getValue: ( { item } ) => getPatternDescription( item ),
render: ( { item } ) => {
const description = getPatternDescription( item );
return description ? <Text>{ description }</Text> : null;
},
Edit: {
control: 'textarea',
rows: 4,
},
enableSorting: false,
enableHiding: false,
filterBy: false,
enableGlobalSearch: true,
};

/**
* Description field for patterns.
*/
export default patternDescriptionField;
Loading
Loading