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

Protect: Fix ThreatFixHeader component title #38312

Merged
merged 5 commits into from
Jul 15, 2024

Conversation

dkmyta
Copy link
Contributor

@dkmyta dkmyta commented Jul 11, 2024

Fix

  • The ThreatFixHeader component that displays for each threat in the FixAllThreatsModal is missing the title element.
  • Unselecting all threats from the list in the modal, then reselecting them causes console errors and results in the threat IDs not being added back to the threatIds array to be fixed when initiated.

Proposed changes:

  • Update the modals that facilitate this component to ensure that the property containing the title is accessible and used
  • Disable the Fix all threats button in the modal when all threats are unselected
  • Fix the handleCheckboxClick functionality to avoid console errors

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

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

  • No

Testing instructions:

  • Create a new Jurassic Ninja site and enable this branch of Protect using the Beta Tester plugin
  • Add an upgrade and multiple fixable threats and run a scan
  • Once located, connect your user and enter your credentials and click Fix all threat or within an individual threat accordion item Fix threat
  • Verify that the threat title displays in either modal for each threat present
  • From the Fix all threats modal ensure that you can unselect all threats, that the Fix all button becomes disabled, and that you can reselect threats (without console errors) and the Fix all buttons becomes available once again
  • Ensure no regressions are introduced

Screenshots:

Single threat:
Screen Shot on 2024-07-11 at 14-46-47

Before w/ multiple threats:
Screen Shot on 2024-07-11 at 13-48-29

After w/ multiple threats:
Screen Shot on 2024-07-11 at 14-27-31

@dkmyta dkmyta marked this pull request as ready for review July 11, 2024 21:28
@github-actions github-actions bot added [Plugin] Protect A plugin with features to protect a site: brute force protection, security scanning, and a WAF. [Status] In Progress labels Jul 11, 2024
Copy link
Contributor

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


Once your PR is ready for review, check one last time that all required checks appearing at the bottom of this PR are passing or skipped.
Then, add the "[Status] Needs Team Review" label and ask someone from your team review the code. Once reviewed, it can then be merged.
If you need an extra review from someone familiar with the codebase, you can update the labels from "[Status] Needs Team Review" to "[Status] Needs Review", and in that case Jetpack Approvers will do a final review of your PR.


Protect plugin:

  • Next scheduled release: August 6, 2024.
  • Scheduled code freeze: July 29, 2024.

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

@dkmyta dkmyta self-assigned this Jul 11, 2024
@@ -35,7 +35,7 @@ const FixAllThreatsModal = ( { threatList = [] } ) => {
if ( ! checked ) {
setThreatIds( threatIds.filter( id => id !== threat.id ) );
} else {
setThreatIds( threatIds.push( threat.id ) );
setThreatIds( [ ...threatIds, threat.id ] );
Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch and nice fix!

@@ -53,7 +53,7 @@ const ThreatAccordionItem = ( {
event.preventDefault();
setModal( {
type: 'FIX_THREAT',
props: { id, label, title, icon, severity, fixable },
props: { id, fixable, title, icon, severity },
Copy link
Contributor

Choose a reason for hiding this comment

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

Using title makes sense to me, does this affect the handleIgnoreThreatClick() method above this one as well? i.e. can we potentially remove the getLabel() method entirely?

I'm not sure why the label was not displaying in the first place, since we're generating the value programmatically. Maybe an issue of not using callback/memo hooks? I'm just testing to verify that, and then I'll approve this PR 👍 👍

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've gone through this in more detail now and discovered that we don't generate the label prop for the threats list in advance of rendering this particular modal, whereas we do in others. Getting rid of the getLabel methods doesn't appear to be a logical solution either as we use that property in a variety of other location in the scan UI. Therefor, I've opted to reassess and bring in the label prop to the FixAllThreatsModal by generating the property initially directly within the useThreatsList hook, rather than the location that list is passed to.

Copy link
Contributor

@nateweller nateweller left a comment

Choose a reason for hiding this comment

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

LGTM!

@dkmyta dkmyta merged commit 5645b63 into trunk Jul 15, 2024
53 checks passed
@dkmyta dkmyta deleted the fix/protect-threat-fix-header-title branch July 15, 2024 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Plugin] Protect A plugin with features to protect a site: brute force protection, security scanning, and a WAF.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants