]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix(files): Fix folders not being selectable in the smart picker
authorChristopher Ng <chrng8@gmail.com>
Tue, 1 Oct 2024 22:55:14 +0000 (15:55 -0700)
committerChristopher Ng <chrng8@gmail.com>
Tue, 1 Oct 2024 22:55:14 +0000 (15:55 -0700)
Signed-off-by: Christopher Ng <chrng8@gmail.com>
apps/files/src/views/FileReferencePickerElement.vue

index c2a502ee1a8e61f3e3930819789e99baa29b9f10..b4d4bc54f14ef3e70fab36ac02932cb9b0f5b71e 100644 (file)
@@ -39,7 +39,7 @@ export default defineComponent({
                },
                filepickerOptions() {
                        return {
-                               allowPickDirectory: false,
+                               allowPickDirectory: true,
                                buttons: this.buttonFactory,
                                container: `#${this.containerId}`,
                                multiselect: false,
@@ -53,18 +53,17 @@ export default defineComponent({
                buttonFactory(selected: NcNode[]): IFilePickerButton[] {
                        const buttons = [] as IFilePickerButton[]
                        if (selected.length === 0) {
-                               buttons.push({
-                                       label: t('files', 'Choose file'),
-                                       type: 'tertiary' as never,
-                                       callback: this.onClose,
-                               })
-                       } else {
-                               buttons.push({
-                                       label: t('files', 'Choose {file}', { file: selected[0].basename }),
-                                       type: 'primary',
-                                       callback: this.onClose,
-                               })
+                               return []
+                       }
+                       const node = selected.at(0)
+                       if (node.path === '/') {
+                               return [] // Do not allow selecting the users root folder
                        }
+                       buttons.push({
+                               label: t('files', 'Choose {file}', { file: node.displayname }),
+                               type: 'primary',
+                               callback: this.onClose,
+                       })
                        return buttons
                },