Skip to content

Commit d10ffa2

Browse files
Merge pull request #7199 from nextcloud/backport/7180/stable29
[stable29] fix submit button on file picker dialog
2 parents c66db59 + 9b65432 commit d10ffa2

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

src/components/Menu/ActionInsertLink.vue

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
<script>
8181
import { NcActions, NcActionButton, NcActionInput } from '@nextcloud/vue'
8282
import { getLinkWithPicker } from '@nextcloud/vue/dist/Components/NcRichText.js'
83-
import { FilePickerType, getFilePickerBuilder } from '@nextcloud/dialogs'
83+
import { getFilePickerBuilder } from '@nextcloud/dialogs'
8484
import { generateUrl } from '@nextcloud/router'
8585
import { loadState } from '@nextcloud/initial-state'
8686
@@ -140,7 +140,25 @@ export default {
140140
.startAt(this.startPath)
141141
.allowDirectories(true)
142142
.setMultiSelect(false)
143-
.setType(FilePickerType.Choose)
143+
.setButtonFactory((nodes, path) => {
144+
const buttons = []
145+
const node = nodes?.[0]?.attributes?.displayName || nodes?.[0]?.basename
146+
const isRoot = nodes?.[0]?.root === nodes?.[0]?.attributes?.filename
147+
let label = t('text', 'Choose')
148+
149+
if (nodes.length === 1 && !isRoot) {
150+
label = t('text', 'Choose {file}', { file: node })
151+
}
152+
153+
buttons.push({
154+
callback: () => {},
155+
type: 'primary',
156+
label,
157+
disabled: isRoot,
158+
})
159+
160+
return buttons
161+
})
144162
.build()
145163
146164
filePicker.pick()

0 commit comments

Comments
 (0)