diff --git a/packages/notebook-extension/schema/edit-notebook-metadata.json b/packages/notebook-extension/schema/edit-notebook-metadata.json index f93274e1cc..70e0f7a465 100644 --- a/packages/notebook-extension/schema/edit-notebook-metadata.json +++ b/packages/notebook-extension/schema/edit-notebook-metadata.json @@ -3,6 +3,15 @@ "description": "Jupyter Notebook Menu Entries", "jupyter.lab.menus": { "main": [ + { + "id": "jp-mainmenu-file", + "items": [ + { + "command": "notebook:open-tree-tab", + "rank": 1 + } + ] + }, { "id": "jp-mainmenu-edit", "items": [ diff --git a/packages/notebook-extension/src/index.ts b/packages/notebook-extension/src/index.ts index a4ea978b62..ca1f2e89e7 100644 --- a/packages/notebook-extension/src/index.ts +++ b/packages/notebook-extension/src/index.ts @@ -177,6 +177,31 @@ 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, + optional: [ITranslator], + activate: (app: JupyterFrontEnd, 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); + }, + }); + }, +}; + /** * The kernel logo plugin. */ @@ -570,6 +595,7 @@ const editNotebookMetadata: JupyterFrontEndPlugin = { const plugins: JupyterFrontEndPlugin[] = [ checkpoints, closeTab, + openTreeTab, editNotebookMetadata, kernelLogo, kernelStatus, diff --git a/ui-tests/test/menus.spec.ts-snapshots/opened-menu-file-chromium-linux.png b/ui-tests/test/menus.spec.ts-snapshots/opened-menu-file-chromium-linux.png index 34fe51769f..0976e1f3be 100644 Binary files a/ui-tests/test/menus.spec.ts-snapshots/opened-menu-file-chromium-linux.png and b/ui-tests/test/menus.spec.ts-snapshots/opened-menu-file-chromium-linux.png differ diff --git a/ui-tests/test/menus.spec.ts-snapshots/opened-menu-file-firefox-linux.png b/ui-tests/test/menus.spec.ts-snapshots/opened-menu-file-firefox-linux.png index 8bfc3cecce..e1516d0f01 100644 Binary files a/ui-tests/test/menus.spec.ts-snapshots/opened-menu-file-firefox-linux.png and b/ui-tests/test/menus.spec.ts-snapshots/opened-menu-file-firefox-linux.png differ