feat: note editing (edit form + PUT proxy + Edit button) #30
No reviewers
Labels
No labels
domain:backend
domain:devops
domain:frontend
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
forgejo_admin/pal-e-docs-app!30
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "27-feat-note-editing-edit-form-put-proxy-ed"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Add full note editing capability to pal-e-app. Authenticated users see an "Edit" button on note detail pages that links to a pre-populated edit form. The form submits via a PUT proxy endpoint to the pal-e-docs API.
Changes
src/lib/api.ts-- Addedis_publicto Note interface,UpdateNotePayloadinterface, andupdateNote()functionsrc/routes/api/notes/[slug]/+server.ts(NEW) -- PUT proxy with auth guard, field filtering, and upstream error forwardingsrc/routes/notes/[slug]/edit/+page.server.ts(NEW) -- Server load for edit page (fetches note, projects, tags; redirects unauthenticated users)src/routes/notes/[slug]/edit/+page.svelte(NEW) -- Edit form with title, HTML content textarea, note_type dropdown (16 types), dynamic status dropdown, project selector, tags input with clickable tag picker, parent slug, visibility togglesrc/lib/components/NoteLayout.svelte-- AddedisAuthenticatedprop and Edit button in headersrc/routes/notes/[slug]/+page.server.ts-- Added session to returned data for auth-aware renderingsrc/routes/notes/[slug]/+page.svelte-- PassisAuthenticatedto NoteLayoutTest Plan
Review Checklist
npm run build)npm run lint)npm run check-- 0 errors)Related
Self-Review
Verdict: PASS -- ready for human review.
Findings
Note (non-blocking): The diff includes
createBoardItemanddeleteBoardItemfunctions added toapi.ts. These were auto-injected by system hooks to fix a pre-existing build error (src/routes/api/boards/[slug]/items/[id]/+server.tsimportsdeleteBoardItemwhich was missing fromapi.tson main). These are not part of the note editing feature but are required for the build to pass. Acceptable to ship together.What was verified
npm run build-- passes (0 errors)npm run check-- 0 errors, 2 pre-existing warnings (state_referenced_locally in edit page is intentional for form init; a11y_autofocus in search page is pre-existing)npm run lint-- passes (0 errors)PR #30 Review
BLOCKERS
None. This PR is clean, correct, and secure.
NITS
Scope creep in
api.tsdiff -- The diff includescreateBoardItemanddeleteBoardItemfunctions (lines +206 through +251 in api.ts). These already exist on main from a prior merge. This suggests the branch was forked before that code landed. Not harmful since the code is identical, but a rebase onto main before merge would produce a cleaner diff and avoid any merge confusion.No E2E tests for edit flow -- The repo has a mature
e2e/directory with 7 Playwright spec files. This PR adds a significant new user flow (edit form, PUT proxy, auth guard on edit page) but the Test Plan consists entirely of manual checkboxes. Consider adding ane2e/note-edit.spec.tsthat covers at minimum: (a) unauthenticated user cannot reach/notes/{slug}/edit, (b) authenticated user sees a pre-populated form, (c) save triggers PUT and redirects. This can be a follow-up issue if needed.Redirect after save uses original slug --
handleSubmitredirects todata.note.slugafter save. TheUpdateNotePayloadinterface includes an optionalslugfield, but the form does not expose slug editing. This is currently fine, but if slug editing is added later, the redirect would go to the old (now 404) URL. A comment noting this would help future developers. Alternatively, use the slug from the API response instead ofdata.note.slug.Missing
Content-Typeheader on client-side PUT -- ThehandleSubmitfunction correctly setsContent-Type: application/jsonon the client-side fetch. Good.$effectinitial-load behavior -- The status-reset$effectruns on mount and checks!opts.includes(status). This is correct -- it will not reset a valid initial status. Clean use of Svelte 5 reactivity.SOP COMPLIANCE
27-feat-note-editing-edit-form-put-proxy-edreferences issue #27..envfiles, credentials, or API keys in the diff. Auth handled server-side vialocals.auth().createBoardItem/deleteBoardItemoverlap inapi.tsis cosmetic (already on main).Code Quality Notes
src/routes/api/notes/[slug]/+server.tsfollows the exact same pattern as the existing POST notes proxy and PATCH/DELETE board item proxies:locals.auth()check, 401 throw, field filtering, upstream call with error forwarding.is_public), number (position), and array (tagswith type guard). No unvalidated passthrough.$props(),$state(),$derived(),$effect()used correctly. No legacy Svelte 4 patterns.bg-[#0a0a14],border-[#1a1a2e],bg-[#0e0e18], accent#e94560all consistent with existing components.VERDICT: APPROVED
ff3ab79c20b6a473e740