From 56e86c0a455c3b716021b7e1ab503036a07420e2 Mon Sep 17 00:00:00 2001 From: Vidar Tonaas Fauske Date: Thu, 17 Oct 2019 12:21:20 +0100 Subject: [PATCH 1/5] Allow main app ext to work without palette --- packages/application-extension/src/index.tsx | 50 ++++++++++++++------ 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/packages/application-extension/src/index.tsx b/packages/application-extension/src/index.tsx index d9cf0a57085b..0226d60e3a05 100644 --- a/packages/application-extension/src/index.tsx +++ b/packages/application-extension/src/index.tsx @@ -90,14 +90,14 @@ namespace CommandIDs { */ const main: JupyterFrontEndPlugin = { id: '@jupyterlab/application-extension:main', - requires: [ICommandPalette, IRouter, IWindowResolver], - optional: [IConnectionLost], + requires: [IRouter, IWindowResolver], + optional: [ICommandPalette, IConnectionLost], activate: ( app: JupyterFrontEnd, - palette: ICommandPalette, router: IRouter, resolver: IWindowResolver, - connectionLost: IConnectionLost | undefined + palette: ICommandPalette | null, + connectionLost: IConnectionLost | null ) => { if (!(app instanceof JupyterLab)) { throw new Error(`${main.id} must be activated in JupyterLab.`); @@ -486,7 +486,7 @@ const sidebar: JupyterFrontEndPlugin = { /** * Add the main application commands. */ -function addCommands(app: JupyterLab, palette: ICommandPalette): void { +function addCommands(app: JupyterLab, palette: ICommandPalette | null): void { const { commands, contextMenu, shell } = app; const category = 'Main Area'; @@ -572,7 +572,9 @@ function addCommands(app: JupyterLab, palette: ICommandPalette): void { shell.activateNextTab(); } }); - palette.addItem({ command: CommandIDs.activateNextTab, category }); + if (palette) { + palette.addItem({ command: CommandIDs.activateNextTab, category }); + } commands.addCommand(CommandIDs.activatePreviousTab, { label: 'Activate Previous Tab', @@ -580,7 +582,9 @@ function addCommands(app: JupyterLab, palette: ICommandPalette): void { shell.activatePreviousTab(); } }); - palette.addItem({ command: CommandIDs.activatePreviousTab, category }); + if (palette) { + palette.addItem({ command: CommandIDs.activatePreviousTab, category }); + } commands.addCommand(CommandIDs.activateNextTabBar, { label: 'Activate Next Tab Bar', @@ -614,7 +618,9 @@ function addCommands(app: JupyterLab, palette: ICommandPalette): void { } } }); - palette.addItem({ command: CommandIDs.close, category }); + if (palette) { + palette.addItem({ command: CommandIDs.close, category }); + } contextMenu.addItem({ command: CommandIDs.close, selector: tabSelector, @@ -627,7 +633,9 @@ function addCommands(app: JupyterLab, palette: ICommandPalette): void { shell.closeAll(); } }); - palette.addItem({ command: CommandIDs.closeAll, category }); + if (palette) { + palette.addItem({ command: CommandIDs.closeAll, category }); + } commands.addCommand(CommandIDs.closeOtherTabs, { label: () => `Close All Other Tabs`, @@ -648,7 +656,9 @@ function addCommands(app: JupyterLab, palette: ICommandPalette): void { closeWidgets(otherWidgets); } }); - palette.addItem({ command: CommandIDs.closeOtherTabs, category }); + if (palette) { + palette.addItem({ command: CommandIDs.closeOtherTabs, category }); + } contextMenu.addItem({ command: CommandIDs.closeOtherTabs, selector: tabSelector, @@ -667,7 +677,9 @@ function addCommands(app: JupyterLab, palette: ICommandPalette): void { closeWidgets(widgetsRightOf(widget)); } }); - palette.addItem({ command: CommandIDs.closeRightTabs, category }); + if (palette) { + palette.addItem({ command: CommandIDs.closeRightTabs, category }); + } contextMenu.addItem({ command: CommandIDs.closeRightTabs, selector: tabSelector, @@ -689,7 +701,9 @@ function addCommands(app: JupyterLab, palette: ICommandPalette): void { isToggled: () => !shell.leftCollapsed, isVisible: () => !shell.isEmpty('left') }); - palette.addItem({ command: CommandIDs.toggleLeftArea, category }); + if (palette) { + palette.addItem({ command: CommandIDs.toggleLeftArea, category }); + } app.commands.addCommand(CommandIDs.toggleRightArea, { label: () => 'Show Right Sidebar', @@ -706,7 +720,9 @@ function addCommands(app: JupyterLab, palette: ICommandPalette): void { isToggled: () => !shell.rightCollapsed, isVisible: () => !shell.isEmpty('right') }); - palette.addItem({ command: CommandIDs.toggleRightArea, category }); + if (palette) { + palette.addItem({ command: CommandIDs.toggleRightArea, category }); + } app.commands.addCommand(CommandIDs.togglePresentationMode, { label: () => 'Presentation Mode', @@ -716,7 +732,9 @@ function addCommands(app: JupyterLab, palette: ICommandPalette): void { isToggled: () => shell.presentationMode, isVisible: () => true }); - palette.addItem({ command: CommandIDs.togglePresentationMode, category }); + if (palette) { + palette.addItem({ command: CommandIDs.togglePresentationMode, category }); + } app.commands.addCommand(CommandIDs.setMode, { isVisible: args => { @@ -744,7 +762,9 @@ function addCommands(app: JupyterLab, palette: ICommandPalette): void { return app.commands.execute(CommandIDs.setMode, args); } }); - palette.addItem({ command: CommandIDs.toggleMode, category }); + if (palette) { + palette.addItem({ command: CommandIDs.toggleMode, category }); + } } /** From c888095c0408db36f10f61838f6dba77c96e4bce Mon Sep 17 00:00:00 2001 From: Vidar Tonaas Fauske Date: Thu, 17 Oct 2019 14:18:04 +0100 Subject: [PATCH 2/5] Make palette (and a few others) optional when possible --- packages/console-extension/src/index.ts | 202 +++++++++--------- packages/hub-extension/src/index.ts | 27 ++- packages/launcher-extension/src/index.ts | 11 +- packages/mainmenu-extension/src/index.ts | 38 ++-- packages/settingeditor-extension/src/index.ts | 10 +- 5 files changed, 152 insertions(+), 136 deletions(-) diff --git a/packages/console-extension/src/index.ts b/packages/console-extension/src/index.ts index 4dc70aa1d01f..22c14004b649 100644 --- a/packages/console-extension/src/index.ts +++ b/packages/console-extension/src/index.ts @@ -97,8 +97,6 @@ const tracker: JupyterFrontEndPlugin = { id: '@jupyterlab/console-extension:tracker', provides: IConsoleTracker, requires: [ - IMainMenu, - ICommandPalette, ConsolePanel.IContentFactory, IEditorServices, ILayoutRestorer, @@ -106,7 +104,7 @@ const tracker: JupyterFrontEndPlugin = { IRenderMimeRegistry, ISettingRegistry ], - optional: [ILauncher, ILabStatus, ISessionContextDialogs], + optional: [IMainMenu, ICommandPalette, ILauncher, ILabStatus, ISessionContextDialogs], activate: activateConsole, autoStart: true }; @@ -136,14 +134,14 @@ export default plugins; */ async function activateConsole( app: JupyterFrontEnd, - mainMenu: IMainMenu, - palette: ICommandPalette, contentFactory: ConsolePanel.IContentFactory, editorServices: IEditorServices, restorer: ILayoutRestorer, browserFactory: IFileBrowserFactory, rendermime: IRenderMimeRegistry, settingRegistry: ISettingRegistry, + mainMenu: IMainMenu | null, + palette: ICommandPalette | null, launcher: ILauncher | null, status: ILabStatus | null, sessionDialogs: ISessionContextDialogs | null @@ -511,90 +509,94 @@ async function activateConsole( isEnabled }); - // Add command palette items - [ - CommandIDs.create, - CommandIDs.linebreak, - CommandIDs.clear, - CommandIDs.runUnforced, - CommandIDs.runForced, - CommandIDs.restart, - CommandIDs.interrupt, - CommandIDs.changeKernel, - CommandIDs.closeAndShutdown - ].forEach(command => { - palette.addItem({ command, category, args: { isPalette: true } }); - }); - - // Add a console creator to the File menu - mainMenu.fileMenu.newMenu.addGroup([{ command: CommandIDs.create }], 0); - - // Add a close and shutdown command to the file menu. - mainMenu.fileMenu.closeAndCleaners.add({ - tracker, - action: 'Shutdown', - name: 'Console', - closeAndCleanup: (current: ConsolePanel) => { - return showDialog({ - title: 'Shut down the console?', - body: `Are you sure you want to close "${current.title.label}"?`, - buttons: [Dialog.cancelButton(), Dialog.warnButton()] - }).then(result => { - if (result.button.accept) { - return current.console.sessionContext.shutdown().then(() => { - current.dispose(); - }); - } else { - return void 0; - } - }); - } - } as IFileMenu.ICloseAndCleaner); + if (palette) { + // Add command palette items + [ + CommandIDs.create, + CommandIDs.linebreak, + CommandIDs.clear, + CommandIDs.runUnforced, + CommandIDs.runForced, + CommandIDs.restart, + CommandIDs.interrupt, + CommandIDs.changeKernel, + CommandIDs.closeAndShutdown + ].forEach(command => { + palette.addItem({ command, category, args: { isPalette: true } }); + }); + } - // Add a kernel user to the Kernel menu - mainMenu.kernelMenu.kernelUsers.add({ - tracker, - interruptKernel: current => { - let kernel = current.console.sessionContext.session?.kernel; - if (kernel) { - return kernel.interrupt(); - } - return Promise.resolve(void 0); - }, - noun: 'Console', - restartKernel: current => - sessionDialogs!.restart(current.console.sessionContext), - restartKernelAndClear: current => { - return sessionDialogs! - .restart(current.console.sessionContext) - .then(restarted => { - if (restarted) { - current.console.clear(); + if (mainMenu) { + // Add a console creator to the File menu + mainMenu.fileMenu.newMenu.addGroup([{ command: CommandIDs.create }], 0); + + // Add a close and shutdown command to the file menu. + mainMenu.fileMenu.closeAndCleaners.add({ + tracker, + action: 'Shutdown', + name: 'Console', + closeAndCleanup: (current: ConsolePanel) => { + return showDialog({ + title: 'Shut down the console?', + body: `Are you sure you want to close "${current.title.label}"?`, + buttons: [Dialog.cancelButton(), Dialog.warnButton()] + }).then(result => { + if (result.button.accept) { + return current.console.sessionContext.shutdown().then(() => { + current.dispose(); + }); + } else { + return void 0; } - return restarted; }); - }, - changeKernel: current => - sessionDialogs!.selectKernel(current.console.sessionContext), - shutdownKernel: current => current.console.sessionContext.shutdown() - } as IKernelMenu.IKernelUser); - - // Add a code runner to the Run menu. - mainMenu.runMenu.codeRunners.add({ - tracker, - noun: 'Cell', - pluralNoun: 'Cells', - run: current => current.console.execute(true) - } as IRunMenu.ICodeRunner); - - // Add a clearer to the edit menu - mainMenu.editMenu.clearers.add({ - tracker, - noun: 'Console Cells', - clearCurrent: (current: ConsolePanel) => { - return current.console.clear(); - } - } as IEditMenu.IClearer); + } + } as IFileMenu.ICloseAndCleaner); + + // Add a kernel user to the Kernel menu + mainMenu.kernelMenu.kernelUsers.add({ + tracker, + interruptKernel: current => { + let kernel = current.console.sessionContext.session?.kernel; + if (kernel) { + return kernel.interrupt(); + } + return Promise.resolve(void 0); + }, + noun: 'Console', + restartKernel: current => + sessionDialogs!.restart(current.console.sessionContext), + restartKernelAndClear: current => { + return sessionDialogs! + .restart(current.console.sessionContext) + .then(restarted => { + if (restarted) { + current.console.clear(); + } + return restarted; + }); + }, + changeKernel: current => + sessionDialogs!.selectKernel(current.console.sessionContext), + shutdownKernel: current => current.console.sessionContext.shutdown() + } as IKernelMenu.IKernelUser); + + // Add a code runner to the Run menu. + mainMenu.runMenu.codeRunners.add({ + tracker, + noun: 'Cell', + pluralNoun: 'Cells', + run: current => current.console.execute(true) + } as IRunMenu.ICodeRunner); + + // Add a clearer to the edit menu + mainMenu.editMenu.clearers.add({ + tracker, + noun: 'Console Cells', + clearCurrent: (current: ConsolePanel) => { + return current.console.clear(); + } + } as IEditMenu.IClearer); + } // For backwards compatibility and clarity, we explicitly label the run // keystroke with the actual effected change, rather than the generic @@ -634,21 +636,23 @@ async function activateConsole( }) ); - mainMenu.settingsMenu.addGroup( - [ - { - type: 'submenu' as Menu.ItemType, - submenu: executeMenu - } - ], - 10 - ); + if (mainMenu) { + mainMenu.settingsMenu.addGroup( + [ + { + type: 'submenu' as Menu.ItemType, + submenu: executeMenu + } + ], + 10 + ); - // Add kernel information to the application help menu. - mainMenu.helpMenu.kernelUsers.add({ - tracker, + // Add kernel information to the application help menu. + mainMenu.helpMenu.kernelUsers.add({ + tracker, getKernel: current => current.sessionContext.session?.kernel - } as IHelpMenu.IKernelUser); + } as IHelpMenu.IKernelUser); + } app.contextMenu.addItem({ command: CommandIDs.clear, diff --git a/packages/hub-extension/src/index.ts b/packages/hub-extension/src/index.ts index 9444bcad6372..864071c73010 100644 --- a/packages/hub-extension/src/index.ts +++ b/packages/hub-extension/src/index.ts @@ -35,8 +35,8 @@ export namespace CommandIDs { function activateHubExtension( app: JupyterFrontEnd, paths: JupyterFrontEnd.IPaths, - palette: ICommandPalette, - mainMenu: IMainMenu + palette: ICommandPalette | null, + mainMenu: IMainMenu | null, ): void { const hubHost = paths.urls.hubHost || ''; const hubPrefix = paths.urls.hubPrefix || ''; @@ -85,14 +85,18 @@ function activateHubExtension( } }); - // Add commands and menu itmes. - mainMenu.fileMenu.addGroup( - [{ command: CommandIDs.controlPanel }, { command: CommandIDs.logout }], - 100 - ); - const category = 'Hub'; - palette.addItem({ category, command: CommandIDs.controlPanel }); - palette.addItem({ category, command: CommandIDs.logout }); + // Add palette and menu itmes. + if (mainMenu) { + mainMenu.fileMenu.addGroup( + [{ command: CommandIDs.controlPanel }, { command: CommandIDs.logout }], + 100 + ); + } + if (palette) { + const category = 'Hub'; + palette.addItem({ category, command: CommandIDs.controlPanel }); + palette.addItem({ category, command: CommandIDs.logout }); + } } /** @@ -101,7 +105,8 @@ function activateHubExtension( const hubExtension: JupyterFrontEndPlugin = { activate: activateHubExtension, id: 'jupyter.extensions.hub-extension', - requires: [JupyterFrontEnd.IPaths, ICommandPalette, IMainMenu], + requires: [JupyterFrontEnd.IPaths], + optional: [ICommandPalette, IMainMenu], autoStart: true }; diff --git a/packages/launcher-extension/src/index.ts b/packages/launcher-extension/src/index.ts index ff501aae42ef..d3c6de9cb00f 100644 --- a/packages/launcher-extension/src/index.ts +++ b/packages/launcher-extension/src/index.ts @@ -27,7 +27,8 @@ namespace CommandIDs { const plugin: JupyterFrontEndPlugin = { activate, id: '@jupyterlab/launcher-extension:plugin', - requires: [ICommandPalette, ILabShell], + requires: [ILabShell], + optional: [ICommandPalette], provides: ILauncher, autoStart: true }; @@ -42,8 +43,8 @@ export default plugin; */ function activate( app: JupyterFrontEnd, - palette: ICommandPalette, - labShell: ILabShell + labShell: ILabShell, + palette: ICommandPalette | null ): ILauncher { const { commands } = app; const model = new LauncherModel(); @@ -79,7 +80,9 @@ function activate( } }); - palette.addItem({ command: CommandIDs.create, category: 'Launcher' }); + if (palette) { + palette.addItem({ command: CommandIDs.create, category: 'Launcher' }); + } return model; } diff --git a/packages/mainmenu-extension/src/index.ts b/packages/mainmenu-extension/src/index.ts index 8e0d43e837ff..98427ef72d2c 100644 --- a/packages/mainmenu-extension/src/index.ts +++ b/packages/mainmenu-extension/src/index.ts @@ -116,13 +116,13 @@ export namespace CommandIDs { */ const plugin: JupyterFrontEndPlugin = { id: '@jupyterlab/mainmenu-extension:plugin', - requires: [ICommandPalette, IRouter], - optional: [ILabShell], + requires: [IRouter], + optional: [ICommandPalette, ILabShell], provides: IMainMenu, activate: ( app: JupyterFrontEnd, - palette: ICommandPalette, router: IRouter, + palette: ICommandPalette | null, labShell: ILabShell | null ): IMainMenu => { const { commands } = app; @@ -203,28 +203,30 @@ const plugin: JupyterFrontEndPlugin = { } }); - // Add some of the commands defined here to the command palette. - if (menu.fileMenu.quitEntry) { + if (palette) { + // Add some of the commands defined here to the command palette. + if (menu.fileMenu.quitEntry) { + palette.addItem({ + command: CommandIDs.shutdown, + category: 'Main Area' + }); + palette.addItem({ + command: CommandIDs.logout, + category: 'Main Area' + }); + } + palette.addItem({ - command: CommandIDs.shutdown, - category: 'Main Area' + command: CommandIDs.shutdownAllKernels, + category: 'Kernel Operations' }); + palette.addItem({ - command: CommandIDs.logout, + command: CommandIDs.activatePreviouslyUsedTab, category: 'Main Area' }); } - palette.addItem({ - command: CommandIDs.shutdownAllKernels, - category: 'Kernel Operations' - }); - - palette.addItem({ - command: CommandIDs.activatePreviouslyUsedTab, - category: 'Main Area' - }); - app.shell.add(logo, 'top'); app.shell.add(menu, 'top'); diff --git a/packages/settingeditor-extension/src/index.ts b/packages/settingeditor-extension/src/index.ts index fb4c7bc8f3be..aa5668265ffb 100644 --- a/packages/settingeditor-extension/src/index.ts +++ b/packages/settingeditor-extension/src/index.ts @@ -46,10 +46,10 @@ const plugin: JupyterFrontEndPlugin = { ISettingRegistry, IEditorServices, IStateDB, - IRenderMimeRegistry, - ICommandPalette, + IRenderMimeRegistry ILabStatus ], + optional: [ICommandPalette], autoStart: true, provides: ISettingEditorTracker, activate @@ -65,8 +65,8 @@ function activate( editorServices: IEditorServices, state: IStateDB, rendermime: IRenderMimeRegistry, - palette: ICommandPalette, status: ILabStatus + palette: ICommandPalette | null ): ISettingEditorTracker { const { commands, shell } = app; const namespace = 'setting-editor'; @@ -141,7 +141,9 @@ function activate( }, label: 'Advanced Settings Editor' }); - palette.addItem({ category: 'Settings', command: CommandIDs.open }); + if (palette) { + palette.addItem({ category: 'Settings', command: CommandIDs.open }); + } commands.addCommand(CommandIDs.revert, { execute: () => { From 8f005441e22715e2d7d0093fa3833e70e9299b1e Mon Sep 17 00:00:00 2001 From: Vidar Tonaas Fauske Date: Tue, 14 Jan 2020 19:03:33 +0000 Subject: [PATCH 3/5] rebase fixup --- packages/application-extension/src/index.tsx | 8 ++++++-- packages/settingeditor-extension/src/index.ts | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/application-extension/src/index.tsx b/packages/application-extension/src/index.tsx index 0226d60e3a05..34ada983ad17 100644 --- a/packages/application-extension/src/index.tsx +++ b/packages/application-extension/src/index.tsx @@ -592,7 +592,9 @@ function addCommands(app: JupyterLab, palette: ICommandPalette | null): void { shell.activateNextTabBar(); } }); - palette.addItem({ command: CommandIDs.activateNextTabBar, category }); + if (palette) { + palette.addItem({ command: CommandIDs.activateNextTabBar, category }); + } commands.addCommand(CommandIDs.activatePreviousTabBar, { label: 'Activate Previous Tab Bar', @@ -600,7 +602,9 @@ function addCommands(app: JupyterLab, palette: ICommandPalette | null): void { shell.activatePreviousTabBar(); } }); - palette.addItem({ command: CommandIDs.activatePreviousTabBar, category }); + if (palette) { + palette.addItem({ command: CommandIDs.activatePreviousTabBar, category }); + } // A CSS selector targeting tabs in the main area. This is a very // specific selector since we really only want tabs that are diff --git a/packages/settingeditor-extension/src/index.ts b/packages/settingeditor-extension/src/index.ts index aa5668265ffb..128217657226 100644 --- a/packages/settingeditor-extension/src/index.ts +++ b/packages/settingeditor-extension/src/index.ts @@ -46,7 +46,7 @@ const plugin: JupyterFrontEndPlugin = { ISettingRegistry, IEditorServices, IStateDB, - IRenderMimeRegistry + IRenderMimeRegistry, ILabStatus ], optional: [ICommandPalette], @@ -65,7 +65,7 @@ function activate( editorServices: IEditorServices, state: IStateDB, rendermime: IRenderMimeRegistry, - status: ILabStatus + status: ILabStatus, palette: ICommandPalette | null ): ISettingEditorTracker { const { commands, shell } = app; From dea1145a734c25ed802bf4f9bd80998fafb49827 Mon Sep 17 00:00:00 2001 From: Vidar Tonaas Fauske Date: Tue, 14 Jan 2020 19:05:08 +0000 Subject: [PATCH 4/5] app-ext: put all palette commands together --- packages/application-extension/src/index.tsx | 45 ++++++-------------- 1 file changed, 12 insertions(+), 33 deletions(-) diff --git a/packages/application-extension/src/index.tsx b/packages/application-extension/src/index.tsx index 34ada983ad17..e4c7ec8054af 100644 --- a/packages/application-extension/src/index.tsx +++ b/packages/application-extension/src/index.tsx @@ -572,9 +572,6 @@ function addCommands(app: JupyterLab, palette: ICommandPalette | null): void { shell.activateNextTab(); } }); - if (palette) { - palette.addItem({ command: CommandIDs.activateNextTab, category }); - } commands.addCommand(CommandIDs.activatePreviousTab, { label: 'Activate Previous Tab', @@ -582,9 +579,6 @@ function addCommands(app: JupyterLab, palette: ICommandPalette | null): void { shell.activatePreviousTab(); } }); - if (palette) { - palette.addItem({ command: CommandIDs.activatePreviousTab, category }); - } commands.addCommand(CommandIDs.activateNextTabBar, { label: 'Activate Next Tab Bar', @@ -592,9 +586,6 @@ function addCommands(app: JupyterLab, palette: ICommandPalette | null): void { shell.activateNextTabBar(); } }); - if (palette) { - palette.addItem({ command: CommandIDs.activateNextTabBar, category }); - } commands.addCommand(CommandIDs.activatePreviousTabBar, { label: 'Activate Previous Tab Bar', @@ -602,9 +593,6 @@ function addCommands(app: JupyterLab, palette: ICommandPalette | null): void { shell.activatePreviousTabBar(); } }); - if (palette) { - palette.addItem({ command: CommandIDs.activatePreviousTabBar, category }); - } // A CSS selector targeting tabs in the main area. This is a very // specific selector since we really only want tabs that are @@ -622,9 +610,6 @@ function addCommands(app: JupyterLab, palette: ICommandPalette | null): void { } } }); - if (palette) { - palette.addItem({ command: CommandIDs.close, category }); - } contextMenu.addItem({ command: CommandIDs.close, selector: tabSelector, @@ -637,9 +622,6 @@ function addCommands(app: JupyterLab, palette: ICommandPalette | null): void { shell.closeAll(); } }); - if (palette) { - palette.addItem({ command: CommandIDs.closeAll, category }); - } commands.addCommand(CommandIDs.closeOtherTabs, { label: () => `Close All Other Tabs`, @@ -660,9 +642,6 @@ function addCommands(app: JupyterLab, palette: ICommandPalette | null): void { closeWidgets(otherWidgets); } }); - if (palette) { - palette.addItem({ command: CommandIDs.closeOtherTabs, category }); - } contextMenu.addItem({ command: CommandIDs.closeOtherTabs, selector: tabSelector, @@ -681,9 +660,6 @@ function addCommands(app: JupyterLab, palette: ICommandPalette | null): void { closeWidgets(widgetsRightOf(widget)); } }); - if (palette) { - palette.addItem({ command: CommandIDs.closeRightTabs, category }); - } contextMenu.addItem({ command: CommandIDs.closeRightTabs, selector: tabSelector, @@ -705,9 +681,6 @@ function addCommands(app: JupyterLab, palette: ICommandPalette | null): void { isToggled: () => !shell.leftCollapsed, isVisible: () => !shell.isEmpty('left') }); - if (palette) { - palette.addItem({ command: CommandIDs.toggleLeftArea, category }); - } app.commands.addCommand(CommandIDs.toggleRightArea, { label: () => 'Show Right Sidebar', @@ -724,9 +697,6 @@ function addCommands(app: JupyterLab, palette: ICommandPalette | null): void { isToggled: () => !shell.rightCollapsed, isVisible: () => !shell.isEmpty('right') }); - if (palette) { - palette.addItem({ command: CommandIDs.toggleRightArea, category }); - } app.commands.addCommand(CommandIDs.togglePresentationMode, { label: () => 'Presentation Mode', @@ -736,9 +706,6 @@ function addCommands(app: JupyterLab, palette: ICommandPalette | null): void { isToggled: () => shell.presentationMode, isVisible: () => true }); - if (palette) { - palette.addItem({ command: CommandIDs.togglePresentationMode, category }); - } app.commands.addCommand(CommandIDs.setMode, { isVisible: args => { @@ -766,7 +733,19 @@ function addCommands(app: JupyterLab, palette: ICommandPalette | null): void { return app.commands.execute(CommandIDs.setMode, args); } }); + if (palette) { + palette.addItem({ command: CommandIDs.activateNextTab, category }); + palette.addItem({ command: CommandIDs.activatePreviousTab, category }); + palette.addItem({ command: CommandIDs.activateNextTabBar, category }); + palette.addItem({ command: CommandIDs.activatePreviousTabBar, category }); + palette.addItem({ command: CommandIDs.close, category }); + palette.addItem({ command: CommandIDs.closeAll, category }); + palette.addItem({ command: CommandIDs.closeOtherTabs, category }); + palette.addItem({ command: CommandIDs.closeRightTabs, category }); + palette.addItem({ command: CommandIDs.toggleLeftArea, category }); + palette.addItem({ command: CommandIDs.toggleRightArea, category }); + palette.addItem({ command: CommandIDs.togglePresentationMode, category }); palette.addItem({ command: CommandIDs.toggleMode, category }); } } From b99db395eb8ea026261e8c9e326d036218495477 Mon Sep 17 00:00:00 2001 From: "Afshin T. Darian" Date: Tue, 14 Jan 2020 19:18:34 +0000 Subject: [PATCH 5/5] Appease lint. --- packages/console-extension/src/index.ts | 10 ++++++++-- packages/hub-extension/src/index.ts | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/console-extension/src/index.ts b/packages/console-extension/src/index.ts index 22c14004b649..655f4f8a92bf 100644 --- a/packages/console-extension/src/index.ts +++ b/packages/console-extension/src/index.ts @@ -104,7 +104,13 @@ const tracker: JupyterFrontEndPlugin = { IRenderMimeRegistry, ISettingRegistry ], - optional: [IMainMenu, ICommandPalette, ILauncher, ILabStatus, ISessionContextDialogs], + optional: [ + IMainMenu, + ICommandPalette, + ILauncher, + ILabStatus, + ISessionContextDialogs + ], activate: activateConsole, autoStart: true }; @@ -650,7 +656,7 @@ async function activateConsole( // Add kernel information to the application help menu. mainMenu.helpMenu.kernelUsers.add({ tracker, - getKernel: current => current.sessionContext.session?.kernel + getKernel: current => current.sessionContext.session?.kernel } as IHelpMenu.IKernelUser); } diff --git a/packages/hub-extension/src/index.ts b/packages/hub-extension/src/index.ts index 864071c73010..5c01e9944d4c 100644 --- a/packages/hub-extension/src/index.ts +++ b/packages/hub-extension/src/index.ts @@ -36,7 +36,7 @@ function activateHubExtension( app: JupyterFrontEnd, paths: JupyterFrontEnd.IPaths, palette: ICommandPalette | null, - mainMenu: IMainMenu | null, + mainMenu: IMainMenu | null ): void { const hubHost = paths.urls.hubHost || ''; const hubPrefix = paths.urls.hubPrefix || '';