Skip to content

Commit

Permalink
Merge pull request #7618 from blink1073/session-dialogs
Browse files Browse the repository at this point in the history
Make session dialogs configurable
  • Loading branch information
Steven Silvester committed Dec 24, 2019
2 parents 7fb0185 + 92d1dc0 commit 47de94a
Show file tree
Hide file tree
Showing 20 changed files with 470 additions and 385 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
6 changes: 3 additions & 3 deletions examples/test_examples.py
Expand Up @@ -17,12 +17,12 @@

here = osp.abspath(osp.dirname(__file__))

def header(path, cwd = ''):
def header(path):
test_name = osp.basename(path)
print('\n'.join((
'\n',
'*' * 40,
'Starting %s test in %s' % (test_name, cwd),
'Starting %s test in %s' % (test_name, path),
'*' * 40
)), flush=True)

Expand All @@ -46,7 +46,7 @@ def main():
with tempfile.TemporaryDirectory() as cwd:
header(path)
runner = osp.join(path, 'main.py')
subprocess.check_call([sys.executable, runner])
subprocess.check_call([sys.executable, runner], cwd=cwd)
count += 1
elif osp.exists(osp.join(path, 'main.py')):
with tempfile.TemporaryDirectory() as cwd:
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 { URLExt } from '@jupyterlab/coreutils';
Expand Down Expand Up @@ -441,6 +443,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 @@ -452,6 +466,7 @@ const plugins: JupyterFrontEndPlugin<any>[] = [
settingsPlugin,
state,
splash,
sessionDialogs,
themesPlugin,
themesPaletteMenuPlugin
];
Expand Down

0 comments on commit 47de94a

Please sign in to comment.