mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-23 19:28:19 +00:00
fix(webui): show archive icon in front of file name in breadcrumb bar
This commit is contained in:
@@ -304,4 +304,27 @@ describe('BreadcrumbNav component', () => {
|
||||
expect(items.some((i) => i.textContent?.includes('1080p'))).toBe(true)
|
||||
expect(items.some((i) => i.textContent?.includes('480p'))).toBe(false)
|
||||
})
|
||||
|
||||
it('renders archive icon in front of file name without archived text when status is archived', () => {
|
||||
render(
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<BreadcrumbNav
|
||||
{...baseProps}
|
||||
fileId="file-archived"
|
||||
currentAsset={{
|
||||
id: 'file-archived',
|
||||
name: 'video.mp4',
|
||||
type: 'file',
|
||||
status: 'archived',
|
||||
version: 1,
|
||||
}}
|
||||
/>
|
||||
</QueryClientProvider>,
|
||||
)
|
||||
|
||||
const archiveIcon = screen.getByTestId('detail-header-archived-badge')
|
||||
expect(archiveIcon).toBeDefined()
|
||||
expect(screen.queryByText('Archived')).toBeNull()
|
||||
expect(screen.queryByText('已归档')).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -269,25 +269,24 @@ export function BreadcrumbNav({
|
||||
return (
|
||||
<DropdownMenu modal={false} open={isFileMenuOpen} onOpenChange={setIsFileMenuOpen}>
|
||||
<div
|
||||
className="flex items-center gap-1 truncate rounded px-2 py-1 text-sm font-medium text-foreground transition-colors hover:bg-accent hover:text-accent-foreground cursor-pointer select-none"
|
||||
className="flex items-center gap-1.5 truncate rounded px-2 py-1 text-sm font-medium text-foreground transition-colors hover:bg-accent hover:text-accent-foreground cursor-pointer select-none"
|
||||
onClick={() => setIsFileMenuOpen((prev) => !prev)}
|
||||
>
|
||||
{currentAsset.status === 'archived' && (
|
||||
<span
|
||||
data-testid="detail-header-archived-badge"
|
||||
title={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">{currentAsset.name}</span>
|
||||
{currentAsset.version !== undefined && (
|
||||
<Badge variant="outline" className="px-1 py-0 text-xs shrink-0">
|
||||
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"
|
||||
|
||||
@@ -184,4 +184,20 @@ describe('MobileFileHeader', () => {
|
||||
expect(items.some((i) => i.textContent?.includes('1080p'))).toBe(true)
|
||||
expect(items.some((i) => i.textContent?.includes('1920p'))).toBe(false)
|
||||
})
|
||||
|
||||
it('renders archive icon in front of file name without archived text when status is archived', () => {
|
||||
render(
|
||||
<MobileFileHeader
|
||||
fileName="video.mp4"
|
||||
activeFileId="file-archived"
|
||||
status="archived"
|
||||
onBack={vi.fn()}
|
||||
/>,
|
||||
)
|
||||
|
||||
const archiveIcon = screen.getByTestId('detail-header-archived-badge')
|
||||
expect(archiveIcon).toBeDefined()
|
||||
expect(screen.queryByText('Archived')).toBeNull()
|
||||
expect(screen.queryByText('已归档')).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -155,6 +155,15 @@ export function MobileFileHeader({
|
||||
<DropdownMenu modal={false}>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<button className="flex items-center gap-1 min-w-0 truncate text-xs font-medium text-foreground hover:bg-accent rounded px-1 py-0.5 transition-colors cursor-pointer">
|
||||
{status === 'archived' && (
|
||||
<span
|
||||
data-testid="detail-header-archived-badge"
|
||||
title={m.archived_status()}
|
||||
className="inline-flex items-center shrink-0"
|
||||
>
|
||||
<Archive className="h-3 w-3 text-muted-foreground" />
|
||||
</span>
|
||||
)}
|
||||
<span className="truncate max-w-[120px] font-semibold">{fileName}</span>
|
||||
{version !== undefined && (
|
||||
<Badge variant="outline" className="px-1 py-0 text-[10px] shrink-0 font-normal">
|
||||
@@ -185,6 +194,15 @@ export function MobileFileHeader({
|
||||
</DropdownMenu>
|
||||
) : (
|
||||
<div className="flex items-center gap-1 min-w-0 truncate">
|
||||
{status === 'archived' && (
|
||||
<span
|
||||
data-testid="detail-header-archived-badge"
|
||||
title={m.archived_status()}
|
||||
className="inline-flex items-center shrink-0"
|
||||
>
|
||||
<Archive className="h-3 w-3 text-muted-foreground" />
|
||||
</span>
|
||||
)}
|
||||
<span className="truncate text-xs font-semibold text-foreground max-w-[140px]">
|
||||
{fileName}
|
||||
</span>
|
||||
@@ -195,16 +213,6 @@ 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"
|
||||
|
||||
Reference in New Issue
Block a user