forked from jupyterlab/jupyterlab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
85 lines (67 loc) · 1.8 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
75
76
77
78
79
80
81
82
83
84
85
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
import {
IServiceManager
} from '@jupyterlab/services';
import {
JupyterLab, JupyterLabPlugin
} from '@jupyterlab/application';
import {
ICommandLinker, ICommandPalette, ILayoutRestorer
} from '@jupyterlab/apputils';
import {
ILauncher, LauncherModel, LauncherWidget
} from '@jupyterlab/launcher';
/**
* The command IDs used by the launcher plugin.
*/
namespace CommandIDs {
export
const show = 'launcher-jupyterlab:show';
};
/**
* A service providing an interface to the the launcher.
*/
const plugin: JupyterLabPlugin<ILauncher> = {
activate,
id: 'jupyter.services.launcher',
requires: [
IServiceManager,
ICommandPalette,
ICommandLinker,
ILayoutRestorer
],
provides: ILauncher,
autoStart: true
};
/**
* Export the plugin as default.
*/
export default plugin;
/**
* Activate the launcher.
*/
function activate(app: JupyterLab, services: IServiceManager, palette: ICommandPalette, linker: ICommandLinker, restorer: ILayoutRestorer): ILauncher {
const { commands, shell } = app;
let model = new LauncherModel();
let widget = new LauncherWidget({ linker });
widget.model = model;
widget.id = 'launcher';
widget.title.label = 'Launcher';
// Let the application restorer track the launcher for restoration of
// application state (e.g. setting the launcher as the current side bar
// widget).
restorer.add(widget, 'launcher');
commands.addCommand(CommandIDs.show, {
label: 'Show Launcher',
execute: () => {
if (!widget.isAttached) {
shell.addToLeftArea(widget);
}
shell.activateById(widget.id);
}
});
palette.addItem({ command: CommandIDs.show, category: 'Help' });
shell.addToLeftArea(widget);
return model;
}