Skip to content

Commit f0583c6

Browse files
committed
Add missing "Open..." file menu
1 parent 433f180 commit f0583c6

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

packages/notebook-extension/src/index.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,40 @@ 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+
requires: [IMainMenu],
189+
optional: [ITranslator],
190+
activate: (
191+
app: JupyterFrontEnd,
192+
menu: IMainMenu,
193+
translator: ITranslator | null
194+
) => {
195+
const { commands } = app;
196+
translator = translator ?? nullTranslator;
197+
const trans = translator.load('notebook');
198+
199+
const id = 'notebook:open-tree-tab';
200+
commands.addCommand(id, {
201+
label: trans.__('Open...'),
202+
execute: async () => {
203+
const url = URLExt.join(PageConfig.getBaseUrl(), 'tree');
204+
window.open(url);
205+
},
206+
});
207+
menu.fileMenu.addItem({
208+
command: id,
209+
rank: 1,
210+
});
211+
},
212+
};
213+
180214
/**
181215
* The kernel logo plugin.
182216
*/
@@ -570,6 +604,7 @@ const editNotebookMetadata: JupyterFrontEndPlugin<void> = {
570604
const plugins: JupyterFrontEndPlugin<any>[] = [
571605
checkpoints,
572606
closeTab,
607+
openTreeTab,
573608
editNotebookMetadata,
574609
kernelLogo,
575610
kernelStatus,

0 commit comments

Comments
 (0)