File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33 * SPDX-License-Identifier: AGPL-3.0-or-later
44 */
55
6- import { FilePickerType , getFilePickerBuilder } from '@nextcloud/dialogs'
6+ import { getFilePickerBuilder } from '@nextcloud/dialogs'
77
88export const buildFilePicker = ( startPath ) => {
99 return getFilePickerBuilder ( t ( 'text' , 'Select file or folder to link to' ) )
1010 . startAt ( startPath )
1111 . allowDirectories ( true )
1212 . setMultiSelect ( false )
13- . setType ( FilePickerType . Choose )
13+ . setButtonFactory ( ( nodes , path ) => {
14+ const buttons = [ ]
15+ const node = nodes ?. [ 0 ] ?. attributes ?. displayName || nodes ?. [ 0 ] ?. basename
16+ const isRoot = nodes ?. [ 0 ] ?. root === nodes ?. [ 0 ] ?. attributes ?. filename
17+ let label = t ( 'text' , 'Choose' )
18+
19+ if ( nodes . length === 1 && ! isRoot ) {
20+ label = t ( 'text' , 'Choose {file}' , { file : node } )
21+ }
22+
23+ buttons . push ( {
24+ callback : ( ) => { } ,
25+ type : 'primary' ,
26+ label,
27+ disabled : isRoot ,
28+ } )
29+
30+ return buttons
31+ } )
1432 . build ( )
1533}
You can’t perform that action at this time.
0 commit comments