Add modern wp-build DataForm route for AI settings page#340
Add modern wp-build DataForm route for AI settings page#340jorgefilipecosta wants to merge 37 commits intodevelopfrom
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. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #340 +/- ##
=============================================
+ Coverage 57.70% 60.91% +3.20%
+ Complexity 617 596 -21
=============================================
Files 46 46
Lines 3173 3116 -57
=============================================
+ Hits 1831 1898 +67
+ Misses 1342 1218 -124
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@dkotter or @justlevine, can you verify that the proposed approach to the build step is compatible as the intermediate step? It would allow converge on one approach in other PRs, namely I was thinking about this work from @Jameswlepage: |
|
Ideally we're able to show Features at the top of the page, here's some low-fi mockups of what this could look like: #234 (comment) |
dkotter
left a comment
There was a problem hiding this comment.
Left a few minor comments but overall this looks okay to me. Not sure I love the actual UI but that's probably a separate conversation.
One thing we are missing here is previously we have a single button to enable/disable things. We've now reverted back to a checkbox that requires you to also hit the save button. Any chance we can bring that single button click back, as that was a requested enhancement we added a few releases back.
includes/bootstrap.php
Outdated
| /** | ||
| * Gets feature group metadata for the settings UI. | ||
| * | ||
| * @since 0.6.0 |
There was a problem hiding this comment.
We try and leave @since statements as x.x.x and we then replace those when we do the actual release, as we don't always know what the version number will be when merging a PR (and in this case, we've already release 0.6.0)
There was a problem hiding this comment.
Done — replaced all @since 0.6.0 with @since x.x.x in bootstrap.php (5 occurrences).
Changes to the build script look fine to me, assuming this question is around the changes in |
|
I tested this PR and here are my findings:
Proposed fix: Use separate build folders for each tool so they don't interfere with each other during development. |
f4d0d70 to
7cd1cf3
Compare
- Replace @SInCE 0.6.0 with @SInCE x.x.x placeholders in bootstrap.php - Add /routes and /tools to .distignore - Keep Settings_Page class with static init() method instead of inlining admin_menu logic in bootstrap.php - Extend webpack clean.keep regex to preserve wp-build output directories during watch mode
|
Addressed the Regarding separate build folders — both Instead, extended the |
The previous regex preserved wp-build directories (modules/, pages/, etc.) but missed root-level PHP files (build.php, constants.php) that bootstrap.php requires to load the settings page render function.
@jorgefilipecosta @gziolo how future-compat is this current config? It's one thing to be dogfooding a library to provide early feedback, but based on the lack of basic "plugin" support and these coexistence workarounds y'all had to find, how confident do you feel that our config won't require undue maintenance while the lib has a chance to stabilize? If it is unstable, I ultimately defer to @dkotter and @jeffpaul as to whether they think it's a good idea to assume the potential tech debt, but I do want to remind folks that we're not just about to become a canonical plugin, but we're about to become the first canonical plugin that WordPress directly promotes in Core, and we don't want a breaking I'm not sure what parts of this new build process are required for the latest dataviews lib, nor what about the new build process delayed WP7.0/how it was eventually resolved and whether it's relevant to us here, but assuming knowing both help decide whether this is a conversation worth having, or premature worry. (Changes themselves look fine to me 🚀) |
|
@justlevine, all fair feedback. I wasn’t aware of all the limitations of wp-build surfaced in this PR. I’m less worried about that as Gutenberg and WP core also use it, so in theory it should improve substantially over time. @jorgefilipecosta, wp-scripts is flexible enough to output to a different folder. If I recall correctly in the past Gutenberg was using two different build folders to avoid race conditions between scripts and script modules. The solution you proposed works today but it really brittle and something unexpected can pop up in the future as soon wp-build will need its cleanup. It all really depends on how long two build systems will coexist. Therefore, I’m too worried about it, but it’s important to keep it in mind. |
Summary
routes/ai-home/) that renders the AI settings page using@wordpress/dataviewsDataForm and@wordpress/admin-uiPage componentsshow_in_rest) so the frontend can read/save themKey changes
routes/ai-home/stage.tsx— Full DataForm-based settings page with:routes/ai-home/style.scss— Centered layout (max-width 680px) matching the Connectors page designincludes/Settings/Settings_Registration.php— Addedshow_in_rest => trueto all settingspackage.json— Added@wordpress/admin-uiand@wordpress/dataviewsdependenciesNote on
tools/ensure-boot-asset.cjsThe
wp-buildgenerated page template (page-wp-admin.php) hardcodes a reference tobuild/modules/boot/index.min.asset.phpfor dependency metadata. In Gutenberg core this file is generated frompackages/boot/, but plugins don't have a local boot package — they rely on WordPress core's@wordpress/bootscript module.The
tools/ensure-boot-asset.cjsscript creates a small PHP proxy that defers to core's boot asset at runtime. This is necessary until@wordpress/buildadds plugin-aware boot asset resolution (i.e., falling back to core'swp-includes/js/dist/script-modules/boot/index.min.asset.phpwhen no local boot package exists).Test plan
npm run build:routesthen visit Settings > AI (New)Screenshot