Skip to content

Commit

Permalink
Add to the menu (#57)
Browse files Browse the repository at this point in the history
* Add to the menu

* update yarn.lock
  • Loading branch information
jtpio authored Sep 30, 2024
1 parent 3ee8bfb commit ec87ceb
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 12 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
"@jupyterlab/docmanager": "^4.2.5",
"@jupyterlab/filebrowser": "^4.2.5",
"@jupyterlab/services": "^7.2.5",
"@jupyterlab/settingregistry": "^4.2.5"
"@jupyterlab/settingregistry": "^4.2.5",
"@jupyterlab/translation": "^4.2.5"
},
"devDependencies": {
"@jupyterlab/builder": "^4.0.0",
Expand Down
17 changes: 17 additions & 0 deletions schema/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,23 @@
"default": false
}
},
"jupyter.lab.menus": {
"main": [
{
"id": "jp-mainmenu-view",
"items": [
{
"command": "quickopen:activate",
"rank": 1
},
{
"type": "separator",
"rank": 1
}
]
}
]
},
"jupyter.lab.shortcuts": [
{
"command": "quickopen:activate",
Expand Down
22 changes: 11 additions & 11 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { IDocumentManager } from '@jupyterlab/docmanager';
import { ServerConnection } from '@jupyterlab/services';
import { ISettingRegistry } from '@jupyterlab/settingregistry';
import { FileBrowser, IDefaultFileBrowser } from '@jupyterlab/filebrowser';
import { ITranslator, nullTranslator } from '@jupyterlab/translation';
import { CommandRegistry } from '@lumino/commands';
import { ReadonlyPartialJSONObject } from '@lumino/coreutils';
import { Message } from '@lumino/messaging';
Expand Down Expand Up @@ -128,20 +129,17 @@ class QuickOpenWidget extends CommandPalette {
const extension: JupyterFrontEndPlugin<void> = {
id: 'jupyterlab-quickopen:plugin',
autoStart: true,
requires: [
ICommandPalette,
IDocumentManager,
ISettingRegistry,
IDefaultFileBrowser
],
requires: [IDocumentManager, ISettingRegistry, IDefaultFileBrowser],
optional: [ICommandPalette, ITranslator],
activate: async (
app: JupyterFrontEnd,
palette: ICommandPalette,
docManager: IDocumentManager,
settingRegistry: ISettingRegistry,
defaultFileBrowser: IDefaultFileBrowser
defaultFileBrowser: IDefaultFileBrowser,
palette: ICommandPalette | null,
translator: ITranslator | null
) => {
console.log(`Activated extension: ${extension.id}`);
const trans = (translator ?? nullTranslator).load('jupyterlab-quickopen');
const commands: CommandRegistry = new CommandRegistry();
const settings: ISettingRegistry.ISettings = await settingRegistry.load(
extension.id
Expand Down Expand Up @@ -173,12 +171,14 @@ const extension: JupyterFrontEndPlugin<void> = {
// palette, assign a hotkey, etc.
const command = 'quickopen:activate';
app.commands.addCommand(command, {
label: 'Quick Open',
label: trans.__('Quick Open'),
execute: () => {
modalPalette.activate();
}
});
palette.addItem({ command, category: 'File Operations' });
if (palette) {
palette.addItem({ command, category: 'File Operations' });
}
}
};

Expand Down
1 change: 1 addition & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3417,6 +3417,7 @@ __metadata:
"@jupyterlab/filebrowser": ^4.2.5
"@jupyterlab/services": ^7.2.5
"@jupyterlab/settingregistry": ^4.2.5
"@jupyterlab/translation": ^4.2.5
"@types/json-schema": ^7.0.11
"@types/react": ^18.0.26
"@types/react-addons-linked-state-mixin": ^0.14.22
Expand Down

0 comments on commit ec87ceb

Please sign in to comment.