Skip to content

fix(dashboard): exclude hidden MarketplacePanel resources from sidebar menu#2177

Merged
kvaps merged 1 commit intomainfrom
fix/sidebar-respect-hidden-marketplace
Mar 10, 2026
Merged

fix(dashboard): exclude hidden MarketplacePanel resources from sidebar menu#2177
kvaps merged 1 commit intomainfrom
fix/sidebar-respect-hidden-marketplace

Conversation

@IvanHunters
Copy link
Collaborator

@IvanHunters IvanHunters commented Mar 9, 2026

Summary

  • Sidebar menu was showing all resources regardless of their MarketplacePanel hidden state
  • Fetch MarketplacePanels during sidebar reconciliation and skip resources where hidden=true
  • Hiding a resource from the marketplace now also removes it from the sidebar navigation

Test plan

  • Set hidden: true on a MarketplacePanel (e.g. qdrant)
  • Trigger controller reconciliation
  • Verify the resource is removed from the sidebar menu
  • Set hidden: false and verify the resource reappears in the sidebar

Summary by CodeRabbit

  • New Features
    • Sidebar can now hide resources based on MarketplacePanel configuration parsed from panel definitions.
    • Hidden resources are filtered early when assembling sidebar categories, preventing them from contributing to menu items.
    • Listing failures are non-fatal: if configuration fetch fails, no hiding is applied and the dashboard remains functional.

@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Mar 9, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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 resolves an issue where resources configured as hidden within MarketplacePanels were still being displayed in the dashboard's sidebar menu. The changes introduce logic to fetch MarketplacePanel configurations during sidebar generation, allowing the system to identify and exclude hidden resources. This ensures that the sidebar accurately reflects the visibility status of marketplace items, improving the overall user experience and consistency of the dashboard.

Highlights

  • Sidebar Menu Display: Resources with 'hidden=true' in their MarketplacePanel were incorrectly appearing in the dashboard sidebar menu.
  • Resource Filtering: The sidebar reconciliation process now fetches all MarketplacePanels and filters out resources explicitly marked as hidden.
  • User Experience: Hiding a resource in the marketplace will now correctly remove it from the dashboard's sidebar navigation, providing a more accurate user interface.

🧠 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
  • internal/controller/dashboard/sidebar.go
    • Added logic to fetch all MarketplacePanel resources to determine their hidden status.
    • Implemented parsing of the raw MarketplacePanel specification to extract the 'hidden' field.
    • Introduced a filtering step to skip resources marked as hidden when constructing the sidebar menu.
Activity
  • The pull request was opened by IvanHunters.
  • No additional review comments or activity have been recorded yet.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@dosubot dosubot bot added the bug Something isn't working label Mar 9, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 9, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 25f45989-45f4-4abf-9c20-bce38ef167bb

📥 Commits

Reviewing files that changed from the base of the PR and between 5d77824 and 318079b.

📒 Files selected for processing (1)
  • internal/controller/dashboard/sidebar.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • internal/controller/dashboard/sidebar.go

📝 Walkthrough

Walkthrough

The sidebar construction logic in the dashboard controller now includes a pre-processing step that lists MarketplacePanel resources, builds a hiddenResources map from each panel's spec.raw hidden flags, and filters CRDs from sidebar assembly based on that map. Listing errors are non-fatal and simply disable hiding.

Changes

Cohort / File(s) Summary
Dashboard Sidebar Filtering
internal/controller/dashboard/sidebar.go
Adds a MarketplacePanel listing pre-step, decodes spec.raw to build a hiddenResources map, and filters CRDs during sidebar assembly based on that map; listing errors are treated as non-fatal so hiding only applies on successful fetch.

Sequence Diagram(s)

sequenceDiagram
    participant Controller as Controller
    participant K8sAPI as Kubernetes API
    participant CRDStore as CRD list
    participant Sidebar as Sidebar Builder

    Controller->>K8sAPI: List MarketplacePanel
    alt list successful
        K8sAPI-->>Controller: MarketplacePanel list
        Controller->>Controller: Decode spec.raw, build hiddenResources map
        Controller->>CRDStore: List CRDs
        CRDStore-->>Controller: CRD defs
        Controller->>Controller: Filter out CRDs in hiddenResources
        Controller->>Sidebar: Build sidebar from remaining CRDs
        Sidebar-->>Controller: Sidebar structure
    else list failed
        K8sAPI-->>Controller: Error
        Controller->>CRDStore: List CRDs
        CRDStore-->>Controller: CRD defs
        Controller->>Sidebar: Build sidebar from all CRDs (no hiding)
        Sidebar-->>Controller: Sidebar structure
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 I nibble through panels, a whisper and hop,
Hidden flags noted, I give them a stop,
CRDs pruned softly, the sidebar breathes light,
Marketplace secrets tucked snug out of sight,
Hooray — the controller hops through the night.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly and concisely describes the main change: excluding hidden MarketplacePanel resources from the sidebar menu, which matches the core functionality added in the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/sidebar-respect-hidden-marketplace

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.

❤️ Share

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
internal/controller/dashboard/sidebar.go (1)

41-56: Consider logging errors instead of silently swallowing them.

While treating these errors as non-fatal is reasonable for graceful degradation, silently ignoring them could mask underlying issues (e.g., RBAC misconfiguration preventing MarketplacePanel listing, or malformed spec JSON). Adding debug/warning-level logs would aid troubleshooting without changing the behavior.

♻️ Suggested improvement
+	logger := log.FromContext(ctx)
+
 	// 1b) Fetch all MarketplacePanels to determine which resources are hidden
 	hiddenResources := map[string]bool{}
 	var mpList dashv1alpha1.MarketplacePanelList
