[dashboard] Fix broken backup menu links missing cluster context#2232
[dashboard] Fix broken backup menu links missing cluster context#2232sircthulhu wants to merge 1 commit intomaincozystack/cozystack:mainfrom fix/dashboard-backup-menu-linkscozystack/cozystack:fix/dashboard-backup-menu-linksCopy head branch name to clipboard
Conversation
Backup resources (plans, backupjobs, backups) are not
ApplicationDefinitions, so ensureNavigation() never adds their
baseFactoriesMapping entries. Without these mappings the OpenUI
frontend cannot resolve the {cluster} context for backup pages,
producing broken sidebar links with an empty cluster segment
(e.g. /openapi-ui//tenant-root/...).
Add the three missing entries to the static Navigation resource.
Assisted-By: Claude AI
Signed-off-by: Kirill Ilin <stitch14@yandex.ru>
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical navigation issue within the dashboard where links to backup-related resources were malformed and non-functional. The problem stemmed from the system's inability to correctly map these resources, as they are not classified as Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThree new backup resource navigation entries are added to the baseFactoriesMapping in the dashboard controller's CreateAllNavigations function, expanding navigation coverage for plan-details, backupjob-details, and backup-details resources. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip You can disable sequence diagrams in the walkthrough.Disable the |
There was a problem hiding this comment.
Code Review
This pull request adds missing navigation mappings for backup resources. My review focuses on the maintainability of the new code. I have one suggestion to refactor the newly added entries to reduce code duplication by generating them programmatically. This is an optional improvement that could also be handled in a follow-up.
| // Backup resources (not ApplicationDefinitions, so ensureNavigation doesn't cover them) | ||
| "base-factory-namespaced-api-backups.cozystack.io-v1alpha1-plans": "plan-details", | ||
| "base-factory-namespaced-api-backups.cozystack.io-v1alpha1-backupjobs": "backupjob-details", | ||
| "base-factory-namespaced-api-backups.cozystack.io-v1alpha1-backups": "backup-details", |
There was a problem hiding this comment.
While this change is correct, the three new entries for backup resources share a long common prefix, which leads to code duplication. To improve maintainability and readability, consider generating these entries programmatically.
This would involve removing these lines from the map literal and adding a small loop after the map is initialized. This makes it easier to manage backup-related navigation entries in the future.
Here is an example of how you could do it:
// Assuming `baseFactoriesMapping` is the name of the map variable
backupResources := []string{"plans", "backupjobs", "backups"}
const backupPrefix = "base-factory-namespaced-api-backups.cozystack.io/v1alpha1-"
for _, resource := range backupResources {
key := backupPrefix + resource
value := fmt.Sprintf("%s-details", strings.TrimSuffix(resource, "s"))
baseFactoriesMapping[key] = value
}This would require fmt and strings imports if they are not already present. Given this is a structural change, feel free to address this in a follow-up PR if you prefer to keep this fix minimal.
What this PR does
Adds missing
baseFactoriesMappingentries for backup resources (plans, backupjobs, backups) to the static Navigation resource.Backup resources are not ApplicationDefinitions, so
ensureNavigation()never creates their navigation mappings. Without these mappings, the OpenUI frontend cannot resolve the{cluster}context for backup pages, producing broken sidebar links with an empty cluster segment (e.g./openapi-ui//tenant-root/api-table/backups.cozystack.io/v1alpha1/plansinstead of/openapi-ui/default/tenant-root/...).Release note
Summary by CodeRabbit