Compare commits

...

2 Commits

3 changed files with 109 additions and 6 deletions

View File

@@ -112,11 +112,11 @@ This file is the single source of truth for roadmap and delivery progress.
- [x] [P1] `todo/mvp1-media-foundation`: - [x] [P1] `todo/mvp1-media-foundation`:
media model, artwork entity, grouping primitives (gallery/album/category/tag), rendition slots media model, artwork entity, grouping primitives (gallery/album/category/tag), rendition slots
- [~] [P1] `todo/mvp1-media-upload-pipeline`: - [x] [P1] `todo/mvp1-media-upload-pipeline`:
S3/local upload adapter, media processing presets, metadata input flows, admin media CRUD UI S3/local upload adapter, media processing presets, metadata input flows, admin media CRUD UI
- [x] [P1] `todo/mvp1-pages-navigation-builder`: - [x] [P1] `todo/mvp1-pages-navigation-builder`:
page CRUD, navigation tree, reusable page blocks (forms/price cards/gallery embeds) page CRUD, navigation tree, reusable page blocks (forms/price cards/gallery embeds)
- [~] [P1] `todo/mvp1-commissions-customers`: - [x] [P1] `todo/mvp1-commissions-customers`:
commission request intake + admin CRUD + kanban + customer entity/linking commission request intake + admin CRUD + kanban + customer entity/linking
- [x] [P1] `todo/mvp1-announcements-news`: - [x] [P1] `todo/mvp1-announcements-news`:
announcement management/rendering + news/blog CRUD and public rendering announcement management/rendering + news/blog CRUD and public rendering
@@ -139,7 +139,7 @@ This file is the single source of truth for roadmap and delivery progress.
- [x] [P1] Page management (create/edit/publish/unpublish/schedule) - [x] [P1] Page management (create/edit/publish/unpublish/schedule)
- [x] [P1] Page builder with reusable content blocks (hero, rich text, gallery, CTA, forms, price cards) - [x] [P1] Page builder with reusable content blocks (hero, rich text, gallery, CTA, forms, price cards)
- [x] [P1] Navigation management (menus, nested items, order, visibility) - [x] [P1] Navigation management (menus, nested items, order, visibility)
- [~] [P1] Media library (upload, browse, replace, delete) with media-type classification (artwork, banner, promo, generic, video/gif) - [x] [P1] Media library (upload, browse, replace, delete) with media-type classification (artwork, banner, promo, generic, video/gif)
- [x] [P1] Media enrichment metadata (alt text, copyright, author, source, tags, licensing, usage context) - [x] [P1] Media enrichment metadata (alt text, copyright, author, source, tags, licensing, usage context)
- [x] [P1] Portfolio grouping primitives (galleries, albums, categories, tags) with ordering/visibility controls - [x] [P1] Portfolio grouping primitives (galleries, albums, categories, tags) with ordering/visibility controls
- [x] [P1] Artwork refinement fields (medium, dimensions, year, framing, availability, price visibility) - [x] [P1] Artwork refinement fields (medium, dimensions, year, framing, availability, price visibility)
@@ -164,7 +164,7 @@ This file is the single source of truth for roadmap and delivery progress.
- [x] [P1] Portfolio views (gallery/album/category/tag) for artworks with filter and sort controls - [x] [P1] Portfolio views (gallery/album/category/tag) for artworks with filter and sort controls
- [x] [P1] Rendition-aware media delivery (thumbnail/card/full) per template slot - [x] [P1] Rendition-aware media delivery (thumbnail/card/full) per template slot
- [x] [P1] Translation-ready content model for public entities (pages/news/navigation labels) - [x] [P1] Translation-ready content model for public entities (pages/news/navigation labels)
- [ ] [P2] Artwork views and listing filters - [x] [P2] Artwork views and listing filters
- [x] [P1] Commission request submission flow - [x] [P1] Commission request submission flow
- [x] [P1] Header banner render logic and fallbacks - [x] [P1] Header banner render logic and fallbacks
- [x] [P1] Announcement render slots (homepage + optional global/top banner position) - [x] [P1] Announcement render slots (homepage + optional global/top banner position)
@@ -372,6 +372,7 @@ This file is the single source of truth for roadmap and delivery progress.
- [2026-02-12] Announcements/news completed: announcements now support locale audience targeting (`targetLocales`) with public locale-aware rendering, and homepage news list now uses locale-aware published posts only. - [2026-02-12] Announcements/news completed: announcements now support locale audience targeting (`targetLocales`) with public locale-aware rendering, and homepage news list now uses locale-aware published posts only.
- [2026-02-12] Public rendering integration completed: portfolio now supports locale-aware tag filters and explicit sort controls, while db/service sorting and rendition selection align public listing/detail media delivery. - [2026-02-12] Public rendering integration completed: portfolio now supports locale-aware tag filters and explicit sort controls, while db/service sorting and rendition selection align public listing/detail media delivery.
- [2026-02-12] Page scheduling completed: `Page.scheduledPublishAt` added with admin create/edit support and public page resolution now treating due scheduled pages as published. - [2026-02-12] Page scheduling completed: `Page.scheduledPublishAt` added with admin create/edit support and public page resolution now treating due scheduled pages as published.
- [2026-02-12] Media library replace flow completed: admin `/media/:id` can now replace an assets source file in-place, update `storageKey`/MIME/size metadata, and clean up old storage objects with fallback notices.
- [2026-02-12] Public UX pass: commission request flow now reports explicit invalid budget range errors, and header navigation now falls back to localized defaults (`home`, `portfolio`, `news`, `commissions`) when no CMS menu exists; seed data now creates those default menu entries. - [2026-02-12] Public UX pass: commission request flow now reports explicit invalid budget range errors, and header navigation now falls back to localized defaults (`home`, `portfolio`, `news`, `commissions`) when no CMS menu exists; seed data now creates those default menu entries.
- [2026-02-12] Added `e2e/public-rendering.pw.ts` web coverage for fallback navigation visibility, portfolio routes, and commission submission validation (invalid budget range + successful submission path). - [2026-02-12] Added `e2e/public-rendering.pw.ts` web coverage for fallback navigation visibility, portfolio routes, and commission submission validation (invalid budget range + successful submission path).
- [2026-02-12] Testing execution is temporarily paused for delivery velocity: root test scripts are stubbed and CI test steps are disabled; all testing backlog is consolidated under `MVP 3: Testing and Quality`. - [2026-02-12] Testing execution is temporarily paused for delivery velocity: root test scripts are stubbed and CI test steps are disabled; all testing backlog is consolidated under `MVP 3: Testing and Quality`.

