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: Separate scanner and history views via React Router and UI adjustments #38325

Merged

Conversation

nateweller
Copy link
Contributor

@nateweller nateweller commented Jul 12, 2024

Related to #38144

Proposed changes:

  • Adds /scan/history and /scan/history/:filter routes.
  • Adds a /scan route and default redirect from / -> /scan.
  • Removes useThreatHistory() hook and uses separate routes/root components for the scanner and history views.
  • Use initial state provided by server for scan history.
  • Only refetch scan history when necessary (i.e. after upgrade or threat fix/ignore).
  • Moves filtering of threat history to the client side.
  • Adds several supporting components.

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

#38144

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

No

Testing instructions:

  • Protect Free
    • Ensure no reference/path to threat history is displayed.
  • Protect Paid - No Threats
    • Validate "Scan Now" button is displayed on the screen.
    • Review empty History screen.
  • Protect Paid - Threats
    • Validate "Scan Now" button is displayed on the screen.
    • Auto-fix and/or ignore threat(s), then navigate to History and validate the new items are displayed.
    • Test reloading the page to validate the server-provided initial state also accurately includes the new threat history.

Screenshots

Screenshot 2024-07-12 at 3 48 55 PM Screenshot 2024-07-12 at 3 49 10 PM Screenshot 2024-07-12 at 3 48 23 PM
@nateweller nateweller added [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Status] Needs Team Review [Plugin] Protect A plugin with features to protect a site: brute force protection, security scanning, and a WAF. labels Jul 12, 2024
@nateweller nateweller requested a review from a team July 12, 2024 22:07
@nateweller nateweller self-assigned this Jul 12, 2024
Copy link
Contributor

github-actions bot commented Jul 12, 2024

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.


🔴 Action required: Please add missing changelog entries for the following projects: projects/plugins/protect

Use the Jetpack CLI tool to generate changelog entries by running the following command: jetpack changelog add.
Guidelines: /docs/writing-a-good-changelog-entry.md


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: none scheduled.

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

Copy link
Contributor

github-actions bot commented Jul 12, 2024

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/protect-threat-history-routes branch.

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

    bin/jetpack-downloader test jetpack add/protect-threat-history-routes
    

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
@nateweller nateweller force-pushed the add/protect-threat-history-routes branch 2 times, most recently from ca6908d to c8a08d5 Compare July 13, 2024 00:30
@nateweller nateweller force-pushed the add/protect-threat-history-routes branch from c8a08d5 to 27c6505 Compare July 13, 2024 00:51
@nateweller nateweller force-pushed the add/protect-threat-history-routes branch from 27c6505 to 7094605 Compare July 15, 2024 16:34
@nateweller nateweller marked this pull request as ready for review July 15, 2024 20:39
@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 Jul 15, 2024
Copy link
Contributor

@dkmyta dkmyta left a comment

Choose a reason for hiding this comment

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

Shaping up really nicely! I believe a few of the points I made in my review of the initial enhancements still require attention or further discussion:

  • I think it would still be nice to have the ability to flip back and forth from the Scanner and History page from the various states of the page (eg. currently when scanning or in scan error state we cannot access History)
  • Manually unignored threats (via the VPMC tool) retain an ignored status and therefor display the ScanHistoryDetails component even when in the current threats list. I think this might actually also be an issue in Calypso so perhaps the full and proper solution is ensuring that status gets set correctly when it gets unignored.
  • Could we now display what filter is being applied in the EmptyList (eg. So far, there are no **fixed** threats in your scan history..., instead of ...selected filters)?

A few new things I came across:

  • The display of the error state in the History page could maybe use some love (eg. conditionally removing the sub-header message, perhaps structuring/styling it more like scan error with the in-progress image):
    Screen Shot on 2024-07-15 at 12-42-21 (1)
  • There is now an odd animation/styling issue when the onboarding popover displays next to the Scan now button:
    Screen Capture on 2024-07-15 at 11-24-08
  • The History page is still accessible and empty (missing data) when a user does not have an upgrade. I see we've removed the toggles to get there easily, but anyone can still visit /admin.php?page=jetpack-protect#/scan/history to access it.
  • Now that some of our classes and models have been moved to dedicated packages (packages/protect-status, and packages/protect-models), should we consider also moving class-scan-history?
  • When viewing History, and selecting a specific plugin, if you toggle the ignored or fixed filter and that plugin is not there, or if you do not have any of either fixed or ignored archived threats, the EmptyList component is displayed and you are no longer able to access the filter toggles:
    Screen Capture on 2024-07-15 at 13-06-33
  • Separately, but as you'll see in the above screen capture, for some reason, WordPress threats show up in the display of all threats, but then are missing when we filter by ignored or fixed.
  • Now that the secondary Scan now button has been moved to the EmptyList component, we appear to be missing the onboarding popover for that flow:
    Screen Shot on 2024-07-15 at 13-32-52
