Skip to content

Commit 1e2ed7f

Browse files
committed
Move menu items to the settings
1 parent 19dcd0d commit 1e2ed7f

File tree

12 files changed

+149
-82
lines changed

12 files changed

+149
-82
lines changed

packages/application-extension/schema/menus.json

+31
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,37 @@
1515
"rank": 20
1616
}
1717
]
18+
},
19+
{
20+
"id": "jp-mainmenu-run",
21+
"items": [
22+
{
23+
"type": "separator",
24+
"rank": 1000
25+
},
26+
{
27+
"type": "submenu",
28+
"rank": 1010,
29+
"submenu": {
30+
"id": "jp-runmenu-change-cell-type",
31+
"label": "Cell Type",
32+
"items": [
33+
{
34+
"command": "notebook:change-cell-to-code",
35+
"rank": 0
36+
},
37+
{
38+
"command": "notebook:change-cell-to-markdown",
39+
"rank": 0
40+
},
41+
{
42+
"command": "notebook:change-cell-to-raw",
43+
"rank": 0
44+
}
45+
]
46+
}
47+
}
48+
]
1849
}
1950
]
2051
},
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"title": "Jupyter Notebook Pages",
3+
"description": "Jupyter Notebook Pages",
4+
"jupyter.lab.menus": {
5+
"main": [
6+
{
7+
"id": "jp-mainmenu-view",
8+
"items": [
9+
{
10+
"command": "application:open-lab",
11+
"rank": 2
12+
},
13+
{
14+
"command": "application:open-tree",
15+
"rank": 2
16+
}
17+
]
18+
}
19+
]
20+
},
21+
"properties": {},
22+
"additionalProperties": false,
23+
"type": "object"
24+
}

packages/application-extension/schema/top.json

+13
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,19 @@
33
"jupyter.lab.setting-icon-label": "Jupyter Notebook Top Area",
44
"title": "Jupyter Notebook Top Area",
55
"description": "Jupyter Notebook Top Area settings",
6+
"jupyter.lab.menus": {
7+
"main": [
8+
{
9+
"id": "jp-mainmenu-view",
10+
"items": [
11+
{
12+
"command": "application:toggle-top",
13+
"rank": 2
14+
}
15+
]
16+
}
17+
]
18+
},
619
"properties": {
720
"visible": {
821
"type": "boolean",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"title": "Jupyter Notebook Zen Mode",
3+
"description": "Jupyter Notebook Zen Mode",
4+
"jupyter.lab.menus": {
5+
"main": [
6+
{
7+
"id": "jp-mainmenu-view",
8+
"items": [
9+
{
10+
"command": "application:toggle-zen",
11+
"rank": 3
12+
}
13+
]
14+
}
15+
]
16+
},
17+
"properties": {},
18+
"additionalProperties": false,
19+
"type": "object"
20+
}

packages/application-extension/src/index.ts

+5-23
Original file line numberDiff line numberDiff line change
@@ -236,12 +236,11 @@ const pages: JupyterFrontEndPlugin<void> = {
236236
id: '@jupyter-notebook/application-extension:pages',
237237
autoStart: true,
238238
requires: [ITranslator],
239-
optional: [ICommandPalette, IMainMenu],
239+
optional: [ICommandPalette],
240240
activate: (
241241
app: JupyterFrontEnd,
242242
translator: ITranslator,
243-
palette: ICommandPalette | null,
244-
menu: IMainMenu | null
243+
palette: ICommandPalette | null
245244
): void => {
246245
const trans = translator.load('notebook');
247246
const baseUrl = PageConfig.getBaseUrl();
@@ -265,13 +264,6 @@ const pages: JupyterFrontEndPlugin<void> = {
265264
palette.addItem({ command, category: 'View' });
266265
});
267266
}
268-
269-
if (menu) {
270-
menu.viewMenu.addGroup(
271-
[{ command: CommandIDs.openLab }, { command: CommandIDs.openTree }],
272-
0
273-
);
274-
}
275267
}
276268
};
277269

@@ -489,12 +481,11 @@ const title: JupyterFrontEndPlugin<void> = {
489481
const topVisibility: JupyterFrontEndPlugin<void> = {
490482
id: '@jupyter-notebook/application-extension:top',
491483
requires: [INotebookShell, ITranslator],
492-
optional: [IMainMenu, ISettingRegistry],
484+
optional: [ISettingRegistry],
493485
activate: (
494486
app: JupyterFrontEnd<JupyterFrontEnd.IShell>,
495487
notebookShell: INotebookShell,
496488
translator: ITranslator,
497-
menu: IMainMenu | null,
498489
settingRegistry: ISettingRegistry | null
499490
) => {
500491
const trans = translator.load('notebook');
@@ -512,10 +503,6 @@ const topVisibility: JupyterFrontEndPlugin<void> = {
512503
isToggled: () => top.isVisible
513504
});
514505

515-
if (menu) {
516-
menu.viewMenu.addGroup([{ command: CommandIDs.toggleTop }], 2);
517-
}
518-
519506
let settingsOverride = false;
520507

521508
if (settingRegistry) {
@@ -648,13 +635,12 @@ const zen: JupyterFrontEndPlugin<void> = {
648635
id: '@jupyter-notebook/application-extension:zen',
649636
autoStart: true,
650637
requires: [ITranslator],
651-
optional: [ICommandPalette, INotebookShell, IMainMenu],
638+
optional: [ICommandPalette, INotebookShell],
652639
activate: (
653640
app: JupyterFrontEnd,
654641
translator: ITranslator,
655642
palette: ICommandPalette | null,
656-
notebookShell: INotebookShell | null,
657-
menu: IMainMenu | null
643+
notebookShell: INotebookShell | null
658644
): void => {
659645
const { commands } = app;
660646
const elem = document.documentElement;
@@ -695,10 +681,6 @@ const zen: JupyterFrontEndPlugin<void> = {
695681
if (palette) {
696682
palette.addItem({ command: CommandIDs.toggleZen, category: 'Mode' });
697683
}
698-
699-
if (menu) {
700-
menu.viewMenu.addGroup([{ command: CommandIDs.toggleZen }], 3);
701-
}
702684
}
703685
};
704686

packages/help-extension/schema/plugin.json

+8
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@
99
{
1010
"command": "help:about",
1111
"rank": 0
12+
},
13+
{
14+
"type": "separator",
15+
"rank": 10
16+
},
17+
{
18+
"command": "help:shortcuts",
19+
"rank": 11
1220
}
1321
]
1422
}

packages/help-extension/src/index.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,7 @@ const plugin: JupyterFrontEndPlugin<void> = {
168168
}));
169169

