From f36faa533400ec3a49f67dae6bdeb6e53835754f Mon Sep 17 00:00:00 2001 From: Andrii Ieroshenko Date: Wed, 28 Aug 2024 10:40:04 -0700 Subject: [PATCH] Check for and remove "RTC:" prefix added by the jupyter-collaboration from the file path --- src/index.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index 5ab16a57..bc1665c8 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -143,11 +143,19 @@ function getSelectedFileBaseName(widget: FileBrowser | null): string | null { } // Get the file name, with all parent directories, of the currently selected file. -function getSelectedFilePath(widget: FileBrowser | null): string | null { +function getSelectedFilePath( + widget: FileBrowser | null, + app: JupyterFrontEnd +): string | null { const selectedItem = getSelectedItem(widget); if (selectedItem === null) { return null; } + + if (app.serviceManager.contents.driveName(selectedItem.path) === 'RTC') { + return app.serviceManager.contents.localPath(selectedItem.path); + } + return selectedItem.path; } @@ -260,7 +268,8 @@ function activatePlugin( execute: async () => { eventLogger('file-browser.create-job'); const widget = fileBrowserTracker.currentWidget; - const filePath = getSelectedFilePath(widget) ?? ''; + const filePath = getSelectedFilePath(widget, app) ?? ''; + console.log(filePath); // Update the job form inside the notebook jobs widget const newCreateModel = emptyCreateJobModel();