Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
23 changes: 23 additions & 0 deletions lib/experimental/dashboard-widgets/load.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
/**
* Bootstraps the Dashboard Widgets page in wp-admin.
*
* @package gutenberg
*/

add_action( 'admin_menu', 'gutenberg_register_dashboard_widgets_menu' );

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Later, we could replace the regular route with the experiment, and explore what backwards compatibility should look like.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.


/**
* Registers the Dashboard Widgets menu item.
*/
function gutenberg_register_dashboard_widgets_menu() {
add_menu_page(
__( 'Dashboard (Beta)', 'gutenberg' ),
__( 'Dashboard (Beta)', 'gutenberg' ),
'read',
'dashboard-wp-admin',
'gutenberg_dashboard_wp_admin_render_page',
'dashicons-dashboard',
1
);
}
5 changes: 5 additions & 0 deletions lib/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,3 +226,8 @@ function gutenberg_is_experiment_enabled( $name ) {
require __DIR__ . '/experimental/content-types/load.php';
require __DIR__ . '/experimental/content-types/index.php';
}

// Dashboard Widgets (only load when experiment is enabled).
if ( gutenberg_is_experiment_enabled( 'gutenberg-dashboard-widgets' ) ) {
require __DIR__ . '/experimental/dashboard-widgets/load.php';
}
14 changes: 14 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"font-library",
"options-connectors",
"guidelines",
"taxonomies"
"taxonomies",
"dashboard"
]
},
"config": {
Expand Down
17 changes: 17 additions & 0 deletions routes/dashboard/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "@wordpress/dashboard-route",
"version": "1.0.0",
"private": true,
"route": {
"path": "/",
"page": [
"dashboard"
]
},
"dependencies": {
"@wordpress/admin-ui": "file:../../packages/admin-ui",
"@wordpress/base-styles": "file:../../packages/base-styles",
"@wordpress/element": "file:../../packages/element",
"@wordpress/i18n": "file:../../packages/i18n"
}
}
15 changes: 15 additions & 0 deletions routes/dashboard/stage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* WordPress dependencies
*/
import { Page } from '@wordpress/admin-ui';
import { __ } from '@wordpress/i18n';

function Dashboard() {
return (
<Page title={ __( 'Dashboard' ) } headingLevel={ 1 }>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, h1 is the right default for a page component. I'll drop the explicit headingLevel once yours lands.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR: #77617

Yeah or alternatively we merge with headingLevel=1 here and I'll just update mine to remove it, whichever goes first.

<div className="dashboard-widgets" />
</Page>
);
}

export const stage = Dashboard;
Loading