Site Editor > Patterns & Parts: generate sidebar from view config#76823
Site Editor > Patterns & Parts: generate sidebar from view config#76823
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
| templatePartCounts={ templatePartCounts } | ||
| patternCounts={ patternCounts } |
There was a problem hiding this comment.
Computing the counts per category client-side is a design decision, the same as retrieving the icons client-side. The rationale for this is that the experimental site editor doesn't have any, so I'm not convinced counts/icon need to be part of the endpoint. If that changes, we can add them later — which is easier than removing them once they've part of the endpoint.
There was a problem hiding this comment.
Pull request overview
Refactors the Site Editor “Patterns & Parts” sidebar to derive its category list from server-provided view config (useViewConfig().view_list), aligning this sidebar’s source of truth with other DataViews-driven sidebars (e.g., Templates/Pages) while preserving category counts.
Changes:
- Switch sidebar category sources from client-side hooks to server-provided
view_listforwp_template_partandwp_block. - Add client-side counting hooks for template parts (by
area) and patterns (by category and “My patterns”). - Extend the REST view-config controller (WP 7.1 compat) to provide
view_listentries for template parts and patterns.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js | Uses useViewConfig() lists for rendering and adds new counting logic for template part areas and pattern categories. |
| lib/compat/wordpress-7.1/class-gutenberg-rest-view-config-controller-7-1.php | Adds server-side view_list generation for wp_template_part areas and wp_block (patterns) categories. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js
Outdated
Show resolved
Hide resolved
packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js
Outdated
Show resolved
Hide resolved
lib/compat/wordpress-7.1/class-gutenberg-rest-view-config-controller-7-1.php
Show resolved
Hide resolved
|
Size Change: -94 B (0%) Total Size: 7.69 MB
ℹ️ View Unchanged
|
|
Flaky tests detected in 8c87579. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/23636429508
|
lib/compat/wordpress-7.1/class-gutenberg-rest-view-config-controller-7-1.php
Outdated
Show resolved
Hide resolved
packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js
Outdated
Show resolved
Hide resolved
packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js
Outdated
Show resolved
Hide resolved
8226746 to
8c87579
Compare
Part of #76544
Backported at WordPress/wordpress-develop#11272
What?
Refactor Site Editor > Patterns sidebar to source its category list from the server, using
useViewConfighook'sview_list. This aligns with how the Templates and Pages sidebars already work, and it continues work from #76734Why?
See #76544
How?
PHP:
get_view_list_for_wp_template_part— returns "All template parts" plus one entry per registered area (header, footer, sidebar, etc.).get_view_list_for_wp_block— returns "All patterns", "My patterns", plus one entry per category from WP_Block_Pattern_Categories_Registry and wp_pattern_category taxonomy terms, sorted alphabetically.JS:
Testing Instructions
Use of AI Tools
This PR and summary were authored with assistance from Claude Code (Claude Opus 4.6).