File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed
Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change 6666<script >
6767import { NcActions , NcActionButton , NcActionInput } from ' @nextcloud/vue'
6868import { getLinkWithPicker } from ' @nextcloud/vue/dist/Components/NcRichText.js'
69- import { FilePickerType , getFilePickerBuilder } from ' @nextcloud/dialogs'
69+ import { getFilePickerBuilder } from ' @nextcloud/dialogs'
7070import { generateUrl } from ' @nextcloud/router'
7171import { 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 ()
You can’t perform that action at this time.
0 commit comments