Skip to content

ROX-35504: Redirect /main/risk to /main/risk/workloads#21519

Open
dvail wants to merge 1 commit into
masterfrom
dv/ROX-35504-risk-workloads-redirect
Open

ROX-35504: Redirect /main/risk to /main/risk/workloads#21519
dvail wants to merge 1 commit into
masterfrom
dv/ROX-35504-risk-workloads-redirect

Conversation

@dvail

@dvail dvail commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Description

With the upcoming addition of Secrets to the Risk subsection, and likely RBAC addition after, this sets up risk link redirects so we have a cohesive structure moving forward:
/risk -> /risk/workloads (for backwards compat)
/risk/workloads
/risk/secrets
/risk/rbac

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

Manual testing the UI and verifying existing functionality works.

Existing e2e tests for RIsk.

New e2e tests to validate redirects are working correctly.

@dvail

dvail commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

This change is part of the following stack:

Change managed by git-spice.

@openshift-ci

openshift-ci Bot commented Jul 1, 2026

Copy link
Copy Markdown

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

@dvail dvail force-pushed the dv/ROX-35504-risk-workloads-redirect branch from bf029d0 to c9ef3cd Compare July 1, 2026 15:16
@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 5811f891-5956-4e41-aab0-02b00f167a79

📥 Commits

Reviewing files that changed from the base of the PR and between 86a78a1 and b6e20c7.

📒 Files selected for processing (16)
  • ui/apps/platform/cypress/integration/risk/Risk.helpers.js
  • ui/apps/platform/cypress/integration/risk/riskRedirect.test.js
  • ui/apps/platform/cypress/integration/risk/riskSearchToPolicy.test.js
  • ui/apps/platform/src/Containers/Audit/ListeningEndpoints/ListeningEndpointsTable.tsx
  • ui/apps/platform/src/Containers/Dashboard/Widgets/DeploymentsAtMostRisk.tsx
  • ui/apps/platform/src/Containers/Dashboard/Widgets/DeploymentsAtMostRiskTable.tsx
  • ui/apps/platform/src/Containers/MainPage/Body.tsx
  • ui/apps/platform/src/Containers/MainPage/Navigation/HorizontalSubnav.tsx
  • ui/apps/platform/src/Containers/MainPage/Navigation/NavigationSidebar.tsx
  • ui/apps/platform/src/Containers/Risk/DeploymentNameColumn.tsx
  • ui/apps/platform/src/Containers/Search/ViewLinks.test.ts
  • ui/apps/platform/src/Containers/Search/searchCategories.ts
  • ui/apps/platform/src/routePaths.ts
  • ui/apps/platform/src/utils/URLGenerator.js
  • ui/apps/platform/src/utils/URLParser.ts
  • ui/apps/platform/src/utils/URLService.js
🚧 Files skipped from review as they are similar to previous changes (16)
  • ui/apps/platform/cypress/integration/risk/riskRedirect.test.js
  • ui/apps/platform/src/Containers/Dashboard/Widgets/DeploymentsAtMostRisk.tsx
  • ui/apps/platform/src/Containers/Dashboard/Widgets/DeploymentsAtMostRiskTable.tsx
  • ui/apps/platform/cypress/integration/risk/riskSearchToPolicy.test.js
  • ui/apps/platform/src/utils/URLGenerator.js
  • ui/apps/platform/src/Containers/Search/ViewLinks.test.ts
  • ui/apps/platform/src/Containers/MainPage/Navigation/HorizontalSubnav.tsx
  • ui/apps/platform/src/Containers/Audit/ListeningEndpoints/ListeningEndpointsTable.tsx
  • ui/apps/platform/src/utils/URLService.js
  • ui/apps/platform/src/Containers/Search/searchCategories.ts
  • ui/apps/platform/src/utils/URLParser.ts
  • ui/apps/platform/src/Containers/MainPage/Navigation/NavigationSidebar.tsx
  • ui/apps/platform/src/Containers/Risk/DeploymentNameColumn.tsx
  • ui/apps/platform/src/Containers/MainPage/Body.tsx
  • ui/apps/platform/src/routePaths.ts
  • ui/apps/platform/cypress/integration/risk/Risk.helpers.js

📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Added a new Risk Workloads route and updated navigation, subnav, sidebar, and search/view links to point to /main/risk/workloads.
    • Added a redirect from the legacy Risk route to Risk Workloads.
  • Bug Fixes
    • Legacy Risk URLs now redirect correctly while preserving query parameters (including filtered and deployment-specific views).
  • Tests
    • Added Cypress coverage for Risk redirects and updated existing link/search expectations for the new route.

Walkthrough

The risk route now redirects legacy /main/risk visits to /main/risk/workloads, with updated route constants, navigation targets, search links, Cypress coverage, and legacy URL parsing/generation.

Changes

Risk workloads route migration

Layer / File(s) Summary
Route path contracts and requirements
ui/apps/platform/src/routePaths.ts
Adds workloads-scoped Risk route constants, updates RouteKey, and adds a risk/workloads requirements entry.
Route wiring and redirect component
ui/apps/platform/src/Containers/MainPage/Body.tsx
Adds the risk/workloads route, routes legacy risk traffic to RiskRedirect, and preserves query strings during navigation.
Navigation, search, dashboard, and Cypress updates
ui/apps/platform/src/Containers/MainPage/Navigation/HorizontalSubnav.tsx, ui/apps/platform/src/Containers/MainPage/Navigation/NavigationSidebar.tsx, ui/apps/platform/src/Containers/Audit/ListeningEndpoints/ListeningEndpointsTable.tsx, ui/apps/platform/src/Containers/Dashboard/Widgets/DeploymentsAtMostRisk.tsx, ui/apps/platform/src/Containers/Dashboard/Widgets/DeploymentsAtMostRiskTable.tsx, ui/apps/platform/src/Containers/Risk/DeploymentNameColumn.tsx, ui/apps/platform/src/Containers/Search/searchCategories.ts, ui/apps/platform/src/Containers/Search/ViewLinks.test.ts, ui/apps/platform/cypress/integration/risk/Risk.helpers.js, ui/apps/platform/cypress/integration/risk/riskSearchToPolicy.test.js, ui/apps/platform/cypress/integration/risk/riskRedirect.test.js
Switches links, route keys, and test expectations to riskWorkloadsBasePath across navigation, tables, search descriptors, and Cypress coverage.
Legacy URL utilities
ui/apps/platform/src/utils/URLGenerator.js, ui/apps/platform/src/utils/URLParser.ts, ui/apps/platform/src/utils/URLService.js
Updates legacy RISK route mappings to use riskWorkloadPath and /main/risk/workloads for entity, list, and dashboard page types.

Estimated code review effort: 3 (Moderate) | ~25 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.22% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states the main change: redirecting /main/risk to /main/risk/workloads.
Description check ✅ Passed The description follows the template structure and includes the change summary, docs, testing, and validation sections.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dv/ROX-35504-risk-workloads-redirect

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (3)
ui/apps/platform/src/utils/URLService.js (1)

93-95: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use riskWorkloadsBasePath instead of a hardcoded string.

Same drift risk as in URLGenerator.js: ENTITY uses riskWorkloadPath but LIST/DASHBOARD hardcode '/main/risk/workloads' as a literal rather than reusing riskWorkloadsBasePath.

♻️ Suggested fix
-    riskWorkloadPath,
+    riskWorkloadPath,
+    riskWorkloadsBasePath,
             [pageTypes.ENTITY]: riskWorkloadPath,
-            [pageTypes.LIST]: '/main/risk/workloads',
-            [pageTypes.DASHBOARD]: '/main/risk/workloads',
+            [pageTypes.LIST]: riskWorkloadsBasePath,
+            [pageTypes.DASHBOARD]: riskWorkloadsBasePath,
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ui/apps/platform/src/utils/URLService.js` around lines 93 - 95, The page type
path mapping in URLService uses a hardcoded workloads URL for LIST and DASHBOARD
instead of the shared riskWorkloadsBasePath, creating drift with ENTITY’s
riskWorkloadPath usage. Update the pageTypes mapping in URLService to reuse
riskWorkloadsBasePath for LIST and DASHBOARD, matching the existing pattern used
by riskWorkloadPath and keeping the URL source centralized.
ui/apps/platform/src/utils/URLGenerator.js (1)

31-33: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use riskWorkloadsBasePath instead of a hardcoded string.

LIST/DASHBOARD hardcode '/main/risk/workloads' while ENTITY uses the riskWorkloadPath constant. Importing and using riskWorkloadsBasePath here keeps all three mappings tied to the single source of truth in routePaths.ts.

♻️ Suggested fix
-    riskWorkloadPath,
+    riskWorkloadPath,
+    riskWorkloadsBasePath,
         [pageTypes.ENTITY]: riskWorkloadPath,
-        [pageTypes.LIST]: '/main/risk/workloads',
-        [pageTypes.DASHBOARD]: '/main/risk/workloads',
+        [pageTypes.LIST]: riskWorkloadsBasePath,
+        [pageTypes.DASHBOARD]: riskWorkloadsBasePath,
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ui/apps/platform/src/utils/URLGenerator.js` around lines 31 - 33, The
`URLGenerator` page type mappings are hardcoding the risk workloads base route
for `LIST` and `DASHBOARD` instead of using the shared route constant. Update
the mapping in `URLGenerator` so `pageTypes.LIST` and `pageTypes.DASHBOARD`
reference `riskWorkloadsBasePath`, matching the existing `riskWorkloadPath`
usage for `pageTypes.ENTITY`. Make sure the constant is imported from the shared
route definitions so all three entries stay tied to the single source of truth
in `routePaths.ts`.
ui/apps/platform/src/Containers/MainPage/Body.tsx (1)

316-320: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider extracting a shared redirect factory.

RiskRedirect duplicates the exact same pathname-replace + Navigate pattern already used by WorkloadCvesRedirect (lines 305-314). Extracting a small factory would avoid repeating this logic for future legacy-path redirects.

♻️ Suggested refactor
-function WorkloadCvesRedirect() {
-    const location = useLocation();
-
-    const newPath = location.pathname.replace(
-        vulnerabilitiesWorkloadCvesPath,
-        vulnerabilitiesAllImagesPath
-    );
-
-    return <Navigate to={`${newPath}${location.search}`} replace />;
-}
-
-function RiskRedirect() {
-    const location = useLocation();
-    const newPath = location.pathname.replace(riskBasePath, riskWorkloadsBasePath);
-    return <Navigate to={`${newPath}${location.search}`} replace />;
-}
+function createLegacyRedirect(oldPath: string, newPath: string) {
+    return function LegacyRedirect() {
+        const location = useLocation();
+        const nextPath = location.pathname.replace(oldPath, newPath);
+        return <Navigate to={`${nextPath}${location.search}`} replace />;
+    };
+}
+
+const WorkloadCvesRedirect = createLegacyRedirect(
+    vulnerabilitiesWorkloadCvesPath,
+    vulnerabilitiesAllImagesPath
+);
+const RiskRedirect = createLegacyRedirect(riskBasePath, riskWorkloadsBasePath);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ui/apps/platform/src/Containers/MainPage/Body.tsx` around lines 316 - 320,
`RiskRedirect` repeats the same pathname-replace plus `Navigate` redirect logic
already used by `WorkloadCvesRedirect`, so extract a shared redirect factory or
helper in `Body.tsx` and have both redirect components use it. Keep the existing
behavior of preserving `location.search` and using `replace`, and wire the new
helper into the `RiskRedirect` and `WorkloadCvesRedirect` symbols so future
legacy redirects can reuse the same pattern.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@ui/apps/platform/src/routePaths.ts`:
- Around line 316-318: The routeRequirementsMap entry for the legacy risk route
was removed, but RouteKey still includes risk and isRouteEnabled reads
routeRequirementsMap[routeKey] directly, so keep a risk requirement entry
alongside risk/workloads. Update the route requirements map in routePaths.ts to
preserve the legacy risk key (likely matching the same requirements as the
redirect target) so any checks against risk continue to resolve safely.

---

Nitpick comments:
In `@ui/apps/platform/src/Containers/MainPage/Body.tsx`:
- Around line 316-320: `RiskRedirect` repeats the same pathname-replace plus
`Navigate` redirect logic already used by `WorkloadCvesRedirect`, so extract a
shared redirect factory or helper in `Body.tsx` and have both redirect
components use it. Keep the existing behavior of preserving `location.search`
and using `replace`, and wire the new helper into the `RiskRedirect` and
`WorkloadCvesRedirect` symbols so future legacy redirects can reuse the same
pattern.

