@@ -15,8 +15,8 @@ import type { Node as NcNode } from '@nextcloud/files'
1515
1616import { FilePickerVue as FilePicker } from ' @nextcloud/dialogs/filepicker.js'
1717import { translate as t } from ' @nextcloud/l10n'
18- import { generateUrl } from ' @nextcloud/router'
1918import { defineComponent } from ' vue'
19+ import { generateFileUrl } from ' ../../../files_sharing/src/utils/generateUrl.ts'
2020
2121export default defineComponent ({
2222 name: ' FileReferencePickerElement' ,
@@ -57,13 +57,11 @@ export default defineComponent({
5757
5858 buttonFactory(selected : NcNode []): IFilePickerButton [] {
5959 const buttons = [] as IFilePickerButton []
60- if (selected .length === 0 ) {
60+ const [node] = selected
61+ // Do not allow selecting the users root folder or if no node is selected
62+ if (node === undefined || node .path === ' /' ) {
6163 return []
6264 }
63- const node = selected .at (0 )
64- if (node .path === ' /' ) {
65- return [] // Do not allow selecting the users root folder
66- }
6765 buttons .push ({
6866 label: t (' files' , ' Choose {file}' , { file: node .displayname }),
6967 type: ' primary' ,
@@ -81,10 +79,7 @@ export default defineComponent({
8179 },
8280
8381 onSubmit(node : NcNode ) {
84- const url = new URL (window .location .href )
85- url .pathname = generateUrl (' /f/{fileId}' , { fileId: node .fileid ! })
86- url .search = ' '
87- this .$emit (' submit' , url .href )
82+ this .$emit (' submit' , generateFileUrl (node .fileid ! ))
8883 },
8984 },
9085})
0 commit comments