mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-05 23:54:25 +00:00
fix(webui): display archive icon in breadcrumbs when restoring
This commit is contained in:
@@ -327,4 +327,27 @@ describe('BreadcrumbNav component', () => {
|
|||||||
expect(screen.queryByText('Archived')).toBeNull()
|
expect(screen.queryByText('Archived')).toBeNull()
|
||||||
expect(screen.queryByText('已归档')).toBeNull()
|
expect(screen.queryByText('已归档')).toBeNull()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('renders archive icon in front of file name without restoring text when status is restoring', () => {
|
||||||
|
render(
|
||||||
|
<QueryClientProvider client={queryClient}>
|
||||||
|
<BreadcrumbNav
|
||||||
|
{...baseProps}
|
||||||
|
fileId="file-restoring"
|
||||||
|
currentAsset={{
|
||||||
|
id: 'file-restoring',
|
||||||
|
name: 'restoring-video.mp4',
|
||||||
|
type: 'file',
|
||||||
|
status: 'restoring',
|
||||||
|
version: 1,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</QueryClientProvider>,
|
||||||
|
)
|
||||||
|
|
||||||
|
const archiveIcon = screen.getByTestId('detail-header-restoring-badge')
|
||||||
|
expect(archiveIcon).toBeDefined()
|
||||||
|
expect(screen.queryByText('Restoring...')).toBeNull()
|
||||||
|
expect(screen.queryByText('恢复中...')).toBeNull()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -272,10 +272,16 @@ export function BreadcrumbNav({
|
|||||||
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"
|
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)}
|
onClick={() => setIsFileMenuOpen((prev) => !prev)}
|
||||||
>
|
>
|
||||||
{currentAsset.status === 'archived' && (
|
{(currentAsset.status === 'archived' || currentAsset.status === 'restoring') && (
|
||||||
<span
|
<span
|
||||||
data-testid="detail-header-archived-badge"
|
data-testid={
|
||||||
title={m.archived_status()}
|
currentAsset.status === 'restoring'
|
||||||
|
? 'detail-header-restoring-badge'
|
||||||
|
: 'detail-header-archived-badge'
|
||||||
|
}
|
||||||
|
title={
|
||||||
|
currentAsset.status === 'restoring' ? m.restoring_status() : m.archived_status()
|
||||||
|
}
|
||||||
className="inline-flex items-center shrink-0"
|
className="inline-flex items-center shrink-0"
|
||||||
>
|
>
|
||||||
<Archive className="h-3.5 w-3.5 text-muted-foreground" />
|
<Archive className="h-3.5 w-3.5 text-muted-foreground" />
|
||||||
@@ -297,16 +303,6 @@ export function BreadcrumbNav({
|
|||||||
<span>{m.archiving_status()}</span>
|
<span>{m.archiving_status()}</span>
|
||||||
</Badge>
|
</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
|
<DropdownMenuTrigger
|
||||||
asChild
|
asChild
|
||||||
onClick={(e) => e.stopPropagation()}
|
onClick={(e) => e.stopPropagation()}
|
||||||
|
|||||||
@@ -200,4 +200,20 @@ describe('MobileFileHeader', () => {
|
|||||||
expect(screen.queryByText('Archived')).toBeNull()
|
expect(screen.queryByText('Archived')).toBeNull()
|
||||||
expect(screen.queryByText('已归档')).toBeNull()
|
expect(screen.queryByText('已归档')).toBeNull()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('renders archive icon in front of file name without restoring text when status is restoring', () => {
|
||||||
|
render(
|
||||||
|
<MobileFileHeader
|
||||||
|
fileName="restoring-video.mp4"
|
||||||
|
activeFileId="file-restoring"
|
||||||
|
status="restoring"
|
||||||
|
onBack={vi.fn()}
|
||||||
|
/>,
|
||||||
|
)
|
||||||
|
|
||||||
|
const archiveIcon = screen.getByTestId('detail-header-restoring-badge')
|
||||||
|
expect(archiveIcon).toBeDefined()
|
||||||
|
expect(screen.queryByText('Restoring...')).toBeNull()
|
||||||
|
expect(screen.queryByText('恢复中...')).toBeNull()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -155,10 +155,14 @@ export function MobileFileHeader({
|
|||||||
<DropdownMenu modal={false}>
|
<DropdownMenu modal={false}>
|
||||||
<DropdownMenuTrigger asChild>
|
<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">
|
<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' && (
|
{(status === 'archived' || status === 'restoring') && (
|
||||||
<span
|
<span
|
||||||
data-testid="detail-header-archived-badge"
|
data-testid={
|
||||||
title={m.archived_status()}
|
status === 'restoring'
|
||||||
|
? 'detail-header-restoring-badge'
|
||||||
|
: 'detail-header-archived-badge'
|
||||||
|
}
|
||||||
|
title={status === 'restoring' ? m.restoring_status() : m.archived_status()}
|
||||||
className="inline-flex items-center shrink-0"
|
className="inline-flex items-center shrink-0"
|
||||||
>
|
>
|
||||||
<Archive className="h-3 w-3 text-muted-foreground" />
|
<Archive className="h-3 w-3 text-muted-foreground" />
|
||||||
@@ -194,10 +198,14 @@ export function MobileFileHeader({
|
|||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
) : (
|
) : (
|
||||||
<div className="flex items-center gap-1 min-w-0 truncate">
|
<div className="flex items-center gap-1 min-w-0 truncate">
|
||||||
{status === 'archived' && (
|
{(status === 'archived' || status === 'restoring') && (
|
||||||
<span
|
<span
|
||||||
data-testid="detail-header-archived-badge"
|
data-testid={
|
||||||
title={m.archived_status()}
|
status === 'restoring'
|
||||||
|
? 'detail-header-restoring-badge'
|
||||||
|
: 'detail-header-archived-badge'
|
||||||
|
}
|
||||||
|
title={status === 'restoring' ? m.restoring_status() : m.archived_status()}
|
||||||
className="inline-flex items-center shrink-0"
|
className="inline-flex items-center shrink-0"
|
||||||
>
|
>
|
||||||
<Archive className="h-3 w-3 text-muted-foreground" />
|
<Archive className="h-3 w-3 text-muted-foreground" />
|
||||||
@@ -223,16 +231,6 @@ export function MobileFileHeader({
|
|||||||
<span>{m.archiving_status()}</span>
|
<span>{m.archiving_status()}</span>
|
||||||
</Badge>
|
</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>
|
</div>
|
||||||
|
|
||||||
{/* Prev / Next file navigation buttons */}
|
{/* Prev / Next file navigation buttons */}
|
||||||
|
|||||||
Reference in New Issue
Block a user