Files
shumai/packages/webui/stores/top-nav.ts
T
Yiling-J ba3c6dbfee feat(storage): add archive storage support for assets (#514)
* feat(storage): add archive storage support for assets

* fix(webui): show archive icon in front of file name in breadcrumb bar

* fix(webui): display archive icon in breadcrumbs when restoring

* refactor(transcode): simplify restore asset workflow to single while loop

* docs(configuration): add archive storage documentation and readme entries

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

* fix(webui): fix overflow in manage versions dialog scroll area

* fix(webui): prevent manage versions dialog overflow on long file names

* docs(configuration): fix archive storage environment variables and defaults

* fix(storage): address code review findings for archive storage
2026-11-03 20:31:56 +08:00

82 lines
2.1 KiB
TypeScript

import { create } from 'zustand'
import type { AncestorFolder } from '@shumai/dtos'
export interface TopNavProjectState {
teamId: string
projectId: string
projectName: string
rootFolderId?: string
ancestorFolders: AncestorFolder[]
currentAsset: {
id?: string
name?: string
type: 'file' | 'folder'
version?: number
status?: string
proxyType?: 'image' | 'video' | 'audio' | 'pdf' | '3d' | null
}
isRootFolder: boolean
customTerminalBreadcrumb?: string
fileId?: string
downloadInfo?: {
originalKey?: string
videoTranscodes?: Array<{
key: string
width: number
height: number
resolution?: string
hdr?: boolean
}>
}
versions?: Array<{
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
}>
isPublic?: boolean
shareId?: string
/** When false, the public share hides download affordances. Defaults to true. */
allowDownload?: boolean
onFolderClick?: (folderId: string) => void
onRename?: () => void
onDelete?: () => void
onArchive?: () => void
onRestoreArchive?: () => void
isRightSidebarCollapsed?: boolean
onRightSidebarToggle?: () => void
// Compare Versions
compareMode?: boolean
canCompareVersions?: boolean
onCompareVersions?: () => void
}
interface TopNavStore {
projectState: TopNavProjectState | null
setProjectState: (state: TopNavProjectState | null) => void
clearProjectState: () => void
}
let timeoutId: ReturnType<typeof setTimeout> | null = null
export const useTopNavStore = create<TopNavStore>((set) => ({
projectState: null,
setProjectState: (state) => {
if (timeoutId) {
clearTimeout(timeoutId)
timeoutId = null
}
set({ projectState: state })
},
clearProjectState: () => {
if (timeoutId) clearTimeout(timeoutId)
timeoutId = setTimeout(() => {
set({ projectState: null })
timeoutId = null
}, 10) // Small debounce to prevent flicker during transitions
},
}))