diff --git a/schema/drives-file-browser.json b/schema/drives-file-browser.json index 55f3be1..aa008ad 100644 --- a/schema/drives-file-browser.json +++ b/schema/drives-file-browser.json @@ -71,6 +71,17 @@ "command": "drives:create-new-notebook", "selector": ".jp-DirListing-content", "rank": 54 + }, + { + "command": "filebrowser:rename", + "selector": ".jp-DirListing-item[data-isdir]", + "rank": 5, + "disabled": true + }, + { + "command": "drives:rename", + "selector": ".jp-DirListing-item[data-isdir]", + "rank": 5 } ] }, @@ -95,6 +106,13 @@ "default": [] } }, + "jupyter.lab.shortcuts": [ + { + "command": "drives:rename", + "keys": ["F2"], + "selector": ".jp-DirListing-content .jp-DirListing-itemText" + } + ], "additionalProperties": false, "definitions": { "toolbarItem": { diff --git a/src/plugins/driveBrowserPlugin.ts b/src/plugins/driveBrowserPlugin.ts index a919b95..5105879 100644 --- a/src/plugins/driveBrowserPlugin.ts +++ b/src/plugins/driveBrowserPlugin.ts @@ -25,7 +25,8 @@ import { IScore, newFolderIcon, fileIcon, - notebookIcon + notebookIcon, + editIcon } from '@jupyterlab/ui-components'; import { CommandRegistry } from '@lumino/commands'; import { Widget } from '@lumino/widgets'; @@ -413,5 +414,16 @@ namespace Private { icon: notebookIcon.bindprops({ stylesheet: 'menuItem' }), label: 'New Notebook' }); + + app.commands.addCommand(CommandIDs.rename, { + isEnabled: () => { + return browser.model.path !== 's3:'; + }, + execute: () => { + app.commands.execute('filebrowser:rename'); + }, + icon: editIcon.bindprops({ stylesheet: 'menuItem' }), + label: 'Rename' + }); } } diff --git a/src/token.ts b/src/token.ts index bd317f4..195a47b 100644 --- a/src/token.ts +++ b/src/token.ts @@ -13,6 +13,7 @@ export namespace CommandIDs { export const createNewDirectory = 'drives:create-new-directory'; export const createNewFile = 'drives:create-new-file'; export const createNewNotebook = 'drives:create-new-notebook'; + export const rename = 'drives:rename'; } /**