Skip to content

Forms: add field file as paid with custom setup #43177

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

Open
wants to merge 17 commits into
base: trunk
Choose a base branch
from

Conversation

CGastrell
Copy link
Contributor

@CGastrell CGastrell commented Apr 21, 2025

Closes #41677
Closes JETPACK-335

Proposed changes:

The changes include a combination of:

  • register block as plan supported feature (wpcomsh)
  • register block as plan supported by Jetpack
  • use default upgrade nudge for dotcom and AT
  • use wrapped upgrade nudge for self-hosted
  • customize upgrade nudge looks for self-hosted (debatable)

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

peKye1-1vf-p2

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

No

Testing instructions:

On all cases, test the upgrade flow works and lands on the right plans (for now, personal and above for dotcom, Complete on Jetpack).

Locally:

Build packages/plans, packages/forms, plugins/wpcomsh and plugins/jetpack.
Open the editor, add a form and then insert a File Upload field block. Test with and without add_filter( 'jetpack_block_editor_enable_upgrade_nudge', '__return_true' );

Without the filter (custom styled nudge):
image

With the filter (as will likely look on dotcom):
image

Use the PR links to test on sandbox and simple/business sites, you need to checkout 181551-ghe-Automattic/wpcom

Test on AT sites.

@CGastrell CGastrell added [Status] In Progress [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Package] Plans [Package] Forms [Feature] Forms Blocks Blocks designed to streamline user input and engagement, such as contact, newsletter sign-ups, etc. Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR labels Apr 21, 2025
@CGastrell CGastrell requested a review from a team April 21, 2025 19:40
@CGastrell CGastrell self-assigned this Apr 21, 2025
Copy link
Contributor

github-actions bot commented Apr 21, 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 WoA dev 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 (Jetpack or WordPress.com Site Helper), and enable the add/field-file-custom-paid-block branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack add/field-file-custom-paid-block
bin/jetpack-downloader test jetpack-mu-wpcom-plugin add/field-file-custom-paid-block

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

@github-actions github-actions bot added [Block] Contact Form Form block (also see Contact Form label) [Feature] Contact Form labels Apr 21, 2025
Copy link
Contributor

github-actions bot commented Apr 21, 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 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 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: May 6, 2025
    • Code freeze: May 5, 2025

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Wpcomsh plugin:

  • Next scheduled release: Atomic deploys happen twice daily on weekdays (p9o2xV-2EN-p2)

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

Copy link

jp-launch-control bot commented Apr 21, 2025

Code Coverage Summary

Coverage changed in 3 files.

File Coverage Δ% Δ Uncovered
projects/packages/forms/src/blocks/contact-form/class-contact-form-block.php 95/195 (48.72%) -1.81% 7 💔
projects/packages/forms/src/blocks/contact-form/components/jetpack-field-file/index.js 0/17 (0.00%) 0.00% 7 💔
projects/packages/forms/src/contact-form/class-contact-form-plugin.php 290/849 (34.16%) -0.08% 2 ❤️‍🩹

1 file is newly checked for coverage.

File Coverage
projects/packages/forms/src/blocks/contact-form/components/upsell-nudge/index.js 0/3 (0.00%) 💔

Full summary · PHP report · JS report

Coverage check overridden by Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR .

