Skip to content

fix(dashboard): hide sidebar on cluster-level pages when no tenant selected#2106

Merged
androndo merged 1 commit intomainfrom
fix/sidebar-cluster-pages
Feb 26, 2026
Merged

fix(dashboard): hide sidebar on cluster-level pages when no tenant selected#2106
androndo merged 1 commit intomainfrom
fix/sidebar-cluster-pages

Conversation

@sircthulhu
Copy link
Contributor

@sircthulhu sircthulhu commented Feb 26, 2026

What this PR does

In the current version, the sidebar incorrectly shows namespace-scoped menu items on cluster-level pages (before a tenant is selected). Clicking these items produces broken URLs with double // (e.g. default//api-table/backups.cozystack.io/...) because the {namespace} placeholder resolves to an empty string.

This PR fixes the issue by:

  • Removing stock-instance-* sidebar resources that were populated with the same namespace-scoped menu as stock-project-* sidebars
  • Clearing the CUSTOMIZATION_SIDEBAR_FALLBACK_ID env var so the frontend renders no sidebar when no matching sidebar resource exists
  • Removing stock-instance-* from the expected resource set so orphan cleanup removes stale instances on upgrade

Screenshot after changes
dashboard screenshot with no tenant selected

Test plan

  • On cluster list page (no tenant selected), sidebar is empty
  • After selecting a tenant, sidebar shows full menu
  • No double // in sidebar URLs
  • Existing tests pass: go test ./internal/controller/dashboard/...

Release note

[dashboard] fix: hide sidebar on cluster-level pages when no tenant selected

Summary by CodeRabbit

  • Refactor
    • Streamlined sidebar resource management by reducing the number of static sidebar configurations generated by the system.
    • Removed sidebar fallback behavior, resulting in simplified sidebar customization defaults.

…lected

Remove stock-instance-* sidebars that were populated with namespace-scoped
menu items, causing the sidebar to incorrectly appear on cluster-level pages.
Clear the sidebar fallback ID so the frontend gracefully renders no sidebar
when no matching sidebar resource exists.

Co-Authored-By: Claude <[email protected]>
Signed-off-by: Kirill Ilin <[email protected]>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 26, 2026

📝 Walkthrough

Walkthrough

The PR removes deprecated stock-instance sidebar identifiers from the dashboard management system, consolidating sidebar resource configuration to use only stock-project sidebars and removing the sidebar customization fallback ID reference.

Changes

Cohort / File(s) Summary
Manager Configuration
internal/controller/dashboard/manager.go
Removed four stock sidebar identifiers ("stock-instance-api-form", "stock-instance-api-table", "stock-instance-builtin-form", "stock-instance-builtin-table") from the stockSidebars list, reducing the set of expected sidebar resources for cleanup.
Sidebar Resource Construction
internal/controller/dashboard/sidebar.go
Updated ensureSidebar function to drop static stock-instance sidebars from targetIDs and consolidated documented stock-sidebar list to stock-project sidebars only. Dynamic per-CRD detail sidebars logic remains preserved.
Template Configuration
packages/system/dashboard/templates/web.yaml
Changed CUSTOMIZATION_SIDEBAR_FALLBACK_ID from "stock-project-api-table" to an empty string, removing the sidebar customization fallback reference.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 Sidebars trimmed with careful paw,
Instances gone, the project stays,
Less to manage, cleaner claw,
Dynamic dashboards light the ways!

🚥 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 title accurately describes the main fix: hiding the sidebar on cluster-level pages when no tenant is selected, which is the core issue addressed by removing stock-instance sidebars and clearing the fallback ID.
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-cluster-pages

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.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @sircthulhu, 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 an issue where the dashboard sidebar displayed incorrect namespace-scoped menu items on cluster-level pages before a tenant was selected, leading to broken URLs. The changes ensure that the sidebar remains empty in this state, providing a cleaner and more functional user experience by preventing the creation of inappropriate sidebar resources and configuring the frontend to hide the sidebar when no tenant is selected.

Highlights

  • Sidebar Resource Removal: Eliminated stock-instance-* sidebar resources that were incorrectly populated with namespace-scoped menu items.
  • Sidebar Fallback Configuration: Cleared the CUSTOMIZATION_SIDEBAR_FALLBACK_ID environment variable to ensure the frontend renders no sidebar when no matching resource exists.
  • Orphan Cleanup Prevention: Removed stock-instance-* from the expected resource set to prevent orphan cleanup from removing stale instances on upgrade.

🧠 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/manager.go
    • Removed stock-instance-api-form, stock-instance-api-table, stock-instance-builtin-form, and stock-instance-builtin-table from the list of stockSidebars that are part of the expected resource set.
  • internal/controller/dashboard/sidebar.go
    • Updated comments to reflect the removal of stock-instance sidebars.
    • Removed stock-instance-api-form, stock-instance-api-table, stock-instance-builtin-form, and stock-instance-builtin-table from the targetIDs list, preventing their creation.
  • packages/system/dashboard/templates/web.yaml
    • Modified the CUSTOMIZATION_SIDEBAR_FALLBACK_ID environment variable value from stock-project-api-table to an empty string.
Activity
  • The author has verified that the sidebar is empty on the cluster list page when no tenant is selected.
  • The author confirmed that the sidebar shows the full menu after selecting a tenant.
  • The author checked that no double // appear in sidebar URLs.
  • Existing tests for internal/controller/dashboard/... have passed.
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.

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 addresses the issue of the sidebar being incorrectly displayed on cluster-level pages by removing the stock-instance-* sidebar resources and clearing the fallback sidebar ID. The changes are logical and align with the description. I've also identified a related issue in manager.go where the list of expected sidebar resources for cleanup is incomplete, which could lead to the incorrect deletion of other static sidebars. I've added a suggestion to fix this.

@sircthulhu sircthulhu self-assigned this Feb 26, 2026
@sircthulhu sircthulhu marked this pull request as ready for review February 26, 2026 08:49
@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. bug Something isn't working labels Feb 26, 2026
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)

283-284: Stale comment references removed sidebar type.

The comment mentions stock-instance-* sidebars, but these are no longer created after this PR. Consider updating the comment to reflect the current behavior.

📝 Suggested comment update
-			// Only set owner reference for dynamic sidebars (stock-project-factory-{kind}-details)
-			// Static sidebars (stock-instance-*, stock-project-*) should not have owner references
+			// Only set owner reference for dynamic sidebars (stock-project-factory-{kind}-details)
+			// Static sidebars (stock-project-*) should not have owner references
🤖 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 283 - 284, Update the
stale comment in internal/controller/dashboard/sidebar.go that currently reads
"Only set owner reference for dynamic sidebars
(stock-project-factory-{kind}-details) // Static sidebars (stock-instance-*,
stock-project-*) should not have owner references" to remove the obsolete
"stock-instance-*" reference and reflect current behavior; keep the mention of
dynamic sidebar pattern "stock-project-factory-{kind}-details" and the rule
about static sidebars not receiving owner references so the comment accurately
documents the code's intent.
🤖 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 283-284: Update the stale comment in
internal/controller/dashboard/sidebar.go that currently reads "Only set owner
reference for dynamic sidebars (stock-project-factory-{kind}-details) // Static
sidebars (stock-instance-*, stock-project-*) should not have owner references"
to remove the obsolete "stock-instance-*" reference and reflect current
behavior; keep the mention of dynamic sidebar pattern
"stock-project-factory-{kind}-details" and the rule about static sidebars not
receiving owner references so the comment accurately documents the code's
intent.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e16d987 and 7a10729.

📒 Files selected for processing (3)
  • internal/controller/dashboard/manager.go
  • internal/controller/dashboard/sidebar.go
  • packages/system/dashboard/templates/web.yaml
💤 Files with no reviewable changes (1)
  • internal/controller/dashboard/manager.go

Copy link
Contributor

@androndo androndo left a comment

Choose a reason for hiding this comment

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

works as expected)

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Feb 26, 2026
@androndo androndo enabled auto-merge February 26, 2026 11:20
@androndo androndo merged commit f887e34 into main Feb 26, 2026
14 of 15 checks passed
@androndo androndo deleted the fix/sidebar-cluster-pages branch February 26, 2026 11:26
sircthulhu added a commit that referenced this pull request Mar 2, 2026
…ages

PR #2106 removed stock-instance-* sidebar resources to fix broken URLs
on the main page before namespace selection. However, these sidebars are
required for rendering namespace-level pages (api-table, api-form, etc.)
such as the Backup Plans page.

Without stock-instance-api-table, the frontend cannot find the sidebar
for namespace-scoped api-table pages and renders an empty page instead.

The original bug (broken URLs with empty namespace placeholder) is already
fixed by CUSTOMIZATION_SIDEBAR_FALLBACK_ID="" in web.yaml, so re-adding
stock-instance-* sidebars does not reintroduce it.

Co-Authored-By: Claude <[email protected]>
Signed-off-by: Kirill Ilin <[email protected]>
kvaps added a commit that referenced this pull request Mar 2, 2026
…pages (#2136)

## What this PR does

Restores `stock-instance-api-form`, `stock-instance-api-table`,
`stock-instance-builtin-form`, and `stock-instance-builtin-table`
sidebar
resources that were removed in #2106, and adds them back to the orphan
cleanup allowlist.

PR #2106 removed these sidebars to fix broken URLs on the main page
before
namespace selection (`default//api-table/...`). However,
`stock-instance-*`
sidebars are required by the frontend for namespace-level
api-table/api-form
pages. Without them and with `CUSTOMIZATION_SIDEBAR_FALLBACK_ID=""`, the
frontend cannot find a sidebar for pages like Backup Plans and renders
an
empty page where no interaction is possible.

The broken-URL bug is already fully fixed by
`CUSTOMIZATION_SIDEBAR_FALLBACK_ID=""`
in `web.yaml`. Re-adding `stock-instance-*` does not reintroduce it,
since
these sidebars are only shown when the user is on a namespace-level page
where the `{namespace}` placeholder is filled.

### Release note

```release-note
[dashboard] fix empty page on Backup Plans and other namespace-level api-table pages
```

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **New Features**
* Added four new dashboard sidebar resources for stock instances: API
form, API table, built-in form, and built-in table views. These enable
expanded dashboard customization options for managing stock instance
configurations and data.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
github-actions bot pushed a commit that referenced this pull request Mar 2, 2026
…ages

PR #2106 removed stock-instance-* sidebar resources to fix broken URLs
on the main page before namespace selection. However, these sidebars are
required for rendering namespace-level pages (api-table, api-form, etc.)
such as the Backup Plans page.

Without stock-instance-api-table, the frontend cannot find the sidebar
for namespace-scoped api-table pages and renders an empty page instead.

The original bug (broken URLs with empty namespace placeholder) is already
fixed by CUSTOMIZATION_SIDEBAR_FALLBACK_ID="" in web.yaml, so re-adding
stock-instance-* sidebars does not reintroduce it.

Co-Authored-By: Claude <[email protected]>
Signed-off-by: Kirill Ilin <[email protected]>
(cherry picked from commit 45b61f8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

2 participants