@@ -39,9 +40,10 @@ const AdminPage = ( { children } ) => {
setTimeout( () => {
refreshPlan();
refreshStatus( true );
refreshScanHistory();
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason why we shouldn't treat this like refreshStatus with a hard refresh?

@@ -176,9 +182,7 @@ const PaidList = ( { list } ) => {
diff,
filename,
firstDetected, // todo: still needs a proper fix
Copy link
Contributor

Choose a reason for hiding this comment

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

We can remove this todo now since I think we've addressed this by camelizing the scanHistory initial state variable in the reducer.

@nateweller
Copy link
Contributor Author

When viewing History, and selecting a specific plugin, if you toggle the ignored or fixed filter and that plugin is not there, or if you do not have any of either fixed or ignored archived threats, the EmptyList component is displayed and you are no longer able to access the filter toggles:

This one is extra strange, as there appears to be fixed core threats that should be displaying. Looking into it 👀

@nateweller nateweller force-pushed the add/protect-threat-history-routes branch from 8a424f5 to 674d3a9 Compare July 17, 2024 05:02
@nateweller nateweller force-pushed the add/protect-threat-history-routes branch from 674d3a9 to 71f1191 Compare July 26, 2024 00:39
@dkmyta dkmyta self-requested a review July 30, 2024 16:17
Copy link
Contributor

@dkmyta dkmyta left a comment

Choose a reason for hiding this comment

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

Very nice enhancements! Let's go ahead and merge this into the project branch and address any additional items in dedicated followup tasks.

@nateweller nateweller merged commit 5856382 into add/protect-threat-history Jul 30, 2024
63 of 66 checks passed
@nateweller nateweller deleted the add/protect-threat-history-routes branch July 30, 2024 16:58
@github-actions github-actions bot removed [Status] Needs Team Review [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! labels Jul 30, 2024
@nateweller nateweller restored the add/protect-threat-history-routes branch July 30, 2024 18:57
@dkmyta dkmyta mentioned this pull request Jul 30, 2024
3 tasks
dkmyta added a commit that referenced this pull request Aug 6, 2024
* Add Scan_History class

* changelog

* Update changelog

* Merge trunk, fix versions

* Add initial UI for scan history

* Add firstDetected and fixedOn details to threat cards

* Fix ignored message

* Fix console error

* Adjust wording and styles

* Optimize

* Fix firstDetected and fixedOn property retrieval issues, add todos

* Remove unneeded ref

* Consolidate scan history UI to existing components

* Remove todos

* Return false for scanHistory when upgrade is missing

* Manage ScanPage states when viewing history

* Move source data logic to useProtectData hook

* Improve Summary component Button logic

* ScanPage refactoring

* Reapply missing scanIsUnavailable check

* Add comments

* Hide ignore when viewing threats, and clear history cache when updating or fixing

* Add unignore actions and conditional handling to the UI

* Add null coalescing to core threat prop assignment

* Fix core threat normalization

* Optimizations and refactoring

* Revert standarization, and use conditionals

* Add dummy arg to avoid bad translation minification

* Changlog entry

* Move viewingScanHistory out of initial state

* Use threat status over lack of fixedOn to display unignore button

* Add foundation for unignore request

* Remove need for signature_id

* Add TypeScript support to Jetpack Protect

* Downgrade typescript to 5.0.4, to match other monorepo projects

* Add TypeScript support to Jetpack Protect

* Init feature branch

* Protect: Add Scan_History class (#37903)

* Protect: Add Scan History UI (#37988)

* Init feature branch

* Init feature branch

* Init feature branch

* Use react router for threat history, separate scan and history root components, minor UI adjustments

* changelog

* Add dummy args to avoid bad minification

* Hide scan section navigation when user has no plan

* Wrap ScanButton with forwardRef

* Add onboarding popover to Scan Now button in empty state

* Fix filtering of core threat history

* Redirect to /scan from /scan/history when user has no plan

* Fix animation glitch in onboarding popover

* Remove unnecessary additions

* Further removals after failed base merge

* More removals

* Add todos

* Use status to conditional render unignore action button

* Move ignore/unignore actions to dedicated modals

* Add TypeScript support to Jetpack Protect

* Downgrade typescript to 5.0.4, to match other monorepo projects

* Add TypeScript support to Jetpack Protect

* Init feature branch

* Protect: Add Scan_History class (#37903)

* Protect: Add Scan History UI (#37988)

* changelog

* Protect: Separate scanner and history views via React Router and UI adjustments (#38325)

* Run ./tools/fixup-project-versions.sh

* Restore project versions

* Run ./tools/fixup-project-versions.sh

* Remove todo comment (#38628)

* Remove changelog

* Display fix threat button only for current threats

* Further unification

* Refresh scan history after unignore

* Update projects/plugins/protect/src/js/components/unignore-threat-modal/index.jsx

Co-authored-by: Nate Weller <nate.weller@automattic.com>

* Fix lint errors

---------

Co-authored-by: Nate Weller <hello@nateweller.com>
Co-authored-by: Nate Weller <nate.weller@automattic.com>
nateweller added a commit that referenced this pull request Aug 6, 2024
* Add Scan_History class

* changelog

* Update changelog

* Merge trunk, fix versions

* Add initial UI for scan history

* Add firstDetected and fixedOn details to threat cards

* Fix ignored message

* Fix console error

* Adjust wording and styles

* Optimize

* Fix firstDetected and fixedOn property retrieval issues, add todos

* Remove unneeded ref

* Consolidate scan history UI to existing components

* Remove todos

* Return false for scanHistory when upgrade is missing

* Manage ScanPage states when viewing history

* Move source data logic to useProtectData hook

* Improve Summary component Button logic

* ScanPage refactoring

* Reapply missing scanIsUnavailable check

* Add comments

* Hide ignore when viewing threats, and clear history cache when updating or fixing

* Add unignore actions and conditional handling to the UI

* Add null coalescing to core threat prop assignment

* Fix core threat normalization

* Optimizations and refactoring

* Revert standarization, and use conditionals

* Add dummy arg to avoid bad translation minification

* Changlog entry

* Move viewingScanHistory out of initial state

* Use threat status over lack of fixedOn to display unignore button

* Add foundation for unignore request

* Remove need for signature_id

* Add TypeScript support to Jetpack Protect

* Downgrade typescript to 5.0.4, to match other monorepo projects

* Add TypeScript support to Jetpack Protect

* Init feature branch

* Protect: Add Scan_History class (#37903)

* Protect: Add Scan History UI (#37988)

* Init feature branch

* Init feature branch

* Init feature branch

* Use react router for threat history, separate scan and history root components, minor UI adjustments

* changelog

* Add dummy args to avoid bad minification

* Hide scan section navigation when user has no plan

* Wrap ScanButton with forwardRef

* Add onboarding popover to Scan Now button in empty state

* Fix filtering of core threat history

* Redirect to /scan from /scan/history when user has no plan

* Fix animation glitch in onboarding popover

* Remove unnecessary additions

* Further removals after failed base merge

* More removals

* Add todos

* Use status to conditional render unignore action button

* Move ignore/unignore actions to dedicated modals

* Add TypeScript support to Jetpack Protect

* Downgrade typescript to 5.0.4, to match other monorepo projects

* Add TypeScript support to Jetpack Protect

* Init feature branch

* Protect: Add Scan_History class (#37903)

* Protect: Add Scan History UI (#37988)

* changelog

* Protect: Separate scanner and history views via React Router and UI adjustments (#38325)

* Run ./tools/fixup-project-versions.sh

* Restore project versions

* Run ./tools/fixup-project-versions.sh

* Remove todo comment (#38628)

* Remove changelog

* Display fix threat button only for current threats

* Further unification

* Refresh scan history after unignore

* Update projects/plugins/protect/src/js/components/unignore-threat-modal/index.jsx

Co-authored-by: Nate Weller <nate.weller@automattic.com>

* Fix lint errors

---------

Co-authored-by: Nate Weller <hello@nateweller.com>
Co-authored-by: Nate Weller <nate.weller@automattic.com>
nateweller added a commit that referenced this pull request Aug 8, 2024
* Add Scan_History class

* changelog

* Update changelog

* Merge trunk, fix versions

* Add initial UI for scan history

* Add firstDetected and fixedOn details to threat cards

* Fix ignored message

* Fix console error

* Adjust wording and styles

* Optimize

* Fix firstDetected and fixedOn property retrieval issues, add todos

* Remove unneeded ref

* Consolidate scan history UI to existing components

* Remove todos

* Return false for scanHistory when upgrade is missing

* Manage ScanPage states when viewing history

* Move source data logic to useProtectData hook

* Improve Summary component Button logic

* ScanPage refactoring

* Reapply missing scanIsUnavailable check

* Add comments

* Hide ignore when viewing threats, and clear history cache when updating or fixing

* Add unignore actions and conditional handling to the UI

* Add null coalescing to core threat prop assignment

* Fix core threat normalization

* Optimizations and refactoring

* Revert standarization, and use conditionals

* Add dummy arg to avoid bad translation minification

* Changlog entry

* Move viewingScanHistory out of initial state

* Use threat status over lack of fixedOn to display unignore button

* Add foundation for unignore request

* Remove need for signature_id

* Add TypeScript support to Jetpack Protect

* Downgrade typescript to 5.0.4, to match other monorepo projects

* Add TypeScript support to Jetpack Protect

* Init feature branch

* Protect: Add Scan_History class (#37903)

* Protect: Add Scan History UI (#37988)

* Init feature branch

* Init feature branch

* Init feature branch

* Use react router for threat history, separate scan and history root components, minor UI adjustments

* changelog

* Add dummy args to avoid bad minification

* Hide scan section navigation when user has no plan

* Wrap ScanButton with forwardRef

* Add onboarding popover to Scan Now button in empty state

* Fix filtering of core threat history

* Redirect to /scan from /scan/history when user has no plan

* Fix animation glitch in onboarding popover

* Remove unnecessary additions

* Further removals after failed base merge

* More removals

* Add todos

* Use status to conditional render unignore action button

* Move ignore/unignore actions to dedicated modals

* Add TypeScript support to Jetpack Protect

* Downgrade typescript to 5.0.4, to match other monorepo projects

* Add TypeScript support to Jetpack Protect

* Init feature branch

* Protect: Add Scan_History class (#37903)

* Protect: Add Scan History UI (#37988)

* changelog

* Protect: Separate scanner and history views via React Router and UI adjustments (#38325)

* Run ./tools/fixup-project-versions.sh

* Restore project versions

* Run ./tools/fixup-project-versions.sh

* Remove todo comment (#38628)

* Remove changelog

* Display fix threat button only for current threats

* Further unification

* Refresh scan history after unignore

* Update projects/plugins/protect/src/js/components/unignore-threat-modal/index.jsx

Co-authored-by: Nate Weller <nate.weller@automattic.com>

* Fix lint errors

---------

Co-authored-by: Nate Weller <hello@nateweller.com>
Co-authored-by: Nate Weller <nate.weller@automattic.com>
nateweller added a commit that referenced this pull request Aug 9, 2024
* Add Scan_History class

* changelog

* Update changelog

* Merge trunk, fix versions

* Add initial UI for scan history

* Add firstDetected and fixedOn details to threat cards

* Fix ignored message

* Fix console error

* Adjust wording and styles

* Optimize

* Fix firstDetected and fixedOn property retrieval issues, add todos

* Remove unneeded ref

* Consolidate scan history UI to existing components

* Remove todos

* Return false for scanHistory when upgrade is missing

* Manage ScanPage states when viewing history

* Move source data logic to useProtectData hook

* Improve Summary component Button logic

* ScanPage refactoring

* Reapply missing scanIsUnavailable check

* Add comments

* Hide ignore when viewing threats, and clear history cache when updating or fixing

* Add unignore actions and conditional handling to the UI

* Add null coalescing to core threat prop assignment

* Fix core threat normalization

* Optimizations and refactoring

* Revert standarization, and use conditionals

* Add dummy arg to avoid bad translation minification

* Changlog entry

* Move viewingScanHistory out of initial state

* Use threat status over lack of fixedOn to display unignore button

* Add foundation for unignore request

* Remove need for signature_id

* Add TypeScript support to Jetpack Protect

* Downgrade typescript to 5.0.4, to match other monorepo projects

* Add TypeScript support to Jetpack Protect

* Init feature branch

* Protect: Add Scan_History class (#37903)

* Protect: Add Scan History UI (#37988)

* Init feature branch

* Init feature branch

* Init feature branch

* Use react router for threat history, separate scan and history root components, minor UI adjustments

* changelog

* Add dummy args to avoid bad minification

* Hide scan section navigation when user has no plan

* Wrap ScanButton with forwardRef

* Add onboarding popover to Scan Now button in empty state

* Fix filtering of core threat history

* Redirect to /scan from /scan/history when user has no plan

* Fix animation glitch in onboarding popover

* Remove unnecessary additions

* Further removals after failed base merge

* More removals

* Add todos

* Use status to conditional render unignore action button

* Move ignore/unignore actions to dedicated modals

* Add TypeScript support to Jetpack Protect

* Downgrade typescript to 5.0.4, to match other monorepo projects

* Add TypeScript support to Jetpack Protect

* Init feature branch

* Protect: Add Scan_History class (#37903)

* Protect: Add Scan History UI (#37988)

* changelog

* Protect: Separate scanner and history views via React Router and UI adjustments (#38325)

* Run ./tools/fixup-project-versions.sh

* Restore project versions

* Run ./tools/fixup-project-versions.sh

* Remove todo comment (#38628)

* Remove changelog

* Display fix threat button only for current threats

* Further unification

* Refresh scan history after unignore

* Update projects/plugins/protect/src/js/components/unignore-threat-modal/index.jsx

Co-authored-by: Nate Weller <nate.weller@automattic.com>

* Fix lint errors

---------

Co-authored-by: Nate Weller <hello@nateweller.com>
Co-authored-by: Nate Weller <nate.weller@automattic.com>
nateweller added a commit that referenced this pull request Aug 9, 2024
* Add Scan_History class

* changelog

* Update changelog

* Merge trunk, fix versions

* Add initial UI for scan history

* Add firstDetected and fixedOn details to threat cards

* Fix ignored message

* Fix console error

* Adjust wording and styles

* Optimize

* Fix firstDetected and fixedOn property retrieval issues, add todos

* Remove unneeded ref

* Consolidate scan history UI to existing components

* Remove todos

* Return false for scanHistory when upgrade is missing

* Manage ScanPage states when viewing history

* Move source data logic to useProtectData hook

* Improve Summary component Button logic

* ScanPage refactoring

* Reapply missing scanIsUnavailable check

* Add comments

* Hide ignore when viewing threats, and clear history cache when updating or fixing

* Add unignore actions and conditional handling to the UI

* Add null coalescing to core threat prop assignment

* Fix core threat normalization

* Optimizations and refactoring

* Revert standarization, and use conditionals

* Add dummy arg to avoid bad translation minification

* Changlog entry

* Move viewingScanHistory out of initial state

* Use threat status over lack of fixedOn to display unignore button

* Add foundation for unignore request

* Remove need for signature_id

* Add TypeScript support to Jetpack Protect

* Downgrade typescript to 5.0.4, to match other monorepo projects

* Add TypeScript support to Jetpack Protect

* Init feature branch

* Protect: Add Scan_History class (#37903)

* Protect: Add Scan History UI (#37988)

* Init feature branch

* Init feature branch

* Init feature branch

* Use react router for threat history, separate scan and history root components, minor UI adjustments

* changelog

* Add dummy args to avoid bad minification

* Hide scan section navigation when user has no plan

* Wrap ScanButton with forwardRef

* Add onboarding popover to Scan Now button in empty state

* Fix filtering of core threat history

* Redirect to /scan from /scan/history when user has no plan

* Fix animation glitch in onboarding popover

* Remove unnecessary additions

* Further removals after failed base merge

* More removals

* Add todos

* Use status to conditional render unignore action button

* Move ignore/unignore actions to dedicated modals

* Add TypeScript support to Jetpack Protect

* Downgrade typescript to 5.0.4, to match other monorepo projects

* Add TypeScript support to Jetpack Protect

* Init feature branch

* Protect: Add Scan_History class (#37903)

* Protect: Add Scan History UI (#37988)

* changelog

* Protect: Separate scanner and history views via React Router and UI adjustments (#38325)

* Run ./tools/fixup-project-versions.sh

* Restore project versions

* Run ./tools/fixup-project-versions.sh

* Remove todo comment (#38628)

* Remove changelog

* Display fix threat button only for current threats

* Further unification

* Refresh scan history after unignore

* Update projects/plugins/protect/src/js/components/unignore-threat-modal/index.jsx

Co-authored-by: Nate Weller <nate.weller@automattic.com>

* Fix lint errors

---------

Co-authored-by: Nate Weller <hello@nateweller.com>
Co-authored-by: Nate Weller <nate.weller@automattic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Protect Models [Plugin] Protect A plugin with features to protect a site: brute force protection, security scanning, and a WAF. [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
2 participants