Skip to content

Commit b4dfccd

Browse files
fix: submit button on file picker dialog
Signed-off-by: Luka Trovic <luka@nextcloud.com>
1 parent 9279ed3 commit b4dfccd

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/components/Menu/ActionInsertLink.vue

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
<script>
6767
import { NcActions, NcActionButton, NcActionInput } from '@nextcloud/vue'
6868
import { getLinkWithPicker } from '@nextcloud/vue/dist/Components/NcRichText.js'
69-
import { FilePickerType, getFilePickerBuilder } from '@nextcloud/dialogs'
69+
import { getFilePickerBuilder } from '@nextcloud/dialogs'
7070
import { generateUrl } from '@nextcloud/router'
7171
import { loadState } from '@nextcloud/initial-state'
7272
@@ -126,7 +126,25 @@ export default {
126126
.startAt(this.startPath)
127127
.allowDirectories(true)
128128
.setMultiSelect(false)
129-
.setType(FilePickerType.Choose)
129+
.setButtonFactory((nodes, path) => {
130+
const buttons = []
131+
const node = nodes?.[0]?.attributes?.displayName || nodes?.[0]?.basename
132+
const isRoot = nodes?.[0]?.root === nodes?.[0]?.attributes?.filename
133+
let label = t('text', 'Choose')
134+
135+
if (nodes.length === 1 && !isRoot) {
136+
label = t('text', 'Choose {file}', { file: node })
137+
}
138+
139+
buttons.push({
140+
callback: () => {},
141+
type: 'primary',
142+
label,
143+
disabled: isRoot,
144+
})
145+
146+
return buttons
147+
})
130148
.build()
131149
132150
filePicker.pick()

0 commit comments

Comments
 (0)