mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-25 23:59:26 +00:00
Merge pull request #14 from shumaiOne/feat/unified-header
feat(ui): unify header bar
This commit is contained in:
@@ -9,10 +9,10 @@ import { useFieldStore } from '@/ui/stores/fields'
|
||||
import { useMemberStore } from '@/ui/stores/members'
|
||||
import { useUiStore } from '@/ui/stores/ui'
|
||||
import { useUserMetadataStore } from '@/ui/stores/user-metadata'
|
||||
import { useTopNavStore } from '@/ui/stores/top-nav'
|
||||
import { useInfiniteQuery, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { useNavigate } from '@tanstack/react-router'
|
||||
import { useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { BreadcrumbNav } from './breadcrumb-nav'
|
||||
import { FileBrowser } from './file-browser/file-browser'
|
||||
import { FileViewerRightSidebar } from './file-viewer-right-sidebar'
|
||||
import { FolderTree } from './folder-tree'
|
||||
@@ -106,13 +106,9 @@ export default function FileSystemManager({
|
||||
fileListRightSidebarCollapsed: isRightSidebarCollapsed,
|
||||
setFileListRightSidebarCollapsed: setIsRightSidebarCollapsed,
|
||||
viewModes,
|
||||
setViewMode,
|
||||
} = useUiStore()
|
||||
|
||||
const displayStyle = viewModes[projectId] ?? 'card'
|
||||
const setDisplayStyle = (style: 'card' | 'list') => {
|
||||
setViewMode(projectId, style)
|
||||
}
|
||||
|
||||
const containerRef = useRef<HTMLDivElement>(null)
|
||||
|
||||
@@ -129,6 +125,40 @@ export default function FileSystemManager({
|
||||
},
|
||||
})
|
||||
|
||||
const { setProjectState, clearProjectState } = useTopNavStore()
|
||||
|
||||
useEffect(() => {
|
||||
setProjectState({
|
||||
teamId,
|
||||
projectId,
|
||||
projectName,
|
||||
ancestorFolders: folderInfo?.ancestorFolders ?? [],
|
||||
currentAsset: isRecentlyDeleted
|
||||
? { name: 'Recently Deleted', type: 'folder' }
|
||||
: { name: folderInfo?.name, type: 'folder' },
|
||||
isRootFolder: !isRecentlyDeleted && assetId === rootFolderId,
|
||||
onFolderClick: (id: string) => {
|
||||
navigate({
|
||||
to: '/projects/$projectId/folders/$folderId',
|
||||
params: { projectId, folderId: id },
|
||||
})
|
||||
},
|
||||
})
|
||||
|
||||
return () => clearProjectState()
|
||||
}, [
|
||||
teamId,
|
||||
projectId,
|
||||
projectName,
|
||||
folderInfo,
|
||||
isRecentlyDeleted,
|
||||
assetId,
|
||||
rootFolderId,
|
||||
setProjectState,
|
||||
clearProjectState,
|
||||
navigate,
|
||||
])
|
||||
|
||||
const {
|
||||
data: foldersData,
|
||||
fetchNextPage: fetchNextFoldersPage,
|
||||
@@ -358,26 +388,7 @@ export default function FileSystemManager({
|
||||
onDragStart={handleDragStart}
|
||||
onDragEnd={handleDragEnd}
|
||||
>
|
||||
<div className="flex h-screen flex-col bg-background">
|
||||
<BreadcrumbNav
|
||||
teamId={teamId}
|
||||
projectId={projectId}
|
||||
projectName={projectName}
|
||||
ancestorFolders={folderInfo?.ancestorFolders ?? []}
|
||||
currentAsset={
|
||||
isRecentlyDeleted
|
||||
? { name: 'Recently Deleted', type: 'folder' }
|
||||
: { name: folderInfo?.name, type: 'folder' }
|
||||
}
|
||||
isRootFolder={assetId === rootFolderId}
|
||||
displayStyle={displayStyle}
|
||||
onDisplayStyleChange={setDisplayStyle}
|
||||
isLeftSidebarCollapsed={isLeftSidebarCollapsed}
|
||||
onLeftSidebarToggle={() => setIsLeftSidebarCollapsed(!isLeftSidebarCollapsed)}
|
||||
isRightSidebarCollapsed={isRightSidebarCollapsed}
|
||||
onRightSidebarToggle={() => setIsRightSidebarCollapsed(!isRightSidebarCollapsed)}
|
||||
/>
|
||||
|
||||
<div className="flex flex-1 flex-col bg-background">
|
||||
<div ref={containerRef} className="flex flex-1 overflow-hidden relative">
|
||||
{!isLeftSidebarCollapsed && (
|
||||
<div
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
'use client'
|
||||
|
||||
import { client } from '@/ui/api/client'
|
||||
import { useTopNavStore } from '@/ui/stores/top-nav'
|
||||
import { useInfiniteQuery, useQuery } from '@tanstack/react-query'
|
||||
import { useEffect, useState, useMemo, useRef } from 'react'
|
||||
import { BreadcrumbNav } from './breadcrumb-nav'
|
||||
import { TopNav } from './top-nav'
|
||||
import { FileBrowser } from './file-browser/file-browser'
|
||||
import { FileViewerRightSidebar } from './file-viewer-right-sidebar'
|
||||
import { ResizeHandle } from './resize-handle'
|
||||
@@ -85,7 +86,7 @@ export function PublicShareManager({
|
||||
|
||||
const [selectedIds, setSelectedIds] = useState<Set<string>>(new Set())
|
||||
const [rightSidebarWidth, setRightSidebarWidth] = useState(360)
|
||||
const [isRightSidebarCollapsed, setIsRightSidebarCollapsed] = useState(false)
|
||||
const [isRightSidebarCollapsed] = useState(false)
|
||||
const videoRef = useRef<Player | null>(null)
|
||||
const [annotations, setAnnotations] = useState<Annotation[]>([])
|
||||
|
||||
@@ -268,9 +269,53 @@ export function PublicShareManager({
|
||||
setAnnotations([])
|
||||
}
|
||||
|
||||
const { setProjectState, clearProjectState } = useTopNavStore()
|
||||
|
||||
useEffect(() => {
|
||||
if (isPasswordValid && !shareInfo.isExpired && !shareInfo.isDisabled) {
|
||||
const currentFolderName =
|
||||
currentFolderId === shareInfo.rootFolderId
|
||||
? shareInfo.name
|
||||
: folders.find((f) => f.id === currentFolderId)?.name || shareInfo.name
|
||||
|
||||
setProjectState({
|
||||
teamId: '', // Public view doesn't have team context
|
||||
projectId: shareInfo.projectId,
|
||||
projectName: shareInfo.name,
|
||||
ancestorFolders: ancestorFolders,
|
||||
currentAsset: {
|
||||
name: viewingFileData?.name || currentFolderName,
|
||||
type: viewingFileId ? 'file' : 'folder',
|
||||
version: viewingFileData?.versionStack
|
||||
? (viewingFileData.versionStack.versions.find((v) => v.id === viewingFileData.id)
|
||||
?.version ?? viewingFileData.versionStack.versions.length)
|
||||
: undefined,
|
||||
},
|
||||
isRootFolder: currentFolderId === shareInfo.rootFolderId && !viewingFileId,
|
||||
isPublic: true,
|
||||
shareId: shareInfo.id,
|
||||
onFolderClick: handleBreadcrumbClick,
|
||||
})
|
||||
}
|
||||
|
||||
return () => clearProjectState()
|
||||
}, [
|
||||
isPasswordValid,
|
||||
shareInfo,
|
||||
currentFolderId,
|
||||
folders,
|
||||
viewingFileData,
|
||||
viewingFileId,
|
||||
ancestorFolders,
|
||||
setProjectState,
|
||||
clearProjectState,
|
||||
])
|
||||
|
||||
let content
|
||||
|
||||
if (shareInfo.isExpired || shareInfo.isDisabled) {
|
||||
return (
|
||||
<div className="flex h-screen items-center justify-center p-4">
|
||||
content = (
|
||||
<div className="flex flex-1 items-center justify-center p-4">
|
||||
<Card className="w-full max-w-md">
|
||||
<CardHeader className="text-center">
|
||||
<div className="mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-destructive/10">
|
||||
@@ -286,11 +331,9 @@ export function PublicShareManager({
|
||||
</Card>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (!isPasswordValid) {
|
||||
return (
|
||||
<div className="flex h-screen items-center justify-center p-4">
|
||||
} else if (!isPasswordValid) {
|
||||
content = (
|
||||
<div className="flex flex-1 items-center justify-center p-4">
|
||||
<Card className="w-full max-w-md">
|
||||
<CardHeader className="text-center">
|
||||
<div className="mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-primary/10">
|
||||
@@ -315,39 +358,8 @@ export function PublicShareManager({
|
||||
</Card>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const currentFolderName =
|
||||
currentFolderId === shareInfo.rootFolderId
|
||||
? shareInfo.name
|
||||
: folders.find((f) => f.id === currentFolderId)?.name || shareInfo.name
|
||||
|
||||
return (
|
||||
<div className="flex h-screen flex-col bg-background">
|
||||
<BreadcrumbNav
|
||||
teamId="" // Public view doesn't have team context
|
||||
projectId={shareInfo.projectId}
|
||||
projectName={shareInfo.name}
|
||||
ancestorFolders={ancestorFolders}
|
||||
currentAsset={{
|
||||
name: viewingFileData?.name || currentFolderName,
|
||||
type: viewingFileId ? 'file' : 'folder',
|
||||
version: viewingFileData?.versionStack
|
||||
? (viewingFileData.versionStack.versions.find((v) => v.id === viewingFileData.id)
|
||||
?.version ?? viewingFileData.versionStack.versions.length)
|
||||
: undefined,
|
||||
}}
|
||||
isRootFolder={currentFolderId === shareInfo.rootFolderId && !viewingFileId}
|
||||
displayStyle="card"
|
||||
onDisplayStyleChange={() => {}}
|
||||
isLeftSidebarCollapsed={true}
|
||||
onLeftSidebarToggle={() => {}}
|
||||
isRightSidebarCollapsed={isRightSidebarCollapsed}
|
||||
onRightSidebarToggle={() => setIsRightSidebarCollapsed(!isRightSidebarCollapsed)}
|
||||
isPublic={true}
|
||||
onFolderClick={handleBreadcrumbClick}
|
||||
/>
|
||||
|
||||
} else {
|
||||
content = (
|
||||
<div className="flex flex-1 overflow-hidden relative">
|
||||
{viewingFileId ? (
|
||||
<div className="flex-1 relative bg-muted/30">
|
||||
@@ -423,6 +435,13 @@ export function PublicShareManager({
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex h-screen flex-col bg-background">
|
||||
<TopNav />
|
||||
{content}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
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,
|
||||
versions,
|
||||
isPublic,
|
||||
shareId,
|
||||
onFolderClick,
|
||||
} = projectState
|
||||
|
||||
const isFileView = !!fileId
|
||||
|
||||
const isLeftSidebarCollapsed = isFileView
|
||||
? uiStore.fileViewLeftSidebarCollapsed
|
||||
: uiStore.fileListLeftSidebarCollapsed
|
||||
const onLeftSidebarToggle = isPublic
|
||||
? undefined
|
||||
: () =>
|
||||
isFileView
|
||||
? uiStore.setFileViewLeftSidebarCollapsed(!uiStore.fileViewLeftSidebarCollapsed)
|
||||
: uiStore.setFileListLeftSidebarCollapsed(!uiStore.fileListLeftSidebarCollapsed)
|
||||
|
||||
const isRightSidebarCollapsed = isFileView
|
||||
? uiStore.fileViewRightSidebarCollapsed
|
||||
: uiStore.fileListRightSidebarCollapsed
|
||||
const onRightSidebarToggle = () =>
|
||||
isFileView
|
||||
? uiStore.setFileViewRightSidebarCollapsed(!uiStore.fileViewRightSidebarCollapsed)
|
||||
: 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 ? undefined : displayStyle}
|
||||
onDisplayStyleChange={isFileView ? undefined : onDisplayStyleChange}
|
||||
isLeftSidebarCollapsed={isLeftSidebarCollapsed}
|
||||
onLeftSidebarToggle={onLeftSidebarToggle}
|
||||
isRightSidebarCollapsed={isRightSidebarCollapsed}
|
||||
onRightSidebarToggle={onRightSidebarToggle}
|
||||
isPublic={isPublic}
|
||||
shareId={shareId}
|
||||
fileId={fileId}
|
||||
versions={versions}
|
||||
onFolderClick={onFolderClick}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
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>
|
||||
)
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
} from '@tanstack/react-router'
|
||||
import { HomeIcon } from 'lucide-react'
|
||||
import { useEffect } from 'react'
|
||||
import { TopNav } from '@/ui/components/top-nav'
|
||||
|
||||
function RootComponent() {
|
||||
const user = useAuthStore((state) => state.user)
|
||||
@@ -47,7 +48,7 @@ function RootComponent() {
|
||||
}, [teamId, projectId, setTeamId, ensureTeamIdForProject])
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="flex h-screen w-full bg-background overflow-hidden">
|
||||
<Toaster />
|
||||
<DualSidebar>
|
||||
<DualSidebarItem
|
||||
@@ -77,10 +78,13 @@ function RootComponent() {
|
||||
<UploadTasks />
|
||||
</DualSidebarItem>
|
||||
</DualSidebar>
|
||||
<main className="md:pl-16">
|
||||
<Outlet />
|
||||
</main>
|
||||
</>
|
||||
<div className="flex flex-col flex-1 md:pl-16 overflow-hidden relative">
|
||||
<TopNav />
|
||||
<main className="flex-1 overflow-y-auto overflow-x-hidden relative flex flex-col">
|
||||
<Outlet />
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { InferRequestType, InferResponseType } from 'hono/client'
|
||||
import { useMutation } from '@tanstack/react-query'
|
||||
import { client } from '@/ui/api/client'
|
||||
import { BreadcrumbNav } from '@/ui/components/breadcrumb-nav'
|
||||
import { FileViewer } from '@/ui/components/file-viewer'
|
||||
import { FileViewerLeftSidebar } from '@/ui/components/file-viewer-left-sidebar'
|
||||
import { FileViewerRightSidebar } from '@/ui/components/file-viewer-right-sidebar'
|
||||
@@ -9,10 +8,11 @@ import { ResizeHandle } from '@/ui/components/resize-handle'
|
||||
import { useMemberStore } from '@/ui/stores/members'
|
||||
import { useTeamContextStore } from '@/ui/stores/team-context'
|
||||
import { useUiStore } from '@/ui/stores/ui'
|
||||
import { useTopNavStore } from '@/ui/stores/top-nav'
|
||||
import { type Annotation } from '@/ui/types'
|
||||
|
||||
import { keepPreviousData, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { createFileRoute } from '@tanstack/react-router'
|
||||
import { createFileRoute, useNavigate } from '@tanstack/react-router'
|
||||
import { Loader2 } from 'lucide-react'
|
||||
import { useEffect, useState, useRef } from 'react'
|
||||
import type { CommentInfo, AssetInfo } from '@/dtos/asset'
|
||||
@@ -27,7 +27,6 @@ function FileViewPage() {
|
||||
const videoRef = useRef<Player | null>(null)
|
||||
const {
|
||||
fileViewRightSidebarCollapsed: isRightSidebarCollapsed,
|
||||
setFileViewRightSidebarCollapsed: setIsRightSidebarCollapsed,
|
||||
fileViewLeftSidebarCollapsed: isLeftSidebarCollapsed,
|
||||
setFileViewLeftSidebarCollapsed: setIsLeftSidebarCollapsed,
|
||||
} = useUiStore()
|
||||
@@ -119,12 +118,56 @@ function FileViewPage() {
|
||||
},
|
||||
})
|
||||
|
||||
const navigate = useNavigate()
|
||||
const { setProjectState, clearProjectState } = useTopNavStore()
|
||||
|
||||
const isLoading = isStackLoading || (!!versionAssetId && isVersionLoading)
|
||||
const isError = isStackError || (!!versionAssetId && isVersionError)
|
||||
const isFetching = isStackFetching || (!!versionAssetId && isVersionFetching)
|
||||
const fileData = versionData || stackData
|
||||
const versionsDataList = versionAssetId ? versionsList : stackData?.versionStack?.versions
|
||||
|
||||
useEffect(() => {
|
||||
if (fileData && projectInfo && teamId) {
|
||||
setProjectState({
|
||||
teamId,
|
||||
projectId,
|
||||
projectName: projectInfo.name ?? '',
|
||||
ancestorFolders: fileData.ancestorFolders ?? [],
|
||||
currentAsset: {
|
||||
name: fileData.name,
|
||||
type: 'file',
|
||||
version: versionsDataList
|
||||
? (versionsDataList.find((v: { id: string }) => v.id === activeFileId)?.version ??
|
||||
versionsDataList.length)
|
||||
: undefined,
|
||||
},
|
||||
isRootFolder: false,
|
||||
fileId,
|
||||
versions: versionsDataList,
|
||||
onFolderClick: (id: string) => {
|
||||
navigate({
|
||||
to: '/projects/$projectId/folders/$folderId',
|
||||
params: { projectId, folderId: id },
|
||||
})
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
return () => clearProjectState()
|
||||
}, [
|
||||
teamId,
|
||||
projectId,
|
||||
projectInfo,
|
||||
fileData,
|
||||
versionsDataList,
|
||||
activeFileId,
|
||||
fileId,
|
||||
setProjectState,
|
||||
clearProjectState,
|
||||
navigate,
|
||||
])
|
||||
|
||||
if (isLoading && !fileData) {
|
||||
return <div>Loading...</div>
|
||||
}
|
||||
@@ -167,28 +210,7 @@ function FileViewPage() {
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex h-screen flex-col bg-background">
|
||||
<BreadcrumbNav
|
||||
teamId={teamId}
|
||||
projectId={projectId}
|
||||
projectName={projectInfo.name ?? ''}
|
||||
ancestorFolders={fileData.ancestorFolders ?? []}
|
||||
currentAsset={{
|
||||
name: fileData.name,
|
||||
type: 'file',
|
||||
version: versionsDataList
|
||||
? (versionsDataList.find((v) => v.id === activeFileId)?.version ??
|
||||
versionsDataList.length)
|
||||
: undefined,
|
||||
}}
|
||||
isRootFolder={false}
|
||||
isLeftSidebarCollapsed={isLeftSidebarCollapsed}
|
||||
onLeftSidebarToggle={() => setIsLeftSidebarCollapsed(!isLeftSidebarCollapsed)}
|
||||
isRightSidebarCollapsed={isRightSidebarCollapsed}
|
||||
onRightSidebarToggle={() => setIsRightSidebarCollapsed(!isRightSidebarCollapsed)}
|
||||
fileId={fileId}
|
||||
versions={versionsDataList}
|
||||
/>
|
||||
<div className="flex flex-1 flex-col bg-background">
|
||||
<div className="flex flex-1 overflow-hidden">
|
||||
{!isLeftSidebarCollapsed && (
|
||||
<>
|
||||
|
||||
@@ -205,180 +205,171 @@ function TeamPage() {
|
||||
const safeMembers = Array.isArray(members) ? members : []
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="flex h-14 flex-wrap items-center justify-center gap-2 border-b border-border bg-card px-4 py-2">
|
||||
<ShumaiLogo className="w-10 h-10 text-orange-600" />
|
||||
</div>
|
||||
<div className="p-4">
|
||||
<div className="flex flex-wrap items-center justify-between mb-4 gap-4">
|
||||
<h1 className="text-2xl font-bold">Projects</h1>
|
||||
<div className="flex flex-wrap items-center gap-4">
|
||||
<div
|
||||
className="flex items-center -space-x-2 cursor-pointer hover:opacity-90"
|
||||
onClick={() => setIsMembersDialogOpen(true)}
|
||||
>
|
||||
{safeMembers.slice(0, 3).map((member) => (
|
||||
<Avatar key={member.id} className="border-2 border-background w-8 h-8">
|
||||
<AvatarFallback className="text-[10px]">
|
||||
{getInitials(member.name)}
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
))}
|
||||
{safeMembers.length > 3 && (
|
||||
<div className="flex items-center justify-center w-8 h-8 rounded-full border-2 border-background bg-muted text-[10px] font-medium">
|
||||
+{safeMembers.length - 3}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<SortDropdown
|
||||
sortBy={sortBy}
|
||||
sortDirection={sortDirection}
|
||||
onSortChange={handleSortChange}
|
||||
/>
|
||||
<Button
|
||||
className="bg-orange-600 hover:bg-orange-700 text-white gap-2"
|
||||
onClick={handleCreateProjectClick}
|
||||
>
|
||||
<PlusIcon className="w-4 h-4" />
|
||||
Create Project
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="grid grid-cols-1 sm:grid-cols-3 md:grid-cols-5 lg:grid-cols-7 gap-4">
|
||||
{projects.data?.map((project: ProjectInfo) => (
|
||||
<div
|
||||
key={project.id}
|
||||
className={cn(
|
||||
'shadow-md relative border rounded-xl overflow-hidden cursor-pointer transition-transform duration-100 ease-in-out',
|
||||
clickedProjectId === project.id ? 'scale-95' : 'scale-100',
|
||||
)}
|
||||
onClick={(e) => handleCardClick(project.id!, e)}
|
||||
>
|
||||
<div className="flex flex-col">
|
||||
<div className="relative w-full h-full aspect-square flex items-center justify-center bg-zinc-400/20">
|
||||
{project.coverImage ? (
|
||||
<img
|
||||
src={project.coverImage}
|
||||
alt={project.name}
|
||||
className="w-full h-full object-cover rounded"
|
||||
/>
|
||||
) : (
|
||||
<div className="text-center text-muted-foreground font-bold tracking-wider z-10">
|
||||
<ShumaiLogo className="w-8 h-8 text-zinc-400" />
|
||||
</div>
|
||||
)}
|
||||
<div className="absolute bottom-0 left-0 w-full h-[65%] bg-linear-to-t from-black/35 to-black/0" />
|
||||
<p className="absolute left-1 bottom-2 text-white">{project.name}</p>
|
||||
</div>
|
||||
<div className="px-2 h-10 flex justify-between items-center">
|
||||
<p className="truncate pr-1 text-xs text-muted-foreground">
|
||||
Updated {formatDateAgo((project.updatedAt as string) ?? '')}
|
||||
</p>
|
||||
<div onClick={(e) => e.stopPropagation()}>
|
||||
<DropdownMenu modal={false}>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<button className="hover:bg-muted outline-none flex px-1">
|
||||
<MoreHorizontal className="w-5 h-5 text-muted-foreground" />
|
||||
</button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end">
|
||||
<DropdownMenuItem
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
handleEditProjectClick(project)
|
||||
}}
|
||||
>
|
||||
Project Settings
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem
|
||||
className="text-destructive focus:text-destructive"
|
||||
onClick={() => handleDeleteProjectClick(project)}
|
||||
>
|
||||
Delete
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
<div className="p-4">
|
||||
<div className="flex flex-wrap items-center justify-between mb-4 gap-4">
|
||||
<h1 className="text-2xl font-bold">Projects</h1>
|
||||
<div className="flex flex-wrap items-center gap-4">
|
||||
<div
|
||||
className={cn(
|
||||
'shadow-md relative border rounded-xl overflow-hidden cursor-pointer transition-transform duration-100 ease-in-out border-dashed hover:border-orange-600/50 group',
|
||||
clickedProjectId === 'create' ? 'scale-95' : 'scale-100',
|
||||
className="flex items-center -space-x-2 cursor-pointer hover:opacity-90"
|
||||
onClick={() => setIsMembersDialogOpen(true)}
|
||||
>
|
||||
{safeMembers.slice(0, 3).map((member) => (
|
||||
<Avatar key={member.id} className="border-2 border-background w-8 h-8">
|
||||
<AvatarFallback className="text-[10px]">{getInitials(member.name)}</AvatarFallback>
|
||||
</Avatar>
|
||||
))}
|
||||
{safeMembers.length > 3 && (
|
||||
<div className="flex items-center justify-center w-8 h-8 rounded-full border-2 border-background bg-muted text-[10px] font-medium">
|
||||
+{safeMembers.length - 3}
|
||||
</div>
|
||||
)}
|
||||
onClick={handleCreateCardClick}
|
||||
</div>
|
||||
<SortDropdown
|
||||
sortBy={sortBy}
|
||||
sortDirection={sortDirection}
|
||||
onSortChange={handleSortChange}
|
||||
/>
|
||||
<Button
|
||||
className="bg-orange-600 hover:bg-orange-700 text-white gap-2"
|
||||
onClick={handleCreateProjectClick}
|
||||
>
|
||||
<PlusIcon className="w-4 h-4" />
|
||||
Create Project
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="grid grid-cols-1 sm:grid-cols-3 md:grid-cols-5 lg:grid-cols-7 gap-4">
|
||||
{projects.data?.map((project: ProjectInfo) => (
|
||||
<div
|
||||
key={project.id}
|
||||
className={cn(
|
||||
'shadow-md relative border rounded-xl overflow-hidden cursor-pointer transition-transform duration-100 ease-in-out',
|
||||
clickedProjectId === project.id ? 'scale-95' : 'scale-100',
|
||||
)}
|
||||
onClick={(e) => handleCardClick(project.id!, e)}
|
||||
>
|
||||
<div className="flex flex-col">
|
||||
<div className="relative w-full aspect-square flex items-center justify-center bg-zinc-400/5 group-hover:bg-orange-600/5 transition-colors">
|
||||
<PlusIcon className="w-8 h-8 text-zinc-400 group-hover:text-orange-600 transition-colors" />
|
||||
<div className="relative w-full h-full aspect-square flex items-center justify-center bg-zinc-400/20">
|
||||
{project.coverImage ? (
|
||||
<img
|
||||
src={project.coverImage}
|
||||
alt={project.name}
|
||||
className="w-full h-full object-cover rounded"
|
||||
/>
|
||||
) : (
|
||||
<div className="text-center text-muted-foreground font-bold tracking-wider z-10">
|
||||
<ShumaiLogo className="w-8 h-8 text-zinc-400" />
|
||||
</div>
|
||||
)}
|
||||
<div className="absolute bottom-0 left-0 w-full h-[65%] bg-linear-to-t from-black/35 to-black/0" />
|
||||
<p className="absolute left-1 bottom-2 text-white">{project.name}</p>
|
||||
</div>
|
||||
<div className="px-2 h-10 flex items-center justify-center bg-zinc-400/10 border-t group-hover:bg-orange-600/10 transition-colors">
|
||||
<p className="text-sm text-muted-foreground group-hover:text-orange-600 transition-colors">
|
||||
Create Project
|
||||
<div className="px-2 h-10 flex justify-between items-center">
|
||||
<p className="truncate pr-1 text-xs text-muted-foreground">
|
||||
Updated {formatDateAgo((project.updatedAt as string) ?? '')}
|
||||
</p>
|
||||
<div onClick={(e) => e.stopPropagation()}>
|
||||
<DropdownMenu modal={false}>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<button className="hover:bg-muted outline-none flex px-1">
|
||||
<MoreHorizontal className="w-5 h-5 text-muted-foreground" />
|
||||
</button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end">
|
||||
<DropdownMenuItem
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
handleEditProjectClick(project)
|
||||
}}
|
||||
>
|
||||
Project Settings
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem
|
||||
className="text-destructive focus:text-destructive"
|
||||
onClick={() => handleDeleteProjectClick(project)}
|
||||
>
|
||||
Delete
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
<div
|
||||
className={cn(
|
||||
'shadow-md relative border rounded-xl overflow-hidden cursor-pointer transition-transform duration-100 ease-in-out border-dashed hover:border-orange-600/50 group',
|
||||
clickedProjectId === 'create' ? 'scale-95' : 'scale-100',
|
||||
)}
|
||||
onClick={handleCreateCardClick}
|
||||
>
|
||||
<div className="flex flex-col">
|
||||
<div className="relative w-full aspect-square flex items-center justify-center bg-zinc-400/5 group-hover:bg-orange-600/5 transition-colors">
|
||||
<PlusIcon className="w-8 h-8 text-zinc-400 group-hover:text-orange-600 transition-colors" />
|
||||
</div>
|
||||
<div className="px-2 h-10 flex items-center justify-center bg-zinc-400/10 border-t group-hover:bg-orange-600/10 transition-colors">
|
||||
<p className="text-sm text-muted-foreground group-hover:text-orange-600 transition-colors">
|
||||
Create Project
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ProjectDialog
|
||||
open={isProjectDialogOpen}
|
||||
onOpenChange={setIsProjectDialogOpen}
|
||||
mode={projectDialogMode}
|
||||
teamId={teamId}
|
||||
project={selectedProject}
|
||||
/>
|
||||
|
||||
<AlertDialog open={isDeleteDialogOpen} onOpenChange={setIsDeleteDialogOpen}>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>Are you absolutely sure?</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
This action cannot be undone. This will permanently delete the project "
|
||||
{projectToDelete?.name}" and all its assets.
|
||||
<div className="mt-4 flex flex-col gap-2 text-foreground">
|
||||
<span className="text-sm font-medium">
|
||||
Type <strong>delete</strong> to confirm:
|
||||
</span>
|
||||
<Input
|
||||
value={deleteConfirmText}
|
||||
onChange={(e) => setDeleteConfirmText(e.target.value)}
|
||||
placeholder="delete"
|
||||
className="h-9"
|
||||
autoFocus
|
||||
/>
|
||||
</div>
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel disabled={deleteProjectMutation.isPending}>
|
||||
Cancel
|
||||
</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
onClick={(e) => {
|
||||
e.preventDefault()
|
||||
handleConfirmDelete()
|
||||
}}
|
||||
disabled={deleteConfirmText !== 'delete' || deleteProjectMutation.isPending}
|
||||
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
|
||||
>
|
||||
{deleteProjectMutation.isPending ? 'Deleting...' : 'Delete'}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
|
||||
<MembersDialog
|
||||
open={isMembersDialogOpen}
|
||||
onOpenChange={setIsMembersDialogOpen}
|
||||
title="Team Members"
|
||||
members={safeMembers}
|
||||
isOwner={me?.role === 'owner'}
|
||||
onInvite={handleInvite}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<ProjectDialog
|
||||
open={isProjectDialogOpen}
|
||||
onOpenChange={setIsProjectDialogOpen}
|
||||
mode={projectDialogMode}
|
||||
teamId={teamId}
|
||||
project={selectedProject}
|
||||
/>
|
||||
|
||||
<AlertDialog open={isDeleteDialogOpen} onOpenChange={setIsDeleteDialogOpen}>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>Are you absolutely sure?</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
This action cannot be undone. This will permanently delete the project "
|
||||
{projectToDelete?.name}" and all its assets.
|
||||
<div className="mt-4 flex flex-col gap-2 text-foreground">
|
||||
<span className="text-sm font-medium">
|
||||
Type <strong>delete</strong> to confirm:
|
||||
</span>
|
||||
<Input
|
||||
value={deleteConfirmText}
|
||||
onChange={(e) => setDeleteConfirmText(e.target.value)}
|
||||
placeholder="delete"
|
||||
className="h-9"
|
||||
autoFocus
|
||||
/>
|
||||
</div>
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel disabled={deleteProjectMutation.isPending}>Cancel</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
onClick={(e) => {
|
||||
e.preventDefault()
|
||||
handleConfirmDelete()
|
||||
}}
|
||||
disabled={deleteConfirmText !== 'delete' || deleteProjectMutation.isPending}
|
||||
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
|
||||
>
|
||||
{deleteProjectMutation.isPending ? 'Deleting...' : 'Delete'}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
|
||||
<MembersDialog
|
||||
open={isMembersDialogOpen}
|
||||
onOpenChange={setIsMembersDialogOpen}
|
||||
title="Team Members"
|
||||
members={safeMembers}
|
||||
isOwner={me?.role === 'owner'}
|
||||
onInvite={handleInvite}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
import { ImageTranscodeStrategy, VideoTranscodeStrategy } from '@/dtos/team'
|
||||
import { client } from '@/ui/api/client'
|
||||
import { VideoTranscodeStrategy, ImageTranscodeStrategy } from '@/dtos/team'
|
||||
import { AgentsSettings } from '@/ui/components/settings/AgentsSettings'
|
||||
import { ProvidersSettings } from '@/ui/components/settings/ProvidersSettings'
|
||||
import { SandboxSettings } from '@/ui/components/settings/SandboxSettings'
|
||||
import { SkillsConfigCard } from '@/ui/components/settings/SkillsConfigCard'
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/ui/components/ui/card'
|
||||
import { Switch } from '@/ui/components/ui/switch'
|
||||
import { useQueryClient, useQuery, useMutation } from '@tanstack/react-query'
|
||||
import { createFileRoute } from '@tanstack/react-router'
|
||||
import { Loader2, User, Film, Cpu, Puzzle } from 'lucide-react'
|
||||
import { cn } from '@/ui/lib/utils'
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { createFileRoute } from '@tanstack/react-router'
|
||||
import { Bot, Cpu, Film, Loader2, Puzzle, Shield, User } from 'lucide-react'
|
||||
import { useState } from 'react'
|
||||
import { ProvidersSettings } from '@/ui/components/settings/ProvidersSettings'
|
||||
import { SkillsConfigCard } from '@/ui/components/settings/SkillsConfigCard'
|
||||
import { AgentsSettings } from '@/ui/components/settings/AgentsSettings'
|
||||
import { SandboxSettings } from '@/ui/components/settings/SandboxSettings'
|
||||
import { Bot, Shield } from 'lucide-react'
|
||||
|
||||
type SettingsTab = 'general' | 'transcode' | 'skills' | 'providers' | 'agents' | 'sandbox'
|
||||
|
||||
@@ -105,10 +104,10 @@ function TeamSettingsPage() {
|
||||
(settings as any)?.transcode?.imageStrategy || ImageTranscodeStrategy.single
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-slate-50 dark:bg-slate-950 font-sans selection:bg-blue-100 dark:selection:bg-blue-900 transition-colors duration-300">
|
||||
<div className="flex flex-col md:flex-row min-h-screen">
|
||||
<div className="h-full bg-slate-50 dark:bg-slate-950 font-sans selection:bg-blue-100 dark:selection:bg-blue-900 transition-colors duration-300">
|
||||
<div className="flex flex-col md:flex-row h-full">
|
||||
{/* Sidebar */}
|
||||
<aside className="w-full md:w-72 bg-white dark:bg-slate-900 border-b md:border-b-0 md:border-r border-slate-200 dark:border-slate-800 flex-shrink-0 z-10 md:fixed md:inset-y-0 md:left-16 overflow-y-auto transition-colors duration-300">
|
||||
<div className="w-full h-full md:w-72 bg-white dark:bg-slate-900 border-b md:border-b-0 md:border-r border-slate-200 dark:border-slate-800 z-10 md:left-16 overflow-y-auto transition-colors duration-300">
|
||||
<nav className="p-4 space-y-1 mt-4">
|
||||
<div className="mb-2 px-4 text-xs font-semibold text-slate-400 dark:text-slate-500 uppercase tracking-wider">
|
||||
Settings
|
||||
@@ -214,10 +213,10 @@ function TeamSettingsPage() {
|
||||
)}
|
||||
</button>
|
||||
</nav>
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
{/* Main Content Area */}
|
||||
<main className="flex-1 bg-slate-50/50 dark:bg-slate-950 md:ml-72 h-screen flex flex-col transition-colors duration-300 overflow-hidden">
|
||||
<main className="flex-1 bg-slate-50/50 dark:bg-slate-950 h-full flex flex-col transition-colors duration-300 overflow-y-hidden">
|
||||
<div className="flex-1 flex flex-col max-w-4xl w-full mx-auto p-6 md:p-10 overflow-hidden">
|
||||
<div className="flex-none flex items-center justify-between mb-6">
|
||||
<div>
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
import { create } from 'zustand'
|
||||
import type { AncestorFolder } from '@/dtos/asset'
|
||||
|
||||
export interface TopNavProjectState {
|
||||
teamId: string
|
||||
projectId: string
|
||||
projectName: string
|
||||
ancestorFolders: AncestorFolder[]
|
||||
currentAsset: {
|
||||
name?: string
|
||||
type: 'file' | 'folder'
|
||||
version?: number
|
||||
}
|
||||
isRootFolder: boolean
|
||||
fileId?: string
|
||||
versions?: Array<{
|
||||
id: string
|
||||
version: number
|
||||
name?: string | null
|
||||
previewUrl?: string | null
|
||||
creator?: { id: string; name: string | null } | null
|
||||
}>
|
||||
isPublic?: boolean
|
||||
shareId?: string
|
||||
onFolderClick?: (folderId: string) => 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
|
||||
},
|
||||
}))
|
||||
Reference in New Issue
Block a user