revert(admin): remove MediaThumbnailCell — crashes admin list view
Some checks are pending
CI / Type Check (push) Waiting to run
CI / Lint (push) Waiting to run
CI / Unit Tests (push) Waiting to run
Deploy / Build & Push Image (push) Waiting to run
Deploy / Deploy to VPS (push) Blocked by required conditions

This commit is contained in:
Vadym Samoilenko 2026-06-05 11:59:44 +01:00
parent f6712ae8d2
commit 8e2b79f01f
2 changed files with 21 additions and 18 deletions

View file

@ -43,17 +43,5 @@ export const Media: CollectionConfig = {
update: isAdminOrEditor,
delete: isAdminOrEditor,
},
fields: [
{
name: 'alt',
type: 'text',
required: true,
label: 'Alt text',
admin: {
components: {
Cell: '@/components/admin/MediaThumbnailCell',
},
},
},
],
fields: [{ name: 'alt', type: 'text', required: true, label: 'Alt text' }],
}

View file

@ -2,22 +2,37 @@
interface Props {
cellData?: string
rowData?: Record<string, unknown>
// Payload v3 passes the full document as rowData
rowData?: {
url?: string
filename?: string
mimeType?: string
alt?: string
sizes?: { tablet?: { url?: string }; mobile?: { url?: string } }
[key: string]: unknown
}
}
export default function MediaThumbnailCell({ cellData, rowData }: Props) {
const url = (rowData as { url?: string })?.url
const text = cellData ?? rowData?.alt ?? ''
const imgUrl =
rowData?.sizes?.tablet?.url ??
rowData?.sizes?.mobile?.url ??
rowData?.url ??
(rowData?.filename ? `/api/media/file/${rowData.filename}` : undefined)
const isImage = rowData?.mimeType?.startsWith('image/') ?? !!imgUrl
return (
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
{url && (
{imgUrl && isImage && (
// eslint-disable-next-line @next/next/no-img-element
<img
src={url}
src={imgUrl}
alt=""
style={{ width: 40, height: 40, objectFit: 'cover', borderRadius: 4, flexShrink: 0 }}
/>
)}
<span>{cellData}</span>
<span>{text}</span>
</div>
)
}