-	if err := m.List(ctx, &mpList, &client.ListOptions{}); err == nil {
+	if err := m.List(ctx, &mpList, &client.ListOptions{}); err != nil {
+		logger.V(1).Info("failed to list MarketplacePanels, proceeding without hidden filtering", "error", err)
+	} else {
 		for i := range mpList.Items {
 			mp := &mpList.Items[i]
 			if mp.Spec.Raw != nil {
 				var spec map[string]any
 				if err := json.Unmarshal(mp.Spec.Raw, &spec); err == nil {
 					if hidden, ok := spec["hidden"].(bool); ok && hidden {
 						hiddenResources[mp.Name] = true
 					}
+				} else {
+					logger.V(1).Info("failed to unmarshal MarketplacePanel spec", "name", mp.Name, "error", err)
 				}
 			}
 		}
 	}

As per coding guidelines, internal/**/*.go: Follow controller-runtime patterns and kubebuilder style for Go code in internal directory.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/controller/dashboard/sidebar.go` around lines 41 - 56, The loop that
builds hiddenResources currently swallows errors from m.List and json.Unmarshal;
update it to log non-fatal failures at debug/warn level so issues are visible
without changing control flow: when calling m.List(ctx, &mpList,
&client.ListOptions{}) log the returned err (use the controller logger or
processLogger) if non-nil and continue, and inside the loop log json.Unmarshal
failures for mp.Spec.Raw as well as unexpected types when asserting
spec["hidden"].(bool); reference the hiddenResources map,
mpList/MarketplacePanelList, m.List, mp.Spec.Raw, json.Unmarshal, and mp.Name
when emitting messages to give clear context.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@internal/controller/dashboard/sidebar.go`:
- Around line 41-56: The loop that builds hiddenResources currently swallows
errors from m.List and json.Unmarshal; update it to log non-fatal failures at
debug/warn level so issues are visible without changing control flow: when
calling m.List(ctx, &mpList, &client.ListOptions{}) log the returned err (use
the controller logger or processLogger) if non-nil and continue, and inside the
loop log json.Unmarshal failures for mp.Spec.Raw as well as unexpected types
when asserting spec["hidden"].(bool); reference the hiddenResources map,
mpList/MarketplacePanelList, m.List, mp.Spec.Raw, json.Unmarshal, and mp.Name
when emitting messages to give clear context.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1585be49-40f4-4d21-87b6-cccb660553fa

📥 Commits

Reviewing files that changed from the base of the PR and between adacd44 and 5d77824.

📒 Files selected for processing (1)
  • internal/controller/dashboard/sidebar.go

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly implements the logic to exclude hidden MarketplacePanel resources from the sidebar menu. The approach of fetching all panels and checking the hidden flag is sound. My review includes a suggestion to improve error handling to make the feature more robust, particularly around API calls and JSON parsing, which currently allow for silent failures.

Comment on lines +44 to +56
if err := m.List(ctx, &mpList, &client.ListOptions{}); err == nil {
for i := range mpList.Items {
mp := &mpList.Items[i]
if mp.Spec.Raw != nil {
var spec map[string]any
if err := json.Unmarshal(mp.Spec.Raw, &spec); err == nil {
if hidden, ok := spec["hidden"].(bool); ok && hidden {
hiddenResources[mp.Name] = true
}
}
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

high

This block has a couple of error handling issues that could lead to incorrect behavior or make debugging difficult:

  1. m.List error is ignored: The logic is wrapped in an if err == nil block. If fetching MarketplacePanelList fails (e.g., due to a transient API server error), the function proceeds as if no resources are hidden. This would cause hidden resources to incorrectly appear in the sidebar. The error should be returned to trigger a reconciliation retry.

  2. json.Unmarshal error is ignored: A malformed MarketplacePanel spec will be silently skipped. This makes debugging difficult. This error should at least be logged to help administrators identify misconfigured resources.

The suggestion below refactors the block to handle these errors more robustly.

	if err := m.List(ctx, &mpList, &client.ListOptions{}); err != nil {
		return fmt.Errorf("failed to list MarketplacePanels to check for hidden resources: %w", err)
	}

	for i := range mpList.Items {
		mp := &mpList.Items[i]
		if mp.Spec.Raw == nil {
			continue
		}

		var spec map[string]any
		if err := json.Unmarshal(mp.Spec.Raw, &spec); err != nil {
			// TODO: Log this error. A malformed panel shouldn't fail the whole reconciliation.
			continue
		}

		if hidden, ok := spec["hidden"].(bool); ok && hidden {
			hiddenResources[mp.Name] = true
		}
	}

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Mar 9, 2026
…r menu

The sidebar was generated independently from MarketplacePanels, always
showing all resources regardless of their hidden state. Fetch
MarketplacePanels during sidebar reconciliation and skip resources
where hidden=true, so hiding a resource from the marketplace also
removes it from the sidebar navigation.

Signed-off-by: IvanHunters <[email protected]>
@kvaps kvaps force-pushed the fix/sidebar-respect-hidden-marketplace branch from 5d77824 to 318079b Compare March 10, 2026 11:41
@kvaps kvaps merged commit 27c5b0b into main Mar 10, 2026
8 of 9 checks passed
@kvaps kvaps deleted the fix/sidebar-respect-hidden-marketplace branch March 10, 2026 16:49
@kvaps kvaps added backport Should change be backported on previus release backport-previous labels Mar 10, 2026
@github-actions
Copy link

@github-actions
Copy link

kvaps added a commit that referenced this pull request Mar 10, 2026
…l resources from sidebar menu (#2203)

# Description
Backport of #2177 to `release-1.1`.
kvaps added a commit that referenced this pull request Mar 10, 2026
…l resources from sidebar menu (#2204)

# Description
Backport of #2177 to `release-1.0`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport Should change be backported on previus release backport-previous bug Something isn't working lgtm This PR has been approved by a maintainer size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants