@@ -15,8 +15,8 @@ import type { IFilePickerButton } from '@nextcloud/dialogs'
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' ,
@@ -52,13 +52,11 @@ export default defineComponent({
5252
5353 buttonFactory(selected : NcNode []): IFilePickerButton [] {
5454 const buttons = [] as IFilePickerButton []
55- if (selected .length === 0 ) {
55+ const [node] = selected
56+ // Do not allow selecting the users root folder or if no node is selected
57+ if (node === undefined || node .path === ' /' ) {
5658 return []
5759 }
58- const node = selected .at (0 )
59- if (node .path === ' /' ) {
60- return [] // Do not allow selecting the users root folder
61- }
6260 buttons .push ({
6361 label: t (' files' , ' Choose {file}' , { file: node .displayname }),
6462 type: ' primary' ,
@@ -76,10 +74,7 @@ export default defineComponent({
7674 },
7775
7876 onSubmit(node : NcNode ) {
79- const url = new URL (window .location .href )
80- url .pathname = generateUrl (' /f/{fileId}' , { fileId: node .fileid ! })
81- url .search = ' '
82- this .$emit (' submit' , url .href )
77+ this .$emit (' submit' , generateFileUrl (node .fileid ! ))
8378 },
8479 },
8580})
0 commit comments