mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-23 20:58:44 +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('已归档')).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"
|
||||
onClick={() => setIsFileMenuOpen((prev) => !prev)}
|
||||
>
|
||||
{currentAsset.status === 'archived' && (
|
||||
{(currentAsset.status === 'archived' || currentAsset.status === 'restoring') && (
|
||||
<span
|
||||
data-testid="detail-header-archived-badge"
|
||||
title={m.archived_status()}
|
||||
data-testid={
|
||||
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"
|
||||
>
|
||||
<Archive className="h-3.5 w-3.5 text-muted-foreground" />
|
||||
@@ -297,16 +303,6 @@ export function BreadcrumbNav({
|
||||
<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()}
|
||||
|
||||
@@ -200,4 +200,20 @@ describe('MobileFileHeader', () => {
|
||||
expect(screen.queryByText('Archived')).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}>
|
||||
<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' && (
|
||||
{(status === 'archived' || status === 'restoring') && (
|
||||
<span
|
||||
data-testid="detail-header-archived-badge"
|
||||
title={m.archived_status()}
|
||||
data-testid={
|
||||
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"
|
||||
>
|
||||
<Archive className="h-3 w-3 text-muted-foreground" />
|
||||
@@ -194,10 +198,14 @@ export function MobileFileHeader({
|
||||
</DropdownMenu>
|
||||
) : (
|
||||
<div className="flex items-center gap-1 min-w-0 truncate">
|
||||
{status === 'archived' && (
|
||||
{(status === 'archived' || status === 'restoring') && (
|
||||
<span
|
||||
data-testid="detail-header-archived-badge"
|
||||
title={m.archived_status()}
|
||||
data-testid={
|
||||
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"
|
||||
>
|
||||
<Archive className="h-3 w-3 text-muted-foreground" />
|
||||
@@ -223,16 +231,6 @@ export function MobileFileHeader({
|
||||
<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 */}
|
||||
|
||||
Reference in New Issue
Block a user