mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-04 23:24:21 +00:00
feat(asset): Recently Deleted previews, retention countdown, and version stack delete/restore (#418)
* feat(asset): improve Recently Deleted previews and retention indicators - Include soft-deleted children when building folder previews for the Recently Deleted view, and resolve deleted version stacks to their latest version so a trashed folder shows what was inside it. - Add a "days left" badge (clock + Nd) to file and folder cards in the Recently Deleted view, placed to the left of the comments badge. - Fix an issue where deleting or restoring a version stack from the file list did nothing because the WebUI dropped version_stack items before calling the API. - Share the 30-day trash retention window through TRASH_RETENTION_DAYS. * test(asset): use typed MediaInfo in recently-deleted preview tests Replace the explicit any cast with a fully typed MediaInfo object so the new tests comply with the no-explicit-any policy.
This commit is contained in:
@@ -22,12 +22,13 @@ import {
|
||||
} from '@/ui/components/ui/tooltip'
|
||||
import { ProgressCircle } from '@/ui/components/ui/progress-circle'
|
||||
import { Skeleton } from '@/ui/components/ui/skeleton'
|
||||
import { formatTimeAgo } from '@/ui/lib/time'
|
||||
import { formatTimeAgo, getTrashDaysLeft } from '@/ui/lib/time'
|
||||
import { selectFileNameWithoutExtension } from '@/ui/lib/rename-utils'
|
||||
import { cn } from '@/ui/lib/utils'
|
||||
import { useUploadStore } from '@/ui/stores/upload'
|
||||
import { useDraggable, useDroppable } from '@dnd-kit/react'
|
||||
import {
|
||||
Clock,
|
||||
Download,
|
||||
Edit,
|
||||
History,
|
||||
@@ -252,6 +253,14 @@ export function FileCard({
|
||||
})
|
||||
}, [displayItem.createdAt, displayItem.agent, displayItem.creator?.name])
|
||||
|
||||
const daysLeft = isRecentlyDeleted ? getTrashDaysLeft(displayItem.deletedAt) : null
|
||||
const daysLeftTooltip =
|
||||
daysLeft === null
|
||||
? ''
|
||||
: daysLeft === 1
|
||||
? m.n_days_left_singular({ count: daysLeft })
|
||||
: m.n_days_left_plural({ count: daysLeft })
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={setNodeRef}
|
||||
@@ -333,14 +342,32 @@ export function FileCard({
|
||||
) : (
|
||||
<>
|
||||
<FilePreview item={displayItem} showDuration />
|
||||
{typeof displayItem.commentsCount === 'number' && displayItem.commentsCount > 0 && (
|
||||
<span
|
||||
data-testid="file-card-comments-count"
|
||||
className="pointer-events-none absolute bottom-1 left-1 z-10 flex items-center gap-1 rounded bg-black/60 px-1 py-0.5 text-xs font-medium tabular-nums text-white"
|
||||
{(daysLeft !== null ||
|
||||
(typeof displayItem.commentsCount === 'number' && displayItem.commentsCount > 0)) && (
|
||||
<div
|
||||
data-testid="file-card-preview-badges"
|
||||
className="pointer-events-none absolute bottom-1 left-1 z-10 flex items-center gap-1"
|
||||
>
|
||||
<MessageCircleMore className="h-3.5 w-3.5" />
|
||||
<span>{displayItem.commentsCount}</span>
|
||||
</span>
|
||||
{daysLeft !== null && (
|
||||
<span
|
||||
data-testid="file-card-days-left"
|
||||
title={daysLeftTooltip}
|
||||
className="flex items-center gap-1 rounded bg-black/60 px-1 py-0.5 text-xs font-medium tabular-nums text-white"
|
||||
>
|
||||
<Clock className="h-3.5 w-3.5" />
|
||||
<span>{m.days_left_short({ count: daysLeft })}</span>
|
||||
</span>
|
||||
)}
|
||||
{typeof displayItem.commentsCount === 'number' && displayItem.commentsCount > 0 && (
|
||||
<span
|
||||
data-testid="file-card-comments-count"
|
||||
className="flex items-center gap-1 rounded bg-black/60 px-1 py-0.5 text-xs font-medium tabular-nums text-white"
|
||||
>
|
||||
<MessageCircleMore className="h-3.5 w-3.5" />
|
||||
<span>{displayItem.commentsCount}</span>
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user