170170
if (menu) {
171-
menu.helpMenu.addGroup([{ command: CommandIDs.shortcuts }]);
172-
menu.helpMenu.addGroup(resourcesGroup);
171+
menu.helpMenu.addGroup(resourcesGroup, 20);
173172
}
174173
}
175174
};

packages/lab-extension/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
"@jupyterlab/apputils": "^4.0.0-alpha.8",
4949
"@jupyterlab/coreutils": "^6.0.0-alpha.8",
5050
"@jupyterlab/docregistry": "^4.0.0-alpha.8",
51-
"@jupyterlab/mainmenu": "^4.0.0-alpha.8",
5251
"@jupyterlab/notebook": "^4.0.0-alpha.8",
5352
"@jupyterlab/translation": "^4.0.0-alpha.8",
5453
"@lumino/commands": "^1.20.0",

packages/lab-extension/schema/interface-switcher.json

+17
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,23 @@
44
"jupyter.lab.toolbars": {
55
"Notebook": [{ "name": "interfaceSwitcher", "rank": 990 }]
66
},
7+
"jupyter.lab.menus": {
8+
"main": [
9+
{
10+
"id": "jp-mainmenu-view",
11+
"items": [
12+
{
13+
"command": "jupyter-notebook:open-notebook",
14+
"rank": 1
15+
},
16+
{
17+
"command": "jupyter-notebook:open-lab",
18+
"rank": 1
19+
}
20+
]
21+
}
22+
]
23+
},
724
"properties": {},
825
"additionalProperties": false,
926
"type": "object"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"title": "Launch Shortcuts",
3+
"description": "Launch Shortcuts.",
4+
"jupyter.lab.menus": {
5+
"main": [
6+
{
7+
"id": "jp-mainmenu-help",
8+
"items": [
9+
{
10+
"command": "jupyter-notebook:launch-tree",
11+
"rank": 1
12+
},
13+
{
14+
"command": "jupyter-notebook:open-notebook",
15+
"rank": 1
16+
},
17+
{
18+
"command": "jupyter-notebook:open-lab",
19+
"rank": 1
20+
}
21+
]
22+
}
23+
]
24+
},
25+
"properties": {},
26+
"additionalProperties": false,
27+
"type": "object"
28+
}

packages/lab-extension/src/index.ts

+1-15
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import { ICommandPalette, IToolbarWidgetRegistry } from '@jupyterlab/apputils';
1111

1212
import { PageConfig } from '@jupyterlab/coreutils';
1313

14-
import { IMainMenu } from '@jupyterlab/mainmenu';
15-
1614
import { INotebookTracker, NotebookPanel } from '@jupyterlab/notebook';
1715

1816
import { ITranslator } from '@jupyterlab/translation';
@@ -58,7 +56,6 @@ const launchButtons: JupyterFrontEndPlugin<void> = {
5856
optional: [
5957
INotebookTracker,
6058
ICommandPalette,
61-
IMainMenu,
6259
INotebookShell,
6360
ILabShell,
6461
IToolbarWidgetRegistry
@@ -68,7 +65,6 @@ const launchButtons: JupyterFrontEndPlugin<void> = {
6865
translator: ITranslator,
6966
notebookTracker: INotebookTracker | null,
7067
palette: ICommandPalette | null,
71-
menu: IMainMenu | null,
7268
notebookShell: INotebookShell | null,
7369
labShell: ILabShell | null,
7470
toolbarRegistry: IToolbarWidgetRegistry | null
@@ -112,10 +108,6 @@ const launchButtons: JupyterFrontEndPlugin<void> = {
112108
palette.addItem({ command, category: 'Other' });
113109
}
114110

115-
if (menu) {
116-
menu.viewMenu.addGroup([{ command }], 1);
117-
}
118-
119111
switcher.addItem({ command });
120112
};
121113

@@ -159,11 +151,10 @@ const launchNotebookTree: JupyterFrontEndPlugin<void> = {
159151
id: '@jupyter-notebook/lab-extension:launch-tree',
160152
autoStart: true,
161153
requires: [ITranslator],
162-
optional: [IMainMenu, ICommandPalette],
154+
optional: [ICommandPalette],
163155
activate: (
164156
app: JupyterFrontEnd,
165157
translator: ITranslator,
166-
menu: IMainMenu | null,
167158
palette: ICommandPalette | null
168159
): void => {
169160
const { commands } = app;
@@ -177,11 +168,6 @@ const launchNotebookTree: JupyterFrontEndPlugin<void> = {
177168
}
178169
});
179170

180-
if (menu) {
181-
const helpMenu = menu.helpMenu;
182-
helpMenu.addGroup([{ command: CommandIDs.launchNotebookTree }], 1);
183-
}
184-
185171
if (palette) {
186172
palette.addItem({ command: CommandIDs.launchNotebookTree, category });
187173
}

0 commit comments

Comments
 (0)