From ba698ff57915566a33da7cc0a244f422d3e240b6 Mon Sep 17 00:00:00 2001 From: madhu94 Date: Mon, 22 Apr 2019 23:54:03 +0530 Subject: [PATCH 1/2] Add a Logout command to file menu and rename Quit to Shutdown --- packages/mainmenu-extension/src/index.ts | 43 +++++++++++++++++------- 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/packages/mainmenu-extension/src/index.ts b/packages/mainmenu-extension/src/index.ts index 5a8e3984b664..bf737b72c89c 100644 --- a/packages/mainmenu-extension/src/index.ts +++ b/packages/mainmenu-extension/src/index.ts @@ -10,7 +10,8 @@ import { Menu, Widget } from '@phosphor/widgets'; import { ILabShell, JupyterFrontEnd, - JupyterFrontEndPlugin + JupyterFrontEndPlugin, + IRouter } from '@jupyterlab/application'; import { ICommandPalette, showDialog, Dialog } from '@jupyterlab/apputils'; @@ -60,7 +61,9 @@ export namespace CommandIDs { export const createConsole = 'filemenu:create-console'; - export const quit = 'filemenu:quit'; + export const shutdown = 'filemenu:shutdown'; + + export const logout = 'filemenu:logout'; export const openKernel = 'kernelmenu:open'; @@ -115,12 +118,13 @@ export namespace CommandIDs { */ const plugin: JupyterFrontEndPlugin = { id: '@jupyterlab/mainmenu-extension:plugin', - requires: [ICommandPalette], + requires: [ICommandPalette, IRouter], optional: [IInspector, ILabShell], provides: IMainMenu, activate: ( app: JupyterFrontEnd, palette: ICommandPalette, + router: IRouter, inspector: IInspector | null, labShell: ILabShell | null ): IMainMenu => { @@ -140,7 +144,7 @@ const plugin: JupyterFrontEndPlugin = { // Create the application menus. createEditMenu(app, menu.editMenu); - createFileMenu(app, menu.fileMenu, inspector); + createFileMenu(app, menu.fileMenu, router, inspector); createKernelMenu(app, menu.kernelMenu); createRunMenu(app, menu.runMenu); createSettingsMenu(app, menu.settingsMenu); @@ -200,7 +204,7 @@ const plugin: JupyterFrontEndPlugin = { // Add some of the commands defined here to the command palette. if (menu.fileMenu.quitEntry) { palette.addItem({ - command: CommandIDs.quit, + command: CommandIDs.shutdown, category: 'Main Area' }); } @@ -300,6 +304,7 @@ export function createEditMenu(app: JupyterFrontEnd, menu: EditMenu): void { export function createFileMenu( app: JupyterFrontEnd, menu: FileMenu, + router: IRouter, inspector: IInspector | null ): void { const commands = menu.menu.commands; @@ -342,14 +347,17 @@ export function createFileMenu( execute: Private.delegateExecute(app, menu.consoleCreators, 'createConsole') }); - commands.addCommand(CommandIDs.quit, { - label: 'Quit', - caption: 'Quit JupyterLab', + commands.addCommand(CommandIDs.shutdown, { + label: 'Shutdown', + caption: 'Shut down JupyterLab', execute: () => { return showDialog({ - title: 'Quit confirmation', - body: 'Please confirm you want to quit JupyterLab.', - buttons: [Dialog.cancelButton(), Dialog.warnButton({ label: 'Quit' })] + title: 'Shut down confirmation', + body: 'Please confirm you want to shut down JupyterLab.', + buttons: [ + Dialog.cancelButton(), + Dialog.warnButton({ label: 'Shut Down' }) + ] }).then(result => { if (result.button.accept) { let setting = ServerConnection.makeSettings(); @@ -383,6 +391,14 @@ export function createFileMenu( } }); + commands.addCommand(CommandIDs.logout, { + label: 'Logout', + caption: 'Log out of JupyterLab', + execute: () => { + router.navigate('/logout', { hard: true }); + } + }); + // Add the new group const newGroup = [ { type: 'submenu' as Menu.ItemType, submenu: menu.newMenu.menu }, @@ -424,7 +440,10 @@ export function createFileMenu( }); // Add the quit group. - const quitGroup = [{ command: 'filemenu:quit' }]; + const quitGroup = [ + { command: 'filemenu:logout' }, + { command: 'filemenu:shutdown' } + ]; menu.addGroup(newGroup, 0); menu.addGroup(newViewGroup, 1); From 96c5add989146abab77fd63ad3460fdafa5bcefe Mon Sep 17 00:00:00 2001 From: madhu94 Date: Wed, 1 May 2019 20:07:37 +0530 Subject: [PATCH 2/2] Change 'Shut down confirmation' to 'Shutdown confirmation' --- packages/mainmenu-extension/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mainmenu-extension/src/index.ts b/packages/mainmenu-extension/src/index.ts index bf737b72c89c..e8236bafee61 100644 --- a/packages/mainmenu-extension/src/index.ts +++ b/packages/mainmenu-extension/src/index.ts @@ -352,7 +352,7 @@ export function createFileMenu( caption: 'Shut down JupyterLab', execute: () => { return showDialog({ - title: 'Shut down confirmation', + title: 'Shutdown confirmation', body: 'Please confirm you want to shut down JupyterLab.', buttons: [ Dialog.cancelButton(),