@CGastrell CGastrell added the [Type] Feature Development of a new feature label Apr 22, 2025
@CGastrell CGastrell force-pushed the add/field-file-custom-paid-block branch 2 times, most recently from 0bd1c60 to e208d8c Compare April 24, 2025 16:49
@CGastrell CGastrell force-pushed the add/field-file-custom-paid-block branch from e24793e to d807a98 Compare April 24, 2025 19:04
@CGastrell CGastrell force-pushed the add/field-file-custom-paid-block branch from bf9f993 to 141cdc3 Compare April 25, 2025 14:18
@@ -530,6 +531,11 @@ public static function gutenblock_render_field_consent( $atts, $content ) {
* @return string HTML for the file upload field.
*/
public static function gutenblock_render_field_file( $atts, $content ) {
if ( apply_filters( 'jetpack_unauth_file_upload_plan_check', true ) && ! Plan::supports( 'field-file' ) ) {
Copy link
Member

Choose a reason for hiding this comment

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

Is this filter just to help with testing?

Copy link
Contributor Author

@CGastrell CGastrell Apr 25, 2025

Choose a reason for hiding this comment

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

Testing and development. Setting it to false will allow you to add the block without having to get the upgrade.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can consider removing the filter entirely once we're done with the development? It's comfy though

Copy link
Member

@enejb enejb left a comment

Choose a reason for hiding this comment

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

I left a few comments :)

@@ -704,6 +705,10 @@ class WPCOM_Features {
self::WPCOM_BUSINESS_AND_HIGHER_PLANS,
self::WPCOM_PRO_PLANS,
),
self::FIELD_FILE => array(
self::WPCOM_PERSONAL_AND_HIGHER_PLANS,
Copy link
Member

Choose a reason for hiding this comment

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

I think we should exclude the WOO trial from this.
This way we don't worry about folks that are not paying us and us storing info for free for them.

'jetpack_register_gutenberg_extensions',
function () {
if ( ! apply_filters( 'jetpack_unauth_file_upload_plan_check', true ) ) {
\Jetpack_Gutenberg::set_extension_available( 'field-file' );
Copy link
Member

Choose a reason for hiding this comment

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

Instead of having set_extension_available on the Jetpack_Gutenberg here and creating a Jetpack plugin depenency. It would be good to move it to blocks package. Which we already include.
This way we avoid this dependency.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mmm... I see what you mean, but Blocks depends on Jetpack_Gutenberg. Maybe we can add some set_extension_available on Blocks class, but it feels like duped code and actually out of its scope?

@@ -50,6 +50,10 @@
flex-direction: row;
gap: var(--wp--style--block-gap, 1.5rem);

& > div {
Copy link
Member

Choose a reason for hiding this comment

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

This rule seems really generic. Should it really apply to all the divs?

Copy link
Contributor Author

@CGastrell CGastrell Apr 25, 2025

Choose a reason for hiding this comment

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

It is, it was the only way to make the nudge coexist with our flexbox layout. I could narrow it a bit with:

& > div:first-child

EDIT: scratch that, doesn't work. I was looking at the wrong div. Agreed it is generic, feel free to try alternatives when the nudge is showing, I couldn't think of any other option.

Copy link
Member

Choose a reason for hiding this comment

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

In my testing it doesn't seem to make a difference. What theme are you using? What exactly is the difference?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without the change:
image

After change included in this PR:
image

@@ -79,6 +79,7 @@ class Current_Plan {
'akismet',
'payments',
'videopress',
'field-file', // Forms
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to specific this both places? Once in wpcom_features and here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this takes care of providing the minimum required plan when you are self-hosted or not connected.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think we have a personal plan anymore just complete. See https://cloud.jetpack.com/pricing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I think we'll be better off just pointing at complete for now.

@enejb
Copy link
Member

enejb commented Apr 25, 2025

On my jetpack site the nudge takes me to.

Screenshot 2025-04-25 at 12 09 11 PM

Is this expected? I don't see anything telling about the file upload field. Also I thought I only need to buy Jetpack complete.
The URL end up being - https://wordpress.com/plans/enejdev.jurassic.tube?compare_plans=jetpack_personal,jetpack_backup_t1_yearly,jetpack_anti_spam

@@ -81,7 +81,8 @@
"videopress/video-chapters",
"ai-assistant-backend-prompts",
"ai-list-to-table-transform",
"ai-use-chrome-ai-sometimes"
"ai-use-chrome-ai-sometimes",
"field-file"
Copy link
Member

Choose a reason for hiding this comment

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

Do we need this here? Since the field-file is not part of the jetpack/extensions package at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we remove it, the process no longer registers the block as intended and there's no plan check, meaning the block appears as free and no nudge is shown. Unsure if there's another way, but all the other plan_check blocks are there (send-a-message, calendly, opentable, simple-payments, etc)

@simison
Copy link
Member

simison commented Apr 25, 2025

On my jetpack site the nudge takes me to.

We can make the Dotcom side work first and focus on Jetpack side flows separately.

@CGastrell
Copy link
Contributor Author

On my jetpack site the nudge takes me to.

Screenshot 2025-04-25 at 12 09 11 PM

Is this expected? I don't see anything telling about the file upload field. Also I thought I only need to buy Jetpack complete. The URL end up being - https://wordpress.com/plans/enejdev.jurassic.tube?compare_plans=jetpack_personal,jetpack_backup_t1_yearly,jetpack_anti_spam

After removing the support from Personal plan, the upgrade flow now takes you straight to Complete checkout.

@CGastrell CGastrell requested a review from enejb April 28, 2025 17:53
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) Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR [Feature] Contact Form [Feature] Forms Blocks Blocks designed to streamline user input and engagement, such as contact, newsletter sign-ups, etc. [Package] Forms [Package] Plans [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Wpcomsh [Status] In Progress [Type] Feature Development of a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Forms: file upload field upsell flow
3 participants