View File

@@ -1,10 +1,15 @@
import {
getMediaUploadMaxBytes,
isMimeAllowedForMediaType,
mediaAssetTypeSchema,
} from "@cms/content"
import { deleteMediaAsset, getMediaAssetById, updateMediaAsset } from "@cms/db" import { deleteMediaAsset, getMediaAssetById, updateMediaAsset } from "@cms/db"
import { Button } from "@cms/ui/button" import { Button } from "@cms/ui/button"
import Link from "next/link" import Link from "next/link"
import { redirect } from "next/navigation" import { redirect } from "next/navigation"
import { AdminShell } from "@/components/admin-shell" import { AdminShell } from "@/components/admin-shell"
import { deleteStoredMediaObject } from "@/lib/media/storage" import { deleteStoredMediaObject, storeUpload } from "@/lib/media/storage"
import { requirePermissionForRoute } from "@/lib/route-guards" import { requirePermissionForRoute } from "@/lib/route-guards"
export const dynamic = "force-dynamic" export const dynamic = "force-dynamic"
@@ -79,7 +84,10 @@ function readTags(formData: FormData): string[] {
.filter((item) => item.length > 0) .filter((item) => item.length > 0)
} }
function redirectWithState(mediaAssetId: string, params: { notice?: string; error?: string }) { function redirectWithState(
mediaAssetId: string,
params: { notice?: string; error?: string },
): never {
const query = new URLSearchParams() const query = new URLSearchParams()
if (params.notice) { if (params.notice) {
@@ -189,6 +197,80 @@ export default async function MediaAssetEditorPage({ params, searchParams }: Pag
redirect("/media?notice=Media+asset+deleted") redirect("/media?notice=Media+asset+deleted")
} }
async function replaceMediaFileAction(formData: FormData) {
"use server"
await requirePermissionForRoute({
nextPath: "/media",
permission: "media:write",
scope: "team",
})
const fileEntry = formData.get("file")
if (!(fileEntry instanceof File) || fileEntry.size === 0) {
redirectWithState(mediaAssetId, { error: "Select a replacement file first." })
}
const parsedType = mediaAssetTypeSchema.safeParse(mediaAsset.type)
if (!parsedType.success) {
redirectWithState(mediaAssetId, { error: "Media type is invalid for replacement." })
}
const mediaType = parsedType.data
const maxBytes = getMediaUploadMaxBytes(mediaType)
if (fileEntry.size > maxBytes) {
redirectWithState(mediaAssetId, {
error: `Replacement file is too large for ${mediaType}. Max ${Math.floor(maxBytes / 1024 / 1024)} MB.`,
})
}
if (!isMimeAllowedForMediaType(mediaType, fileEntry.type)) {
redirectWithState(mediaAssetId, {
error: `File type ${fileEntry.type || "unknown"} is not allowed for ${mediaType}.`,
})
}
const previousStorageKey = mediaAsset.storageKey
try {
const stored = await storeUpload({
file: fileEntry,
assetId: mediaAssetId,
variant: "original",
fileRole: "original",
})
await updateMediaAsset({
id: mediaAssetId,
storageKey: stored.storageKey,
mimeType: fileEntry.type || null,
sizeBytes: fileEntry.size,
width: null,
height: null,
})
if (previousStorageKey && previousStorageKey !== stored.storageKey) {
try {
await deleteStoredMediaObject(previousStorageKey)
} catch {
redirectWithState(mediaAssetId, {
notice: "Media file replaced, but old file cleanup failed in storage backend.",
})
}
}
const replacementNotice = stored.fallbackReason
? `Media file replaced. ${stored.fallbackReason}`
: `Media file replaced via ${stored.provider}.`
redirectWithState(mediaAssetId, { notice: replacementNotice })
} catch {
redirectWithState(mediaAssetId, { error: "Failed to replace media file." })
}
}
return ( return (
<AdminShell <AdminShell
role={role} role={role}
@@ -254,6 +336,25 @@ export default async function MediaAssetEditorPage({ params, searchParams }: Pag
) : null} ) : null}
</section> </section>
<section className="rounded-xl border border-neutral-200 p-6">
<h3 className="text-lg font-medium">Replace File</h3>
<p className="mt-1 text-sm text-neutral-600">
Upload a new source file for this media asset while keeping the same metadata and asset
ID.
</p>
<form action={replaceMediaFileAction} className="mt-4 flex flex-wrap items-center gap-3">
<input
name="file"
type="file"
required
className="rounded border border-neutral-300 px-3 py-2 text-sm"
/>
<Button type="submit" variant="secondary">
Replace media file
</Button>
</form>
</section>
<section className="rounded-xl border border-neutral-200 p-6"> <section className="rounded-xl border border-neutral-200 p-6">
<div className="flex flex-wrap items-center justify-between gap-3"> <div className="flex flex-wrap items-center justify-between gap-3">
<div> <div>

View File

@@ -99,6 +99,7 @@ export const updateMediaAssetInputSchema = z.object({
location: z.string().max(180).nullable().optional(), location: z.string().max(180).nullable().optional(),
capturedAt: z.date().nullable().optional(), capturedAt: z.date().nullable().optional(),
tags: z.array(z.string().min(1).max(100)).optional(), tags: z.array(z.string().min(1).max(100)).optional(),
storageKey: z.string().max(500).nullable().optional(),
mimeType: z.string().max(180).nullable().optional(), mimeType: z.string().max(180).nullable().optional(),
width: z.number().int().positive().nullable().optional(), width: z.number().int().positive().nullable().optional(),
height: z.number().int().positive().nullable().optional(), height: z.number().int().positive().nullable().optional(),