|
|
@@ -13,6 +13,7 @@ import {
|
|
|
import { useFileTreeActionable } from './file-tree-actionable'
|
|
|
import { useFileTreeMutable } from './file-tree-mutable'
|
|
|
import { useFileTreeSelectable } from '../contexts/file-tree-selectable'
|
|
|
+import { useFileTreeMainContext } from './file-tree-main'
|
|
|
|
|
|
// HACK ALERT
|
|
|
// DnD binds drag and drop events on window and stop propagation if the dragged
|
|
|
@@ -75,10 +76,11 @@ FileTreeDraggableProvider.propTypes = {
|
|
|
export function useDraggable(draggedEntityId) {
|
|
|
const { t } = useTranslation()
|
|
|
|
|
|
+ const { hasWritePermissions } = useFileTreeMainContext()
|
|
|
const { fileTreeData } = useFileTreeMutable()
|
|
|
const { selectedEntityIds } = useFileTreeSelectable()
|
|
|
|
|
|
- const [isDraggable, setIsDraggable] = useState(true)
|
|
|
+ const [isDraggable, setIsDraggable] = useState(hasWritePermissions)
|
|
|
|
|
|
const item = { type: DRAGGABLE_TYPE }
|
|
|
const [{ isDragging }, dragRef, preview] = useDrag({
|
|
|
@@ -96,6 +98,7 @@ export function useDraggable(draggedEntityId) {
|
|
|
collect: monitor => ({
|
|
|
isDragging: !!monitor.isDragging(),
|
|
|
}),
|
|
|
+ canDrag: () => isDraggable,
|
|
|
})
|
|
|
|
|
|
// remove the automatic preview as we're using a custom preview via
|
|
|
@@ -107,7 +110,6 @@ export function useDraggable(draggedEntityId) {
|
|
|
return {
|
|
|
dragRef,
|
|
|
isDragging,
|
|
|
- isDraggable,
|
|
|
setIsDraggable,
|
|
|
}
|
|
|
}
|