Skip to content

add empty spam button and endpoint #44308

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

Merged
merged 4 commits into from
Jul 15, 2025

Conversation

CGastrell
Copy link
Contributor

Fixes FORMS-214

Proposed changes:

This PR adds a "Empty spam" button to delete ALL responses marked as spam, regardless of selection. It works like (it's a copy of) Empty Trash button.

At this point I didn't see the need to overengineer the component into a reusable one, if we find a 3rd or 4th usage for the same request strategy, then we can revisit. Same goes for the endpoint, we're reusing the /trash endpoint as the verb and action are the same, seems to me it's fine to share the endpoint based on the status param.

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

FORMS-214

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

No

Testing instructions:

Visit Jetpack > Forms dashboard on the Spam view. There should be a "Empty spam" button on the top-right corner:

image

The button will be disabled if there are no responses listed as spam. Clicking the button will open a confirmation dialog:
image

Cancel should work as expected. Confirming will DELETE all responses marked as spam and the view should refresh to update both the list and the number of responses (on the Inbox status toggle tab)

@CGastrell CGastrell self-assigned this Jul 14, 2025
Copy link
Contributor

github-actions bot commented Jul 14, 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), and enable the add/jetpack-forms-empty-spam-endpoint branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack add/jetpack-forms-empty-spam-endpoint

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 Jul 14, 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!

@github-actions github-actions bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Jul 14, 2025
Copy link

jp-launch-control bot commented Jul 14, 2025

Code Coverage Summary

Coverage changed in 2 files.

File Coverage Δ% Δ Uncovered
projects/packages/forms/src/contact-form/class-contact-form-endpoint.php 397/573 (69.28%) 0.05% 4 💔
projects/packages/forms/src/dashboard/components/layout/index.tsx 0/29 (0.00%) 0.00% 1 ❤️‍🩹

1 file is newly checked for coverage.

File Coverage
projects/packages/forms/src/dashboard/components/empty-spam-button/index.tsx 22/24 (91.67%) 💚

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 [Status] Needs Team Review Obsolete. Use Needs Review instead. [Type] Task and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Jul 14, 2025
@simison
Copy link
Member

simison commented Jul 15, 2025

Thanks for working on it!

"Empty spam" should work little differently from "Empty trash"; instead we should move the entire spam folder contents into trash in this case, just like for individual items:

Screenshot 2025-07-15 at 14 07 09

Because the action isn't as destructive, we wouldn't need the confirmation either.

If we returned the list of IDs "trashed" from the API (and in cases where it isn't a ton of IDs) we could then provide "undo" action in the confirmation like we do for individual items, but I don't think that's a biggie to also leave out if it's complicated:

image

cc @ilonagl for thoughts.

@simison simison requested a review from ilonagl July 15, 2025 11:10
@CGastrell
Copy link
Contributor Author

Thanks for the review and clarification @simison

Though I first imagined the "Empty spam" to work as you mention, I then thought it'd make sense to just delete all spam, since the button is in the same position as "Empty trash" and messages marked as spam are there to be reviewed (in case the user wants to double check) but then there's no use for them. Since the user is already on that screen, means he's reviewed them and the button offers to just "purge" them.

Then again, it would also feel natural that responses have a flow of "going right" (from inbox to spam, from spam to trash, then actual deletion from there), so actions from the spam view (being in the middle) should move things to "right or left", not obliterate them.

Both approaches seem fine to me, so if you have a strong opinion I'll just make the change, not a big deal and makes complete sense.

@CGastrell CGastrell added the Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR label Jul 15, 2025
@CGastrell CGastrell merged commit 214d251 into trunk Jul 15, 2025
70 checks passed
@CGastrell CGastrell deleted the add/jetpack-forms-empty-spam-endpoint branch July 15, 2025 17:42
@github-actions github-actions bot removed the [Status] Needs Team Review Obsolete. Use Needs Review instead. label Jul 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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 [Package] Forms [Tests] Includes Tests [Type] Task
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants