UNPKG

2.02 kBPlain TextView Raw
1// Copyright (c) Jupyter Development Team.
2// Distributed under the terms of the Modified BSD License.
3
4import { IRankedMenu, RankedMenu } from '@jupyterlab/ui-components';
5import { SemanticCommand } from '@jupyterlab/apputils';
6
7/**
8 * An interface for a Kernel menu.
9 */
10export interface IKernelMenu extends IRankedMenu {
11 /**
12 * Semantic commands IKernelUsers for the Kernel menu.
13 */
14 readonly kernelUsers: IKernelMenu.IKernelUser;
15}
16
17/**
18 * An extensible Kernel menu for the application.
19 */
20export class KernelMenu extends RankedMenu implements IKernelMenu {
21 /**
22 * Construct the kernel menu.
23 */
24 constructor(options: IRankedMenu.IOptions) {
25 super(options);
26 this.kernelUsers = {
27 changeKernel: new SemanticCommand(),
28 clearWidget: new SemanticCommand(),
29 interruptKernel: new SemanticCommand(),
30 reconnectToKernel: new SemanticCommand(),
31 restartKernel: new SemanticCommand(),
32 shutdownKernel: new SemanticCommand()
33 };
34 }
35
36 /**
37 * Semantic commands IKernelUsers for the Kernel menu.
38 */
39 readonly kernelUsers: IKernelMenu.IKernelUser;
40}
41
42/**
43 * Namespace for IKernelMenu
44 */
45export namespace IKernelMenu {
46 /**
47 * Interface for a Kernel user to register itself
48 * with the IKernelMenu's semantic extension points.
49 */
50 export interface IKernelUser {
51 /**
52 * A semantic command to interrupt the kernel.
53 */
54 interruptKernel: SemanticCommand;
55
56 /**
57 * A semantic command to reconnect to the kernel
58 */
59 reconnectToKernel: SemanticCommand;
60
61 /**
62 * A semantic command to restart the kernel, which
63 * returns a promise of whether the kernel was restarted.
64 */
65 restartKernel: SemanticCommand;
66
67 /**
68 * A semantic command to clear the widget.
69 */
70 clearWidget: SemanticCommand;
71
72 /**
73 * A semantic command to change the kernel.
74 */
75 changeKernel: SemanticCommand;
76
77 /**
78 * A semantic command to shut down the kernel.
79 */
80 shutdownKernel: SemanticCommand;
81 }
82}