Skip to content

Commit

Permalink
fix: check if folder is writeable on file drop
Browse files Browse the repository at this point in the history
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
  • Loading branch information
pedrolamas committed Oct 12, 2023
1 parent 50ac181 commit d53462e
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/components/widgets/filesystem/FileSystemBrowser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
'v-data-table__selected': (isSelected && item.name !== '..')
}"
class="row-select px-1"
:draggable="draggable(item)"
:draggable="isItemDraggable(item)"
@click.prevent="$emit('row-click', item, $event)"
@contextmenu.prevent="$emit('row-click', item, $event)"
@dragstart="handleDragStart(item, $event)"
Expand Down Expand Up @@ -387,13 +387,7 @@ export default class FileSystemBrowser extends Mixins(FilesMixin) {
}
getItemIcon (item: FileBrowserEntry) {
const readonly = (
this.readonly ||
(
item.permissions !== undefined &&
!item.permissions.includes('w')
)
)
const readonly = !this.isItemWriteable(item)
if (item.type === 'file') {
if (item.extension === 'zip') {
Expand All @@ -414,7 +408,7 @@ export default class FileSystemBrowser extends Mixins(FilesMixin) {
}
// Determines if a row is currently in a draggable state or not.
draggable (item: FileBrowserEntry) {
isItemDraggable (item: FileBrowserEntry) {
return (
item.name !== '..' &&
this.files.length > 0 &&
Expand All @@ -425,6 +419,17 @@ export default class FileSystemBrowser extends Mixins(FilesMixin) {
)
}
isItemWriteable (item: FileBrowserEntry) {
return (
item.name !== '..' &&
!this.readonly &&
(
item.permissions === undefined ||
item.permissions.includes('w')
)
)
}
// Fake a drag image when the user drags a file or folder.
handleDragStart (item: FileBrowserEntry, e: DragEvent) {
if (this.dragState !== true) {
Expand Down Expand Up @@ -460,6 +465,7 @@ export default class FileSystemBrowser extends Mixins(FilesMixin) {
if (
item.type === 'directory' &&
this.isItemWriteable(item) &&
e.dataTransfer &&
this.dragItem &&
this.dragItem !== item
Expand All @@ -476,6 +482,7 @@ export default class FileSystemBrowser extends Mixins(FilesMixin) {
handleDragOver (item: FileBrowserEntry, e: DragEvent) {
if (
item.type === 'directory' &&
this.isItemWriteable(item) &&
e.dataTransfer &&
this.dragItem &&
this.dragItem !== item &&
Expand Down

0 comments on commit d53462e

Please sign in to comment.