Skip to content

Commit ec87ceb

Browse files
authored
Add to the menu (#57)
* Add to the menu * update yarn.lock
1 parent 3ee8bfb commit ec87ceb

File tree

4 files changed

+31
-12
lines changed

4 files changed

+31
-12
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@
6262
"@jupyterlab/docmanager": "^4.2.5",
6363
"@jupyterlab/filebrowser": "^4.2.5",
6464
"@jupyterlab/services": "^7.2.5",
65-
"@jupyterlab/settingregistry": "^4.2.5"
65+
"@jupyterlab/settingregistry": "^4.2.5",
66+
"@jupyterlab/translation": "^4.2.5"
6667
},
6768
"devDependencies": {
6869
"@jupyterlab/builder": "^4.0.0",

schema/plugin.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,23 @@
1818
"default": false
1919
}
2020
},
21+
"jupyter.lab.menus": {
22+
"main": [
23+
{
24+
"id": "jp-mainmenu-view",
25+
"items": [
26+
{
27+
"command": "quickopen:activate",
28+
"rank": 1
29+
},
30+
{
31+
"type": "separator",
32+
"rank": 1
33+
}
34+
]
35+
}
36+
]
37+
},
2138
"jupyter.lab.shortcuts": [
2239
{
2340
"command": "quickopen:activate",

src/index.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { IDocumentManager } from '@jupyterlab/docmanager';
88
import { ServerConnection } from '@jupyterlab/services';
99
import { ISettingRegistry } from '@jupyterlab/settingregistry';
1010
import { FileBrowser, IDefaultFileBrowser } from '@jupyterlab/filebrowser';
11+
import { ITranslator, nullTranslator } from '@jupyterlab/translation';
1112
import { CommandRegistry } from '@lumino/commands';
1213
import { ReadonlyPartialJSONObject } from '@lumino/coreutils';
1314
import { Message } from '@lumino/messaging';
@@ -128,20 +129,17 @@ class QuickOpenWidget extends CommandPalette {
128129
const extension: JupyterFrontEndPlugin<void> = {
129130
id: 'jupyterlab-quickopen:plugin',
130131
autoStart: true,
131-
requires: [
132-
ICommandPalette,
133-
IDocumentManager,
134-
ISettingRegistry,
135-
IDefaultFileBrowser
136-
],
132+
requires: [IDocumentManager, ISettingRegistry, IDefaultFileBrowser],
133+
optional: [ICommandPalette, ITranslator],
137134
activate: async (
138135
app: JupyterFrontEnd,
139-
palette: ICommandPalette,
140136
docManager: IDocumentManager,
141137
settingRegistry: ISettingRegistry,
142-
defaultFileBrowser: IDefaultFileBrowser
138+
defaultFileBrowser: IDefaultFileBrowser,
139+
palette: ICommandPalette | null,
140+
translator: ITranslator | null
143141
) => {
144-
console.log(`Activated extension: ${extension.id}`);
142+
const trans = (translator ?? nullTranslator).load('jupyterlab-quickopen');
145143
const commands: CommandRegistry = new CommandRegistry();
146144
const settings: ISettingRegistry.ISettings = await settingRegistry.load(
147145
extension.id
@@ -173,12 +171,14 @@ const extension: JupyterFrontEndPlugin<void> = {
173171
// palette, assign a hotkey, etc.
174172
const command = 'quickopen:activate';
175173
app.commands.addCommand(command, {
176-
label: 'Quick Open',
174+
label: trans.__('Quick Open'),
177175
execute: () => {
178176
modalPalette.activate();
179177
}
180178
});
181-
palette.addItem({ command, category: 'File Operations' });
179+
if (palette) {
180+
palette.addItem({ command, category: 'File Operations' });
181+
}
182182
}
183183
};
184184

yarn.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3417,6 +3417,7 @@ __metadata:
34173417
"@jupyterlab/filebrowser": ^4.2.5
34183418
"@jupyterlab/services": ^7.2.5
34193419
"@jupyterlab/settingregistry": ^4.2.5
3420+
"@jupyterlab/translation": ^4.2.5
34203421
"@types/json-schema": ^7.0.11
34213422
"@types/react": ^18.0.26
34223423
"@types/react-addons-linked-state-mixin": ^0.14.22

0 commit comments

Comments
 (0)