|
@@ -8,8 +8,8 @@ import { IDisposable } from '@phosphor/disposable';
|
|
|
import { Menu, Widget } from '@phosphor/widgets';
|
|
|
|
|
|
import {
|
|
|
+ ILabShell,
|
|
|
JupyterClient,
|
|
|
- JupyterLab,
|
|
|
JupyterLabPlugin
|
|
|
} from '@jupyterlab/application';
|
|
|
|
|
@@ -118,12 +118,13 @@ export namespace CommandIDs {
|
|
|
const plugin: JupyterLabPlugin<IMainMenu> = {
|
|
|
id: '@jupyterlab/mainmenu-extension:plugin',
|
|
|
requires: [ICommandPalette],
|
|
|
- optional: [IInspector],
|
|
|
+ optional: [IInspector, ILabShell],
|
|
|
provides: IMainMenu,
|
|
|
activate: (
|
|
|
app: JupyterClient,
|
|
|
palette: ICommandPalette,
|
|
|
- inspector: IInspector | null
|
|
|
+ inspector: IInspector | null,
|
|
|
+ labShell: ILabShell | null
|
|
|
): IMainMenu => {
|
|
|
const { commands } = app;
|
|
|
|
|
@@ -145,7 +146,11 @@ const plugin: JupyterLabPlugin<IMainMenu> = {
|
|
|
createRunMenu(app, menu.runMenu);
|
|
|
createSettingsMenu(app, menu.settingsMenu);
|
|
|
createViewMenu(app, menu.viewMenu);
|
|
|
- createTabsMenu(app, menu.tabsMenu);
|
|
|
+
|
|
|
+ // The tabs menu relies on lab shell functionality.
|
|
|
+ if (labShell) {
|
|
|
+ createTabsMenu(app, menu.tabsMenu, labShell);
|
|
|
+ }
|
|
|
|
|
|
// Create commands to open the main application menus.
|
|
|
const activateMenu = (item: Menu) => {
|
|
@@ -211,8 +216,8 @@ const plugin: JupyterLabPlugin<IMainMenu> = {
|
|
|
category: 'Main Area'
|
|
|
});
|
|
|
|
|
|
- app.shell.addToTopArea(logo);
|
|
|
- app.shell.addToTopArea(menu);
|
|
|
+ app.shell.add(logo, 'top');
|
|
|
+ app.shell.add(menu, 'top');
|
|
|
|
|
|
return menu;
|
|
|
}
|
|
@@ -221,7 +226,7 @@ const plugin: JupyterLabPlugin<IMainMenu> = {
|
|
|
/**
|
|
|
* Create the basic `Edit` menu.
|
|
|
*/
|
|
|
-export function createEditMenu(app: JupyterLab, menu: EditMenu): void {
|
|
|
+export function createEditMenu(app: JupyterClient, menu: EditMenu): void {
|
|
|
const commands = menu.menu.commands;
|
|
|
|
|
|
// Add the undo/redo commands the the Edit menu.
|
|
@@ -298,7 +303,7 @@ export function createEditMenu(app: JupyterLab, menu: EditMenu): void {
|
|
|
/**
|
|
|
* Create the basic `File` menu.
|
|
|
*/
|
|
|
-export function createFileMenu(app: JupyterLab, menu: FileMenu): void {
|
|
|
+export function createFileMenu(app: JupyterClient, menu: FileMenu): void {
|
|
|
const commands = menu.menu.commands;
|
|
|
|
|
|
// Add a delegator command for closing and cleaning up an activity.
|
|
@@ -460,7 +465,7 @@ export function createFileMenu(app: JupyterLab, menu: FileMenu): void {
|
|
|
/**
|
|
|
* Create the basic `Kernel` menu.
|
|
|
*/
|
|
|
-export function createKernelMenu(app: JupyterLab, menu: KernelMenu): void {
|
|
|
+export function createKernelMenu(app: JupyterClient, menu: KernelMenu): void {
|
|
|
const commands = menu.menu.commands;
|
|
|
|
|
|
commands.addCommand(CommandIDs.interruptKernel, {
|
|
@@ -557,7 +562,7 @@ export function createKernelMenu(app: JupyterLab, menu: KernelMenu): void {
|
|
|
/**
|
|
|
* Create the basic `View` menu.
|
|
|
*/
|
|
|
-export function createViewMenu(app: JupyterLab, menu: ViewMenu): void {
|
|
|
+export function createViewMenu(app: JupyterClient, menu: ViewMenu): void {
|
|
|
const commands = menu.menu.commands;
|
|
|
|
|
|
commands.addCommand(CommandIDs.lineNumbering, {
|
|
@@ -643,7 +648,7 @@ export function createViewMenu(app: JupyterLab, menu: ViewMenu): void {
|
|
|
/**
|
|
|
* Create the basic `Run` menu.
|
|
|
*/
|
|
|
-export function createRunMenu(app: JupyterLab, menu: RunMenu): void {
|
|
|
+export function createRunMenu(app: JupyterClient, menu: RunMenu): void {
|
|
|
const commands = menu.menu.commands;
|
|
|
|
|
|
commands.addCommand(CommandIDs.run, {
|
|
@@ -701,14 +706,18 @@ export function createRunMenu(app: JupyterLab, menu: RunMenu): void {
|
|
|
/**
|
|
|
* Create the basic `Settings` menu.
|
|
|
*/
|
|
|
-export function createSettingsMenu(app: JupyterLab, menu: SettingsMenu): void {
|
|
|
+export function createSettingsMenu(_: JupyterClient, menu: SettingsMenu): void {
|
|
|
menu.addGroup([{ command: 'settingeditor:open' }], 1000);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Create the basic `Tabs` menu.
|
|
|
*/
|
|
|
-export function createTabsMenu(app: JupyterLab, menu: TabsMenu): void {
|
|
|
+export function createTabsMenu(
|
|
|
+ app: JupyterClient,
|
|
|
+ menu: TabsMenu,
|
|
|
+ shell: ILabShell
|
|
|
+): void {
|
|
|
const commands = app.commands;
|
|
|
|
|
|
// Add commands for cycling the active tabs.
|
|
@@ -774,12 +783,12 @@ export function createTabsMenu(app: JupyterLab, menu: TabsMenu): void {
|
|
|
previousId = isPreviouslyUsedTabAttached ? previousId : '';
|
|
|
};
|
|
|
populateTabs();
|
|
|
- app.shell.layoutModified.connect(() => {
|
|
|
+ shell.layoutModified.connect(() => {
|
|
|
populateTabs();
|
|
|
});
|
|
|
// Update the id of the previous active tab if
|
|
|
// a new tab is selected.
|
|
|
- app.shell.currentChanged.connect((sender, args) => {
|
|
|
+ shell.currentChanged.connect((sender, args) => {
|
|
|
let widget = args.oldValue;
|
|
|
if (!widget) {
|
|
|
return;
|
|
@@ -815,7 +824,7 @@ namespace Private {
|
|
|
* A utility function that delegates a portion of a label to an IMenuExtender.
|
|
|
*/
|
|
|
export function delegateLabel<E extends IMenuExtender<Widget>>(
|
|
|
- app: JupyterLab,
|
|
|
+ app: JupyterClient,
|
|
|
s: Set<E>,
|
|
|
label: keyof E
|
|
|
): string {
|
|
@@ -835,7 +844,7 @@ namespace Private {
|
|
|
* to an IMenuExtender.
|
|
|
*/
|
|
|
export function delegateExecute<E extends IMenuExtender<Widget>>(
|
|
|
- app: JupyterLab,
|
|
|
+ app: JupyterClient,
|
|
|
s: Set<E>,
|
|
|
executor: keyof E
|
|
|
): () => Promise<any> {
|
|
@@ -858,7 +867,7 @@ namespace Private {
|
|
|
* to an IMenuExtender.
|
|
|
*/
|
|
|
export function delegateEnabled<E extends IMenuExtender<Widget>>(
|
|
|
- app: JupyterLab,
|
|
|
+ app: JupyterClient,
|
|
|
s: Set<E>,
|
|
|
executor: keyof E
|
|
|
): () => boolean {
|
|
@@ -878,7 +887,7 @@ namespace Private {
|
|
|
* for an IMenuExtender.
|
|
|
*/
|
|
|
export function delegateToggled<E extends IMenuExtender<Widget>>(
|
|
|
- app: JupyterLab,
|
|
|
+ app: JupyterClient,
|
|
|
s: Set<E>,
|
|
|
toggled: keyof E
|
|
|
): () => boolean {
|