Skip to content

Commit 1a03b9d

Browse files
martinRenoukrassowskigithub-actions[bot]
authored
Add missing "Open..." file menu (#7385)
* Add missing "Open..." file menu * Update ellipsis Co-authored-by: Michał Krassowski <5832902+krassowski@users.noreply.github.com> * Update Playwright Snapshots * Update Playwright Snapshots * Use schema * Cleanups * Linter * Revert snapshot test --------- Co-authored-by: Michał Krassowski <5832902+krassowski@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent b010e1d commit 1a03b9d

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

packages/notebook-extension/schema/edit-notebook-metadata.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@
33
"description": "Jupyter Notebook Menu Entries",
44
"jupyter.lab.menus": {
55
"main": [
6+
{
7+
"id": "jp-mainmenu-file",
8+
"items": [
9+
{
10+
"command": "notebook:open-tree-tab",
11+
"rank": 1
12+
}
13+
]
14+
},
615
{
716
"id": "jp-mainmenu-edit",
817
"items": [

packages/notebook-extension/src/index.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,31 @@ const closeTab: JupyterFrontEndPlugin<void> = {
177177
},
178178
};
179179

180+
/**
181+
* Add a command to open the tree view from the notebook view
182+
*/
183+
const openTreeTab: JupyterFrontEndPlugin<void> = {
184+
id: '@jupyter-notebook/notebook-extension:open-tree-tab',
185+
description:
186+
'Add a command to open a browser tab on the tree view when clicking "Open...".',
187+
autoStart: true,
188+
optional: [ITranslator],
189+
activate: (app: JupyterFrontEnd, translator: ITranslator | null) => {
190+
const { commands } = app;
191+
translator = translator ?? nullTranslator;
192+
const trans = translator.load('notebook');
193+
194+
const id = 'notebook:open-tree-tab';
195+
commands.addCommand(id, {
196+
label: trans.__('Open…'),
197+
execute: async () => {
198+
const url = URLExt.join(PageConfig.getBaseUrl(), 'tree');
199+
window.open(url);
200+
},
201+
});
202+
},
203+
};
204+
180205
/**
181206
* The kernel logo plugin.
182207
*/
@@ -570,6 +595,7 @@ const editNotebookMetadata: JupyterFrontEndPlugin<void> = {
570595
const plugins: JupyterFrontEndPlugin<any>[] = [
571596
checkpoints,
572597
closeTab,
598+
openTreeTab,
573599
editNotebookMetadata,
574600
kernelLogo,
575601
kernelStatus,
Loading
Loading

0 commit comments

Comments
 (0)