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

My Jetpack: Allow the "Threats detected" Notice to be closed(X) with persistence. #41728

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

Conversation

elliottprogrammer
Copy link
Contributor

@elliottprogrammer elliottprogrammer commented Feb 11, 2025

This PR allows the Protect "Threats detected" notice to be manually closed (by clicking the close(X) icon), and remain closed (until browser session expires).

Closes https://github.com/Automattic/jetpack-roadmap/issues/2297

Proposed changes:

  • Add prop to show the close button/icon on the Notice.
  • Add onCloseClick event handler. Set a session cookie on close click & remove the Notice.
  • Add logic to only show/set the red-bubble Notice if there is no cookie set.

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

Part of overall task: https://github.com/Automattic/jetpack-roadmap/issues/2050

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

No

Testing instructions:

  • Run this PR branch locally or via a Jurassic Ninja site using the Jetpack Beta plugin.
  • Connect Jetpack (site and user).
  • Install and/or activate the Jetpack Debug Helper (Tools) plugin:
    • If running local dev env, go to Plugins page, & activate the Jetpack Debug Tools plugin.
    • If running JN site, download the plugin zip file from: https://github.com/Automattic/jetpack-debug-helper. Upload zip & install (You may receive an error when the installer tries to activate, that's fine, just go to Plugins page (/wp-admin/plugins.php), verify it was installed, and click activate link.
  • Once the Debug Helper plugin in activated, you should now see a "Jetpack Debug" menu item towards the bottom of the wp-admin side menu. Click "Jetpack Debug" to open the Jetpack Debug dashboard.
  • Select the "Jetpack Scan Helper" checkbox and click "Save" button.
  • You should now see a "Scan Helper" sub-menu item, under the main "Jetpack Debug" menu item. Click the "Scan Helper" menu item to open the Scan helper page.
  • On the Scan Helper page, select EICAR Threat and Create a fake vulnerable plugin, and click the "Update site threats" button.
  • Run this PR branch (either locally in dev env, or on JN site via Jetpack Beta plugin)
  • Purchase a Protect paid plan (jetpack_scan_daily).
  • Once purchased, go to the Protect product card, click View to open Protect/Scan and then start/queue a scan of your site.
  • Scan should run, after a bit, it should detect threats on your site (5 threats, 1 critical).
  • The Protect product card should be showing the threats, and there should be a CTA that says, "Fix Threats". (See Screenshot:)
  • Screen Shot on 2025-02-11 at 14-09-04
  • You should also now see the "Protect/Scan found threats on your site" Notice at the top of My Jetpack.
  • Verify it has a Close(X) icon in the top right corner. (See screenshot:)
  • Screen Shot 2025-02-11 at 14 10 38
  • Click the Close(X) icon to manually close/dismiss the Notice. Verify the Notice disappears after clicking the icon.
  • Reload the page, Verify the Notice remains closed and does not appear again.
  • Keep note of the JN site url and user login credentials (displayed on the WP Dashboard page).
  • Then you can completely quit/kill your browser (or start a new incognito browser widow). Go to the JN site, log in to wp-admin. Verify the Notice is showing again (The Notice dismissal expires when the browser session expires).

@elliottprogrammer elliottprogrammer self-assigned this Feb 11, 2025
Copy link
Contributor

github-actions bot commented Feb 11, 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/mj-notice-close-protect-threats branch.

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

    bin/jetpack-downloader test jetpack add/mj-notice-close-protect-threats
    

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 11, 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.


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 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 11, 2025
Copy link
Contributor

Code Coverage Summary

Coverage changed in 2 files.

File Coverage Δ% Δ Uncovered
projects/packages/my-jetpack/_inc/hooks/use-notification-watcher/use-protect-threats-detected-notice.tsx 0/25 (0.00%) 0.00% 4 💔
projects/packages/my-jetpack/src/class-initializer.php 52/502 (10.36%) -0.04% 2 ❤️‍🩹

Full summary · PHP report · JS report

@elliottprogrammer elliottprogrammer requested a review from a team February 11, 2025 19:32
@elliottprogrammer elliottprogrammer added [Status] Needs Team Review 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 11, 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 11, 2025
Copy link
Contributor

@CodeyGuyDylan CodeyGuyDylan left a comment

Choose a reason for hiding this comment

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

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] My Jetpack [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! [Status] Needs Team Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants