Repository navigation
Forms: add forms list to dashboard - #46580
Conversation
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
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! |
Code Coverage SummaryCoverage changed in 3 files.
2 files are newly checked for coverage.
Full summary · PHP report · JS report If appropriate, add one of these labels to override the failing coverage check:
Covered by non-unit tests
|
7e48f17 to
5fc649b
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds a DataViews-based list of reusable forms to the Jetpack Forms dashboard, enabling centralized form management. The feature is gated behind the central-form-management feature flag and introduces a new REST API endpoint for retrieving forms data, along with a React-based UI to display and manage forms.
Changes:
- Added new REST endpoint
/jetpack-forms/v1/formsto fetch paginated forms list - Created DataViews-based forms list UI with search functionality
- Implemented view state management with URL synchronization
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 16 comments.
Show a summary per file
| File | Description |
|---|---|
projects/packages/forms/src/dashboard/class-forms-endpoint.php |
New REST endpoint for fetching paginated forms list with entry counts |
projects/packages/forms/src/dashboard/hooks/use-forms-data.ts |
Custom React hook to fetch and manage forms data from the API |
projects/packages/forms/src/dashboard/forms/views.ts |
View state management hook with URL synchronization for search |
projects/packages/forms/src/dashboard/forms/index.tsx |
Main forms list component implementing DataViews with actions and fields |
projects/packages/forms/src/dashboard/forms/style.scss |
Styling for forms list filters bar |
projects/packages/forms/src/dashboard/inbox/style.scss |
Adjusted padding to consolidate styling in parent container |
projects/packages/forms/src/dashboard/class-dashboard.php |
Initialized Forms_Endpoint and added conditional preloading |
projects/packages/forms/changelog/add-forms-list-dataviews-table |
Changelog entry documenting the new feature |
d1f005d to
1d5e6ce
Compare
| // Match dashboard behavior: count feedback statuses we display/manage. | ||
| $statuses = array( 'publish', 'draft', 'spam', 'trash' ); | ||
|
|
||
| $args = array_merge( array( Feedback::POST_TYPE ), $form_ids, $statuses ); |
There was a problem hiding this comment.
I feel like this is kind of hard to read and follow.
Can we do without it? $args just passing in array( Feedback::POST_TYPE , $form_ids, $statuses )
instead to $wpdb->prepare(
There was a problem hiding this comment.
I agree hard to read. But I don't think we can do the change you're suggesting - it would change the data structure from flat to nested arrays. That said, this is not my strong suite, and I'm getting AI help with this. After some back and forth, I had my AI try to summarize the issue. You can let me know if you know better :).
$wpdb->prepare( $query, $args ) does not “expand” arrays to fill multiple placeholders.
So if $args is: array( Feedback::POST_TYPE, $form_ids, $statuses )
then from prepare()’s perspective you supplied 3 replacement values total:
- a string (Feedback::POST_TYPE)
- an array ($form_ids)
- an array ($statuses)
But the SQL has many placeholders:
- %s for post_type (1)
- one %d per form id (N)
- one %s per status (M)
prepare() expects 1 + N + M scalar values (string/int), in order. It can’t match an “array value” to “a list of %d placeholders” — it won’t iterate and substitute each element. Best case you get warnings / wrong SQL; worst case you get a broken query or the placeholders don’t get safely substituted.
There was a problem hiding this comment.
Thanks for the explanation Erick.
I think what you have works well.
One thing that I think would help here is still remobing the $args variable.
and just doing
$wpdb->prepare(
"SELECT...',
array_merge( array( Feedback::POST_TYPE ), $form_ids, $statuses );
instead.
There was a problem hiding this comment.
@enej - I think that's still the same thing and presents the same concerns?
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
d6b9ab6 to
2a016dc
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.
Comments suppressed due to low confidence (1)
projects/packages/forms/changelog/add-forms-list-dataviews-table:4
- The changelog entry should start with a capital letter and not include a package-specific prefix for entries in that same package. It should be "Add reusable forms list to dashboard." per the custom coding guidelines.
Forms: add reusable forms list to dashboard.
Addresses FORMS-367
Proposed changes:
This PR adds a DataViews-based list of reusable forms to the forms dashboard. It is part of centralized form management. All this work is still be behind a feature flag. The goal is to move toward the Figma designs here: 8TmDfrB54NU4Rzj19Qs9Tg-fi-5374_18492
Specific changes:
Not done - left for follow ups:
**Before: forms tab has placeholder **

After: forms tab has forms list

Other information:
Jetpack product discussion
Does this pull request change what data or activity we track or use?
Testing instructions:
Add this feature flag to your test site.
Test new tabs:
Test for now regression: