Skip to content

fix(backup): several fixes around backup-pages#11

Open
androndo wants to merge 1 commit into
mainfrom
fix/backup-pages
Open

fix(backup): several fixes around backup-pages#11
androndo wants to merge 1 commit into
mainfrom
fix/backup-pages

Conversation

@androndo
Copy link
Copy Markdown

@androndo androndo commented May 15, 2026

  • form about BackupJob creation now correctly fills backupClass
  • enhanced UX selection of targetApplicationRef with pre-filled values for apps.cozystack.io
  • ResotreJob options input great again

Summary by CodeRabbit

  • New Features

    • Added a dedicated Backup Job creation page with schema-driven form, validation, and submission flow.
  • Bug Fixes

    • Prevented auto-attached backup-class widget from overriding native enum fields.
    • Preserved parent form data when generating defaults for recomputed schemas.
    • Stabilized backup-class selection during loading and improved restore-target validation.
  • Refactor

    • Replaced prior generic backup-create flow and deprecated legacy schema exports with the new page workflow.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 15, 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: 29dd697a-51b7-4b23-9e33-3acf7ed715db

📥 Commits

Reviewing files that changed from the base of the PR and between 361fd3c and 43082bf.

📒 Files selected for processing (9)
  • apps/console/src/components/BackupClassWidget.tsx
  • apps/console/src/components/SchemaForm.tsx
  • apps/console/src/routes/BackupJobCreatePage.tsx
  • apps/console/src/routes/BackupPlanCreatePage.tsx
  • apps/console/src/routes/BackupResourceCreatePage.tsx
  • apps/console/src/routes/BackupResourceCreatePageWithData.tsx
  • apps/console/src/routes/BackupRestoreJobCreatePage.tsx
  • apps/console/src/routes/ConsolePage.tsx
  • apps/console/src/routes/backup-schemas.ts
💤 Files with no reviewable changes (3)
  • apps/console/src/routes/backup-schemas.ts
  • apps/console/src/routes/BackupResourceCreatePage.tsx
  • apps/console/src/routes/BackupResourceCreatePageWithData.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/console/src/components/SchemaForm.tsx
  • apps/console/src/routes/BackupRestoreJobCreatePage.tsx

📝 Walkthrough

Walkthrough

Adds a dedicated BackupJobCreatePage, makes plan/restore pages API-group-aware for enum population, stabilizes BackupClass select rendering, and updates SchemaForm to avoid widget-enum conflicts and to compute defaults from the latest parent formData.

Changes

Backup Creation Pages with API Group Support

Layer / File(s) Summary
SchemaForm Foundation Improvements
apps/console/src/components/SchemaForm.tsx
Schema form guards against attaching BackupClassWidget when a native enum exists, and switches default emission to use current formData via a ref instead of an initial snapshot.
BackupClassWidget Stability
apps/console/src/components/BackupClassWidget.tsx
Normalizes currentValue, keeps the parent's selection visible as an <option> when it's not in the loaded list, removes the loading-disabled state, and only shows the empty-list option when not loading and no current value exists.
New BackupJobCreatePage Component
apps/console/src/routes/BackupJobCreatePage.tsx
New page that loads the BackupJob CRD schema, fetches backupclasses/plans/instances, enriches the schema with enums and a default applicationRef.apiGroup, validates input, creates BackupJob manifests, and shows loading/error/pending UI.
BackupPlanCreatePage API Group Filtering
apps/console/src/routes/BackupPlanCreatePage.tsx
Derives selectedApiGroup from form state, gates instance fetching and enum population to apps.cozystack.io, wraps schema parse in try/catch, and sets a default cron value when present.
BackupRestoreJobCreatePage API Group Support
apps/console/src/routes/BackupRestoreJobCreatePage.tsx
Switches to targetApplicationRef, derives selectedApiGroup, conditionally populates kind/name enums for apps.cozystack.io, removes certain CRD defaults, rewrites spec.options as a string map, and updates submit validation to omit empty target refs.
Console Routing Update
apps/console/src/routes/ConsolePage.tsx, removed BackupResourceCreatePageWithData.tsx
Routes backups/backupjobs/create to the new BackupJobCreatePage, replacing the previous generic creator and updating imports.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A rabbit hops through backup flows so bright,

enums aligned and apiGroups set right,
New JobCreator hops with schema in hand,
selects stay steady, defaults now understand,
The warren's backups snug and light! ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'fix(backup): several fixes around backup-pages' is vague and generic, using 'several fixes' without specifying what was actually fixed or the main change. Use a more specific title that describes the primary change, such as 'fix(backup): refactor backup creation pages with schema-driven forms' or 'fix(backup): improve backup job and restore job form field handling'.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/backup-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.

Copy link
Copy Markdown

@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 introduces a dedicated BackupJobCreatePage and refactors existing backup-related creation pages to handle API groups more robustly, specifically filtering application kinds and instances when the API group is apps.cozystack.io. It also improves SchemaForm to preserve user input during async schema updates and fixes UI issues where defaults interfered with selection widgets. Feedback includes suggestions to wrap JSON.parse calls in try-catch blocks for safety, replace alert() calls with better UX patterns like toast notifications, and improve accessibility by adding id and htmlFor attributes to form labels and inputs.

Comment thread apps/console/src/routes/BackupJobCreatePage.tsx Outdated
Comment thread apps/console/src/routes/BackupPlanCreatePage.tsx Outdated
Comment thread apps/console/src/routes/BackupRestoreJobCreatePage.tsx Outdated
Comment on lines +104 to +137
alert("Tenant namespace is not available. Please refresh.")
return
}

if (!name.trim()) {
alert("Name is required")
return
}

if (!formData.applicationRef?.kind || !formData.applicationRef?.name) {
alert("Application reference is required")
return
}

if (!formData.backupClassName) {
alert("Backup class name is required")
return
}

const resource = {
apiVersion: "backups.cozystack.io/v1alpha1",
kind: "BackupJob",
metadata: {
name: name.trim(),
namespace: tenantNamespace ?? undefined,
},
spec: formData,
}

try {
await createMutation.mutateAsync(resource)
navigate("/console/backups/backupjobs")
} catch (err) {
alert(`Failed to create BackupJob: ${(err as Error).message}`)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Using alert() for validation and error reporting is generally discouraged as it provides a poor user experience and blocks the main thread. Consider using a toast notification system or inline validation messages. Additionally, these strings are hardcoded and should be moved to a localization system if the project supports i18n.

Comment thread apps/console/src/routes/BackupJobCreatePage.tsx Outdated
@androndo androndo force-pushed the fix/backup-pages branch from 361fd3c to 5bbda8f Compare May 15, 2026 15:55
Signed-off-by: Andrey Kolkov <androndo@gmail.com>
@androndo androndo force-pushed the fix/backup-pages branch from 5bbda8f to 43082bf Compare May 18, 2026 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant