Skip to content

Commit 9895f85

Browse files
committed
feat(FilePicker): Prevent navigation to non readable nodes
Signed-off-by: Louis Chmn <[email protected]>
1 parent 7442fac commit 9895f85

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

lib/components/FilePicker/FileListRow.vue

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
:class="[
1111
{
1212
'file-picker__row--selected': selected && !showCheckbox,
13+
'file-picker__row--not-navigatable': isDirectory && !isNavigatable,
1314
'file-picker__row--not-pickable': !isPickable,
1415
},
1516
]"
@@ -47,7 +48,7 @@
4748
<script setup lang="ts">
4849
import type { INode } from '@nextcloud/files'
4950
50-
import { FileType, formatFileSize } from '@nextcloud/files'
51+
import { FileType, formatFileSize, Permission } from '@nextcloud/files'
5152
import { computed } from 'vue'
5253
import NcCheckboxRadioSwitch from '@nextcloud/vue/components/NcCheckboxRadioSwitch'
5354
import NcDateTime from '@nextcloud/vue/components/NcDateTime'
@@ -98,6 +99,11 @@ const isDirectory = computed(() => props.node.type === FileType.Folder)
9899
*/
99100
const isPickable = computed(() => props.canPick && (props.allowPickDirectory || !isDirectory.value))
100101
102+
/**
103+
* If this node is not readable, then we cannot navigate to it.
104+
*/
105+
const isNavigatable = computed(() => (props.node.permissions & Permission.READ) === Permission.READ)
106+
101107
/**
102108
* Toggle the selection state
103109
*/
@@ -114,7 +120,9 @@ function toggleSelected() {
114120
*/
115121
function handleClick() {
116122
if (isDirectory.value) {
117-
emit('enterDirectory', props.node)
123+
if (isNavigatable.value) {
124+
emit('enterDirectory', props.node)
125+
}
118126
} else {
119127
toggleSelected()
120128
}
@@ -145,6 +153,12 @@ function handleKeyDown(event: KeyboardEvent) {
145153
background-color: var(--color-background-dark);
146154
}
147155
156+
&--not-navigatable {
157+
filter: saturate(0.7);
158+
opacity: 0.7;
159+
}
160+
161+
&--not-navigatable,
148162
&--not-pickable {
149163
150164
* {

0 commit comments

Comments
 (0)