Premium Analytics: trim dashboard sections API to the server contract#50661
Premium Analytics: trim dashboard sections API to the server contract#50661louwie17 wants to merge 1 commit into
Conversation
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
Add a derived section slug to Dashboard_Section and its REST
representation, trim GET /sections to { id, slug, label, order },
retire the per-user section-layout write routes (PUT/DELETE layout,
DELETE sections) and the helpers that served them, and relabel the
woocommerce/store section to Store. Layout persistence stays on core
@wordpress/preferences.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KKXV17Z2FVzrtTt8zK5RaF
9c9df41 to
b0ef0a1
Compare
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
Code Coverage SummaryCoverage changed in 3 files.
Full summary · PHP report · JS report If appropriate, add one of these labels to override the failing coverage check:
Covered by non-unit tests
|
Fixes #
Proposed changes
First of two PRs wiring the dashboard tab bar to the server-side section registry (see the linked plan discussion). This one lands the server contract only — there is no live JS consumer of these routes yet, so it is safe to reshape them. A follow-up PR will make the frontend consume
GET /sections.slugtoDashboard_Section, derived from the section ID segment after the namespace (analytics/traffic→traffic,woocommerce/store→store), and expose it in the REST representation. The frontend will use the slug for?section=URLs and preference keys, so existing bookmarks and stored layouts keep working with zero migration.GET /wpcom/v2/dashboards/{name}/sectionsto return section definitions only —{ id, slug, label, order }per section. The resolvedlayoutandhasCustomLayoutfields are gone: layout persistence stays entirely on core@wordpress/preferences(dashboardSectionLayoutskey), which already covers reads and writes.PUT /dashboards/{name}/sections/{ns}/{slug}/layoutDELETE /dashboards/{name}/sections/{ns}/{slug}/layoutDELETE /dashboards/{name}/sections(reset-all)get_dashboard_section_layouts_for_user(),update/delete_dashboard_section_layout_for_user(),delete_dashboard_section_layouts_for_user(),get_stored_persisted_preferences_for_user(), and the section-layout validators.GET /sectionsandGET .../default-layout(the reset path) unchanged, along with the inject-on-read default seeding indashboard-layout.php.woocommerce/storesection from "WooCommerce" to "Store", matching the label the static frontend tab uses today, so switching to server-driven labels causes no visible change.Related product discussion/links
Does this pull request change what data or activity we track or use?
No.
Testing instructions
cd projects/packages/premium-analytics && composer phpunit— the suite covers the newslugfield, the leanGET /sectionsresponse shape, WooCommerce availability filtering via thejetpack_premium_analytics_woocommerce_dashboard_section_availablefilter, the retired routes returning404 rest_no_route, ordering, and themanage_optionspermission check.In the browser with
wp.apiFetchOn a Jetpack-connected test site with this branch built, log in as an admin, open the Premium Analytics dashboard (or the block editor — any admin screen that loads
wp-api-fetch), and run in the browser console:{ id, slug, label, order }objects only — nolayoutorhasCustomLayoutkeys. With WooCommerce active it ends with{ id: 'woocommerce/store', slug: 'store', label: 'Store', order: 40 }; with WooCommerce deactivated that entry disappears.rest_no_route(404):No user-facing change
The dashboard UI is unaffected: the tab bar still renders from the static frontend config (no JS consumer of these routes exists yet), and layout customization/reset still works through core preferences.
🤖 Generated with Claude Code
https://claude.ai/code/session_01KKXV17Z2FVzrtTt8zK5RaF