Skip to content

Commit

Permalink
Add missing "Open..." file menu
Browse files Browse the repository at this point in the history
  • Loading branch information
martinRenou committed May 30, 2024
1 parent 433f180 commit f0583c6
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions packages/notebook-extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,40 @@ const closeTab: JupyterFrontEndPlugin<void> = {
},
};

/**
* Add a command to open the tree view from the notebook view
*/
const openTreeTab: JupyterFrontEndPlugin<void> = {
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.
*/
Expand Down Expand Up @@ -570,6 +604,7 @@ const editNotebookMetadata: JupyterFrontEndPlugin<void> = {
const plugins: JupyterFrontEndPlugin<any>[] = [
checkpoints,
closeTab,
openTreeTab,
editNotebookMetadata,
kernelLogo,
kernelStatus,
Expand Down

0 comments on commit f0583c6

Please sign in to comment.