Skip to content

Commit ac271b4

Browse files
committed
Basic kernel controls
1 parent 3573e98 commit ac271b4

File tree

3 files changed

+185
-6
lines changed

3 files changed

+185
-6
lines changed

packages/blockly-extension/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"@jupyterlab/codeeditor": "^3.4",
4949
"@jupyterlab/filebrowser": "^3.4",
5050
"@jupyterlab/launcher": "^3.4",
51+
"@jupyterlab/mainmenu": "^3.4",
5152
"@jupyterlab/rendermime": "^3.4",
5253
"@jupyterlab/settingregistry": "^3.4",
5354
"@jupyterlab/translation": "^3.4",

packages/blockly-extension/src/index.ts

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { IFileBrowserFactory } from '@jupyterlab/filebrowser';
1111
import { ILauncher } from '@jupyterlab/launcher';
1212
import { ITranslator } from '@jupyterlab/translation';
1313
import { ISettingRegistry } from '@jupyterlab/settingregistry';
14+
import { IKernelMenu, IMainMenu } from '@jupyterlab/mainmenu';
1415

1516
import { BlocklyEditorFactory } from 'jupyterlab-blockly';
1617
import { IBlocklyRegistry } from 'jupyterlab-blockly';
@@ -48,7 +49,7 @@ const plugin: JupyterFrontEndPlugin<IBlocklyRegistry> = {
4849
ISettingRegistry,
4950
ITranslator
5051
],
51-
optional: [ILauncher, ICommandPalette],
52+
optional: [ILauncher, ICommandPalette, IMainMenu],
5253
provides: IBlocklyRegistry,
5354
activate: (
5455
app: JupyterFrontEnd,
@@ -59,7 +60,8 @@ const plugin: JupyterFrontEndPlugin<IBlocklyRegistry> = {
5960
settings: ISettingRegistry,
6061
translator: ITranslator,
6162
launcher: ILauncher | null,
62-
palette: ICommandPalette | null
63+
palette: ICommandPalette | null,
64+
mainMenu: IMainMenu | null
6365
): IBlocklyRegistry => {
6466
console.log('JupyterLab extension jupyterlab-blocky is activated!');
6567

@@ -80,7 +82,6 @@ const plugin: JupyterFrontEndPlugin<IBlocklyRegistry> = {
8082
}
8183

8284
const { commands } = app;
83-
const command = CommandIDs.createNew;
8485

8586
// Creating the widget factory to register it so the document manager knows about
8687
// our new DocumentWidget
@@ -159,7 +160,7 @@ const plugin: JupyterFrontEndPlugin<IBlocklyRegistry> = {
159160
widgetFactory.registry.setlanguage(language);
160161
});
161162

162-
commands.addCommand(command, {
163+
commands.addCommand(CommandIDs.createNew, {
163164
label: args =>
164165
args['isPalette'] ? 'New Blockly Editor' : 'Blockly Editor',
165166
caption: 'Create a new Blockly Editor',
@@ -188,7 +189,7 @@ const plugin: JupyterFrontEndPlugin<IBlocklyRegistry> = {
188189
// Add the command to the launcher
189190
if (launcher) {
190191
launcher.add({
191-
command,
192+
command: CommandIDs.createNew,
192193
category: 'Other',
193194
rank: 1
194195
});
@@ -197,12 +198,42 @@ const plugin: JupyterFrontEndPlugin<IBlocklyRegistry> = {
197198
// Add the command to the palette
198199
if (palette) {
199200
palette.addItem({
200-
command,
201+
command: CommandIDs.createNew,
201202
args: { isPalette: true },
202203
category: PALETTE_CATEGORY
203204
});
204205
}
205206

207+
// Add the command to the main menu
208+
if (mainMenu) {
209+
mainMenu.kernelMenu.kernelUsers.add({
210+
tracker,
211+
interruptKernel: current => {
212+
const kernel = current.context.sessionContext.session?.kernel;
213+
console.debug('Interrupt:', kernel);
214+
if (kernel) {
215+
return kernel.interrupt();
216+
}
217+
return Promise.resolve(void 0);
218+
},
219+
reconnectToKernel: current => {
220+
const kernel = current.context.sessionContext.session?.kernel;
221+
if (kernel) {
222+
return kernel.reconnect();
223+
}
224+
return Promise.resolve(void 0);
225+
},
226+
restartKernel: current => {
227+
const kernel = current.context.sessionContext.session?.kernel;
228+
if (kernel) {
229+
return kernel.restart();
230+
}
231+
return Promise.resolve(void 0);
232+
},
233+
shutdownKernel: current => current.context.sessionContext.shutdown()
234+
} as IKernelMenu.IKernelUser<BlocklyEditor>);
235+
}
236+
206237
return widgetFactory.registry;
207238
}
208239
};

yarn.lock

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,35 @@
232232
sanitize-html "~2.5.3"
233233
url "^0.11.0"
234234

235+
"@jupyterlab/apputils@^3.4.6":
236+
version "3.4.6"
237+
resolved "https://registry.yarnpkg.com/@jupyterlab/apputils/-/apputils-3.4.6.tgz#e86e03605926ade4b8ed337ebf62aa738148f21a"
238+
integrity sha512-/FTxFIqpgdWTYZFfB/XWKd3TjZV4WxG6i2Gwx2IFTBN2ZiRi6qRmyh7NOs6GXbOxyfw58IXFrKsqoDe6MeALbg==
239+
dependencies:
240+
"@jupyterlab/coreutils" "^5.4.6"
241+
"@jupyterlab/observables" "^4.4.6"
242+
"@jupyterlab/services" "^6.4.6"
243+
"@jupyterlab/settingregistry" "^3.4.6"
244+
"@jupyterlab/statedb" "^3.4.6"
245+
"@jupyterlab/translation" "^3.4.6"
246+
"@jupyterlab/ui-components" "^3.4.6"
247+
"@lumino/algorithm" "^1.9.0"
248+
"@lumino/commands" "^1.19.0"
249+
"@lumino/coreutils" "^1.11.0"
250+
"@lumino/disposable" "^1.10.0"
251+
"@lumino/domutils" "^1.8.0"
252+
"@lumino/messaging" "^1.10.0"
253+
"@lumino/polling" "^1.9.0"
254+
"@lumino/properties" "^1.8.0"
255+
"@lumino/signaling" "^1.10.0"
256+
"@lumino/virtualdom" "^1.14.0"
257+
"@lumino/widgets" "^1.33.0"
258+
"@types/react" "^17.0.0"
259+
react "^17.0.1"
260+
react-dom "^17.0.1"
261+
sanitize-html "~2.5.3"
262+
url "^0.11.0"
263+
235264
"@jupyterlab/attachments@^3.4.3":
236265
version "3.4.3"
237266
resolved "https://registry.yarnpkg.com/@jupyterlab/attachments/-/attachments-3.4.3.tgz#a958bb529c3f606694d0b60211b7b8b882a1ebf7"
@@ -394,6 +423,19 @@
394423
path-browserify "^1.0.0"
395424
url-parse "~1.5.1"
396425

426+
"@jupyterlab/coreutils@^5.4.6":
427+
version "5.4.6"
428+
resolved "https://registry.yarnpkg.com/@jupyterlab/coreutils/-/coreutils-5.4.6.tgz#abe3b66ac06ae6cfc54700e5b8ee6c91a9904187"
429+
integrity sha512-WvXhJhoDgR+KC1voJf6lLDY16nA6p2f8r0ggIBFYn9vxpd02AU1Xhocr44k5r3zXM33HT5jDz1U9hpCbkr+vCQ==
430+
dependencies:
431+
"@lumino/coreutils" "^1.11.0"
432+
"@lumino/disposable" "^1.10.0"
433+
"@lumino/signaling" "^1.10.0"
434+
minimist "~1.2.0"
435+
moment "^2.24.0"
436+
path-browserify "^1.0.0"
437+
url-parse "~1.5.1"
438+
397439
"@jupyterlab/docmanager@^3.4.3":
398440
version "3.4.3"
399441
resolved "https://registry.yarnpkg.com/@jupyterlab/docmanager/-/docmanager-3.4.3.tgz#26e9571a93f1a6a6d7b59f9296499fdcabd998b7"
@@ -493,13 +535,34 @@
493535
"@lumino/widgets" "^1.30.0"
494536
react "^17.0.1"
495537

538+
"@jupyterlab/mainmenu@^3.4":
539+
version "3.4.6"
540+
resolved "https://registry.yarnpkg.com/@jupyterlab/mainmenu/-/mainmenu-3.4.6.tgz#2301e8e9c441e02f900e18e9e817cdc7c88d1974"
541+
integrity sha512-LZ8Pb9VlT1MMLZC8eKfh9oJXxkhkRyNNMtceYV+nXYtx8uSn3hapP9zMhqPVwS4bTI83QNUOvYna2Rg7xwm86Q==
542+
dependencies:
543+
"@jupyterlab/apputils" "^3.4.6"
544+
"@jupyterlab/services" "^6.4.6"
545+
"@jupyterlab/translation" "^3.4.6"
546+
"@jupyterlab/ui-components" "^3.4.6"
547+
"@lumino/algorithm" "^1.9.0"
548+
"@lumino/commands" "^1.19.0"
549+
"@lumino/coreutils" "^1.11.0"
550+
"@lumino/widgets" "^1.33.0"
551+
496552
"@jupyterlab/nbformat@^3.4.3":
497553
version "3.4.3"
498554
resolved "https://registry.yarnpkg.com/@jupyterlab/nbformat/-/nbformat-3.4.3.tgz#cbab1bf507677b7f0f309d8353fc83fe5a973c82"
499555
integrity sha512-i/yADrwhhAJJCUOTa+fEBMyJO7fvX9Y73I0B7V6dQhGcrmrEKLC3wk4yOo63+jRntd5+dupbiOtz3w1ncIXwIA==
500556
dependencies:
501557
"@lumino/coreutils" "^1.11.0"
502558

559+
"@jupyterlab/nbformat@^3.4.6":
560+
version "3.4.6"
561+
resolved "https://registry.yarnpkg.com/@jupyterlab/nbformat/-/nbformat-3.4.6.tgz#926273d0e9e340adf0bdd3b3573253e5f428cfbb"
562+
integrity sha512-VWg+HfEyF59irxV+xv5Zeioqhk7M8ZdVaXaPqsvBmHP81Ew7Ss83Do6b9bb2TEe6Bz7sCcGmcRr/zSkhTatmEw==
563+
dependencies:
564+
"@lumino/coreutils" "^1.11.0"
565+
503566
"@jupyterlab/observables@^4.4.3":
504567
version "4.4.3"
505568
resolved "https://registry.yarnpkg.com/@jupyterlab/observables/-/observables-4.4.3.tgz#41d07af0987dc37953214e20ee1dfc0b15669ef0"
@@ -511,6 +574,17 @@
511574
"@lumino/messaging" "^1.10.0"
512575
"@lumino/signaling" "^1.10.0"
513576

577+
"@jupyterlab/observables@^4.4.6":
578+
version "4.4.6"
579+
resolved "https://registry.yarnpkg.com/@jupyterlab/observables/-/observables-4.4.6.tgz#970a9bbb5c31e96a2da062169e2fbc6c06817432"
580+
integrity sha512-RuSroUJalcPIGuleiLiwrtUbtNktv0mLGFcOrT24AAMC25O+caWWDUo1VLUIX56V/DYphgOzclxlDRsaDpFWgQ==
581+
dependencies:
582+
"@lumino/algorithm" "^1.9.0"
583+
"@lumino/coreutils" "^1.11.0"
584+
"@lumino/disposable" "^1.10.0"
585+
"@lumino/messaging" "^1.10.0"
586+
"@lumino/signaling" "^1.10.0"
587+
514588
"@jupyterlab/outputarea@^3.4.3":
515589
version "3.4.3"
516590
resolved "https://registry.yarnpkg.com/@jupyterlab/outputarea/-/outputarea-3.4.3.tgz#285bb767334d82bbbb3b94f80cefeee746972c3d"
@@ -579,6 +653,24 @@
579653
node-fetch "^2.6.0"
580654
ws "^7.4.6"
581655

656+
"@jupyterlab/services@^6.4.6":
657+
version "6.4.6"
658+
resolved "https://registry.yarnpkg.com/@jupyterlab/services/-/services-6.4.6.tgz#790c2c14b82bd00f68d59675f141204ef0f6f4a2"
659+
integrity sha512-k6xUoOnamdVJETaNh0EIl3DtvK4zhB59FABBxjpyvvOixo3WShmdJVywHgpdG7MkOK9NdRM9/pNASKUj0/836w==
660+
dependencies:
661+
"@jupyterlab/coreutils" "^5.4.6"
662+
"@jupyterlab/nbformat" "^3.4.6"
663+
"@jupyterlab/observables" "^4.4.6"
664+
"@jupyterlab/settingregistry" "^3.4.6"
665+
"@jupyterlab/statedb" "^3.4.6"
666+
"@lumino/algorithm" "^1.9.0"
667+
"@lumino/coreutils" "^1.11.0"
668+
"@lumino/disposable" "^1.10.0"
669+
"@lumino/polling" "^1.9.0"
670+
"@lumino/signaling" "^1.10.0"
671+
node-fetch "^2.6.0"
672+
ws "^7.4.6"
673+
582674
"@jupyterlab/settingregistry@^3.4", "@jupyterlab/settingregistry@^3.4.3":
583675
version "3.4.3"
584676
resolved "https://registry.yarnpkg.com/@jupyterlab/settingregistry/-/settingregistry-3.4.3.tgz#531cb702a7eefdd12cce541893152056f66841d2"
@@ -592,6 +684,19 @@
592684
ajv "^6.12.3"
593685
json5 "^2.1.1"
594686

687+
"@jupyterlab/settingregistry@^3.4.6":
688+
version "3.4.6"
689+
resolved "https://registry.yarnpkg.com/@jupyterlab/settingregistry/-/settingregistry-3.4.6.tgz#6fd66e8568bd4fdcd598b4684c0478a232d0e38e"
690+
integrity sha512-2wKL3+yyvdRJHYhUQ6Jxbxd0HuMdS+Tj/DcIrPkA4Zp6GTsZyd1TrUisSzKxSf8YLGqy1ef3fVvNX4w5LPQ1GA==
691+
dependencies:
692+
"@jupyterlab/statedb" "^3.4.6"
693+
"@lumino/commands" "^1.19.0"
694+
"@lumino/coreutils" "^1.11.0"
695+
"@lumino/disposable" "^1.10.0"
696+
"@lumino/signaling" "^1.10.0"
697+
ajv "^6.12.3"
698+
json5 "^2.1.1"
699+
595700
"@jupyterlab/shared-models@^3.4.3":
596701
version "3.4.3"
597702
resolved "https://registry.yarnpkg.com/@jupyterlab/shared-models/-/shared-models-3.4.3.tgz#656b7108f16f78e092b11b6bf7ddaec59d518099"
@@ -615,6 +720,17 @@
615720
"@lumino/properties" "^1.8.0"
616721
"@lumino/signaling" "^1.10.0"
617722

723+
"@jupyterlab/statedb@^3.4.6":
724+
version "3.4.6"
725+
resolved "https://registry.yarnpkg.com/@jupyterlab/statedb/-/statedb-3.4.6.tgz#9f3548d1b8cca5ba5191b85851f34a37ade94efb"
726+
integrity sha512-3ojiwhErFNH7McL+++ApOFcxzxx20Ddwopr/rFi2ARFOu3hfhXMwuIt9272G2+RgRQebZhq7qzb7mxXZOpid4Q==
727+
dependencies:
728+
"@lumino/commands" "^1.19.0"
729+
"@lumino/coreutils" "^1.11.0"
730+
"@lumino/disposable" "^1.10.0"
731+
"@lumino/properties" "^1.8.0"
732+
"@lumino/signaling" "^1.10.0"
733+
618734
"@jupyterlab/statusbar@^3.4.3":
619735
version "3.4.3"
620736
resolved "https://registry.yarnpkg.com/@jupyterlab/statusbar/-/statusbar-3.4.3.tgz#d9a35b79bb5c61b3215b778ff563fcf260c60070"
@@ -645,6 +761,16 @@
645761
"@jupyterlab/statedb" "^3.4.3"
646762
"@lumino/coreutils" "^1.11.0"
647763

764+
"@jupyterlab/translation@^3.4.6":
765+
version "3.4.6"
766+
resolved "https://registry.yarnpkg.com/@jupyterlab/translation/-/translation-3.4.6.tgz#4e079cf77ca5b50d6cde3dcafff6e2117fa09926"
767+
integrity sha512-L/hSjBYyza9vWwS/+CbUkn7ad0BfJ6Q+w9XMbcf7ac/7Wycd5pSdyWc37HDbsYYwSKXe90IbdR1YKke5HKCFfw==
768+
dependencies:
769+
"@jupyterlab/coreutils" "^5.4.6"
770+
"@jupyterlab/services" "^6.4.6"
771+
"@jupyterlab/statedb" "^3.4.6"
772+
"@lumino/coreutils" "^1.11.0"
773+
648774
"@jupyterlab/ui-components@^3.4", "@jupyterlab/ui-components@^3.4.3":
649775
version "3.4.3"
650776
resolved "https://registry.yarnpkg.com/@jupyterlab/ui-components/-/ui-components-3.4.3.tgz#180ba2e0a273fce78ec9cf38782060a12064f02c"
@@ -666,6 +792,27 @@
666792
react-dom "^17.0.1"
667793
typestyle "^2.0.4"
668794

795+
"@jupyterlab/ui-components@^3.4.6":
796+
version "3.4.6"
797+
resolved "https://registry.yarnpkg.com/@jupyterlab/ui-components/-/ui-components-3.4.6.tgz#d9b1c4ccf8d3ce94d71dd94f95b3d401aca4a6f0"
798+
integrity sha512-kLwHnQ7hNXoNU41yvN5n1ghRQA/c2jxE1EC1k6ddAtCTDlN8e+a8uDIJqxR1wYGKBAJNZEKgBPRKNk0G62VoCA==
799+
dependencies:
800+
"@blueprintjs/core" "^3.36.0"
801+
"@blueprintjs/select" "^3.15.0"
802+
"@jupyterlab/coreutils" "^5.4.6"
803+
"@jupyterlab/translation" "^3.4.6"
804+
"@lumino/algorithm" "^1.9.0"
805+
"@lumino/commands" "^1.19.0"
806+
"@lumino/coreutils" "^1.11.0"
807+
"@lumino/disposable" "^1.10.0"
808+
"@lumino/signaling" "^1.10.0"
809+
"@lumino/virtualdom" "^1.14.0"
810+
"@lumino/widgets" "^1.33.0"
811+
"@rjsf/core" "^3.1.0"
812+
react "^17.0.1"
813+
react-dom "^17.0.1"
814+
typestyle "^2.0.4"
815+
669816
"@lerna/add@5.1.0":
670817
version "5.1.0"
671818
resolved "https://registry.yarnpkg.com/@lerna/add/-/add-5.1.0.tgz#5a2abcae01f360a9b56dd047e0388a99ec2ba151"

0 commit comments

Comments
 (0)