Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make session dialogs configurable #7618

Merged
merged 14 commits into from Dec 24, 2019
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