@@ -18,6 +18,7 @@ import {
18
18
Uploader
19
19
} from '@jupyterlab/filebrowser' ;
20
20
import { IStateDB } from '@jupyterlab/statedb' ;
21
+ import { editIcon } from '@jupyterlab/ui-components' ;
21
22
22
23
import { ISettingRegistry } from '@jupyterlab/settingregistry' ;
23
24
import { ITranslator } from '@jupyterlab/translation' ;
@@ -44,6 +45,7 @@ namespace CommandIDs {
44
45
export const copyToAnotherBucket = 'drives:copy-to-another-bucket' ;
45
46
export const toggleBucketSwitching = 'drives:toggle-bucket-switching-ui' ;
46
47
export const toggleBrowser = 'filebrowser:toggle-main' ;
48
+ export const rename = 'drives:rename' ;
47
49
}
48
50
49
51
const FILE_BROWSER_FACTORY = 'DriveBrowser' ;
@@ -511,6 +513,29 @@ namespace Private {
511
513
'.jp-SidePanel .jp-DirListing-content .jp-DirListing-item[data-isDir]' ,
512
514
rank : 10
513
515
} ) ;
516
+
517
+ app . commands . addCommand ( CommandIDs . rename , {
518
+ execute : args => {
519
+ const widget = tracker . currentWidget ;
520
+
521
+ if ( widget ) {
522
+ return widget . rename ( ) ;
523
+ }
524
+ } ,
525
+ isVisible : ( ) =>
526
+ // So long as this command only handles one file at time, don't show it
527
+ // if multiple files are selected.
528
+ ! ! tracker . currentWidget &&
529
+ Array . from ( tracker . currentWidget . selectedItems ( ) ) . length === 1 ,
530
+ isEnabled : ( ) =>
531
+ // Disable directory rename for S3 folders.
532
+ ! ! tracker . currentWidget &&
533
+ tracker . currentWidget ?. selectedItems ( ) . next ( ) ! . value . type !==
534
+ 'directory' ,
535
+ icon : editIcon . bindprops ( { stylesheet : 'menuItem' } ) ,
536
+ label : 'Rename' ,
537
+ mnemonic : 0
538
+ } ) ;
514
539
}
515
540
516
541
/**
0 commit comments