Phase 1: Admin Form System Unification
Created by: devin-ai-integration[bot]
Phase 1: Admin Form System Unification - Refactor to Shared Composables
Summary
Refactored three admin forms (EssayForm, AlbumForm, and posts edit page) to use shared composables (useDraftRecovery, useFormGuards) instead of duplicated inline logic. This eliminates ~167 lines of duplicated code and aligns all forms with the ProjectForm pattern.
Key Changes:
-
EssayForm: Replaced inline draft recovery and form guards with composables, replaced inline draft banner with
DraftPromptcomponent - AlbumForm: Added autosave functionality (previously showed hardcoded "idle" status), added draft recovery and form guards using composables
-
Posts edit page: Replaced inline draft recovery and form guards with composables, replaced inline draft banner with
DraftPromptcomponent
Code Reduction:
- Removed 388 lines of duplicated code
- Added 221 lines using shared composables
- Net reduction: 167 lines
Review & Testing Checklist for Human
-
Test AlbumForm autosave - AlbumForm now has autosave for the first time (previously hardcoded to "idle"). Edit an album, make changes, verify autosave triggers and status updates correctly. -
Test draft recovery on all three forms - For each form (EssayForm, AlbumForm, posts edit page): - Start editing content
- Wait for autosave to fail (disconnect network or force offline state)
- Close browser/tab
- Reopen the form
- Verify draft recovery prompt appears with correct timestamp
- Test both "Restore" and "Dismiss" actions
-
Test navigation guards - For each form: - Make unsaved changes
- Try to navigate away (click back button or type new URL)
- Verify autosave flushes before navigation
- Try to close browser tab - verify beforeunload warning appears
- Test Cmd/Ctrl+S keyboard shortcut triggers immediate save
-
Test for regressions - Verify existing functionality still works: - Form validation
- Manual save/publish actions
- Tab switching
- Content editing
- Tag management (EssayForm, posts edit page)
- Photo selection (AlbumForm)
Notes
- All three forms now use the same composables that ProjectForm already uses successfully
- Eslint passes with zero errors (maintained throughout refactoring)
- Draft key logic was slightly adjusted - verify edge cases work correctly (e.g., creating new posts)
- AlbumForm's autosave uses the same 2-second debounce as other forms
Session: https://app.devin.ai/sessions/9c28151548c1410ca9948853ad0c04ad
Requested by: Justin Edmund (justin@jedmund.com) / @jedmund