ROX-35504: Redirect /main/risk to /main/risk/workloads#21519
Conversation
|
This change is part of the following stack: Change managed by git-spice. |
|
Skipping CI for Draft Pull Request. |
bf029d0 to
c9ef3cd
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Central YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (16)
🚧 Files skipped from review as they are similar to previous changes (16)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe risk route now redirects legacy ChangesRisk workloads route migration
Estimated code review effort: 3 (Moderate) | ~25 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (3)
ui/apps/platform/src/utils/URLService.js (1)
93-95: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse
riskWorkloadsBasePathinstead of a hardcoded string.Same drift risk as in
URLGenerator.js:ENTITYusesriskWorkloadPathbutLIST/DASHBOARDhardcode'/main/risk/workloads'as a literal rather than reusingriskWorkloadsBasePath.♻️ 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 winUse
riskWorkloadsBasePathinstead of a hardcoded string.
LIST/DASHBOARDhardcode'/main/risk/workloads'whileENTITYuses theriskWorkloadPathconstant. Importing and usingriskWorkloadsBasePathhere keeps all three mappings tied to the single source of truth inroutePaths.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 valueConsider extracting a shared redirect factory.
RiskRedirectduplicates the exact same pathname-replace +Navigatepattern already used byWorkloadCvesRedirect(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
📒 Files selected for processing (16)
ui/apps/platform/cypress/integration/risk/Risk.helpers.jsui/apps/platform/cypress/integration/risk/riskRedirect.test.jsui/apps/platform/cypress/integration/risk/riskSearchToPolicy.test.jsui/apps/platform/src/Containers/Audit/ListeningEndpoints/ListeningEndpointsTable.tsxui/apps/platform/src/Containers/Dashboard/Widgets/DeploymentsAtMostRisk.tsxui/apps/platform/src/Containers/Dashboard/Widgets/DeploymentsAtMostRiskTable.tsxui/apps/platform/src/Containers/MainPage/Body.tsxui/apps/platform/src/Containers/MainPage/Navigation/HorizontalSubnav.tsxui/apps/platform/src/Containers/MainPage/Navigation/NavigationSidebar.tsxui/apps/platform/src/Containers/Risk/DeploymentNameColumn.tsxui/apps/platform/src/Containers/Search/ViewLinks.test.tsui/apps/platform/src/Containers/Search/searchCategories.tsui/apps/platform/src/routePaths.tsui/apps/platform/src/utils/URLGenerator.jsui/apps/platform/src/utils/URLParser.tsui/apps/platform/src/utils/URLService.js
c9ef3cd to
86a78a1
Compare
🚀 Build Images ReadyImages are ready for commit b6e20c7. To use with deploy scripts: export MAIN_IMAGE_TAG=4.12.x-373-gb6e20c7c82 |
86a78a1 to
b6e20c7
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@dvail: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions 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. |
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/rbacUser-facing documentation
Testing and quality
Automated testing
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.