From f0583c6da5951cc94f791bea9bebbee6e7b3e571 Mon Sep 17 00:00:00 2001 From: martinRenou Date: Thu, 30 May 2024 11:34:49 +0200 Subject: [PATCH] Add missing "Open..." file menu --- packages/notebook-extension/src/index.ts | 35 ++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/packages/notebook-extension/src/index.ts b/packages/notebook-extension/src/index.ts index a4ea978b62..694a3964b7 100644 --- a/packages/notebook-extension/src/index.ts +++ b/packages/notebook-extension/src/index.ts @@ -177,6 +177,40 @@ const closeTab: JupyterFrontEndPlugin = { }, }; +/** + * Add a command to open the tree view from the notebook view + */ +const openTreeTab: JupyterFrontEndPlugin = { + id: '@jupyter-notebook/notebook-extension:open-tree-tab', + description: + 'Add a command to open a browser tab on the tree view when clicking "Open...".', + autoStart: true, + requires: [IMainMenu], + optional: [ITranslator], + activate: ( + app: JupyterFrontEnd, + menu: IMainMenu, + translator: ITranslator | null + ) => { + const { commands } = app; + translator = translator ?? nullTranslator; + const trans = translator.load('notebook'); + + const id = 'notebook:open-tree-tab'; + commands.addCommand(id, { + label: trans.__('Open...'), + execute: async () => { + const url = URLExt.join(PageConfig.getBaseUrl(), 'tree'); + window.open(url); + }, + }); + menu.fileMenu.addItem({ + command: id, + rank: 1, + }); + }, +}; + /** * The kernel logo plugin. */ @@ -570,6 +604,7 @@ const editNotebookMetadata: JupyterFrontEndPlugin = { const plugins: JupyterFrontEndPlugin[] = [ checkpoints, closeTab, + openTreeTab, editNotebookMetadata, kernelLogo, kernelStatus,