Skip to content

chore(ui): Handle encoded and unencoded params in horizontal nav#16074

Merged
dvail merged 1 commit intomasterfrom
dv/better-active-state-handling-horizontal-nav
Jul 23, 2025
Merged

chore(ui): Handle encoded and unencoded params in horizontal nav#16074
dvail merged 1 commit intomasterfrom
dv/better-active-state-handling-horizontal-nav

Conversation

@dvail
Copy link
Copy Markdown
Contributor

@dvail dvail commented Jul 17, 2025

Description

In the react-router v5->v6 change the handling of active states in the Violations page navigation was broken and caught during a bug bash. Since this will be an issue again when moving to the rr-compat library, I've made these checks independent of parameter encoding and added tests to prevent breaking again during the next change.

User-facing documentation

Testing and quality

  • the change is production ready: the change is GA, or otherwise the functionality is gated by a feature flag
  • CI results are inspected

Automated testing

  • added unit tests
  • added e2e tests
  • added regression tests
  • added compatibility tests
  • modified existing tests

How I validated my change

npm run test
npm run test-component

@openshift-ci
Copy link
Copy Markdown

openshift-ci bot commented Jul 17, 2025

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@red-hat-konflux
Copy link
Copy Markdown
Contributor

Caution

There are some errors in your PipelineRun template.

PipelineRun Error
quay-proxy no kind "ImageDigestMirrorSet" is registered for version "config.openshift.io/v1" in scheme "k8s.io/client-go/kubernetes/scheme/register.go:83"

@dvail dvail changed the title Handle encoded and unencoded params in horizontal nav chore(ui): Handle encoded and unencoded params in horizontal nav Jul 17, 2025
@rhacs-bot
Copy link
Copy Markdown
Contributor

rhacs-bot commented Jul 17, 2025

Images are ready for the commit at 01cc05a.

To use with deploy scripts, first export MAIN_IMAGE_TAG=4.9.x-253-g01cc05afac.

@codecov
Copy link
Copy Markdown

codecov bot commented Jul 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 48.68%. Comparing base (0dfb0fd) to head (01cc05a).
Report is 22 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #16074      +/-   ##
==========================================
- Coverage   48.68%   48.68%   -0.01%     
==========================================
  Files        2603     2604       +1     
  Lines      191590   191663      +73     
==========================================
+ Hits        93285    93302      +17     
- Misses      90976    91028      +52     
- Partials     7329     7333       +4     
Flag Coverage Δ
go-unit-tests 48.68% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dvail dvail force-pushed the dv/better-active-state-handling-horizontal-nav branch from 47beff7 to 9311b05 Compare July 17, 2025 20:26
@dvail dvail marked this pull request as ready for review July 17, 2025 20:27
@dvail dvail requested a review from a team as a code owner July 17, 2025 20:27
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @dvail - I've reviewed your changes - here's some feedback:

  • Instead of regex on the search string, consider using URLSearchParams to parse and compare decoded parameter values for more robust handling.
  • Add unit tests for the new containsPatternIgnoringEncoding util to cover edge cases like special characters or multiple parameters.
  • Escape the pattern or avoid interpolating arbitrary strings into the RegExp to prevent unintended regex behavior when pattern contains special characters.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Instead of regex on the search string, consider using URLSearchParams to parse and compare decoded parameter values for more robust handling.
- Add unit tests for the new containsPatternIgnoringEncoding util to cover edge cases like special characters or multiple parameters.
- Escape the pattern or avoid interpolating arbitrary strings into the RegExp to prevent unintended regex behavior when pattern contains special characters.

## Individual Comments

### Comment 1
<location> `ui/apps/platform/src/Containers/MainPage/Navigation/HorizontalSubnav.tsx:35` </location>
<code_context>

 import './HorizontalSubnav.css';

+// Check if the search string contains the pattern or the encoded version of the pattern
+function containsPatternIgnoringEncoding(search: string, pattern: string) {
+    return new RegExp(`${pattern}|${encodeURI(pattern)}`, 'i').test(search);
+}
</code_context>

<issue_to_address>
The regex in containsPatternIgnoringEncoding may match unintended substrings.

Matching with the current regex may cause false positives if the pattern appears within another parameter or value. Parsing the query string and comparing parameter values directly would provide more accurate results.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@dvail dvail force-pushed the dv/better-active-state-handling-horizontal-nav branch from e976e9c to 01cc05a Compare July 21, 2025 12:33
@openshift-ci
Copy link
Copy Markdown

openshift-ci bot commented Jul 21, 2025

@dvail: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/ocp-4-19-nongroovy-e2e-tests 01cc05a link false /test ocp-4-19-nongroovy-e2e-tests

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@dvail dvail merged commit a2e52ee into master Jul 23, 2025
139 of 168 checks passed
@dvail dvail deleted the dv/better-active-state-handling-horizontal-nav branch July 23, 2025 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants