Skip to content

feat(admin): add media library with uploads and reusable picker#46

Merged
mighty840 merged 2 commits into
mainfrom
feat/media-library
May 14, 2026
Merged

feat(admin): add media library with uploads and reusable picker#46
mighty840 merged 2 commits into
mainfrom
feat/media-library

Conversation

@mighty840
Copy link
Copy Markdown
Owner

Summary

  • Adds a Media Library page at /design/media with drag-and-drop upload, multi-select uploads, copy-URL action, and delete.
  • Files are stored locally under /uploads (already served by the server) and indexed in a new MediaAsset table that captures filename, original name, MIME type, size, and uploader.
  • Ships a reusable MediaPickerModal component so other admin forms (gallery, hero, menu items, banners) can adopt it incrementally without re-implementing the listing/upload flow.

Covers item 3 of the Moksha post-pitch backlog (image upload + media library).

New endpoints (staff-only):

  • GET /api/media — paginated list
  • POST /api/media/upload — multipart upload (5 MB, image only)
  • DELETE /api/media/:id — removes DB row + underlying file

Test plan

  • Navigate to Design → Media Library in admin
  • Drag an image onto the drop zone — appears in the grid after upload
  • Click "Upload Image" + select multiple files — all upload
  • Click "Copy URL" — full URL copied, button shows "Copied!" feedback
  • Delete an image — confirms via dialog, then disappears from grid and uploads/ folder
  • Upload an oversized (>5 MB) or non-image file — gracefully fails with an error message

Follow-ups

  • Wire MediaPickerModal into the gallery admin form (F2's DesignGallery) to replace the manual URL paste with a "Pick from library" button.
  • Same for menu item images, hero background, branding logo, etc.

🤖 Generated with Claude Code

Adds a Media Library page under Design with drag-and-drop upload,
multi-select uploads, copy-URL action, and delete. Files are stored
locally under /uploads (already served by the server) and indexed
in a new MediaAsset table that captures filename, original name,
MIME type, size, and uploader.

A reusable MediaPickerModal component is included so other admin
forms (gallery, hero, menu items, banners) can adopt it incrementally
without re-implementing the listing/upload flow.

New endpoints (staff-only):
  GET    /api/media          — paginated list
  POST   /api/media/upload   — multipart upload (5 MB, image only)
  DELETE /api/media/:id      — removes DB row and underlying file

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@mighty840 mighty840 force-pushed the feat/media-library branch from 4c4d920 to 281f84a Compare May 14, 2026 12:42
Adds integration tests for GET /api/media, POST /api/media/upload,
and DELETE /api/media/:id — covering auth gating, the no-file
upload error path, not-found, and the happy-path delete that
clears both the file (mocked) and the DB row.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@mighty840 mighty840 force-pushed the feat/media-library branch from 281f84a to 3d1f8e5 Compare May 14, 2026 13:32
@mighty840 mighty840 merged commit 69cffe7 into main May 14, 2026
8 checks passed
@mighty840 mighty840 deleted the feat/media-library branch May 14, 2026 13:36
@mighty840 mighty840 mentioned this pull request May 14, 2026
2 tasks
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