[8655] Fix FE2 Save as Draft functionality#4853
[8655] Fix FE2 Save as Draft functionality#4853jvega190 wants to merge 1 commit intocraftercms:developfrom
Conversation
|
Warning Rate limit exceeded
To continue reviewing without waiting, purchase usage credits in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
WalkthroughThe PR implements a draft-saving feature across the FormsEngine system by introducing draft state tracking and field validation, refactoring SaveCard to use a split-button UI exposing separate save and save-as-draft actions, and updating unlock-on-close logic to respect draft state. It also enhances the SplitButton component with controlled selection and full-width layout capabilities. ChangesDraft-Saving Feature in FormsEngine
SplitButton Component Enhancement
Sequence DiagramsequenceDiagram
participant User
participant FormsEngine
participant SaveCard
participant SplitButton
participant useSaveForm
participant formUtils
User->>FormsEngine: Edit form fields
FormsEngine->>FormsEngine: Subscribe to field updates (debounced)
FormsEngine->>FormsEngine: Update invalidForm state via checkValidationState
FormsEngine->>SaveCard: Render with saveAsDraft, invalidForm, setSaveAsDraft
User->>SaveCard: Click "Save Draft" option in SplitButton
SaveCard->>SaveCard: setSaveAsDraft(true)
SaveCard->>SaveCard: onSave(event, draft=true)
SaveCard->>useSaveForm: saveFn(draft=true)
useSaveForm->>useSaveForm: Compute isFormInvalid, set saveAsDraft=true
useSaveForm->>useSaveForm: Execute save flow with draft flag
Note over FormsEngine,formUtils: On component unmount/close
FormsEngine->>formUtils: useUnlockOnClose({ saveAsDraft, invalidForm })
formUtils->>formUtils: shouldUnlockItem checks: not invalidForm AND not saveAsDraft
formUtils->>formUtils: Conditionally unlock item based on flags
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Possibly related issues
Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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 |
craftercms/craftercms#8655
Summary by CodeRabbit
New Features
Improvements