In `@ui/apps/platform/src/utils/URLGenerator.js`:
- Around line 31-33: The `URLGenerator` page type mappings are hardcoding the
risk workloads base route for `LIST` and `DASHBOARD` instead of using the shared
route constant. Update the mapping in `URLGenerator` so `pageTypes.LIST` and
`pageTypes.DASHBOARD` reference `riskWorkloadsBasePath`, matching the existing
`riskWorkloadPath` usage for `pageTypes.ENTITY`. Make sure the constant is
imported from the shared route definitions so all three entries stay tied to the
single source of truth in `routePaths.ts`.

In `@ui/apps/platform/src/utils/URLService.js`:
- Around line 93-95: The page type path mapping in URLService uses a hardcoded
workloads URL for LIST and DASHBOARD instead of the shared
riskWorkloadsBasePath, creating drift with ENTITY’s riskWorkloadPath usage.
Update the pageTypes mapping in URLService to reuse riskWorkloadsBasePath for
LIST and DASHBOARD, matching the existing pattern used by riskWorkloadPath and
keeping the URL source centralized.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: f4545395-f7d4-42c3-96c6-3cc966ef09bb

📥 Commits

Reviewing files that changed from the base of the PR and between 7857a1f and bf029d0.

📒 Files selected for processing (16)
  • ui/apps/platform/cypress/integration/risk/Risk.helpers.js
  • ui/apps/platform/cypress/integration/risk/riskRedirect.test.js
  • ui/apps/platform/cypress/integration/risk/riskSearchToPolicy.test.js
  • ui/apps/platform/src/Containers/Audit/ListeningEndpoints/ListeningEndpointsTable.tsx
  • ui/apps/platform/src/Containers/Dashboard/Widgets/DeploymentsAtMostRisk.tsx
  • ui/apps/platform/src/Containers/Dashboard/Widgets/DeploymentsAtMostRiskTable.tsx
  • ui/apps/platform/src/Containers/MainPage/Body.tsx
  • ui/apps/platform/src/Containers/MainPage/Navigation/HorizontalSubnav.tsx
  • ui/apps/platform/src/Containers/MainPage/Navigation/NavigationSidebar.tsx
  • ui/apps/platform/src/Containers/Risk/DeploymentNameColumn.tsx
  • ui/apps/platform/src/Containers/Search/ViewLinks.test.ts
  • ui/apps/platform/src/Containers/Search/searchCategories.ts
  • ui/apps/platform/src/routePaths.ts
  • ui/apps/platform/src/utils/URLGenerator.js
  • ui/apps/platform/src/utils/URLParser.ts
  • ui/apps/platform/src/utils/URLService.js

Comment thread ui/apps/platform/src/routePaths.ts
@dvail dvail force-pushed the dv/ROX-35504-risk-workloads-redirect branch from c9ef3cd to 86a78a1 Compare July 1, 2026 15:21
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

🚀 Build Images Ready

Images are ready for commit b6e20c7. To use with deploy scripts:

export MAIN_IMAGE_TAG=4.12.x-373-gb6e20c7c82

@dvail dvail force-pushed the dv/ROX-35504-risk-workloads-redirect branch from 86a78a1 to b6e20c7 Compare July 1, 2026 15:45
@dvail dvail marked this pull request as ready for review July 1, 2026 15:54
@dvail dvail requested a review from a team as a code owner July 1, 2026 15:54
@dvail dvail requested a review from bradr5 July 1, 2026 15:54
@codecov

codecov Bot commented Jul 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 50.22%. Comparing base (7857a1f) to head (b6e20c7).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #21519      +/-   ##
==========================================
- Coverage   50.25%   50.22%   -0.04%     
==========================================
  Files        2844     2844              
  Lines      218117   218117              
==========================================
- Hits       109624   109542      -82     
- Misses     100535   100598      +63     
- Partials     7958     7977      +19     
Flag Coverage Δ
go-unit-tests 50.22% <ø> (-0.04%) ⬇️

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

☔ View full report in Codecov by Harness.
📢 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.

@openshift-ci

openshift-ci Bot commented Jul 1, 2026

Copy link
Copy Markdown

@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-22-ui-e2e-tests b6e20c7 link false /test ocp-4-22-ui-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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant