8000 BED-5765: Preserve `environmentId` query param through links by maffkipp · Pull Request #1376 · SpecterOps/BloodHound · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

BED-5765: Preserve environmentId query param through links #1376

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 8 commits into from
Apr 18, 2025

Conversation

maffkipp
Copy link
Contributor
@maffkipp maffkipp commented Apr 17, 2025

Description

Adds a new AppLink component and useAppNavigation hook to be used as drop-in replacements for Link and useNavigate from react-router-dom. These wrappers have additional functionality for preserving any query params that we have defined as globally available (namely our environmentId params currently).

This also adds a boolean prop and config option respectfully called discardQueryParams that can optionally be set to true if we want to ignore the behavior (such as when navigating back to the login component for an unauthenticated user).

We currently only have globally available params in BHE, so there should be no noticeable impact on the behavior of the BHCE app.

Motivation and Context

Resolves BED-5765
Resolves BED-5779
Resolves BED-5770

Previously, we were fetching the environmentId from the API and re-applying it to the query param after following a link from one page of the app to another. This would create additional history entries, and then keep creating more as you try to back up through them.

This also by necessity cleans up a couple other minor bugs around environmentId linked in the above tickets.

How Has This Been Tested?

All existing tests pass and I've done quite a bit of manual testing in both apps. I am currently working on some unit tests as well, but since this is a quick fix before our last RC I wanted to get this up for review.

Screenshots (optional):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

@maffkipp maffkipp added bug Something isn't working user interface A pull request containing changes affecting the UI code. labels Apr 17, 2025
@maffkipp maffkipp self-assigned this Apr 17, 2025
Comment on lines +116 to +117
...Object.fromEntries(preservedParams),
...Object.fromEntries(baseSearchParams),
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!! what a clean way to let passed in params override the existing ones

@maffkipp maffkipp merged commit c6a004c into stage/v7.3.0 Apr 18, 2025
8 checks passed
@maffkipp maffkipp deleted the BED-5765--env-history-bug branch April 18, 2025 18:54
@github-actions github-actions bot locked and limited conversation to collaborators Apr 18, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working user interface A pull request containing changes affecting the UI code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0