fix(webui): show archive icon in front of version names and prevent version card overflow

This commit is contained in:
yiling
2026-11-02 22:00:13 +08:00
parent 64a3b226db
commit 39e969c3dd
4 changed files with 88 additions and 50 deletions
@@ -350,4 +350,46 @@ describe('BreadcrumbNav component', () => {
expect(screen.queryByText('Restoring...')).toBeNull()
expect(screen.queryByText('恢复中...')).toBeNull()
})
it('renders archive icon in front of version name without text in versions dropdown', () => {
render(
<QueryClientProvider client={queryClient}>
<BreadcrumbNav
{...baseProps}
fileId="file-with-versions"
currentAsset={{
id: 'file-with-versions',
name: 'v2.mp4',
type: 'file',
version: 2,
status: 'processed',
}}
versions={[
{
id: 'file-v2',
version: 2,
name: 'v2.mp4',
status: 'processed',
},
{
id: 'file-v1',
version: 1,
name: 'v1-archived.mp4',
status: 'archived',
},
]}
/>
</QueryClientProvider>,
)
const triggerButton = screen.getByRole('button', { name: 'v2.mp4' })
fireEvent.pointerDown(triggerButton, { button: 0, ctrlKey: false })
const versionsTrigger = screen.getByText('Versions')
fireEvent.click(versionsTrigger)
expect(screen.getByText('v1-archived.mp4')).toBeDefined()
expect(screen.queryByText('Archived')).toBeNull()
expect(screen.queryByText('已归档')).toBeNull()
})
})
+14 -17
View File
@@ -457,31 +457,28 @@ export function BreadcrumbNav({
<div className="flex flex-col flex-1 min-w-0 text-left">
<div className="flex items-center gap-1.5 min-w-0">
{(v.status === 'archived' || v.status === 'restoring') && (
<span
title={
v.status === 'restoring'
? m.restoring_status()
: m.archived_status()
}
className="inline-flex items-center shrink-0"
>
<Archive className="h-3.5 w-3.5 text-muted-foreground" />
</span>
)}
<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()}
<Loader2 className="h-2.5 w-2.5 animate-spin" />
<span>{m.archiving_status()}</span>
</Badge>
)}
</div>
@@ -189,8 +189,11 @@ export function MobileFileHeader({
)}
>
<span>v{v.version}</span>
<span className="text-[11px] text-muted-foreground truncate max-w-[120px]">
{v.name || fileName}
<span className="text-[11px] text-muted-foreground truncate max-w-[120px] flex items-center gap-1">
{(v.status === 'archived' || v.status === 'restoring') && (
<Archive className="h-2.5 w-2.5 shrink-0 text-muted-foreground" />
)}
<span className="truncate">{v.name || fileName}</span>
</span>
</DropdownMenuItem>
))}
@@ -85,7 +85,7 @@ function SortableVersionRow({
return (
<div
ref={ref}
className="group flex items-center gap-3 p-2.5 rounded-lg border border-border bg-card hover:bg-accent/40 transition-colors"
className="group flex items-center gap-3 p-2.5 rounded-lg border border-border bg-card hover:bg-accent/40 transition-colors min-w-0 overflow-hidden"
>
{/* 1. Version Label */}
<div className="flex-shrink-0 flex items-center justify-center bg-muted text-muted-foreground rounded-full px-2.5 py-0.5 text-xs font-semibold select-none min-w-[2.25rem]">
@@ -96,12 +96,12 @@ function SortableVersionRow({
{canEdit ? (
<div
ref={handleRef}
className="cursor-grab active:cursor-grabbing text-muted-foreground hover:text-foreground p-1 -m-1 rounded touch-none flex items-center justify-center"
className="cursor-grab active:cursor-grabbing text-muted-foreground hover:text-foreground p-1 -m-1 rounded touch-none flex items-center justify-center flex-shrink-0"
>
<GripVertical className="h-4 w-4" />
</div>
) : (
<div className="w-4" />
<div className="w-4 flex-shrink-0" />
)}
{/* 3. Thumbnail Preview */}
@@ -118,22 +118,28 @@ function SortableVersionRow({
</div>
{/* 4. Name / Creator / Create Date (2 rows) */}
<div className="flex flex-col flex-1 min-w-0 text-left">
<div className="flex flex-col flex-1 min-w-0 text-left overflow-hidden">
{/* Row 1: Name */}
<div className="flex items-center gap-1.5 min-w-0">
<span className="truncate text-sm font-medium text-foreground" title={version.name || ''}>
<div className="flex items-center gap-1.5 min-w-0 max-w-full">
{(version.status === 'archived' || version.status === 'restoring') && (
<span
data-testid={
version.status === 'restoring'
? 'version-row-restoring-badge'
: 'version-row-archived-badge'
}
title={version.status === 'restoring' ? m.restoring_status() : m.archived_status()}
className="inline-flex items-center shrink-0"
>
<Archive className="h-3.5 w-3.5 text-muted-foreground" />
</span>
)}
<span
className="truncate text-sm font-medium text-foreground min-w-0 flex-1"
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"
@@ -144,21 +150,11 @@ function SortableVersionRow({
<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">
<div className="flex items-center gap-1.5 text-xs text-muted-foreground min-w-0 truncate">
{version.agent ? (
<span className="flex items-center gap-1 truncate">
<span className="flex items-center gap-1 min-w-0 truncate">
<Bot className="h-3 w-3 shrink-0" />
<span className="truncate">
{m.user_via_agent({
@@ -168,12 +164,12 @@ function SortableVersionRow({
</span>
</span>
) : (
<span>{version.creator?.name || m.unknown()}</span>
<span className="truncate">{version.creator?.name || m.unknown()}</span>
)}
{formattedDate && (
<>
<span>•</span>
<span>{formattedDate}</span>
<span className="shrink-0">•</span>
<span className="shrink-0">{formattedDate}</span>
</>
)}
</div>