feat(storage): add archive storage support for assets

This commit is contained in:
yiling
2026-11-02 13:19:10 +08:00
parent 49a2d7c380
commit 9097ec12bb
100 changed files with 6180 additions and 170 deletions
@@ -0,0 +1,56 @@
import { m } from '@/ui/paraglide/messages.js'
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
} from '@/ui/components/ui/alert-dialog'
export interface ArchiveConfirmDialogProps {
open: boolean
onOpenChange: (open: boolean) => void
mode: 'archive' | 'restore'
onConfirm: () => void
isPending?: boolean
}
export function ArchiveConfirmDialog({
open,
onOpenChange,
mode,
onConfirm,
isPending = false,
}: ArchiveConfirmDialogProps) {
const isArchive = mode === 'archive'
return (
<AlertDialog open={open} onOpenChange={onOpenChange}>
<AlertDialogContent data-testid="archive-confirm-dialog">
<AlertDialogHeader>
<AlertDialogTitle>
{isArchive ? m.archive_confirm_title() : m.restore_archive_confirm_title()}
</AlertDialogTitle>
<AlertDialogDescription>
{isArchive ? m.archive_confirm_description() : m.restore_archive_confirm_description()}
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel disabled={isPending}>{m.cancel()}</AlertDialogCancel>
<AlertDialogAction
data-testid="archive-confirm-submit"
disabled={isPending}
onClick={(e) => {
e.preventDefault()
onConfirm()
}}
>
{isArchive ? m.archive() : m.restore_from_archive()}
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
)
}
+106 -6
View File
@@ -33,6 +33,7 @@ import type { AncestorFolder } from '@shumai/dtos'
import { Link, useNavigate } from '@tanstack/react-router'
import { useQuery } from '@tanstack/react-query'
import {
Archive,
Bot,
Check,
ChevronDown,
@@ -41,6 +42,7 @@ import {
History,
LayoutGrid,
List,
Loader2,
Menu,
SquareKanban,
} from 'lucide-react'
@@ -49,6 +51,7 @@ import { useDualSidebarStore } from '@/ui/stores/dual-sidebar'
import { ManageVersionsDialog } from './manage-versions-dialog'
import { AssetLinkedTasksDialog } from './kanban/asset-linked-tasks-dialog'
import { getVideoResolutionLabel } from '@/ui/lib/media'
import { useArchiveConfig } from '@/ui/hooks/use-archive-config'
interface BreadcrumbNavProps {
teamId: string
@@ -60,6 +63,7 @@ interface BreadcrumbNavProps {
name?: string
type: 'file' | 'folder'
version?: number
status?: string
proxyType?: 'image' | 'video' | 'audio' | 'pdf' | '3d' | null
}
isRootFolder: boolean
@@ -78,6 +82,8 @@ interface BreadcrumbNavProps {
onFolderClick?: (folderId: string) => void
onRename?: () => void
onDelete?: () => void
onArchive?: () => void
onRestoreArchive?: () => void
fileId?: string
downloadInfo?: {
originalKey?: string
@@ -93,6 +99,7 @@ interface BreadcrumbNavProps {
id: string
version: number
name?: string | null
status?: string | null
previewUrl?: string | null
creator?: { id: string; name: string | null } | null
agent?: { id: string; name: string } | null
@@ -122,6 +129,8 @@ export function BreadcrumbNav({
onFolderClick,
onRename,
onDelete,
onArchive,
onRestoreArchive,
fileId,
shareId,
allowDownload = true,
@@ -133,6 +142,7 @@ export function BreadcrumbNav({
}: BreadcrumbNavProps) {
const navigate = useNavigate()
const { canEdit } = usePermissions(projectId)
const { archiveStorageEnabled } = useArchiveConfig()
const { openMobileMenu } = useDualSidebarStore()
const [isManageVersionsOpen, setIsManageVersionsOpen] = useState(false)
const [isLinkedTasksOpen, setIsLinkedTasksOpen] = useState(false)
@@ -210,6 +220,10 @@ export function BreadcrumbNav({
const isAudio = currentAsset.proxyType === 'audio'
const hasVideoTranscodes = !isAudio && (downloadInfo?.videoTranscodes?.length ?? 0) > 0
const isOriginalUnavailable =
currentAsset.status === 'archived' ||
currentAsset.status === 'archiving' ||
currentAsset.status === 'restoring'
const hasTerminal = Boolean(customTerminalBreadcrumb || (!isRootFolder && !compareMode))
@@ -264,6 +278,36 @@ export function BreadcrumbNav({
v{currentAsset.version}
</Badge>
)}
{currentAsset.status === 'archived' && (
<Badge
variant="secondary"
data-testid="detail-header-archived-badge"
className="gap-1 px-1.5 py-0 text-xs shrink-0"
>
<Archive className="h-3 w-3" />
<span>{m.archived_status()}</span>
</Badge>
)}
{currentAsset.status === 'archiving' && (
<Badge
variant="secondary"
data-testid="detail-header-archiving-badge"
className="gap-1 px-1.5 py-0 text-xs shrink-0"
>
<Loader2 className="h-3 w-3 animate-spin" />
<span>{m.archiving_status()}</span>
</Badge>
)}
{currentAsset.status === 'restoring' && (
<Badge
variant="secondary"
data-testid="detail-header-restoring-badge"
className="gap-1 px-1.5 py-0 text-xs shrink-0"
>
<Loader2 className="h-3 w-3 animate-spin" />
<span>{m.restoring_status()}</span>
</Badge>
)}
<DropdownMenuTrigger
asChild
onClick={(e) => e.stopPropagation()}
@@ -306,7 +350,13 @@ export function BreadcrumbNav({
<>
<DropdownMenuSeparator />
<DropdownMenuItem
onClick={() => handleDownload(downloadInfo.originalKey!)}
disabled={isOriginalUnavailable}
title={
isOriginalUnavailable ? m.original_archived_tooltip() : undefined
}
onClick={() =>
!isOriginalUnavailable && handleDownload(downloadInfo.originalKey!)
}
className="flex items-center justify-between"
>
<span>Original</span>
@@ -322,9 +372,12 @@ export function BreadcrumbNav({
) : (
<DropdownMenuItem
onClick={() =>
downloadInfo?.originalKey && handleDownload(downloadInfo.originalKey)
downloadInfo?.originalKey &&
!isOriginalUnavailable &&
handleDownload(downloadInfo.originalKey)
}
disabled={!downloadInfo?.originalKey}
disabled={!downloadInfo?.originalKey || isOriginalUnavailable}
title={isOriginalUnavailable ? m.original_archived_tooltip() : undefined}
>
{m.download()}
</DropdownMenuItem>
@@ -332,6 +385,27 @@ export function BreadcrumbNav({
{canEdit && onRename && (
<DropdownMenuItem onClick={onRename}>{m.rename()}</DropdownMenuItem>
)}
{canEdit &&
archiveStorageEnabled &&
!isPublic &&
(!currentAsset.status || currentAsset.status === 'processed') &&
onArchive && (
<DropdownMenuItem data-testid="detail-header-archive-action" onClick={onArchive}>
{m.archive()}
</DropdownMenuItem>
)}
{canEdit &&
archiveStorageEnabled &&
!isPublic &&
currentAsset.status === 'archived' &&
onRestoreArchive && (
<DropdownMenuItem
data-testid="detail-header-restore-archive-action"
onClick={onRestoreArchive}
>
{m.restore_from_archive()}
</DropdownMenuItem>
)}
{canEdit && onDelete && (
<DropdownMenuItem
onClick={onDelete}
@@ -387,9 +461,35 @@ export function BreadcrumbNav({
</div>
<div className="flex flex-col flex-1 min-w-0 text-left">
<span className="truncate text-sm font-semibold text-foreground">
{v.name}
</span>
<div className="flex items-center gap-1.5 min-w-0">
<span className="truncate text-sm font-semibold text-foreground">
{v.name}
</span>
{v.status === 'archived' && (
<Badge
variant="secondary"
className="gap-0.5 px-1 py-0 text-[10px] shrink-0"
>
{m.archived_status()}
</Badge>
)}
{v.status === 'archiving' && (
<Badge
variant="secondary"
className="gap-0.5 px-1 py-0 text-[10px] shrink-0"
>
{m.archiving_status()}
</Badge>
)}
{v.status === 'restoring' && (
<Badge
variant="secondary"
className="gap-0.5 px-1 py-0 text-[10px] shrink-0"
>
{m.restoring_status()}
</Badge>
)}
</div>
<span className="truncate text-xs text-muted-foreground flex items-center gap-1">
{v.agent ? (
<>
@@ -115,7 +115,12 @@ export function CompareControlBar({
onZoomOut={onZoomOut}
onFit={onFit}
onDownload={() => onDownload()}
canDownload={!!activeAsset?.media?.original?.key}
canDownload={
!!activeAsset?.media?.original?.key &&
activeAsset.status !== 'archived' &&
activeAsset.status !== 'archiving' &&
activeAsset.status !== 'restoring'
}
fullscreen={{ isFullScreen, onToggle: onToggleFullScreen }}
allowDownload={allowDownload}
/>
@@ -266,6 +266,16 @@ export function WorkflowTasksDashboard({ teamId }: WorkflowTasksDashboardProps)
</Badge>
)
}
if (type === 'archive_asset' || type === 'restore_asset') {
return (
<Badge
variant="outline"
className="bg-amber-500/10 text-amber-600 dark:text-amber-400 border-amber-500/20 font-mono text-xs"
>
{type}
</Badge>
)
}
return (
<Badge variant="secondary" className="font-mono text-xs">
{type}
@@ -11,6 +11,8 @@ import {
ContextMenuPortal,
} from '@/ui/components/ui/context-menu'
import {
Archive,
ArchiveRestore,
Download,
Edit,
FolderPlus,
@@ -33,6 +35,9 @@ interface FileBrowserContextMenuProps {
onDownload: (items: AssetInfo[]) => void
onCopyNameAndDownloadLink?: (items: AssetInfo[]) => void
onRestore: (items: AssetInfo[]) => void
onArchive?: (items: AssetInfo[]) => void
onRestoreArchive?: (items: AssetInfo[]) => void
archiveStorageEnabled?: boolean
onNewFolder: (name: string) => void
onUploadFile: () => void
onUploadFolder: () => void
@@ -61,6 +66,9 @@ export function FileBrowserContextMenu({
onDownload,
onCopyNameAndDownloadLink,
onRestore,
onArchive,
onRestoreArchive,
archiveStorageEnabled = false,
onNewFolder,
onUploadFile,
onUploadFolder,
@@ -117,6 +125,36 @@ export function FileBrowserContextMenu({
onRestore(itemsToRestore)
}
const canArchiveSelection = itemsToModify.some((i) => {
if (i.type === 'folder') return true
if (i.type === 'version_stack') {
return (
i.status === 'processed' ||
(i.versionStack?.versions.some((v) => !v.status || v.status === 'processed') ?? false)
)
}
return i.status === 'processed'
})
const canRestoreArchiveSelection = itemsToModify.some((i) => {
if (i.type === 'folder') return true
if (i.type === 'version_stack') {
return (
i.status === 'archived' ||
(i.versionStack?.versions.some((v) => v.status === 'archived') ?? false)
)
}
return i.status === 'archived'
})
const isDownloadUnavailable =
itemsToModify.length > 0 &&
itemsToModify.every(
(i) =>
i.type === 'file' &&
(i.status === 'archived' || i.status === 'archiving' || i.status === 'restoring'),
)
if (isRecents) {
return null
}
@@ -196,11 +234,11 @@ export function FileBrowserContextMenu({
e.preventDefault()
}}
>
<ContextMenuItem onSelect={handleDownload}>
<ContextMenuItem onSelect={handleDownload} disabled={isDownloadUnavailable}>
<Download className="mr-2 h-4 w-4" />
<span>{m.download()}</span>
</ContextMenuItem>
<ContextMenuItem onSelect={handleCopyNameAndDownloadLink}>
<ContextMenuItem onSelect={handleCopyNameAndDownloadLink} disabled={isDownloadUnavailable}>
<Copy className="mr-2 h-4 w-4" />
<span>{m.copy_name_and_download_link()}</span>
</ContextMenuItem>
@@ -216,6 +254,24 @@ export function FileBrowserContextMenu({
<span>{m.copy_to()}</span>
</ContextMenuItem>
)}
{canEdit && archiveStorageEnabled && canArchiveSelection && (
<ContextMenuItem
data-testid="context-menu-archive"
onSelect={() => onArchive?.(itemsToModify)}
>
<Archive className="mr-2 h-4 w-4" />
<span>{m.archive()}</span>
</ContextMenuItem>
)}
{canEdit && archiveStorageEnabled && canRestoreArchiveSelection && (
<ContextMenuItem
data-testid="context-menu-restore-archive"
onSelect={() => onRestoreArchive?.(itemsToModify)}
>
<ArchiveRestore className="mr-2 h-4 w-4" />
<span>{m.restore_from_archive()}</span>
</ContextMenuItem>
)}
{canEdit && (
<ContextMenuItem onSelect={handleDelete} className="text-destructive">
<Trash2 className="mr-2 h-4 w-4" />
@@ -270,11 +326,11 @@ export function FileBrowserContextMenu({
<span>{m.rename()}</span>
</ContextMenuItem>
)}
<ContextMenuItem onSelect={handleDownload}>
<ContextMenuItem onSelect={handleDownload} disabled={isDownloadUnavailable}>
<Download className="mr-2 h-4 w-4" />
<span>{m.download()}</span>
</ContextMenuItem>
<ContextMenuItem onSelect={handleCopyNameAndDownloadLink}>
<ContextMenuItem onSelect={handleCopyNameAndDownloadLink} disabled={isDownloadUnavailable}>
<Copy className="mr-2 h-4 w-4" />
<span>{m.copy_name_and_download_link()}</span>
</ContextMenuItem>
@@ -306,6 +362,25 @@ export function FileBrowserContextMenu({
</ContextMenuItem>
)}
{canEdit && archiveStorageEnabled && canArchiveSelection && (
<ContextMenuItem
data-testid="context-menu-archive"
onSelect={() => onArchive?.(itemsToModify)}
>
<Archive className="mr-2 h-4 w-4" />
<span>{m.archive()}</span>
</ContextMenuItem>
)}
{canEdit && archiveStorageEnabled && canRestoreArchiveSelection && (
<ContextMenuItem
data-testid="context-menu-restore-archive"
onSelect={() => onRestoreArchive?.(itemsToModify)}
>
<ArchiveRestore className="mr-2 h-4 w-4" />
<span>{m.restore_from_archive()}</span>
</ContextMenuItem>
)}
{item.type === 'folder' && onOpenAgentsMd && (
<ContextMenuItem onSelect={() => onOpenAgentsMd(item)}>
<FileText className="mr-2 h-4 w-4" />
@@ -58,6 +58,8 @@ import { FileBrowserListView } from './list-view'
import { FileBrowserToolbar } from './toolbar'
import { useFileActions } from './use-file-actions'
import { useBatchFileStatus } from '@/ui/hooks/use-batch-file-status'
import { useArchiveConfig } from '@/ui/hooks/use-archive-config'
import { ArchiveConfirmDialog } from '../archive-confirm-dialog'
interface FileBrowserProps {
teamId: string
@@ -484,6 +486,8 @@ export function FileBrowser({
handleRestore,
handleDownload,
handleCopyNameAndDownloadLink,
handleArchive,
handleRestoreArchive,
handleAction,
onRenameSubmit,
isDeleteDialogOpen,
@@ -493,7 +497,13 @@ export function FileBrowser({
setIsDownloadDialogOpen,
isLoadingLinks,
resolvedFiles,
skippedArchivedCount,
startDownload,
archiveConfirmState,
setArchiveConfirmState,
confirmArchiveOrRestore,
isArchiving,
isRestoringArchive,
} = useFileActions({
teamId,
projectId,
@@ -504,6 +514,7 @@ export function FileBrowser({
isPublic,
shareId,
})
const { archiveStorageEnabled } = useArchiveConfig()
const [isEmptyTrashDialogOpen, setIsEmptyTrashDialogOpen] = useState(false)
const { mutate: emptyTrash, isPending: isEmptyingTrash } = useMutation({
@@ -758,7 +769,10 @@ export function FileBrowser({
}
return
}
handleAction(action as 'rename' | 'delete' | 'download' | 'restore', item)
handleAction(
action as 'rename' | 'delete' | 'download' | 'restore' | 'archive' | 'restore-archive',
item,
)
},
isRecentlyDeleted,
isRecents,
@@ -767,6 +781,7 @@ export function FileBrowser({
allowDownload,
fields: displayedFields,
canEdit,
archiveStorageEnabled,
isExternalDragging,
externalOverFolderId,
setExternalOverFolderId,
@@ -1172,6 +1187,9 @@ export function FileBrowser({
setMoveCopyMode('copy')
}}
onRestore={handleRestore}
onArchive={handleArchive}
onRestoreArchive={handleRestoreArchive}
archiveStorageEnabled={archiveStorageEnabled}
isRecentlyDeleted={isRecentlyDeleted}
isRecents={isRecents}
shareLinks={shareLinksData?.data ?? []}
@@ -1296,6 +1314,14 @@ export function FileBrowser({
<span className="font-semibold text-foreground">{resolvedFiles.length}</span>{' '}
file(s).
</div>
{skippedArchivedCount > 0 && (
<div
data-testid="download-skipped-archived-notice"
className="text-sm text-amber-600 dark:text-amber-400"
>
{m.download_skipped_archived_notice({ count: skippedArchivedCount })}
</div>
)}
<div className="flex items-start gap-3 p-3 text-sm rounded-lg bg-amber-50 dark:bg-amber-950/30 text-amber-800 dark:text-amber-300 border border-amber-200 dark:border-amber-900/30">
<AlertTriangle className="h-5 w-5 shrink-0 mt-0.5" />
<div>
@@ -1356,6 +1382,14 @@ export function FileBrowser({
sharePassword={sharePassword}
isPublic={isPublic}
/>
<ArchiveConfirmDialog
open={archiveConfirmState.open}
onOpenChange={(open) => setArchiveConfirmState((prev) => ({ ...prev, open }))}
mode={archiveConfirmState.mode}
onConfirm={confirmArchiveOrRestore}
isPending={isArchiving || isRestoringArchive}
/>
</>
)
}
@@ -683,4 +683,93 @@ describe('FileCard', () => {
expect(screen.getByDisplayValue('42')).toBeTruthy()
expect(onSelect).not.toHaveBeenCalled()
})
it('renders Archived, Archiving, and Restoring badges and Archive / Restore menu actions when archiveStorageEnabled is true', () => {
const onAction = vi.fn()
const archivedItem: AssetInfo = {
...fileItem,
status: 'archived',
} as AssetInfo
const { rerender } = render(
<QueryClientProvider client={queryClient}>
<FileCard
item={archivedItem}
isSelected={false}
isChecked={false}
isEditing={false}
onSelect={vi.fn()}
onDoubleClick={vi.fn()}
onContextMenu={vi.fn()}
onDragStart={vi.fn()}
onDrop={vi.fn()}
onRename={vi.fn()}
onFinishEditing={vi.fn()}
onSaveField={vi.fn()}
onAction={onAction}
fields={[]}
canEdit={true}
archiveStorageEnabled={true}
/>
</QueryClientProvider>,
)
expect(screen.getByTestId('file-card-archived-badge')).toBeTruthy()
const moreBtn = screen.getByRole('button', { name: '' })
fireEvent.keyDown(moreBtn, { key: 'ArrowDown', code: 'ArrowDown' })
const restoreItem = screen.getByTestId('file-card-restore-archive-action')
expect(restoreItem).toBeTruthy()
fireEvent.click(restoreItem)
expect(onAction).toHaveBeenCalledWith('restore-archive', archivedItem)
rerender(
<QueryClientProvider client={queryClient}>
<FileCard
item={{ ...fileItem, status: 'archiving' } as AssetInfo}
isSelected={false}
isChecked={false}
isEditing={false}
onSelect={vi.fn()}
onDoubleClick={vi.fn()}
onContextMenu={vi.fn()}
onDragStart={vi.fn()}
onDrop={vi.fn()}
onRename={vi.fn()}
onFinishEditing={vi.fn()}
onSaveField={vi.fn()}
onAction={onAction}
fields={[]}
canEdit={true}
archiveStorageEnabled={true}
/>
</QueryClientProvider>,
)
expect(screen.getByTestId('file-card-archiving-badge')).toBeTruthy()
rerender(
<QueryClientProvider client={queryClient}>
<FileCard
item={{ ...fileItem, status: 'restoring' } as AssetInfo}
isSelected={false}
isChecked={false}
isEditing={false}
onSelect={vi.fn()}
onDoubleClick={vi.fn()}
onContextMenu={vi.fn()}
onDragStart={vi.fn()}
onDrop={vi.fn()}
onRename={vi.fn()}
onFinishEditing={vi.fn()}
onSaveField={vi.fn()}
onAction={onAction}
fields={[]}
canEdit={true}
archiveStorageEnabled={true}
/>
</QueryClientProvider>,
)
expect(screen.getByTestId('file-card-restoring-badge')).toBeTruthy()
})
})
@@ -29,11 +29,14 @@ import { useUploadStore } from '@/ui/stores/upload'
import { useDraggable, useDroppable } from '@dnd-kit/react'
import {
AlertCircle,
Archive,
ArchiveRestore,
Clock,
Download,
Edit,
History,
Layers,
Loader2,
MessageCircleMore,
MoreHorizontal,
Trash2,
@@ -64,7 +67,15 @@ interface FileCardProps {
dragState?: DragState
disabled?: boolean
onAction?: (
action: 'rename' | 'delete' | 'download' | 'restore' | 'remove-from-share' | 'manage-versions',
action:
| 'rename'
| 'delete'
| 'download'
| 'restore'
| 'remove-from-share'
| 'manage-versions'
| 'archive'
| 'restore-archive',
item: AssetInfo,
) => void
isRecentlyDeleted?: boolean
@@ -73,6 +84,7 @@ interface FileCardProps {
fields?: MetadataFieldInfo[]
isShareView?: boolean
canEdit?: boolean
archiveStorageEnabled?: boolean
/** When false, hides the download action. Defaults to true. */
allowDownload?: boolean
hideCheckbox?: boolean
@@ -104,6 +116,7 @@ export function FileCard({
fields = [],
isShareView,
canEdit = true,
archiveStorageEnabled = false,
allowDownload = true,
hideCheckbox = false,
hideActions = false,
@@ -133,11 +146,23 @@ export function FileCard({
})
const displayItem = useMemo(() => {
if (item.status === 'processed' || item.status === 'error' || item.status === 'failed') {
if (
item.status === 'processed' ||
item.status === 'archived' ||
item.status === 'error' ||
item.status === 'failed'
) {
return item
}
if (item.status === 'archiving' && polledItem?.status === 'processed') {
return item
}
if (item.status === 'restoring' && polledItem?.status === 'archived') {
return item
}
if (
polledItem?.status === 'processed' ||
polledItem?.status === 'archived' ||
polledItem?.status === 'error' ||
polledItem?.status === 'failed'
) {
@@ -301,6 +326,21 @@ export function FileCard({
}
const failedErrorMessage = displayItem.media?.error || m.processing_failed()
const isOriginalUnavailable =
displayItem.status === 'archived' ||
displayItem.status === 'archiving' ||
displayItem.status === 'restoring'
const canArchiveItem =
displayItem.type === 'version_stack'
? displayItem.status === 'processed' ||
(displayItem.versionStack?.versions.some((v) => !v.status || v.status === 'processed') ??
false)
: displayItem.status === 'processed'
const canRestoreArchiveItem =
displayItem.type === 'version_stack'
? displayItem.status === 'archived' ||
(displayItem.versionStack?.versions.some((v) => v.status === 'archived') ?? false)
: displayItem.status === 'archived'
const previewBadges =
daysLeft !== null ||
@@ -381,6 +421,33 @@ export function FileCard({
displayItem.versionStack.versions.length}
</Badge>
)}
{displayItem.status === 'archived' && (
<span
data-testid="file-card-archived-badge"
className="flex select-none items-center gap-1 rounded bg-black/60 px-1.5 py-0.5 text-xs font-medium text-white shadow-sm"
>
<Archive className="h-3 w-3" />
<span>{m.archived_status()}</span>
</span>
)}
{displayItem.status === 'archiving' && (
<span
data-testid="file-card-archiving-badge"
className="flex select-none items-center gap-1 rounded bg-black/60 px-1.5 py-0.5 text-xs font-medium text-white shadow-sm"
>
<Loader2 className="h-3 w-3 animate-spin" />
<span>{m.archiving_status()}</span>
</span>
)}
{displayItem.status === 'restoring' && (
<span
data-testid="file-card-restoring-badge"
className="flex select-none items-center gap-1 rounded bg-black/60 px-1.5 py-0.5 text-xs font-medium text-white shadow-sm"
>
<Loader2 className="h-3 w-3 animate-spin" />
<span>{m.restoring_status()}</span>
</span>
)}
{isFailed && (
<TooltipProvider delayDuration={100}>
<Tooltip>
@@ -557,6 +624,7 @@ export function FileCard({
<>
{allowDownload && (
<DropdownMenuItem
disabled={displayItem.type !== 'version_stack' && isOriginalUnavailable}
onClick={(e) => {
e.stopPropagation()
onAction?.('download', item)
@@ -615,6 +683,7 @@ export function FileCard({
)}
{allowDownload && (
<DropdownMenuItem
disabled={displayItem.type !== 'version_stack' && isOriginalUnavailable}
onClick={(e) => {
e.stopPropagation()
onAction?.('download', item)
@@ -624,6 +693,30 @@ export function FileCard({
<span>{m.download()}</span>
</DropdownMenuItem>
)}
{canEdit && archiveStorageEnabled && canArchiveItem && (
<DropdownMenuItem
data-testid="file-card-archive-action"
onClick={(e) => {
e.stopPropagation()
onAction?.('archive', item)
}}
>
<Archive className="mr-2 h-4 w-4" />
<span>{m.archive()}</span>
</DropdownMenuItem>
)}
{canEdit && archiveStorageEnabled && canRestoreArchiveItem && (
<DropdownMenuItem
data-testid="file-card-restore-archive-action"
onClick={(e) => {
e.stopPropagation()
onAction?.('restore-archive', item)
}}
>
<ArchiveRestore className="mr-2 h-4 w-4" />
<span>{m.restore_from_archive()}</span>
</DropdownMenuItem>
)}
{canEdit && (
<>
<DropdownMenuSeparator />
@@ -4,7 +4,7 @@ import { m } from '@/ui/paraglide/messages.js'
import { useQuery } from '@tanstack/react-query'
import { useDraggable } from '@dnd-kit/react'
import { AlertCircle, File, Folder, MoreVertical, AudioLines } from 'lucide-react'
import { AlertCircle, Archive, AudioLines, File, Folder, Loader2, MoreVertical } from 'lucide-react'
import React, { useEffect, useMemo, useRef, useState } from 'react'
import { cn } from '@/ui/lib/utils'
import { formatSize } from '@/ui/lib/format'
@@ -88,11 +88,23 @@ export function FileListItem({
})
const displayItem = useMemo(() => {
if (item.status === 'processed' || item.status === 'error' || item.status === 'failed') {
if (
item.status === 'processed' ||
item.status === 'archived' ||
item.status === 'error' ||
item.status === 'failed'
) {
return item
}
if (item.status === 'archiving' && polledItem?.status === 'processed') {
return item
}
if (item.status === 'restoring' && polledItem?.status === 'archived') {
return item
}
if (
polledItem?.status === 'processed' ||
polledItem?.status === 'archived' ||
polledItem?.status === 'error' ||
polledItem?.status === 'failed'
) {
@@ -316,6 +328,36 @@ export function FileListItem({
displayItem.versionStack.versions.length}
</Badge>
)}
{displayItem.status === 'archived' && (
<Badge
variant="secondary"
data-testid="file-list-item-archived-badge"
className="gap-1 px-1.5 py-0 text-xs shrink-0"
>
<Archive className="h-3 w-3" />
<span>{m.archived_status()}</span>
</Badge>
)}
{displayItem.status === 'archiving' && (
<Badge
variant="secondary"
data-testid="file-list-item-archiving-badge"
className="gap-1 px-1.5 py-0 text-xs shrink-0"
>
<Loader2 className="h-3 w-3 animate-spin" />
<span>{m.archiving_status()}</span>
</Badge>
)}
{displayItem.status === 'restoring' && (
<Badge
variant="secondary"
data-testid="file-list-item-restoring-badge"
className="gap-1 px-1.5 py-0 text-xs shrink-0"
>
<Loader2 className="h-3 w-3 animate-spin" />
<span>{m.restoring_status()}</span>
</Badge>
)}
</div>
</div>
<div
@@ -12,7 +12,16 @@ import { useDraggable, useDroppable } from '@dnd-kit/react'
import type { AssetInfo, ChildPreview } from '@shumai/dtos'
import { m } from '@/ui/paraglide/messages.js'
import { getTrashDaysLeft } from '@/ui/lib/time'
import { Clock, Download, Edit, History, MoreHorizontal, Trash2 } from 'lucide-react'
import {
Archive,
ArchiveRestore,
Clock,
Download,
Edit,
History,
MoreHorizontal,
Trash2,
} from 'lucide-react'
import React, { useEffect, useMemo, useRef, useState } from 'react'
import type { DragState } from '../dnd-types'
import { FilePreview } from './file-preview'
@@ -34,13 +43,21 @@ interface FolderCardProps {
dragState?: DragState
disabled?: boolean
onAction?: (
action: 'rename' | 'delete' | 'download' | 'restore' | 'remove-from-share',
action:
| 'rename'
| 'delete'
| 'download'
| 'restore'
| 'remove-from-share'
| 'archive'
| 'restore-archive',
item: AssetInfo,
) => void
isRecentlyDeleted?: boolean
isRecents?: boolean
selectedCount?: number
canEdit?: boolean
archiveStorageEnabled?: boolean
isShareView?: boolean
isExternalDragging?: boolean
externalOverFolderId?: string | null
@@ -127,6 +144,7 @@ export function FolderCard({
isRecents,
selectedCount,
canEdit = true,
archiveStorageEnabled = false,
isShareView,
isExternalDragging,
externalOverFolderId,
@@ -455,6 +473,30 @@ export function FolderCard({
<span>{m.download()}</span>
</DropdownMenuItem>
)}
{canEdit && archiveStorageEnabled && (
<>
<DropdownMenuItem
data-testid="folder-card-archive-action"
onClick={(e) => {
e.stopPropagation()
onAction?.('archive', item)
}}
>
<Archive className="mr-2 h-4 w-4" />
<span>{m.archive()}</span>
</DropdownMenuItem>
<DropdownMenuItem
data-testid="folder-card-restore-archive-action"
onClick={(e) => {
e.stopPropagation()
onAction?.('restore-archive', item)
}}
>
<ArchiveRestore className="mr-2 h-4 w-4" />
<span>{m.restore_from_archive()}</span>
</DropdownMenuItem>
</>
)}
{canEdit && (
<>
<DropdownMenuSeparator />
@@ -55,6 +55,8 @@ import { FolderCard } from './folder-card'
import { useFileActions } from './use-file-actions'
import { MobileFileBrowserContentSkeleton } from '../loading-skeletons'
import { useBatchFileStatus } from '@/ui/hooks/use-batch-file-status'
import { useArchiveConfig } from '@/ui/hooks/use-archive-config'
import { ArchiveConfirmDialog } from '../archive-confirm-dialog'
export interface MobileFileBrowserProps {
teamId: string
@@ -167,7 +169,13 @@ export function MobileFileBrowser({
setIsDownloadDialogOpen,
isLoadingLinks,
resolvedFiles,
skippedArchivedCount,
startDownload,
archiveConfirmState,
setArchiveConfirmState,
confirmArchiveOrRestore,
isArchiving,
isRestoringArchive,
} = useFileActions({
teamId,
projectId,
@@ -178,6 +186,7 @@ export function MobileFileBrowser({
isPublic,
shareId,
})
const { archiveStorageEnabled } = useArchiveConfig()
// Infinite scroll trigger
const { ref: loadMoreRef, inView } = useInView()
@@ -510,12 +519,22 @@ export function MobileFileBrowser({
onRename={(newName) => onRenameSubmit(folder, newName)}
onFinishEditing={() => setEditingItemId(null)}
onAction={(action, item) =>
handleAction(action as 'rename' | 'delete' | 'download' | 'restore', item)
handleAction(
action as
| 'rename'
| 'delete'
| 'download'
| 'restore'
| 'archive'
| 'restore-archive',
item,
)
}
isRecentlyDeleted={isRecentlyDeleted}
isRecents={isRecents}
selectedCount={selectedIds.size}
canEdit={canEdit}
archiveStorageEnabled={archiveStorageEnabled}
isShareView={isShareView}
allowDownload={allowDownload}
/>
@@ -563,12 +582,22 @@ export function MobileFileBrowser({
onSaveField={(fieldId, value) => onSaveField?.(file.id!, fieldId, value)}
fields={[]}
onAction={(action, item) =>
handleAction(action as 'rename' | 'delete' | 'download' | 'restore', item)
handleAction(
action as
| 'rename'
| 'delete'
| 'download'
| 'restore'
| 'archive'
| 'restore-archive',
item,
)
}
isRecentlyDeleted={isRecentlyDeleted}
isRecents={isRecents}
selectedCount={selectedIds.size}
canEdit={canEdit}
archiveStorageEnabled={archiveStorageEnabled}
isShareView={isShareView}
allowDownload={allowDownload}
/>
@@ -742,6 +771,14 @@ export function MobileFileBrowser({
<div className="text-sm text-muted-foreground">
{m.download_includes_files({ count: resolvedFiles.length })}
</div>
{skippedArchivedCount > 0 && (
<div
data-testid="download-skipped-archived-notice"
className="text-sm text-amber-600 dark:text-amber-400"
>
{m.download_skipped_archived_notice({ count: skippedArchivedCount })}
</div>
)}
<div className="flex items-start gap-3 p-3 text-sm rounded-lg bg-amber-50 dark:bg-amber-950/30 text-amber-800 dark:text-amber-300 border border-amber-200 dark:border-amber-900/30">
<AlertTriangle className="h-5 w-5 shrink-0 mt-0.5" />
<div>
@@ -777,6 +814,14 @@ export function MobileFileBrowser({
</DialogFooter>
</DialogContent>
</Dialog>
<ArchiveConfirmDialog
open={archiveConfirmState.open}
onOpenChange={(open) => setArchiveConfirmState((prev) => ({ ...prev, open }))}
mode={archiveConfirmState.mode}
onConfirm={confirmArchiveOrRestore}
isPending={isArchiving || isRestoringArchive}
/>
</div>
)
}
@@ -38,6 +38,12 @@ export function useFileActions({
const [resolvedFiles, setResolvedFiles] = useState<
Array<{ id: string; name: string; url: string }>
>([])
const [skippedArchivedCount, setSkippedArchivedCount] = useState(0)
const [archiveConfirmState, setArchiveConfirmState] = useState<{
open: boolean
mode: 'archive' | 'restore'
items: AssetInfo[]
}>({ open: false, mode: 'archive', items: [] })
const queryClient = useQueryClient()
const $createFolder = client.api.folders.$post
@@ -136,6 +142,32 @@ export function useFileActions({
},
})
type ArchiveFilesPost = typeof client.api.files.archive.$post
const { mutate: archiveFiles, isPending: isArchiving } = useMutation<
InferResponseType<ArchiveFilesPost, 200>,
Error,
InferRequestType<ArchiveFilesPost>
>({
mutationFn: async (request) => {
const res = await client.api.files.archive.$post(request)
if (!res.ok) throw new Error(m.archive_failed_toast())
return (await res.json()) as unknown as InferResponseType<ArchiveFilesPost, 200>
},
})
type RestoreArchiveFilesPost = (typeof client.api.files)['restore-archive']['$post']
const { mutate: restoreArchiveFiles, isPending: isRestoringArchive } = useMutation<
InferResponseType<RestoreArchiveFilesPost, 200>,
Error,
InferRequestType<RestoreArchiveFilesPost>
>({
mutationFn: async (request) => {
const res = await client.api.files['restore-archive'].$post(request)
if (!res.ok) throw new Error(m.restore_archive_failed_toast())
return (await res.json()) as unknown as InferResponseType<RestoreArchiveFilesPost, 200>
},
})
const handleRename = (item: AssetInfo) => {
setEditingItemId(item.id!)
}
@@ -222,11 +254,21 @@ export function useFileActions({
setIsDownloadDialogOpen(true)
setIsLoadingLinks(true)
setResolvedFiles([])
setSkippedArchivedCount(0)
try {
if (isPublic && shareId) {
const password = localStorage.getItem(`share_pwd_${shareId}`) || ''
const links: Array<{ id: string; name: string; url: string }> = []
let skipped = 0
for (const item of items) {
if (
item.status === 'archived' ||
item.status === 'archiving' ||
item.status === 'restoring'
) {
skipped++
continue
}
const key = item.media?.original?.key
if (!key || !item.id) continue
const res = await client.api.shares[':shareId'].files[':fileId']['download-url'].$post(
@@ -245,11 +287,24 @@ export function useFileActions({
links.push({ id: item.id, name: item.name || 'download', url })
}
}
setSkippedArchivedCount(skipped)
if (links.length === 0 && skipped > 0) {
setIsDownloadDialogOpen(false)
toast.error(m.download_all_archived_error())
return
}
setResolvedFiles(links)
} else {
const res = await getDownloadLinks({
json: { ids: items.map((i) => i.id!) },
})
const skipped = res.skippedArchivedCount ?? 0
setSkippedArchivedCount(skipped)
if (res.files.length === 0 && skipped > 0) {
setIsDownloadDialogOpen(false)
toast.error(m.download_all_archived_error())
return
}
setResolvedFiles(res.files)
}
} catch (error) {
@@ -268,7 +323,12 @@ export function useFileActions({
json: { ids: items.map((i) => i.id!) },
})
const files = res.files
if (files.length === 0) return
if (files.length === 0) {
if ((res.skippedArchivedCount ?? 0) > 0) {
toast.error(m.download_all_archived_error())
}
return
}
let text = ''
if (files.length === 1) {
@@ -287,6 +347,73 @@ export function useFileActions({
}
}
const handleArchive = (items: AssetInfo[]) => {
if (items.length === 0) return
setArchiveConfirmState({
open: true,
mode: 'archive',
items,
})
}
const handleRestoreArchive = (items: AssetInfo[]) => {
if (items.length === 0) return
setArchiveConfirmState({
open: true,
mode: 'restore',
items,
})
}
const confirmArchiveOrRestore = () => {
const ids = archiveConfirmState.items.map((i) => i.id!).filter(Boolean)
if (ids.length === 0) {
setArchiveConfirmState((prev) => ({ ...prev, open: false, items: [] }))
return
}
if (archiveConfirmState.mode === 'archive') {
archiveFiles(
{ json: { ids } },
{
onSuccess: (data) => {
if (data.archivedAssetIds.length > 0) {
toast.success(m.archive_started_toast({ count: data.archivedAssetIds.length }))
} else {
toast.info(m.archive_no_eligible_assets_toast())
}
queryClient.removeQueries({ queryKey: ['file', teamId] })
queryClient.invalidateQueries({ queryKey: ['search', teamId] })
setArchiveConfirmState((prev) => ({ ...prev, open: false, items: [] }))
},
onError: () => {
toast.error(m.archive_failed_toast())
},
},
)
} else {
restoreArchiveFiles(
{ json: { ids } },
{
onSuccess: (data) => {
if (data.restoredAssetIds.length > 0) {
toast.success(
m.restore_archive_started_toast({ count: data.restoredAssetIds.length }),
)
} else {
toast.info(m.restore_archive_no_eligible_assets_toast())
}
queryClient.removeQueries({ queryKey: ['file', teamId] })
queryClient.invalidateQueries({ queryKey: ['search', teamId] })
setArchiveConfirmState((prev) => ({ ...prev, open: false, items: [] }))
},
onError: () => {
toast.error(m.restore_archive_failed_toast())
},
},
)
}
}
const startDownload = () => {
const files = [...resolvedFiles]
setIsDownloadDialogOpen(false)
@@ -387,7 +514,14 @@ export function useFileActions({
}
const handleAction = (
action: 'rename' | 'delete' | 'download' | 'restore' | 'copy-name-and-download-link',
action:
| 'rename'
| 'delete'
| 'download'
| 'restore'
| 'copy-name-and-download-link'
| 'archive'
| 'restore-archive',
item: AssetInfo,
) => {
const isSelected = selectedIds.has(item.id!)
@@ -411,6 +545,12 @@ export function useFileActions({
case 'copy-name-and-download-link':
handleCopyNameAndDownloadLink(targetItems)
break
case 'archive':
handleArchive(targetItems)
break
case 'restore-archive':
handleRestoreArchive(targetItems)
break
}
}
@@ -422,6 +562,8 @@ export function useFileActions({
handleRestore,
handleDownload,
handleCopyNameAndDownloadLink,
handleArchive,
handleRestoreArchive,
handleNewFolder,
handleAction,
onRenameSubmit,
@@ -433,6 +575,12 @@ export function useFileActions({
setIsDownloadDialogOpen,
isLoadingLinks,
resolvedFiles,
skippedArchivedCount,
startDownload,
archiveConfirmState,
setArchiveConfirmState,
confirmArchiveOrRestore,
isArchiving,
isRestoringArchive,
}
}
@@ -45,6 +45,7 @@ export interface MobileFileDetailProps {
id: string
version: number
name?: string | null
status?: string | null
previewUrl?: string | null
}>
activeFileId: string
@@ -58,6 +59,8 @@ export interface MobileFileDetailProps {
onNavigateBack: () => void
onRenameFile?: (newName: string) => Promise<void>
onDeleteFile?: () => Promise<void>
onArchiveFile?: () => void
onRestoreArchiveFile?: () => void
onSaveField: (fieldId: string, value: unknown) => void
onSelectVersion?: (versionId: string) => void
}
@@ -81,6 +84,8 @@ export function MobileFileDetail({
onNavigateBack,
onRenameFile,
onDeleteFile,
onArchiveFile,
onRestoreArchiveFile,
onSaveField,
onSelectVersion,
}: MobileFileDetailProps) {
@@ -214,6 +219,7 @@ export function MobileFileDetail({
fileName={file.name}
folderName={folderName}
version={versionNumber}
status={file.status}
versions={versions}
activeFileId={activeFileId}
isPublic={isPublic}
@@ -232,6 +238,8 @@ export function MobileFileDetail({
setIsRenameDialogOpen(true)
}}
onDelete={() => setIsDeleteDialogOpen(true)}
onArchive={onArchiveFile}
onRestoreArchive={onRestoreArchiveFile}
onLinkedTasks={!isPublic ? () => setIsLinkedTasksOpen(true) : undefined}
linkedTaskCount={linkedTaskCount}
/>
@@ -16,10 +16,13 @@ import {
import { cn } from '@/ui/lib/utils'
import { m } from '@/ui/paraglide/messages.js'
import {
Archive,
ArchiveRestore,
ChevronDown,
ChevronLeft,
ChevronRight,
Download,
Loader2,
MoreVertical,
Pencil,
SquareKanban,
@@ -32,10 +35,12 @@ export interface MobileFileHeaderProps {
fileName: string
folderName?: string
version?: number
status?: string
versions?: Array<{
id: string
version: number
name?: string | null
status?: string | null
}>
activeFileId: string
isPublic?: boolean
@@ -60,6 +65,8 @@ export interface MobileFileHeaderProps {
onSelectVersion?: (versionId: string) => void
onRename?: () => void
onDelete?: () => void
onArchive?: () => void
onRestoreArchive?: () => void
onLinkedTasks?: () => void
linkedTaskCount?: number
}
@@ -68,6 +75,7 @@ export function MobileFileHeader({
fileName,
folderName,
version,
status,
versions,
activeFileId,
isPublic = false,
@@ -83,9 +91,13 @@ export function MobileFileHeader({
onSelectVersion,
onRename,
onDelete,
onArchive,
onRestoreArchive,
onLinkedTasks,
linkedTaskCount = 0,
}: MobileFileHeaderProps) {
const isOriginalUnavailable =
status === 'archived' || status === 'archiving' || status === 'restoring'
const handleDownload = async (key: string) => {
try {
const res =
@@ -183,6 +195,36 @@ export function MobileFileHeader({
)}
</div>
)}
{status === 'archived' && (
<Badge
variant="secondary"
data-testid="detail-header-archived-badge"
className="ml-1 gap-0.5 px-1 py-0 text-[10px] shrink-0"
>
<Archive className="h-2.5 w-2.5" />
<span>{m.archived_status()}</span>
</Badge>
)}
{status === 'archiving' && (
<Badge
variant="secondary"
data-testid="detail-header-archiving-badge"
className="ml-1 gap-0.5 px-1 py-0 text-[10px] shrink-0"
>
<Loader2 className="h-2.5 w-2.5 animate-spin" />
<span>{m.archiving_status()}</span>
</Badge>
)}
{status === 'restoring' && (
<Badge
variant="secondary"
data-testid="detail-header-restoring-badge"
className="ml-1 gap-0.5 px-1 py-0 text-[10px] shrink-0"
>
<Loader2 className="h-2.5 w-2.5 animate-spin" />
<span>{m.restoring_status()}</span>
</Badge>
)}
</div>
{/* Prev / Next file navigation buttons */}
@@ -257,7 +299,10 @@ export function MobileFileHeader({
<>
<DropdownMenuSeparator />
<DropdownMenuItem
onClick={() => handleDownload(downloadInfo.originalKey!)}
disabled={isOriginalUnavailable}
onClick={() =>
!isOriginalUnavailable && handleDownload(downloadInfo.originalKey!)
}
className="flex items-center justify-between text-xs cursor-pointer"
>
<span>{m.original?.() || 'Original'}</span>
@@ -273,9 +318,11 @@ export function MobileFileHeader({
) : (
<DropdownMenuItem
onClick={() =>
downloadInfo?.originalKey && handleDownload(downloadInfo.originalKey)
downloadInfo?.originalKey &&
!isOriginalUnavailable &&
handleDownload(downloadInfo.originalKey)
}
disabled={!downloadInfo?.originalKey}
disabled={!downloadInfo?.originalKey || isOriginalUnavailable}
className="flex items-center gap-2 text-xs cursor-pointer"
>
<Download className="h-3.5 w-3.5" />
@@ -345,6 +392,28 @@ export function MobileFileHeader({
</DropdownMenuItem>
)}
{/* Archive / Restore */}
{canEdit && !isPublic && (!status || status === 'processed') && onArchive && (
<DropdownMenuItem
data-testid="detail-header-archive-action"
onClick={onArchive}
className="flex items-center gap-2 text-xs cursor-pointer"
>
<Archive className="h-3.5 w-3.5" />
<span>{m.archive()}</span>
</DropdownMenuItem>
)}
{canEdit && !isPublic && status === 'archived' && onRestoreArchive && (
<DropdownMenuItem
data-testid="detail-header-restore-archive-action"
onClick={onRestoreArchive}
className="flex items-center gap-2 text-xs cursor-pointer"
>
<ArchiveRestore className="h-3.5 w-3.5" />
<span>{m.restore_from_archive()}</span>
</DropdownMenuItem>
)}
{/* Delete */}
{canEdit && onDelete && (
<>
+127 -1
View File
@@ -41,6 +41,8 @@ import { useInfiniteQuery, useMutation, useQueryClient } from '@tanstack/react-q
import { useMatch, useNavigate, useParams } from '@tanstack/react-router'
import {
AlertTriangle,
Archive,
ArchiveRestore,
Bookmark,
ChevronDown,
ChevronRight,
@@ -63,6 +65,8 @@ import { useInView } from 'react-intersection-observer'
import { toast } from 'sonner'
import type { DragState } from './dnd-types'
import { m } from '@/ui/paraglide/messages.js'
import { useArchiveConfig } from '@/ui/hooks/use-archive-config'
import { ArchiveConfirmDialog } from './archive-confirm-dialog'
interface FolderTreeProps {
teamId: string
@@ -96,6 +100,7 @@ export function FolderTree({
const navigate = useNavigate()
const queryClient = useQueryClient()
const { canEdit } = usePermissions(projectId)
const { archiveStorageEnabled } = useArchiveConfig()
const isRecentlyDeleted = useMatch({
from: '/projects/$projectId/recently-deleted',
shouldThrow: false,
@@ -310,17 +315,77 @@ export function FolderTree({
const [resolvedFiles, setResolvedFiles] = useState<
Array<{ id: string; name: string; url: string }>
>([])
const [skippedArchivedCount, setSkippedArchivedCount] = useState(0)
const [archiveConfirmState, setArchiveConfirmState] = useState<{
open: boolean
mode: 'archive' | 'restore'
folderId: string | null
}>({ open: false, mode: 'archive', folderId: null })
const { mutate: archiveFolder, isPending: isArchivingFolder } = useMutation({
mutationFn: async (folderId: string) => {
const res = await client.api.files.archive.$post({
json: { ids: [folderId] },
})
if (!res.ok) throw new Error(m.archive_failed_toast())
return await res.json()
},
onSuccess: (data) => {
if (data.archivedAssetIds.length > 0) {
toast.success(m.archive_started_toast({ count: data.archivedAssetIds.length }))
} else {
toast.info(m.archive_no_eligible_assets_toast())
}
queryClient.removeQueries({ queryKey: ['file', teamId] })
queryClient.invalidateQueries({ queryKey: ['search', teamId] })
setArchiveConfirmState((prev) => ({ ...prev, open: false, folderId: null }))
},
onError: () => {
toast.error(m.archive_failed_toast())
},
})
const { mutate: restoreArchiveFolder, isPending: isRestoringArchiveFolder } = useMutation({
mutationFn: async (folderId: string) => {
const res = await client.api.files['restore-archive'].$post({
json: { ids: [folderId] },
})
if (!res.ok) throw new Error(m.restore_archive_failed_toast())
return await res.json()
},
onSuccess: (data) => {
if (data.restoredAssetIds.length > 0) {
toast.success(m.restore_archive_started_toast({ count: data.restoredAssetIds.length }))
} else {
toast.info(m.restore_archive_no_eligible_assets_toast())
}
queryClient.removeQueries({ queryKey: ['file', teamId] })
queryClient.invalidateQueries({ queryKey: ['search', teamId] })
setArchiveConfirmState((prev) => ({ ...prev, open: false, folderId: null }))
},
onError: () => {
toast.error(m.restore_archive_failed_toast())
},
})
const handleDownloadFolder = async (folderId: string) => {
setIsDownloadOpen(true)
setIsLoadingLinks(true)
setResolvedFiles([])
setSkippedArchivedCount(0)
try {
const res = await client.api.files['download-links'].$post({
json: { ids: [folderId] },
})
if (!res.ok) throw new Error(m.failed_to_prepare_download_links())
const data = await res.json()
const skipped = data.skippedArchivedCount ?? 0
setSkippedArchivedCount(skipped)
if (data.files.length === 0 && skipped > 0) {
setIsDownloadOpen(false)
toast.error(m.download_all_archived_error())
return
}
setResolvedFiles(data.files)
} catch (error) {
toast.error(m.failed_to_prepare_download_links())
@@ -539,6 +604,13 @@ export function FolderTree({
onDownloadTrigger={(id) => {
handleDownloadFolder(id)
}}
archiveStorageEnabled={archiveStorageEnabled}
onArchiveTrigger={(id) => {
setArchiveConfirmState({ open: true, mode: 'archive', folderId: id })
}}
onRestoreArchiveTrigger={(id) => {
setArchiveConfirmState({ open: true, mode: 'restore', folderId: id })
}}
ancestorFolders={ancestorFolders}
/>
@@ -913,6 +985,14 @@ export function FolderTree({
<div className="text-sm text-muted-foreground">
{m.download_includes_files({ count: resolvedFiles.length })}
</div>
{skippedArchivedCount > 0 && (
<div
data-testid="download-skipped-archived-notice"
className="text-sm text-amber-600 dark:text-amber-400"
>
{m.download_skipped_archived_notice({ count: skippedArchivedCount })}
</div>
)}
<div className="flex items-start gap-3 p-3 text-sm rounded-lg bg-amber-50 dark:bg-amber-950/30 text-amber-800 dark:text-amber-300 border border-amber-200 dark:border-amber-900/30">
<AlertTriangle className="h-5 w-5 shrink-0 mt-0.5" />
<div>
@@ -948,6 +1028,21 @@ export function FolderTree({
</DialogFooter>
</DialogContent>
</Dialog>
<ArchiveConfirmDialog
open={archiveConfirmState.open}
onOpenChange={(open) => setArchiveConfirmState((prev) => ({ ...prev, open }))}
mode={archiveConfirmState.mode}
onConfirm={() => {
if (!archiveConfirmState.folderId) return
if (archiveConfirmState.mode === 'archive') {
archiveFolder(archiveConfirmState.folderId)
} else {
restoreArchiveFolder(archiveConfirmState.folderId)
}
}}
isPending={isArchivingFolder || isRestoringArchiveFolder}
/>
</div>
)
}
@@ -1055,9 +1150,12 @@ interface FolderTreeItemProps {
onSelect?: (folder: AssetInfo) => void
selectedFolderId?: string
canEdit?: boolean
archiveStorageEnabled?: boolean
onRenameTrigger: (id: string, name: string) => void
onDeleteTrigger: (id: string) => void
onDownloadTrigger: (id: string) => void
onArchiveTrigger?: (id: string) => void
onRestoreArchiveTrigger?: (id: string) => void
ancestorFolders?: AncestorFolder[]
}
@@ -1071,9 +1169,12 @@ function FolderTreeItem({
onSelect,
selectedFolderId,
canEdit,
archiveStorageEnabled,
onRenameTrigger,
onDeleteTrigger,
onDownloadTrigger,
onArchiveTrigger,
onRestoreArchiveTrigger,
ancestorFolders,
}: FolderTreeItemProps) {
const isAncestor = useMemo(() => {
@@ -1251,7 +1352,7 @@ function FolderTreeItem({
<MoreHorizontal className="h-3.5 w-3.5" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end" className="w-32">
<DropdownMenuContent align="end" className="w-48">
<DropdownMenuItem
onClick={() => {
onRenameTrigger(folder.id!, folder.name)
@@ -1268,6 +1369,28 @@ function FolderTreeItem({
<Download className="mr-2 h-4 w-4" />
{m.download()}
</DropdownMenuItem>
{archiveStorageEnabled && (
<>
<DropdownMenuItem
data-testid="folder-tree-archive-action"
onClick={() => {
onArchiveTrigger?.(folder.id!)
}}
>
<Archive className="mr-2 h-4 w-4" />
{m.archive()}
</DropdownMenuItem>
<DropdownMenuItem
data-testid="folder-tree-restore-archive-action"
onClick={() => {
onRestoreArchiveTrigger?.(folder.id!)
}}
>
<ArchiveRestore className="mr-2 h-4 w-4" />
{m.restore_from_archive()}
</DropdownMenuItem>
</>
)}
<DropdownMenuSeparator />
<DropdownMenuItem
className="text-destructive focus:text-destructive focus:bg-destructive/10"
@@ -1308,6 +1431,9 @@ function FolderTreeItem({
onRenameTrigger={onRenameTrigger}
onDeleteTrigger={onDeleteTrigger}
onDownloadTrigger={onDownloadTrigger}
archiveStorageEnabled={archiveStorageEnabled}
onArchiveTrigger={onArchiveTrigger}
onRestoreArchiveTrigger={onRestoreArchiveTrigger}
ancestorFolders={ancestorFolders}
/>
))}
@@ -1,4 +1,5 @@
import { client } from '@/ui/api/client'
import { Badge } from '@/ui/components/ui/badge'
import { Button } from '@/ui/components/ui/button'
import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/ui/components/ui/dialog'
import {
@@ -8,6 +9,7 @@ import {
DropdownMenuTrigger,
} from '@/ui/components/ui/dropdown-menu'
import { ScrollArea } from '@/ui/components/ui/scroll-area'
import { useArchiveConfig } from '@/ui/hooks/use-archive-config'
import { cn } from '@/ui/lib/utils'
import { m } from '@/ui/paraglide/messages.js'
import { PointerActivationConstraints } from '@dnd-kit/dom'
@@ -16,9 +18,19 @@ import { isSortable, useSortable } from '@dnd-kit/react/sortable'
import type { StackVersionInfo } from '@shumai/dtos'
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import { format, parseISO } from 'date-fns'
import { Bot, FileIcon, GripVertical, MoreVertical, Trash2 } from 'lucide-react'
import {
Archive,
ArchiveRestore,
Bot,
FileIcon,
GripVertical,
Loader2,
MoreVertical,
Trash2,
} from 'lucide-react'
import { useEffect, useState } from 'react'
import { toast } from 'sonner'
import { ArchiveConfirmDialog } from './archive-confirm-dialog'
interface ManageVersionsDialogProps {
open: boolean
@@ -34,7 +46,10 @@ interface SortableVersionRowProps {
displayVersionNumber: number
index: number
canEdit: boolean
archiveStorageEnabled?: boolean
onRemove: (versionId: string) => void
onArchive?: (versionId: string) => void
onRestoreArchive?: (versionId: string) => void
}
function formatVersionDate(dateString?: string | null): string | null {
@@ -53,7 +68,10 @@ function SortableVersionRow({
displayVersionNumber,
index,
canEdit,
archiveStorageEnabled = false,
onRemove,
onArchive,
onRestoreArchive,
}: SortableVersionRowProps) {
const [dropdownOpen, setDropdownOpen] = useState(false)
const { ref, handleRef } = useSortable({
@@ -102,9 +120,41 @@ function SortableVersionRow({
{/* 4. Name / Creator / Create Date (2 rows) */}
<div className="flex flex-col flex-1 min-w-0 text-left">
{/* Row 1: Name */}
<span className="truncate text-sm font-medium text-foreground" title={version.name || ''}>
{version.name || 'Untitled'}
</span>
<div className="flex items-center gap-1.5 min-w-0">
<span className="truncate text-sm font-medium text-foreground" title={version.name || ''}>
{version.name || 'Untitled'}
</span>
{version.status === 'archived' && (
<Badge
variant="secondary"
data-testid="version-row-archived-badge"
className="gap-1 px-1.5 py-0 text-xs shrink-0"
>
<Archive className="h-3 w-3" />
<span>{m.archived_status()}</span>
</Badge>
)}
{version.status === 'archiving' && (
<Badge
variant="secondary"
data-testid="version-row-archiving-badge"
className="gap-1 px-1.5 py-0 text-xs shrink-0"
>
<Loader2 className="h-3 w-3 animate-spin" />
<span>{m.archiving_status()}</span>
</Badge>
)}
{version.status === 'restoring' && (
<Badge
variant="secondary"
data-testid="version-row-restoring-badge"
className="gap-1 px-1.5 py-0 text-xs shrink-0"
>
<Loader2 className="h-3 w-3 animate-spin" />
<span>{m.restoring_status()}</span>
</Badge>
)}
</div>
{/* Row 2: Creator & Create Date */}
<div className="flex items-center gap-1.5 text-xs text-muted-foreground truncate">
{version.agent ? (
@@ -148,6 +198,26 @@ function SortableVersionRow({
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
{archiveStorageEnabled && (!version.status || version.status === 'processed') && (
<DropdownMenuItem
data-testid="version-row-archive-action"
onClick={() => onArchive?.(version.id)}
className="cursor-pointer"
>
<Archive className="h-4 w-4 mr-2" />
<span>{m.archive()}</span>
</DropdownMenuItem>
)}
{archiveStorageEnabled && version.status === 'archived' && (
<DropdownMenuItem
data-testid="version-row-restore-archive-action"
onClick={() => onRestoreArchive?.(version.id)}
className="cursor-pointer"
>
<ArchiveRestore className="h-4 w-4 mr-2" />
<span>{m.restore_from_archive()}</span>
</DropdownMenuItem>
)}
<DropdownMenuItem
onClick={() => onRemove(version.id)}
className="text-destructive focus:text-destructive cursor-pointer"
@@ -171,7 +241,17 @@ export function ManageVersionsDialog({
onStackDissolved,
}: ManageVersionsDialogProps) {
const queryClient = useQueryClient()
const { archiveStorageEnabled } = useArchiveConfig()
const [localVersions, setLocalVersions] = useState<StackVersionInfo[]>([])
const [archiveConfirmState, setArchiveConfirmState] = useState<{
open: boolean
mode: 'archive' | 'restore'
versionId: string | null
}>({ open: false, mode: 'archive', versionId: null })
const hasTransitioningVersions = localVersions.some(
(v) => v.status === 'archiving' || v.status === 'restoring',
)
const { data: fetchedVersions, isLoading } = useQuery({
queryKey: ['version_stacks', stackId, 'versions'],
@@ -183,6 +263,57 @@ export function ManageVersionsDialog({
return (await res.json()) as StackVersionInfo[]
},
enabled: open && !!stackId,
refetchInterval: hasTransitioningVersions ? 2000 : false,
})
const { mutate: archiveVersion, isPending: isArchivingVersion } = useMutation({
mutationFn: async (versionId: string) => {
const res = await client.api.files.archive.$post({
json: { ids: [versionId] },
})
if (!res.ok) throw new Error(m.archive_failed_toast())
return await res.json()
},
onSuccess: (data) => {
if (data.archivedAssetIds.length > 0) {
toast.success(m.archive_started_toast({ count: data.archivedAssetIds.length }))
} else {
toast.info(m.archive_no_eligible_assets_toast())
}
queryClient.invalidateQueries({ queryKey: ['version_stacks', stackId, 'versions'] })
queryClient.invalidateQueries({ queryKey: ['files'] })
queryClient.removeQueries({ queryKey: ['file'] })
queryClient.invalidateQueries({ queryKey: ['search'] })
setArchiveConfirmState((prev) => ({ ...prev, open: false, versionId: null }))
},
onError: () => {
toast.error(m.archive_failed_toast())
},
})
const { mutate: restoreArchiveVersion, isPending: isRestoringArchiveVersion } = useMutation({
mutationFn: async (versionId: string) => {
const res = await client.api.files['restore-archive'].$post({
json: { ids: [versionId] },
})
if (!res.ok) throw new Error(m.restore_archive_failed_toast())
return await res.json()
},
onSuccess: (data) => {
if (data.restoredAssetIds.length > 0) {
toast.success(m.restore_archive_started_toast({ count: data.restoredAssetIds.length }))
} else {
toast.info(m.restore_archive_no_eligible_assets_toast())
}
queryClient.invalidateQueries({ queryKey: ['version_stacks', stackId, 'versions'] })
queryClient.invalidateQueries({ queryKey: ['files'] })
queryClient.removeQueries({ queryKey: ['file'] })
queryClient.invalidateQueries({ queryKey: ['search'] })
setArchiveConfirmState((prev) => ({ ...prev, open: false, versionId: null }))
},
onError: () => {
toast.error(m.restore_archive_failed_toast())
},
})
useEffect(() => {
@@ -318,7 +449,14 @@ export function ManageVersionsDialog({
displayVersionNumber={localVersions.length - index}
index={index}
canEdit={canEdit}
archiveStorageEnabled={archiveStorageEnabled}
onRemove={handleRemove}
onArchive={(versionId) =>
setArchiveConfirmState({ open: true, mode: 'archive', versionId })
}
onRestoreArchive={(versionId) =>
setArchiveConfirmState({ open: true, mode: 'restore', versionId })
}
/>
))}
</DragDropProvider>
@@ -326,6 +464,20 @@ export function ManageVersionsDialog({
)}
</ScrollArea>
</DialogContent>
<ArchiveConfirmDialog
open={archiveConfirmState.open}
onOpenChange={(nextOpen) => setArchiveConfirmState((prev) => ({ ...prev, open: nextOpen }))}
mode={archiveConfirmState.mode}
onConfirm={() => {
if (!archiveConfirmState.versionId) return
if (archiveConfirmState.mode === 'archive') {
archiveVersion(archiveConfirmState.versionId)
} else {
restoreArchiveVersion(archiveConfirmState.versionId)
}
}}
isPending={isArchivingVersion || isRestoringArchiveVersion}
/>
</Dialog>
)
}
@@ -427,6 +427,7 @@ export function PublicShareManager({
currentAsset: {
name: viewingFileData?.name || currentFolderName,
type: viewingFileId ? 'file' : 'folder',
status: viewingFileData?.status,
version: stackFileData?.versionStack
? (stackFileData.versionStack.versions.find((v) => v.id === activeFileId)?.version ??
stackFileData.versionStack.versions.length)
@@ -18,6 +18,7 @@ import RatingField from '../fields/rating-field'
import { useEffect, useMemo } from 'react'
import { useMemberStore } from '@/ui/stores/members'
import { useTeamId } from '@/ui/hooks/use-team-id'
import { useArchiveConfig } from '@/ui/hooks/use-archive-config'
import { m } from '@/ui/paraglide/messages.js'
interface FilterPanelProps {
@@ -39,6 +40,7 @@ export function FilterPanel({
}: FilterPanelProps) {
const teamId = useTeamId()
const { members, fetchMembers } = useMemberStore()
const { archiveStorageEnabled } = useArchiveConfig()
useEffect(() => {
if (teamId) {
@@ -60,6 +62,9 @@ export function FilterPanel({
{ id: 'createdAt', label: m.field_created_at(), type: 'date' },
{ id: 'updatedAt', label: m.field_updated_at(), type: 'date' },
{ id: 'sizeByte', label: m.field_size(), type: 'number' },
...(archiveStorageEnabled
? [{ id: 'isArchived', label: m.filter_archived(), type: 'toggle' }]
: []),
]
const custom = fields.map((f) => ({
id: f.id!,
@@ -72,7 +77,7 @@ export function FilterPanel({
config: f.config,
}))
return [...sys, ...custom].filter((f) => !excludeFields?.includes(f.id))
}, [fields, memberOptions, excludeFields])
}, [fields, memberOptions, excludeFields, archiveStorageEnabled])
const handleAddCondition = () => {
onChange([
@@ -100,7 +105,7 @@ export function FilterPanel({
const field = allFields.find((f) => f.id === value)
if (field) {
newConditions[index].operator = getDefaultOperator(field.type)
newConditions[index].value = ''
newConditions[index].value = field.type === 'toggle' ? true : ''
}
}
@@ -518,6 +523,7 @@ function ConditionValueInput({
}
if (field.type === 'toggle') {
const isArchivedField = field.id === 'isArchived'
return (
<Select
value={value === true ? 'true' : 'false'}
@@ -527,8 +533,12 @@ function ConditionValueInput({
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="true">{m.toggle_checked()}</SelectItem>
<SelectItem value="false">{m.toggle_unchecked()}</SelectItem>
<SelectItem value="true">
{isArchivedField ? m.filter_archived_only() : m.toggle_checked()}
</SelectItem>
<SelectItem value="false">
{isArchivedField ? m.filter_not_archived() : m.toggle_unchecked()}
</SelectItem>
</SelectContent>
</Select>
)
+4
View File
@@ -64,6 +64,8 @@ export function TopNav() {
onFolderClick,
onRename,
onDelete,
onArchive,
onRestoreArchive,
compareMode,
canCompareVersions,
onCompareVersions,
@@ -162,6 +164,8 @@ export function TopNav() {
onFolderClick={onFolderClick}
onRename={onRename}
onDelete={onDelete}
onArchive={onArchive}
onRestoreArchive={onRestoreArchive}
compareMode={compareMode}
canCompareVersions={canCompareVersions}
onCompareVersions={onCompareVersions}
@@ -77,8 +77,14 @@ export const DefaultViewer = React.forwardRef<MediaController, FileViewerProps>(
<div className="relative px-4 py-3 bg-card border-t border-gray-200 dark:border-gray-700 z-10 flex items-center justify-end gap-2 transition-colors duration-200">
{allowDownload && (
<button
data-testid="default-viewer-download-button"
onClick={handleDownload}
disabled={!file.media?.original?.key}
disabled={
!file.media?.original?.key ||
file.status === 'archived' ||
file.status === 'archiving' ||
file.status === 'restoring'
}
className="flex items-center gap-1.5 text-xs font-medium px-3 py-1.5 rounded bg-gray-200/50 dark:bg-white/10 hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-200 transition-colors border border-transparent disabled:opacity-50 animate-in fade-in zoom-in-95 duration-200"
title="Download original file"
>
@@ -213,7 +213,12 @@ export const ImageViewer = React.forwardRef<MediaController, FileViewerProps>(
onZoomOut={() => handleZoom(0.8)}
onFit={handleFit}
onDownload={handleDownload}
canDownload={!!file.media?.original?.key}
canDownload={
!!file.media?.original?.key &&
file.status !== 'archived' &&
file.status !== 'archiving' &&
file.status !== 'restoring'
}
onCopy={handleCopy}
copied={copied}
canCopy={!!bestUrl}
@@ -514,7 +514,14 @@ export const ModelViewer = React.forwardRef<MediaController, FileViewerProps>(
zoom={zoom}
isFullScreen={isFullScreen}
allowDownload={allowDownload}
onDownload={data.media?.original?.key ? handleDownload : undefined}
onDownload={
data.media?.original?.key &&
data.status !== 'archived' &&
data.status !== 'archiving' &&
data.status !== 'restoring'
? handleDownload
: undefined
}
togglePlay={togglePlay}
onSeekDegree={seekToDegree}
onZoomChange={handleZoomChange}
@@ -0,0 +1,38 @@
// @vitest-environment happy-dom
import { cleanup, render, screen } from '@testing-library/react'
import React from 'react'
import { afterEach, describe, expect, it, vi } from 'vitest'
import { PdfViewer } from './pdf-viewer'
import type { AssetInfo } from '@shumai/dtos'
vi.mock('pdfjs-dist', () => ({
GlobalWorkerOptions: { workerSrc: '' },
getDocument: vi.fn(),
}))
describe('PdfViewer', () => {
afterEach(() => {
cleanup()
})
it('renders archived placeholder when native PDF is archived and pdfTranscode.url is absent', () => {
const archivedPdf: AssetInfo = {
id: 'pdf-1',
name: 'document.pdf',
type: 'file',
status: 'archived',
sizeByte: 1024,
fileCount: 0,
createdAt: '2026-01-01T00:00:00Z',
updatedAt: '2026-01-01T00:00:00Z',
media: {
original: { key: 'files/pdf-1/document.pdf' },
pdfTranscode: { key: 'files/pdf-1/document.pdf' },
},
} as AssetInfo
render(<PdfViewer file={archivedPdf} />)
expect(screen.getByTestId('pdf-viewer-archived-state')).toBeTruthy()
})
})
@@ -1,6 +1,8 @@
import { client } from '@/ui/api/client'
import DrawingCanvas from '@/ui/components/drawing-canvas'
import { m } from '@/ui/paraglide/messages.js'
import { useAnnotationStore } from '@/ui/stores/annotation-store'
import { Archive } from 'lucide-react'
import * as pdfjsLib from 'pdfjs-dist'
import React, { useEffect, useImperativeHandle, useRef, useState } from 'react'
import { FileViewerProps, MediaController } from '../types'
@@ -166,6 +168,9 @@ export const PdfViewer = React.forwardRef<MediaController, FileViewerProps>(
}, [])
const fileUrl = file.media?.pdfTranscode?.url
const isOriginalUnavailable =
file.status === 'archived' || file.status === 'archiving' || file.status === 'restoring'
const isNativePdfArchived = !fileUrl && isOriginalUnavailable
// Load PDF Document
useEffect(() => {
@@ -409,6 +414,16 @@ export const PdfViewer = React.forwardRef<MediaController, FileViewerProps>(
<div className="absolute inset-0 flex items-center justify-center bg-black/40 z-20">
<div className="w-8 h-8 border-4 border-white/30 border-t-white rounded-full animate-spin" />
</div>
) : isNativePdfArchived ? (
<div
data-testid="pdf-viewer-archived-state"
className="absolute inset-0 flex flex-col items-center justify-center gap-3 p-6 text-center text-muted-foreground"
>
<Archive className="h-12 w-12 text-muted-foreground/70" />
<p className="text-sm font-medium text-foreground">
{m.pdf_archived_placeholder()}
</p>
</div>
) : error ? (
<div className="absolute inset-0 flex items-center justify-center text-gray-500 text-sm">
{error}
@@ -465,7 +480,7 @@ export const PdfViewer = React.forwardRef<MediaController, FileViewerProps>(
onZoomOut={() => handleZoom(0.8)}
onFit={handleFit}
onDownload={handleDownload}
canDownload={!!file.media?.original?.key}
canDownload={!!file.media?.original?.key && !isOriginalUnavailable}
allowDownload={allowDownload}
/>
</div>
@@ -425,9 +425,20 @@ export const VideoControlBar: React.FC<ControlBarProps> = ({
(isAudio ? (
<button
onClick={() => handleDownload(data.media?.original?.key || '')}
className="transition-colors hover:text-primary"
title={m.download()}
disabled={!data.media?.original?.key}
className="transition-colors hover:text-primary disabled:opacity-50"
title={
data.status === 'archived' ||
data.status === 'archiving' ||
data.status === 'restoring'
? m.original_archived_tooltip()
: m.download()
}
disabled={
!data.media?.original?.key ||
data.status === 'archived' ||
data.status === 'archiving' ||
data.status === 'restoring'
}
>
<Download className="h-5 w-5" />
</button>
@@ -468,7 +479,24 @@ export const VideoControlBar: React.FC<ControlBarProps> = ({
<>
<DropdownMenuSeparator />
<DropdownMenuItem
onClick={() => handleDownload(data.media?.original?.key ?? '')}
disabled={
data.status === 'archived' ||
data.status === 'archiving' ||
data.status === 'restoring'
}
title={
data.status === 'archived' ||
data.status === 'archiving' ||
data.status === 'restoring'
? m.original_archived_tooltip()
: undefined
}
onClick={() =>
data.status !== 'archived' &&
data.status !== 'archiving' &&
data.status !== 'restoring' &&
handleDownload(data.media?.original?.key ?? '')
}
className="flex w-full items-center justify-between px-3 py-2 text-left text-sm text-foreground"
>
<span>{m.original()}</span>