Dashboard: register admin page route + sidebar menu (shell)#77573
Dashboard: register admin page route + sidebar menu (shell)#77573
Conversation
Create routes/dashboard/ with a placeholder stage component,
assigned to a new "dashboard" page in wpPlugin.pages.
The build system auto-generates build/pages/dashboard/
with initSinglePage() bootstrap (wp-admin chrome preserved).
Files: routes/dashboard/{package.json,stage.tsx,tsconfig.json}
Register a top-level "Dashboard (Beta)" menu item in wp-admin, gated behind the gutenberg-dashboard-widgets experiment. Uses initSinglePage() mode so the classic wp-admin sidebar is preserved — the stage renders inside #wpbody-content. Slug: dashboard-wp-admin (position 1, dashicons-dashboard) Render callback auto-generated by the build system.
Require lib/experimental/dashboard-widgets/load.php only when the gutenberg-dashboard-widgets experiment is enabled. Follows the same pattern as gutenberg-guidelines.
|
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. |
|
Size Change: 0 B Total Size: 7.76 MB ℹ️ View Unchanged
|
|
Flaky tests detected in beacfdf. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/24837372932
|
| * @package gutenberg | ||
| */ | ||
|
|
||
| add_action( 'admin_menu', 'gutenberg_register_dashboard_widgets_menu' ); |
There was a problem hiding this comment.
Later, we could replace the regular route with the experiment, and explore what backwards compatibility should look like.
There was a problem hiding this comment.
Agreed, that's the direction. This shell is strictly additive so we can iterate behind the flag without touching the classic dashboard.
The BC surface is the interesting piece: wp_add_dashboard_widget(), wp_dashboard_setup, meta box order stored in user meta, etc. We're looking at it as a separate workstream, probably through an automatic bridge that exposes legacy meta boxes as widgets in the new grid. Out of scope for this PR.
2a0a381 to
beacfdf
Compare
|
|
||
| function Dashboard() { | ||
| return ( | ||
| <Page title={ __( 'Dashboard' ) } headingLevel={ 1 }> |
There was a problem hiding this comment.
Not a blocker here, but I'll open a PR to change the default to 1 for pages like these.
If it merges first, we will just need to remove headingLevel and rebase.
There was a problem hiding this comment.
Makes sense, h1 is the right default for a page component. I'll drop the explicit headingLevel once yours lands.
There was a problem hiding this comment.
PR: #77617
Yeah or alternatively we merge with headingLevel=1 here and I'll just update mine to remove it, whichever goes first.
|
Hey @simison, sorry for the noise here. I accidentally merged Your two comments on |
* add dashboard route and page registration
Create routes/dashboard/ with a placeholder stage component,
assigned to a new "dashboard" page in wpPlugin.pages.
The build system auto-generates build/pages/dashboard/
with initSinglePage() bootstrap (wp-admin chrome preserved).
Files: routes/dashboard/{package.json,stage.tsx,tsconfig.json}
* add dashboard-widgets admin page loader
Register a top-level "Dashboard (Beta)" menu item in wp-admin,
gated behind the gutenberg-dashboard-widgets experiment.
Uses initSinglePage() mode so the classic wp-admin sidebar
is preserved — the stage renders inside #wpbody-content.
Slug: dashboard-wp-admin (position 1, dashicons-dashboard)
Render callback auto-generated by the build system.
* wire dashboard-widgets loader behind experiment flag
Require lib/experimental/dashboard-widgets/load.php only when
the gutenberg-dashboard-widgets experiment is enabled.
Follows the same pattern as gutenberg-guidelines.
* wrap dashboard stage in admin-ui Page shell
* update package-lock for dashboard route deps
Co-authored-by: simison <87168+simison@users.noreply.github.com>
Part of #77616
Context
Follow-up to #77569, which lands the
gutenberg-dashboard-widgetsexperiment flag. This PR adds the admin-page scaffolding that later work will mount real widget UI onto — part of the modernized dashboard direction picking up on the design proposed in #74616 and aligned with the admin-modernization thread in the 7.0 planning post.Shipped as a hidden shell behind the experiment flag: no widgets, no data fetching, no public APIs. Subsequent PRs will mount
<WidgetDashboard>from@wordpress/dashboardinside the page surface.What?
Registers a new Dashboard (Beta) top-level admin page in wp-admin and wires a minimal React route that renders through
@wordpress/admin-ui'sPagecomponent. Everything is gated behindgutenberg_is_experiment_enabled( 'gutenberg-dashboard-widgets' ), so the menu entry and runtime are invisible unless the experiment is on.Why?
Registering the page and route early gives the upcoming widget-framework and core-widget PRs a concrete mount point to iterate against, without committing to any public shape yet. Landing the shell in its own PR also keeps the review surface small — it's boot-plumbing only.
How?
Four commits, staged as independent concerns:
add dashboard route and page registration— addsroutes/dashboard/(route package +stage.tsx) and registersdashboardunderwpPlugin.pagesin the rootpackage.json. The build system auto-generatesbuild/pages/dashboard/using the sharedpage-wp-admin.php.template(same pattern used byguidelines,content-types, etc.).add dashboard-widgets admin page loader— addslib/experimental/dashboard-widgets/load.php, which registers the top-level Dashboard (Beta) menu entry (readcapability,dashicons-dashboard, position 1). The render callbackgutenberg_dashboard_wp_admin_render_pageis the one generated by the build template.wire dashboard-widgets loader behind experiment flag— requires the loader fromlib/load.phponly when the experiment is enabled. Mirrors the pattern used bygutenberg-guidelinesandgutenberg-content-types.wrap dashboard stage in admin-ui Page shell— replaces the bare<h1>placeholder with<Page title={ __( 'Dashboard' ) } />from@wordpress/admin-ui, giving the shell a proper heading region andNavigableRegionchrome. Adds@wordpress/admin-ui+@wordpress/base-stylesto the route's dependencies and drops a redundant per-routetsconfig.json(no sibling route carries one).Testing
Requires the
gutenberg-dashboard-widgetsexperiment flag to be available (#77569). With that merged (or cherry-picked locally):npm install && npm run build?page=dashboard-wp-adminshould 404 / return to the regular admin screen.