File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 8080<script >
8181import { NcActions , NcActionButton , NcActionInput } from ' @nextcloud/vue'
8282import { getLinkWithPicker } from ' @nextcloud/vue/dist/Components/NcRichText.js'
83- import { FilePickerType , getFilePickerBuilder } from ' @nextcloud/dialogs'
83+ import { getFilePickerBuilder } from ' @nextcloud/dialogs'
8484import { generateUrl } from ' @nextcloud/router'
8585import { 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 ()
You can’t perform that action at this time.
0 commit comments