/
index.ts
74 lines (68 loc) · 2.21 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
63
64
65
66
67
68
69
70
71
72
73
74
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
/**
* @packageDocumentation
* @module running-extension
*/
import {
ILabShell,
ILayoutRestorer,
JupyterFrontEnd,
JupyterFrontEndPlugin
} from '@jupyterlab/application';
import {
IRunningSessionManagers,
RunningSessionManagers,
RunningSessions
} from '@jupyterlab/running';
import { ITranslator } from '@jupyterlab/translation';
import { runningIcon } from '@jupyterlab/ui-components';
import { addKernelRunningSessionManager } from './kernels';
import { addOpenTabsSessionManager } from './opentabs';
/**
* The default running sessions extension.
*/
const plugin: JupyterFrontEndPlugin<IRunningSessionManagers> = {
activate,
id: '@jupyterlab/running-extension:plugin',
provides: IRunningSessionManagers,
requires: [ITranslator],
optional: [ILayoutRestorer, ILabShell],
autoStart: true
};
/**
* Export the plugin as default.
*/
export default plugin;
/**
* Activate the running plugin.
*/
function activate(
app: JupyterFrontEnd,
translator: ITranslator,
restorer: ILayoutRestorer | null,
labShell: ILabShell | null
): IRunningSessionManagers {
const trans = translator.load('jupyterlab');
const runningSessionManagers = new RunningSessionManagers();
const running = new RunningSessions(runningSessionManagers, translator);
running.id = 'jp-running-sessions';
running.title.caption = trans.__('Running Terminals and Kernels');
running.title.icon = runningIcon;
running.node.setAttribute('role', 'region');
running.node.setAttribute('aria-label', trans.__('Running Sessions section'));
// 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');
}
if (labShell) {
addOpenTabsSessionManager(runningSessionManagers, translator, labShell);
}
addKernelRunningSessionManager(runningSessionManagers, translator, app);
// Rank has been chosen somewhat arbitrarily to give priority to the running
// sessions widget in the sidebar.
app.shell.add(running, 'left', { rank: 200 });
return runningSessionManagers;
}