fix(backup): several fixes around backup-pages#11
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (9)
💤 Files with no reviewable changes (3)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughAdds 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. ChangesBackup Creation Pages with API Group Support
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
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.
| 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}`) |
There was a problem hiding this comment.
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.
361fd3c to
5bbda8f
Compare
Signed-off-by: Andrey Kolkov <androndo@gmail.com>
5bbda8f to
43082bf
Compare
Summary by CodeRabbit
New Features
Bug Fixes
Refactor