Skip to content

fix(dashboard): added dropdown for backupClasses#2104

Merged
androndo merged 1 commit intomainfrom
fix/dashboard-backup-classes-dropdown
Feb 27, 2026
Merged

fix(dashboard): added dropdown for backupClasses#2104
androndo merged 1 commit intomainfrom
fix/dashboard-backup-classes-dropdown

Conversation

@androndo
Copy link
Contributor

@androndo androndo commented Feb 25, 2026

What this PR does

Release note

- added dropdown for selection backupClasses in Plan/BackupJob creation form
image

Summary by CodeRabbit

  • Refactor
    • Updated backup class field input handling in dashboard forms with improved schema-based mechanisms.
    • Extended dashboard permissions to enable proper read access to backup class resources.

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. enhancement New feature or request labels Feb 25, 2026
@androndo androndo enabled auto-merge February 25, 2026 17:23
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @androndo, 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 enhances the Cozystack dashboard by integrating a user-friendly dropdown for selecting backup classes when creating or modifying BackupJobs and Plans. This change streamlines the workflow for users by providing a pre-populated list of available backup classes, eliminating the need for manual entry and ensuring data consistency. The update also includes the necessary backend logic and permissions to support this new UI element.

Highlights

  • Dashboard UI Enhancement: Implemented a new dropdown component for selecting backupClasses within the BackupJob and Plan creation forms in the dashboard, improving user experience and reducing manual input errors.
  • Configuration for Dropdown: Introduced backupClassListInputCustomProps to define the API endpoint (/api/clusters/{cluster}/k8s/apis/backups.cozystack.io/v1alpha1/backupclasses) and key mappings (metadata.name) for populating the new dropdown.
  • RBAC Permissions Update: Updated the ClusterRole to grant get, list, and watch permissions on backupclasses resources, ensuring the dashboard can fetch the necessary data for the dropdown.

🧠 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/customformsoverride.go
    • Defined backupClassListInputCustomProps to configure the list input for spec.backupClassName.
    • Extended applyListInputOverrides to apply the list input configuration to spec.backupClassName for BackupJob and Plan kinds.
  • internal/controller/dashboard/static_refactored.go
    • Modified createCustomFormsOverride to explicitly call applyListInputOverrides for BackupJob and Plan forms, ensuring the dropdown is rendered.
  • packages/system/dashboard/templates/rbac.yaml
    • Added ClusterRole permissions for the backups.cozystack.io API group, specifically for backupclasses resources, allowing get, list, and watch verbs.
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.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 25, 2026

📝 Walkthrough

Walkthrough

The changes refactor backup class name form configuration from API-driven to schema-based approach in the dashboard controller, and add RBAC permissions for the dashboard to read backupclass resources. Two helper functions support schema construction, and form-merging logic was adjusted to preserve schema properties during override creation.

Changes

Cohort / File(s) Summary
Dashboard Form Configuration
internal/controller/dashboard/static_refactored.go
Replaced API-driven form items for backupClassName with schema-based approach. Added listInputScemaItemBackupClass() and createSchema() helper functions. Updated form-merging logic in createCustomFormsOverride to exclude customizationId, hidden, and strategy (but not schema), allowing schema injection into plans and backupjobs form overrides. Net change: +30/-20 lines.
RBAC Permissions
packages/system/dashboard/templates/rbac.yaml
Added new rule block to ClusterRole cozystack-dashboard-readonly granting get, list, and watch verbs for backupclasses resource in backups.cozystack.io API group. Net change: +8/-0 lines.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰✨ Schema binds where API once called,
Form items reshape, no longer stalled,
RBAC opens backup's door so wide,
Dashboard sees what once did hide! 📋✅

🚥 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 change: adding a dropdown component for selecting backupClasses in dashboard forms, which aligns with the code changes that implement schema-based input for backupClassName.
Docstring Coverage ✅ Passed Docstring coverage is 85.71% which is sufficient. The required threshold is 80.00%.

✏️ 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/dashboard-backup-classes-dropdown

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

@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 successfully adds a dropdown menu for selecting backupClasses within the BackupJob and Plan creation forms in the dashboard. This is achieved by updating the CustomFormsOverride to use a listInput for the backupClassName field and adding the necessary RBAC permissions for the dashboard to fetch the list of backupclasses. The implementation is correct and addresses the feature requirement. I have one suggestion to refactor a small piece of duplicated code to improve maintainability.

Comment on lines +2074 to +2082
if strings.Contains(customizationId, "backups.cozystack.io/v1alpha1/backupjobs") {
schema := map[string]any{}
applyListInputOverrides(schema, "BackupJob", nil)
newSpec["schema"] = schema
} else if strings.Contains(customizationId, "backups.cozystack.io/v1alpha1/plans") {
schema := map[string]any{}
applyListInputOverrides(schema, "Plan", nil)
newSpec["schema"] = schema
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The if and else if blocks for handling BackupJob and Plan are nearly identical, with only the kind string differing. This duplication can be removed by first determining the kind and then executing the common logic once. This will make the code more concise and easier to maintain.

Suggested change
if strings.Contains(customizationId, "backups.cozystack.io/v1alpha1/backupjobs") {
schema := map[string]any{}
applyListInputOverrides(schema, "BackupJob", nil)
newSpec["schema"] = schema
} else if strings.Contains(customizationId, "backups.cozystack.io/v1alpha1/plans") {
schema := map[string]any{}
applyListInputOverrides(schema, "Plan", nil)
newSpec["schema"] = schema
}
var kind string
if strings.Contains(customizationId, "backups.cozystack.io/v1alpha1/backupjobs") {
kind = "BackupJob"
} else if strings.Contains(customizationId, "backups.cozystack.io/v1alpha1/plans") {
kind = "Plan"
}
if kind != "" {
schema := map[string]any{}
applyListInputOverrides(schema, kind, nil)
newSpec["schema"] = schema
}

applyListInputOverrides(schema, "Plan", nil)
newSpec["schema"] = schema
}

Copy link
Contributor

@sircthulhu sircthulhu Feb 25, 2026

Choose a reason for hiding this comment

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

Function applyListInputOverrides is called in customformsoverride.go in function ensureCustomFormsOverride.

It looks as if callers of the createCustomFormsOverride function only perform cleanup, so altering props is noop here

@androndo androndo force-pushed the fix/dashboard-backup-classes-dropdown branch from 4c8e589 to 412a408 Compare February 27, 2026 06:34
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/static_refactored.go (1)

2101-2121: Rename typoed helper for readability (ScemaSchema).

At Line 2101, listInputScemaItemBackupClass has a typo. Consider renaming it (and the parameter name in createSchema) to improve maintainability/searchability.

♻️ Suggested rename
-				"backupClassName": listInputScemaItemBackupClass(),
+				"backupClassName": listInputSchemaItemBackupClass(),

-				"backupClassName": listInputScemaItemBackupClass(),
+				"backupClassName": listInputSchemaItemBackupClass(),

-func listInputScemaItemBackupClass() map[string]any {
+func listInputSchemaItemBackupClass() map[string]any {
 	return map[string]any{
 		"type": "listInput",
 		"customProps": map[string]any{
 			"valueUri":    "/api/clusters/{cluster}/k8s/apis/backups.cozystack.io/v1alpha1/backupclasses",
 			"keysToValue": []any{"metadata", "name"},
 			"keysToLabel": []any{"metadata", "name"},
 		},
 	}
 }

-// backupClassSchema returns the schema for spec.backupClassName as listInput (BackupJob/Plan).
-func createSchema(customProps map[string]any) map[string]any {
+// createSchema returns schema entries under spec.properties.
+func createSchema(specProperties map[string]any) map[string]any {
 	return map[string]any{
 		"properties": map[string]any{
 			"spec": map[string]any{
-				"properties": customProps,
+				"properties": specProperties,
 			},
 		},
 	}
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/controller/dashboard/static_refactored.go` around lines 2101 - 2121,
Rename the misspelled helper function listInputScemaItemBackupClass to
listInputSchemaItemBackupClass (and update its comment accordingly), then update
all references/calls to this function throughout the codebase; also check the
createSchema function signature and any parameter names you intended to change
(ensure createSchema(customProps map[string]any) still matches callers or rename
the parameter consistently if you change it), and run tests/build to catch any
remaining references.
🤖 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/static_refactored.go`:
- Around line 2101-2121: Rename the misspelled helper function
listInputScemaItemBackupClass to listInputSchemaItemBackupClass (and update its
comment accordingly), then update all references/calls to this function
throughout the codebase; also check the createSchema function signature and any
parameter names you intended to change (ensure createSchema(customProps
map[string]any) still matches callers or rename the parameter consistently if
you change it), and run tests/build to catch any remaining references.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4c8e589 and 412a408.

📒 Files selected for processing (3)
  • internal/controller/dashboard/customformsoverride.go
  • internal/controller/dashboard/static_refactored.go
  • packages/system/dashboard/templates/rbac.yaml
🚧 Files skipped from review as they are similar to previous changes (2)
  • internal/controller/dashboard/customformsoverride.go
  • packages/system/dashboard/templates/rbac.yaml

@androndo androndo force-pushed the fix/dashboard-backup-classes-dropdown branch from 412a408 to d366c46 Compare February 27, 2026 06:58
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/static_refactored.go (1)

2101-2113: Fix helper naming/comment consistency to reduce maintenance friction.

There’s a typo in listInputScemaItemBackupClass, and the comment at Line 2112 references a different function name than the implementation.

♻️ Proposed cleanup
-               "backupClassName": listInputScemaItemBackupClass(),
+               "backupClassName": listInputSchemaItemBackupClass(),
@@
-               "backupClassName": listInputScemaItemBackupClass(),
+               "backupClassName": listInputSchemaItemBackupClass(),
@@
-func listInputScemaItemBackupClass() map[string]any {
+func listInputSchemaItemBackupClass() map[string]any {
@@
-// backupClassSchema returns the schema for spec.backupClassName as listInput (BackupJob/Plan).
+// createSchema returns the schema wrapper for spec properties (e.g. backupClassName listInput).
 func createSchema(customProps map[string]any) map[string]any {

Also applies to: 510-510, 525-525

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

In `@internal/controller/dashboard/static_refactored.go` around lines 2101 - 2113,
The helper function name listInputScemaItemBackupClass has a typo and its nearby
comment references the wrong function name; rename the function to
listInputSchemaItemBackupClass (fix "Scema"→"Schema") and update the comment
above createSchema to correctly reference the renamed helper, then update all
usages/references (including the other occurrences mentioned) to the new symbol
so builds/tests compile and comments stay consistent.
🤖 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/static_refactored.go`:
- Around line 2101-2113: The helper function name listInputScemaItemBackupClass
has a typo and its nearby comment references the wrong function name; rename the
function to listInputSchemaItemBackupClass (fix "Scema"→"Schema") and update the
comment above createSchema to correctly reference the renamed helper, then
update all usages/references (including the other occurrences mentioned) to the
new symbol so builds/tests compile and comments stay consistent.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 412a408 and d366c46.

📒 Files selected for processing (3)
  • internal/controller/dashboard/customformsoverride.go
  • internal/controller/dashboard/static_refactored.go
  • packages/system/dashboard/templates/rbac.yaml
🚧 Files skipped from review as they are similar to previous changes (2)
  • internal/controller/dashboard/customformsoverride.go
  • packages/system/dashboard/templates/rbac.yaml

@androndo androndo force-pushed the fix/dashboard-backup-classes-dropdown branch from d366c46 to cbf851a Compare February 27, 2026 07:04
@androndo androndo force-pushed the fix/dashboard-backup-classes-dropdown branch from cbf851a to f0e8e11 Compare February 27, 2026 07:04
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/static_refactored.go (1)

2101-2101: Fix helper name typo to improve maintainability.

listInputScemaItemBackupClass appears to be a typo (ScemaSchema).

✏️ Suggested rename
-func listInputScemaItemBackupClass() map[string]any {
+func listInputSchemaItemBackupClass() map[string]any {
-               "backupClassName": listInputScemaItemBackupClass(),
+               "backupClassName": listInputSchemaItemBackupClass(),
-               "backupClassName": listInputScemaItemBackupClass(),
+               "backupClassName": listInputSchemaItemBackupClass(),
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/controller/dashboard/static_refactored.go` at line 2101, Rename the
misspelled helper function listInputScemaItemBackupClass to
listInputSchemaItemBackupClass and update every reference (calls, tests,
comments) accordingly to avoid breakage; search for the symbol
listInputScemaItemBackupClass in the repository and replace with
listInputSchemaItemBackupClass, keep the function signature and behavior
unchanged, and run tests/compile to ensure no remaining usages of the old name.
🤖 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/static_refactored.go`:
- Line 2101: Rename the misspelled helper function listInputScemaItemBackupClass
to listInputSchemaItemBackupClass and update every reference (calls, tests,
comments) accordingly to avoid breakage; search for the symbol
listInputScemaItemBackupClass in the repository and replace with
listInputSchemaItemBackupClass, keep the function signature and behavior
unchanged, and run tests/compile to ensure no remaining usages of the old name.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d366c46 and f0e8e11.

📒 Files selected for processing (2)
  • internal/controller/dashboard/static_refactored.go
  • packages/system/dashboard/templates/rbac.yaml
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/system/dashboard/templates/rbac.yaml

Copy link
Contributor

@sircthulhu sircthulhu left a comment

Choose a reason for hiding this comment

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

lgtm

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Feb 27, 2026
@androndo androndo merged commit 1825628 into main Feb 27, 2026
10 of 11 checks passed
@androndo androndo deleted the fix/dashboard-backup-classes-dropdown branch February 27, 2026 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants