fix(asset,webui): disallow dropping version stacks onto files and version stacks (#363)

* fix(asset,webui): disallow dropping version stacks onto files and version stacks

* fix(webui): derive isSingleFile from total drag selection and remove unused hasVersionStacks
This commit is contained in:
Yiling-J
2026-08-29 16:09:36 +08:00
committed by GitHub
parent 083753a96d
commit 7fd8623684
8 changed files with 695 additions and 15 deletions
@@ -133,7 +133,7 @@ export function FileCard({
const { ref: setDraggableRef, isDragging: isDraggableDragging } = useDraggable({
id: `browser:${displayItem.id!}`,
data: {
type: 'file',
type: displayItem.type,
id: displayItem.id,
item: displayItem,
},
@@ -143,7 +143,7 @@ export function FileCard({
const { ref: setDroppableRef, isDropTarget: isOver } = useDroppable({
id: `browser:${displayItem.id!}`,
data: {
type: 'file',
type: displayItem.type,
id: displayItem.id,
item: displayItem,
},
@@ -160,14 +160,12 @@ export function FileCard({
isDraggableDragging || (dragState?.draggedIds.has(displayItem.id!) ?? false)
// Determine if this is a valid drop target
// File target is valid ONLY if dragging 1 item AND it is a file (version stack)
// File/version stack target is valid ONLY if dragging 1 single regular file
// And strictly, we shouldn't drop on ourselves
const isValidDropTarget = useMemo(() => {
if (!dragState?.isActive) return false
if (dragState.draggedIds.has(displayItem.id!)) return false // Can't drop on self
if (dragState.hasFolders) return false // Can't drag folders onto file
if (dragState.itemCount !== 1) return false // Can't drag multiple files onto file
return true
return dragState.isSingleFile
}, [dragState, displayItem.id])
const showDropFeedback = isOver && isValidDropTarget
@@ -108,7 +108,7 @@ export function FileListItem({
const { ref: setDraggableRef, isDragging: isDraggableDragging } = useDraggable({
id: `browser:${displayItem.id!}`,
data: {
type: displayItem.type === 'folder' ? 'folder' : 'file',
type: displayItem.type,
id: displayItem.id,
item: displayItem,
},
@@ -72,7 +72,7 @@ function ListRow({
const { ref: setRowRef, isDropTarget: isRowOver } = useDroppable({
id: `browser:${item.id!}`,
data: {
type: item.type === 'folder' ? 'folder' : 'file',
type: item.type,
id: item.id,
item: item,
},
@@ -85,10 +85,8 @@ function ListRow({
if (item.type === 'folder') return true
if (item.type === 'file') {
if (dragState.hasFolders) return false
if (dragState.itemCount !== 1) return false
return true
if (item.type === 'file' || item.type === 'version_stack') {
return dragState.isSingleFile
}
return false