Skip to content

Commit

Permalink
Make session dialogs configurable
Browse files Browse the repository at this point in the history
lint

update notebook example

offer the option to keep no kernel

integrity

lint

fix up merge conflicts

lint

update tests

Update tests

Select a kernel if necessary in the console
  • Loading branch information
Steven Silvester committed Dec 23, 2019
1 parent 72d9e17 commit 9505ae3
Show file tree
Hide file tree
Showing 18 changed files with 454 additions and 371 deletions.
8 changes: 5 additions & 3 deletions examples/notebook/src/commands.ts
Expand Up @@ -2,6 +2,7 @@
* Set up keyboard shortcuts & commands for notebook
*/
import { CommandRegistry } from '@lumino/commands';
import { sessionContextDialogs } from '@jupyterlab/apputils';
import { CompletionHandler } from '@jupyterlab/completer';
import { NotebookPanel, NotebookActions } from '@jupyterlab/notebook';
import {
Expand Down Expand Up @@ -126,12 +127,13 @@ export const SetupCommands = (
});
commands.addCommand(cmdIds.restart, {
label: 'Restart Kernel',
execute: async () =>
nbWidget.context.sessionContext.session?.kernel?.restart()
execute: () =>
sessionContextDialogs.restart(nbWidget.context.sessionContext)
});
commands.addCommand(cmdIds.switchKernel, {
label: 'Switch Kernel',
execute: async () => nbWidget.context.sessionContext.selectKernel()
execute: () =>
sessionContextDialogs.selectKernel(nbWidget.context.sessionContext)
});
commands.addCommand(cmdIds.runAndAdvance, {
label: 'Run and Advance',
Expand Down
2 changes: 1 addition & 1 deletion examples/notebook/src/index.ts
Expand Up @@ -112,7 +112,7 @@ function createApp(manager: ServiceManager.IManager): void {
const model = new CompleterModel();
const completer = new Completer({ editor, model });
const connector = new KernelConnector({
session: nbWidget.sessionContext.session
session: nbWidget.context.sessionContext.session
});
const handler = new CompletionHandler({ completer, connector });

Expand Down
17 changes: 16 additions & 1 deletion packages/apputils-extension/src/index.ts
Expand Up @@ -13,10 +13,12 @@ import {
import {
Dialog,
ICommandPalette,
ISessionContextDialogs,
ISplashScreen,
IWindowResolver,
WindowResolver,
Printing
Printing,
sessionContextDialogs
} from '@jupyterlab/apputils';

import { IStateDB, StateDB, URLExt } from '@jupyterlab/coreutils';
Expand Down Expand Up @@ -439,6 +441,18 @@ const state: JupyterFrontEndPlugin<IStateDB> = {
}
};

/**
* The default session context dialogs extension.
*/
const sessionDialogs: JupyterFrontEndPlugin<ISessionContextDialogs> = {
id: '@jupyterlab/apputils-extension:sessionDialogs',
provides: ISessionContextDialogs,
autoStart: true,
activate: () => {
return sessionContextDialogs;
}
};

/**
* Export the plugins as default.
*/
Expand All @@ -450,6 +464,7 @@ const plugins: JupyterFrontEndPlugin<any>[] = [
settingsPlugin,
state,
splash,
sessionDialogs,
themesPlugin,
themesPaletteMenuPlugin
];
Expand Down

0 comments on commit 9505ae3

Please sign in to comment.