mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-04 23:24:21 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user