Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forms: Add File Upload Field Skeleton (Experimental) #41582

Merged
merged 3 commits into from
Feb 5, 2025

Conversation

lezama
Copy link
Contributor

@lezama lezama commented Feb 5, 2025

Proposed changes:

  • Adds the skeleton/structure for a new File Upload field block in Jetpack Forms
  • Implements the basic block registration as an experimental feature
  • Sets up the foundation for future file upload functionality

Implementation Details:

  • Added new field-file block definition with experimental flag
  • Added basic PHP rendering structure for file upload fields
  • Implemented experimental blocks registration system
  • No file upload functionality is implemented yet - this PR only adds the structural foundation

Testing instructions:

Testing the Block Structure:

  1. Set JETPACK_BLOCKS_VARIATION to 'experimental'
  2. Go to a page/post editor
  3. Add a Contact Form block
  4. Verify that the File Upload field is available in the field selector
  5. Add a File Upload field and verify it shows a basic file input element

Verifying Experimental Gate:

  1. Set JETPACK_BLOCKS_VARIATION to anything other than 'experimental'
  2. Go to a page/post editor
  3. Add a Contact Form block
  4. Verify that the File Upload field is NOT available in the field selector

@lezama lezama requested a review from a team February 5, 2025 21:05
@lezama lezama added the [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. label Feb 5, 2025
Copy link
Contributor

github-actions bot commented Feb 5, 2025

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Team Review, ...).
  • ✅ Add a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ Add testing instructions.
  • 🔴 Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

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 🤖


The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available.


🔴 Action required: We would recommend that you add a section to the PR description to specify whether this PR includes any changes to data or privacy, like so:

## Does this pull request change what data or activity we track or use?

My PR adds *x* and *y*.

Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Choose a review path based on your changes:
    • A. Team Review: add the "[Status] Needs Team Review" label
      • For most changes, including minor cross-team impacts.
      • Example: Updating a team-specific component or a small change to a shared library.
    • B. Crew Review: add the "[Status] Needs Review" label
      • For significant changes to core functionality.
      • Example: Major updates to a shared library or complex features.
    • C. Both: Start with Team, then request Crew
      • For complex changes or when you need extra confidence.
      • Example: Refactor affecting multiple systems.
  3. Get at least one approval before merging.

Still unsure? Reach out in #jetpack-developers for guidance!

@github-actions github-actions bot added [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! and removed [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. labels Feb 5, 2025
Copy link
Contributor

github-actions bot commented Feb 5, 2025

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WordPress.com Simple site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin, and enable the add/form-fields-upload-file branch.

  • To test on Simple, run the following command on your sandbox:

    bin/jetpack-downloader test jetpack add/form-fields-upload-file
    

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

Copy link
Contributor

github-actions bot commented Feb 5, 2025

Code Coverage Summary

Coverage changed in 3 files.

File Coverage Δ% Δ Uncovered
projects/packages/forms/src/blocks/contact-form/class-contact-form-block.php 0/150 (0.00%) 0.00% 9 💔
projects/packages/forms/src/blocks/contact-form/util/register-jetpack-block.js 0/17 (0.00%) 0.00% 4 💔
projects/packages/forms/src/contact-form/class-contact-form-plugin.php 111/830 (13.37%) -0.03% 2 💔

Full summary · PHP report · JS report

*
* @return string HTML for the file upload field.
*/
public static function gutenblock_render_field_file( $atts, $content ) {
Copy link
Member

Choose a reason for hiding this comment

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

beside changing this. We will also have to change the markup of the form html and add
enctype="multipart/form-data"

@enejb
Copy link
Member

enejb commented Feb 5, 2025

This works as described. 🥳
with

define( 'JETPACK_BLOCKS_VARIATION', 'experimental' );

I can see the new form filed.

With

define( 'JETPACK_BLOCKS_VARIATION', '1experimental' );

I don't.

Some things that I noticed that we can address in future PRs.

  1. The icon I think it would make more sense to use one of these
    Screenshot 2025-02-05 at 1 44 57 PM

  2. The user is able to click and select a file in the editor.

  3. I think we should go with a more fancier input field where the end user is able to drag and drop files. Vs the basic file input field. (See https://wpforms.com/templates/file-upload-form-template/ )

@enejb enejb added [Status] Ready to Merge Go ahead, you can push that green button! [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it and removed [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! labels Feb 5, 2025
@github-actions github-actions bot added the [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! label Feb 5, 2025
@lezama
Copy link
Contributor Author

lezama commented Feb 5, 2025

Definitely! Plenty of room for improvement in follow-ups. 😄 This was more about enabling the experimental flag for the field.

@lezama lezama merged commit c89a414 into trunk Feb 5, 2025
65 of 66 checks passed
@lezama lezama deleted the add/form-fields-upload-file branch February 5, 2025 21:59
@github-actions github-actions bot removed [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! [Status] Ready to Merge Go ahead, you can push that green button! labels Feb 5, 2025
talldan added a commit that referenced this pull request Feb 6, 2025
talldan added a commit that referenced this pull request Feb 6, 2025
@talldan talldan mentioned this pull request Feb 6, 2025
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Contact Form Form block (also see Contact Form label) [Feature] Contact Form [Package] Forms [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants