feat(collection): support source folder and selector in collections

This commit is contained in:
yiling
2026-05-25 20:26:03 +08:00
parent 00dc7f7bda
commit 5037b27d81
10 changed files with 238 additions and 131 deletions
+74 -67
View File
@@ -11,7 +11,6 @@ import {
Loader2,
Trash2,
Plus,
MoreHorizontal,
Share2,
LayoutGrid,
Bookmark,
@@ -32,6 +31,8 @@ interface FolderTreeProps {
dragState?: DragState
onSelect?: (folder: AssetInfo) => void
selectedFolderId?: string
hideCollections?: boolean
hideShares?: boolean
}
export function FolderTree({
@@ -42,6 +43,8 @@ export function FolderTree({
dragState,
onSelect,
selectedFolderId,
hideCollections,
hideShares,
}: FolderTreeProps) {
const navigate = useNavigate()
const queryClient = useQueryClient()
@@ -83,8 +86,11 @@ export function FolderTree({
json: {
name: 'Untitled Collection',
filter: {
conditions: [],
recursively: true,
sourceFolderId: rootFolderId,
searchFilter: {
conditions: [],
recursively: true,
},
},
},
})
@@ -186,78 +192,79 @@ export function FolderTree({
</div>
</div>
<div>
<header className="flex items-center justify-between px-2 mb-1">
<h3 className="text-xs font-semibold text-muted-foreground uppercase tracking-wider">
Collections
</h3>
<button
onClick={() => createCollection()}
className="text-muted-foreground hover:text-foreground"
>
<Plus className="h-3.5 w-3.5" />
</button>
</header>
<div className="space-y-0.5">
{collectionsData?.data.map((collection) => (
<div
key={collection.id}
className="group flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-sm transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"
onClick={() =>
navigate({
to: '/projects/$projectId/collections/$collectionId',
params: { projectId, collectionId: collection.id },
})
}
>
<div className="flex h-4 w-4 items-center justify-center">
<Bookmark className="h-4 w-4 text-sidebar-primary" />
</div>
<span className="flex-1 truncate text-sidebar-foreground">{collection.name}</span>
</div>
))}
</div>
</div>
<div>
<header className="flex items-center justify-between px-2 mb-1">
<h3 className="text-xs font-semibold text-muted-foreground uppercase tracking-wider">
Share Links
</h3>
<div className="flex items-center gap-1">
<button className="text-muted-foreground hover:text-foreground">
<MoreHorizontal className="h-3.5 w-3.5" />
</button>
{!hideCollections && (
<div>
<header className="flex items-center justify-between px-2 mb-1">
<h3 className="text-xs font-semibold text-muted-foreground uppercase tracking-wider">
Collections
</h3>
<button
onClick={() => createShareLink()}
onClick={() => createCollection()}
className="text-muted-foreground hover:text-foreground"
>
<Plus className="h-3.5 w-3.5" />
</button>
</div>
</header>
</header>
<div className="space-y-0.5">
<div className="group flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-sm transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground">
<div className="flex h-4 w-4 items-center justify-center">
<LayoutGrid className="h-4 w-4 text-sidebar-primary" />
</div>
<span className="flex-1 truncate text-sidebar-foreground">
All Share Links ({shareLinks.length})
</span>
<div className="space-y-0.5">
{collectionsData?.data.map((collection) => (
<div
key={collection.id}
className="group flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-sm transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"
onClick={() =>
navigate({
to: '/projects/$projectId/collections/$collectionId',
params: { projectId, collectionId: collection.id },
})
}
>
<div className="flex h-4 w-4 items-center justify-center">
<Bookmark className="h-4 w-4 text-sidebar-primary" />
</div>
<span className="flex-1 truncate text-sidebar-foreground">{collection.name}</span>
</div>
))}
</div>
{shareLinks.map((link) => (
<ShareLinkItem
key={link.id}
link={link}
projectId={projectId}
dragState={dragState}
/>
))}
</div>
</div>
)}
{!hideShares && (
<div>
<header className="flex items-center justify-between px-2 mb-1">
<h3 className="text-xs font-semibold text-muted-foreground uppercase tracking-wider">
Share Links
</h3>
<div className="flex items-center gap-1">
<button
onClick={() => createShareLink()}
className="text-muted-foreground hover:text-foreground"
>
<Plus className="h-3.5 w-3.5" />
</button>
</div>
</header>
<div className="space-y-0.5">
<div className="group flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-sm transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground">
<div className="flex h-4 w-4 items-center justify-center">
<LayoutGrid className="h-4 w-4 text-sidebar-primary" />
</div>
<span className="flex-1 truncate text-sidebar-foreground">
All Share Links ({shareLinks.length})
</span>
</div>
{shareLinks.map((link) => (
<ShareLinkItem
key={link.id}
link={link}
projectId={projectId}
dragState={dragState}
/>
))}
</div>
</div>
)}
</div>
</div>
)