This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
/
index.ts
62 lines (53 loc) · 1.69 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
import {
ILayoutRestorer,
JupyterFrontEnd,
JupyterFrontEndPlugin
} from '@jupyterlab/application';
import { RunningSessions } from '@jupyterlab/running';
/**
* The default running sessions extension.
*/
const plugin: JupyterFrontEndPlugin<void> = {
activate,
id: '@jupyterlab/running-extension:plugin',
optional: [ILayoutRestorer],
autoStart: true
};
/**
* Export the plugin as default.
*/
export default plugin;
/**
* Activate the running plugin.
*/
function activate(
app: JupyterFrontEnd,
restorer: ILayoutRestorer | null
): void {
let running = new RunningSessions({ manager: app.serviceManager });
running.id = 'jp-running-sessions';
running.title.iconClass = 'jp-RunningIcon jp-SideBar-tabIcon';
running.title.caption = 'Running Terminals and Kernels';
// Let the application restorer track the running panel for restoration of
// application state (e.g. setting the running panel as the current side bar
// widget).
if (restorer) {
restorer.add(running, 'running-sessions');
}
running.sessionOpenRequested.connect((sender, model) => {
let path = model.path;
if (model.type.toLowerCase() === 'console') {
void app.commands.execute('console:open', { path });
} else {
void app.commands.execute('docmanager:open', { path });
}
});
running.terminalOpenRequested.connect((sender, model) => {
void app.commands.execute('terminal:open', { name: model.name });
});
// Rank has been chosen somewhat arbitrarily to give priority to the running
// sessions widget in the sidebar.
app.shell.add(running, 'left', { rank: 200 });
}