Skip to content

Commit

Permalink
Add missing "Open..." file menu (#7385)
Browse files Browse the repository at this point in the history
* Add missing "Open..." file menu

* Update ellipsis

Co-authored-by: Michał Krassowski <[email protected]>

* Update Playwright Snapshots

* Update Playwright Snapshots

* Use schema

* Cleanups

* Linter

* Revert snapshot test

---------

Co-authored-by: Michał Krassowski <[email protected]>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored May 31, 2024
1 parent b010e1d commit 1a03b9d
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
26 changes: 26 additions & 0 deletions packages/notebook-extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,31 @@ 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,
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.
*/
Expand Down Expand Up @@ -570,6 +595,7 @@ const editNotebookMetadata: JupyterFrontEndPlugin<void> = {
const plugins: JupyterFrontEndPlugin<any>[] = [
checkpoints,
closeTab,
openTreeTab,
editNotebookMetadata,
kernelLogo,
kernelStatus,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1a03b9d

Please sign in to comment.