mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-24 01:47:36 +00:00
Add a Compare Versions mode to the file detail page (authenticated and public share) that splits the viewer into two 50/50 panes showing two versions side by side. - Breadcrumb file menu gains a Compare Versions entry (version stacks with >=2 versions); the file segment is hidden in compare mode. - URL-driven state (compare/cmpLeft/cmpRight/cmpActive) on both file routes so the view is refresh/share-safe. - Per-side topbar with filename, version, version-switch dropdown, an active-side highlight, and an X exit button. - Shared control bar reflects the active pane; for same-type media it coordinates both panes (play/pause, seek, frame-step, zoom, pan sync), seekbar length matches the active side while the shorter side holds its last frame; only the active side plays audio; resolution/download apply to the active side; fullscreen covers the whole compare view. - Right sidebar (comments/fields) binds to the active side; comment selection seeks the active pane and annotations/comments can be created. - Reuses useFramePlayer + DrawingCanvas without modifying the existing single-file video player. - Unit tests for compare selection/clamp logic.
111 lines
3.5 KiB
TypeScript
111 lines
3.5 KiB
TypeScript
import { useTopNavStore } from '@/ui/stores/top-nav'
|
|
import { BreadcrumbNav } from './breadcrumb-nav'
|
|
import { ShumaiLogo } from '@/ui/components/ui/icons'
|
|
import { useUiStore } from '@/ui/stores/ui'
|
|
|
|
export function TopNav() {
|
|
const { projectState } = useTopNavStore()
|
|
const uiStore = useUiStore()
|
|
|
|
if (!projectState) {
|
|
return <TeamHeader />
|
|
}
|
|
|
|
const {
|
|
teamId,
|
|
projectId,
|
|
projectName,
|
|
ancestorFolders,
|
|
currentAsset,
|
|
isRootFolder,
|
|
fileId,
|
|
downloadInfo,
|
|
versions,
|
|
isPublic,
|
|
shareId,
|
|
onFolderClick,
|
|
compareMode,
|
|
canCompareVersions,
|
|
onCompareVersions,
|
|
} = projectState
|
|
|
|
const isFileView = !!fileId
|
|
|
|
const isShareConfig = !!shareId && !isFileView
|
|
|
|
const isLeftSidebarCollapsed = isFileView
|
|
? uiStore.fileViewLeftSidebarCollapsed
|
|
: isShareConfig
|
|
? uiStore.shareConfigLeftSidebarCollapsed
|
|
: uiStore.fileListLeftSidebarCollapsed
|
|
const onLeftSidebarToggle = isPublic
|
|
? undefined
|
|
: () =>
|
|
isFileView
|
|
? uiStore.setFileViewLeftSidebarCollapsed(!uiStore.fileViewLeftSidebarCollapsed)
|
|
: isShareConfig
|
|
? uiStore.setShareConfigLeftSidebarCollapsed(!uiStore.shareConfigLeftSidebarCollapsed)
|
|
: uiStore.setFileListLeftSidebarCollapsed(!uiStore.fileListLeftSidebarCollapsed)
|
|
|
|
const isRightSidebarCollapsed =
|
|
isPublic && projectState.isRightSidebarCollapsed !== undefined
|
|
? projectState.isRightSidebarCollapsed
|
|
: isFileView
|
|
? uiStore.fileViewRightSidebarCollapsed
|
|
: isShareConfig
|
|
? uiStore.shareConfigRightSidebarCollapsed
|
|
: uiStore.fileListRightSidebarCollapsed
|
|
const onRightSidebarToggle =
|
|
isPublic && projectState.onRightSidebarToggle
|
|
? projectState.onRightSidebarToggle
|
|
: () =>
|
|
isFileView
|
|
? uiStore.setFileViewRightSidebarCollapsed(!uiStore.fileViewRightSidebarCollapsed)
|
|
: isShareConfig
|
|
? uiStore.setShareConfigRightSidebarCollapsed(
|
|
!uiStore.shareConfigRightSidebarCollapsed,
|
|
)
|
|
: uiStore.setFileListRightSidebarCollapsed(!uiStore.fileListRightSidebarCollapsed)
|
|
|
|
const displayStyle = projectId ? (uiStore.viewModes[projectId] ?? 'card') : 'card'
|
|
const onDisplayStyleChange = isPublic
|
|
? undefined
|
|
: (style: 'card' | 'list') => {
|
|
if (projectId) uiStore.setViewMode(projectId, style)
|
|
}
|
|
|
|
return (
|
|
<BreadcrumbNav
|
|
teamId={teamId}
|
|
projectId={projectId}
|
|
projectName={projectName}
|
|
ancestorFolders={ancestorFolders}
|
|
currentAsset={currentAsset}
|
|
isRootFolder={isRootFolder}
|
|
displayStyle={isFileView || isShareConfig ? undefined : displayStyle}
|
|
onDisplayStyleChange={isFileView || isShareConfig ? undefined : onDisplayStyleChange}
|
|
isLeftSidebarCollapsed={isLeftSidebarCollapsed}
|
|
onLeftSidebarToggle={onLeftSidebarToggle}
|
|
isRightSidebarCollapsed={isRightSidebarCollapsed}
|
|
onRightSidebarToggle={onRightSidebarToggle}
|
|
isPublic={isPublic}
|
|
shareId={shareId}
|
|
fileId={fileId}
|
|
downloadInfo={downloadInfo}
|
|
versions={versions}
|
|
onFolderClick={onFolderClick}
|
|
compareMode={compareMode}
|
|
canCompareVersions={canCompareVersions}
|
|
onCompareVersions={onCompareVersions}
|
|
/>
|
|
)
|
|
}
|
|
|
|
function TeamHeader() {
|
|
return (
|
|
<div className="flex h-14 flex-wrap items-center justify-center gap-2 border-b border-border bg-card px-4 py-2 flex-shrink-0">
|
|
<ShumaiLogo className="w-10 h-10 text-orange-600" />
|
|
</div>
|
|
)
|
|
}
|