[dashboard-controller] Move bages generation logic to internal dashboard component - #1567
Conversation
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughReplace text/size/color-based badge creation with a Kind/value-based ResourceBadge across dashboard helpers and factories; remove stable color-hash utilities and badge size concepts; update related custom column builders and signatures to use badgeValue and optional style. Changes
Sequence Diagram(s)sequenceDiagram
participant Caller as Factory / Column Builder
participant Unified as unified_helpers
participant Renderer as UI renderer (ResourceBadge)
rect `#F3F7FF`
Note left of Caller: Previous flow (conceptual)
Caller->>Unified: generateBadgeConfig(kind, text, color, title)
Unified->>Unified: compute initials, stable hex color, attach Size
Unified-->>Renderer: rendered/text badge payload
end
rect `#F7FFF3`
Note left of Caller: New flow
Caller->>Unified: createUnifiedBadgeFromKind(id, kind)
Unified-->>Renderer: {type: "ResourceBadge", data: {id, value, style?}}
Renderer-->>Caller: rendered ResourceBadge
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (7)
💤 Files with no reviewable changes (1)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (14)
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 |
Summary of ChangesHello Andrei Kvapil (@kvaps), 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 refactors the dashboard's badge generation mechanism by introducing a dedicated Highlights
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 (@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
|
df0b998 to
8f9f728
Compare
There was a problem hiding this comment.
Code Review
This pull request is a solid refactoring that migrates badge generation logic to a frontend ResourceBadge component. This is a great move for separation of concerns, simplifying the backend by removing styling and color generation logic. The changes are applied consistently across the codebase. I've identified a few areas for improvement: one bug where an incorrect value is passed to the new component, a couple of unused function parameters that can be cleaned up, and an opportunity to further delegate logic to the frontend for consistency.
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
internal/controller/dashboard/static_helpers.go (2)
534-563: Unusedpluralparameter breaks compilationGo requires every parameter to be consumed. After the ResourceBadge refactor we never touch
plural, socreateCustomColumnnow fails to build. Either remove the argument or mark it as intentionally ignored before merging.-func createCustomColumn(name, kind, plural, href string) map[string]any { +func createCustomColumn(name, kind string, _ string, href string) map[string]any {
568-599: Also fix unusedtitlehereSame story:
titleis no longer referenced, so this helper won’t compile. Please drop it or turn it into a blank identifier.-func createCustomColumnWithBadge(name, badgeValue, title, href string) map[string]any { +func createCustomColumnWithBadge(name, badgeValue string, _ string, href string) map[string]any {
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
internal/controller/dashboard/customcolumns.go(1 hunks)internal/controller/dashboard/factory.go(1 hunks)internal/controller/dashboard/helpers.go(0 hunks)internal/controller/dashboard/static_helpers.go(9 hunks)internal/controller/dashboard/static_refactored.go(13 hunks)internal/controller/dashboard/ui_helpers.go(1 hunks)internal/controller/dashboard/unified_helpers.go(3 hunks)
💤 Files with no reviewable changes (1)
- internal/controller/dashboard/helpers.go
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Build
8f9f728 to
ae8a54b
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
internal/controller/dashboard/static_helpers.go (1)
533-563: Fix compile error: use thepluralargumentGo rejects unused parameters, so
pluralnow triggersinternal/controller/dashboard/static_helpers.go:536:2: plural declared but not used. We should either drop the parameter (and touch every caller) or, better, feed it into the unified badge helper so the signature stays intact.func createCustomColumn(name, kind, plural, href string) map[string]any { link := antdLink("name-link", "{reqsJsonPath[0]['.metadata.name']['-']}", href) + badge := createUnifiedBadgeFromKind("header-badge", kind, plural) return map[string]any{ "name": name, "type": "factory", "customProps": map[string]any{ @@ - map[string]any{ - "children": []any{ - map[string]any{ - "type": "ResourceBadge", - "data": map[string]any{ - "id": "header-badge", - "value": kind, - // abbreviation auto-generated by ResourceBadge from value - }, - }, - link, - }, + map[string]any{ + "children": []any{ + badge, + link, + }, "type": "antdFlex", "data": map[string]any{ "align": "center", "gap": float64(6), },
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
internal/controller/dashboard/customcolumns.go(1 hunks)internal/controller/dashboard/factory.go(1 hunks)internal/controller/dashboard/helpers.go(0 hunks)internal/controller/dashboard/static_helpers.go(9 hunks)internal/controller/dashboard/static_refactored.go(13 hunks)internal/controller/dashboard/ui_helpers.go(1 hunks)internal/controller/dashboard/unified_helpers.go(4 hunks)
💤 Files with no reviewable changes (1)
- internal/controller/dashboard/helpers.go
🚧 Files skipped from review as they are similar to previous changes (3)
- internal/controller/dashboard/customcolumns.go
- internal/controller/dashboard/static_refactored.go
- internal/controller/dashboard/factory.go
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Build
component Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
ae8a54b to
af460f1
Compare
|
Successfully created backport PR for |
Signed-off-by: Andrei Kvapil kvapss@gmail.com
What this PR does
Release note
Summary by CodeRabbit