From 1d2b45eb50ea83d63bcf46cfb6df7afbcf460c50 Mon Sep 17 00:00:00 2001 From: DenisaCG Date: Thu, 3 Jul 2025 16:51:58 +0200 Subject: [PATCH 1/2] disable rename context command for drives --- schema/drives-file-browser.json | 11 +++++++++++ src/plugins/driveBrowserPlugin.ts | 14 +++++++++++++- src/token.ts | 1 + 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/schema/drives-file-browser.json b/schema/drives-file-browser.json index 55f3be1..c725e96 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 } ] }, 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'; } /** From a6c279145c4b834712bfe8d251fc2c928d144d2b Mon Sep 17 00:00:00 2001 From: DenisaCG Date: Thu, 3 Jul 2025 17:05:12 +0200 Subject: [PATCH 2/2] keep rename command shortcut --- schema/drives-file-browser.json | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/schema/drives-file-browser.json b/schema/drives-file-browser.json index c725e96..aa008ad 100644 --- a/schema/drives-file-browser.json +++ b/schema/drives-file-browser.json @@ -106,6 +106,13 @@ "default": [] } }, + "jupyter.lab.shortcuts": [ + { + "command": "drives:rename", + "keys": ["F2"], + "selector": ".jp-DirListing-content .jp-DirListing-itemText" + } + ], "additionalProperties": false, "definitions": { "toolbarItem": {