@jupyterlab/running-extension 4.2.0-alpha.1 → 4.2.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +5 -7
- package/lib/index.js +105 -36
- package/lib/index.js.map +1 -1
- package/lib/kernels.js +74 -25
- package/lib/kernels.js.map +1 -1
- package/lib/recents.d.ts +15 -0
- package/lib/recents.js +88 -0
- package/lib/recents.js.map +1 -0
- package/package.json +14 -10
- package/schema/plugin.json +5 -0
- package/src/index.ts +151 -42
- package/src/{kernels.ts → kernels.tsx} +108 -27
- package/src/recents.ts +106 -0
- package/style/index.css +2 -0
- package/style/index.js +2 -0
package/lib/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @module running-extension
|
|
4
4
|
*/
|
|
5
5
|
import { JupyterFrontEndPlugin } from '@jupyterlab/application';
|
|
6
|
-
import { IRunningSessionManagers } from '@jupyterlab/running';
|
|
6
|
+
import { IRunningSessionManagers, IRunningSessionSidebar } from '@jupyterlab/running';
|
|
7
7
|
/**
|
|
8
8
|
* The command IDs used by the running plugin.
|
|
9
9
|
*/
|
|
@@ -13,12 +13,10 @@ export declare namespace CommandIDs {
|
|
|
13
13
|
const kernelOpenSession = "running:kernel-open-session";
|
|
14
14
|
const kernelShutDown = "running:kernel-shut-down";
|
|
15
15
|
const showPanel = "running:show-panel";
|
|
16
|
+
const showModal = "running:show-modal";
|
|
16
17
|
}
|
|
17
18
|
/**
|
|
18
|
-
*
|
|
19
|
+
* Export the plugins.
|
|
19
20
|
*/
|
|
20
|
-
declare const
|
|
21
|
-
|
|
22
|
-
* Export the plugin as default.
|
|
23
|
-
*/
|
|
24
|
-
export default plugin;
|
|
21
|
+
declare const _default: (JupyterFrontEndPlugin<void> | JupyterFrontEndPlugin<IRunningSessionManagers> | JupyterFrontEndPlugin<IRunningSessionSidebar>)[];
|
|
22
|
+
export default _default;
|
package/lib/index.js
CHANGED
|
@@ -5,11 +5,15 @@
|
|
|
5
5
|
* @module running-extension
|
|
6
6
|
*/
|
|
7
7
|
import { ILabShell, ILayoutRestorer } from '@jupyterlab/application';
|
|
8
|
-
import {
|
|
8
|
+
import { Dialog, ICommandPalette } from '@jupyterlab/apputils';
|
|
9
|
+
import { IRunningSessionManagers, IRunningSessionSidebar, RunningSessionManagers, RunningSessions, SearchableSessions } from '@jupyterlab/running';
|
|
10
|
+
import { IRecentsManager } from '@jupyterlab/docmanager';
|
|
11
|
+
import { IStateDB } from '@jupyterlab/statedb';
|
|
9
12
|
import { ITranslator } from '@jupyterlab/translation';
|
|
10
|
-
import { runningIcon } from '@jupyterlab/ui-components';
|
|
13
|
+
import { CommandToolbarButton, launcherIcon, runningIcon } from '@jupyterlab/ui-components';
|
|
11
14
|
import { addKernelRunningSessionManager } from './kernels';
|
|
12
15
|
import { addOpenTabsSessionManager } from './opentabs';
|
|
16
|
+
import { addRecentlyClosedSessionManager } from './recents';
|
|
13
17
|
/**
|
|
14
18
|
* The command IDs used by the running plugin.
|
|
15
19
|
*/
|
|
@@ -20,54 +24,119 @@ export var CommandIDs;
|
|
|
20
24
|
CommandIDs.kernelOpenSession = 'running:kernel-open-session';
|
|
21
25
|
CommandIDs.kernelShutDown = 'running:kernel-shut-down';
|
|
22
26
|
CommandIDs.showPanel = 'running:show-panel';
|
|
27
|
+
CommandIDs.showModal = 'running:show-modal';
|
|
23
28
|
})(CommandIDs || (CommandIDs = {}));
|
|
24
29
|
/**
|
|
25
30
|
* The default running sessions extension.
|
|
26
31
|
*/
|
|
27
32
|
const plugin = {
|
|
28
|
-
activate,
|
|
29
33
|
id: '@jupyterlab/running-extension:plugin',
|
|
30
34
|
description: 'Provides the running session managers.',
|
|
31
35
|
provides: IRunningSessionManagers,
|
|
32
36
|
requires: [ITranslator],
|
|
33
|
-
optional: [
|
|
34
|
-
autoStart: true
|
|
37
|
+
optional: [ILabShell],
|
|
38
|
+
autoStart: true,
|
|
39
|
+
activate: (app, translator, labShell) => {
|
|
40
|
+
const runningSessionManagers = new RunningSessionManagers();
|
|
41
|
+
if (labShell) {
|
|
42
|
+
addOpenTabsSessionManager(runningSessionManagers, translator, labShell);
|
|
43
|
+
}
|
|
44
|
+
void addKernelRunningSessionManager(runningSessionManagers, translator, app);
|
|
45
|
+
return runningSessionManagers;
|
|
46
|
+
}
|
|
35
47
|
};
|
|
36
48
|
/**
|
|
37
|
-
*
|
|
49
|
+
* The plugin enabling the running sidebar.
|
|
38
50
|
*/
|
|
39
|
-
|
|
51
|
+
const sidebarPlugin = {
|
|
52
|
+
id: '@jupyterlab/running-extension:sidebar',
|
|
53
|
+
description: 'Provides the running session sidebar.',
|
|
54
|
+
provides: IRunningSessionSidebar,
|
|
55
|
+
requires: [IRunningSessionManagers, ITranslator],
|
|
56
|
+
optional: [ILayoutRestorer, IStateDB],
|
|
57
|
+
autoStart: true,
|
|
58
|
+
activate: (app, manager, translator, restorer, state) => {
|
|
59
|
+
const trans = translator.load('jupyterlab');
|
|
60
|
+
const running = new RunningSessions(manager, translator, state);
|
|
61
|
+
running.id = 'jp-running-sessions';
|
|
62
|
+
running.title.caption = trans.__('Running Terminals and Kernels');
|
|
63
|
+
running.title.icon = runningIcon;
|
|
64
|
+
running.node.setAttribute('role', 'region');
|
|
65
|
+
running.node.setAttribute('aria-label', trans.__('Running Sessions section'));
|
|
66
|
+
// Let the application restorer track the running panel for restoration of
|
|
67
|
+
// application state (e.g. setting the running panel as the current side bar
|
|
68
|
+
// widget).
|
|
69
|
+
if (restorer) {
|
|
70
|
+
restorer.add(running, 'running-sessions');
|
|
71
|
+
}
|
|
72
|
+
// Rank has been chosen somewhat arbitrarily to give priority to the running
|
|
73
|
+
// sessions widget in the sidebar.
|
|
74
|
+
app.shell.add(running, 'left', { rank: 200, type: 'Sessions and Tabs' });
|
|
75
|
+
app.commands.addCommand(CommandIDs.showPanel, {
|
|
76
|
+
label: trans.__('Sessions and Tabs'),
|
|
77
|
+
execute: () => {
|
|
78
|
+
app.shell.activateById(running.id);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
return running;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
40
84
|
/**
|
|
41
|
-
*
|
|
85
|
+
* An optional adding recently closed tabs.
|
|
42
86
|
*/
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
running.node.setAttribute('role', 'region');
|
|
51
|
-
running.node.setAttribute('aria-label', trans.__('Running Sessions section'));
|
|
52
|
-
// Let the application restorer track the running panel for restoration of
|
|
53
|
-
// application state (e.g. setting the running panel as the current side bar
|
|
54
|
-
// widget).
|
|
55
|
-
if (restorer) {
|
|
56
|
-
restorer.add(running, 'running-sessions');
|
|
57
|
-
}
|
|
58
|
-
if (labShell) {
|
|
59
|
-
addOpenTabsSessionManager(runningSessionManagers, translator, labShell);
|
|
87
|
+
const recentsPlugin = {
|
|
88
|
+
id: '@jupyterlab/running-extension:recently-closed',
|
|
89
|
+
description: 'Adds recently closed documents list.',
|
|
90
|
+
requires: [IRunningSessionManagers, IRecentsManager, ITranslator],
|
|
91
|
+
autoStart: true,
|
|
92
|
+
activate: (app, manager, recents, translator) => {
|
|
93
|
+
addRecentlyClosedSessionManager(manager, recents, app.commands, app.docRegistry, translator);
|
|
60
94
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* An optional plugin allowing to among running items.
|
|
98
|
+
*/
|
|
99
|
+
const searchPlugin = {
|
|
100
|
+
id: '@jupyterlab/running-extension:search-tabs',
|
|
101
|
+
description: 'Adds a widget to search open and closed tabs.',
|
|
102
|
+
requires: [IRunningSessionManagers, ITranslator],
|
|
103
|
+
optional: [ICommandPalette, IRunningSessionSidebar],
|
|
104
|
+
autoStart: true,
|
|
105
|
+
activate: (app, manager, translator, palette, sidebar) => {
|
|
106
|
+
const trans = translator.load('jupyterlab');
|
|
107
|
+
app.commands.addCommand(CommandIDs.showModal, {
|
|
108
|
+
execute: () => {
|
|
109
|
+
const running = new SearchableSessions(manager, translator);
|
|
110
|
+
const dialog = new Dialog({
|
|
111
|
+
title: trans.__('Tabs and Running Sessions'),
|
|
112
|
+
body: running,
|
|
113
|
+
buttons: [Dialog.okButton({})],
|
|
114
|
+
hasClose: true
|
|
115
|
+
});
|
|
116
|
+
dialog.addClass('jp-SearchableSessions-modal');
|
|
117
|
+
return dialog.launch();
|
|
118
|
+
},
|
|
119
|
+
label: trans.__('Search Tabs and Running Sessions')
|
|
120
|
+
});
|
|
121
|
+
if (palette) {
|
|
122
|
+
palette.addItem({
|
|
123
|
+
command: CommandIDs.showModal,
|
|
124
|
+
category: trans.__('Running')
|
|
125
|
+
});
|
|
69
126
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
127
|
+
if (sidebar) {
|
|
128
|
+
const button = new CommandToolbarButton({
|
|
129
|
+
commands: app.commands,
|
|
130
|
+
id: CommandIDs.showModal,
|
|
131
|
+
icon: launcherIcon,
|
|
132
|
+
label: ''
|
|
133
|
+
});
|
|
134
|
+
sidebar.toolbar.addItem('open-as-modal', button);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* Export the plugins.
|
|
140
|
+
*/
|
|
141
|
+
export default [plugin, sidebarPlugin, recentsPlugin, searchPlugin];
|
|
73
142
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAC3D;;;GAGG;AAEH,OAAO,EACL,SAAS,EACT,eAAe,EAGhB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACt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F;;GAEG;AACH,eAAe,CAAC,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,CAAC,CAAC"}
|
package/lib/kernels.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
// Copyright (c) Jupyter Development Team.
|
|
2
2
|
// Distributed under the terms of the Modified BSD License.
|
|
3
3
|
import { PathExt } from '@jupyterlab/coreutils';
|
|
4
|
-
import { closeIcon, consoleIcon, jupyterIcon, notebookIcon } from '@jupyterlab/ui-components';
|
|
4
|
+
import { closeIcon, consoleIcon, jupyterIcon, kernelIcon, notebookIcon } from '@jupyterlab/ui-components';
|
|
5
5
|
import { Throttler } from '@lumino/polling';
|
|
6
6
|
import { Signal } from '@lumino/signaling';
|
|
7
7
|
import { CommandIDs } from '.';
|
|
8
|
-
|
|
8
|
+
import React from 'react';
|
|
9
|
+
const KERNEL_ITEM_CLASS = 'jp-mod-kernel';
|
|
10
|
+
const KERNELSPEC_ITEM_CLASS = 'jp-mod-kernelspec';
|
|
11
|
+
const WIDGET_ITEM_CLASS = 'jp-mod-kernel-widget';
|
|
12
|
+
const KERNEL_LABEL_ID = 'jp-RunningSessions-item-label-kernel-id';
|
|
9
13
|
/**
|
|
10
14
|
* Add the running kernel manager (notebooks & consoles) to the running panel.
|
|
11
15
|
*/
|
|
@@ -23,17 +27,30 @@ export async function addKernelRunningSessionManager(managers, translator, app)
|
|
|
23
27
|
// Add the kernels pane to the running sidebar.
|
|
24
28
|
managers.add({
|
|
25
29
|
name: trans.__('Kernels'),
|
|
26
|
-
running: () =>
|
|
30
|
+
running: () => {
|
|
27
31
|
var _a;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
kernel
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
const kernelsBySpec = new Map();
|
|
33
|
+
for (const kernel of kernels.running()) {
|
|
34
|
+
const list = (_a = kernelsBySpec.get(kernel.name)) !== null && _a !== void 0 ? _a : [];
|
|
35
|
+
kernelsBySpec.set(kernel.name, list);
|
|
36
|
+
list.push(new RunningKernel({
|
|
37
|
+
commands,
|
|
38
|
+
kernel,
|
|
39
|
+
kernels,
|
|
40
|
+
sessions,
|
|
41
|
+
trans
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
return Array.from(kernelsBySpec.entries()).map(([spec, kernels]) => {
|
|
45
|
+
var _a;
|
|
46
|
+
return new Private.KernelSpecItem({
|
|
47
|
+
name: spec,
|
|
48
|
+
kernels,
|
|
49
|
+
spec: (_a = kernelspecs.specs) === null || _a === void 0 ? void 0 : _a.kernelspecs[spec],
|
|
50
|
+
trans
|
|
51
|
+
});
|
|
35
52
|
});
|
|
36
|
-
}
|
|
53
|
+
},
|
|
37
54
|
shutdownAll: () => kernels.shutdownAll(),
|
|
38
55
|
refreshRunning: () => Promise.all([kernels.refreshRunning(), sessions.refreshRunning()]),
|
|
39
56
|
runningChanged,
|
|
@@ -42,7 +59,7 @@ export async function addKernelRunningSessionManager(managers, translator, app)
|
|
|
42
59
|
shutdownAllConfirmationText: trans.__('Are you sure you want to permanently shut down all running kernels?')
|
|
43
60
|
});
|
|
44
61
|
// Add running kernels commands to the registry.
|
|
45
|
-
const test = (node) => node.classList.contains(
|
|
62
|
+
const test = (node) => node.classList.contains(KERNEL_ITEM_CLASS);
|
|
46
63
|
commands.addCommand(CommandIDs.kernelNewConsole, {
|
|
47
64
|
icon: consoleIcon,
|
|
48
65
|
label: trans.__('New Console for Kernel'),
|
|
@@ -130,15 +147,40 @@ export async function addKernelRunningSessionManager(managers, translator, app)
|
|
|
130
147
|
}
|
|
131
148
|
var Private;
|
|
132
149
|
(function (Private) {
|
|
150
|
+
class KernelSpecItem {
|
|
151
|
+
constructor(options) {
|
|
152
|
+
this._name = options.name;
|
|
153
|
+
this.className = KERNELSPEC_ITEM_CLASS;
|
|
154
|
+
this._kernels = options.kernels;
|
|
155
|
+
this.spec = options.spec || null;
|
|
156
|
+
this.trans = options.trans;
|
|
157
|
+
}
|
|
158
|
+
icon() {
|
|
159
|
+
const { spec } = this;
|
|
160
|
+
if (!spec || !spec.resources) {
|
|
161
|
+
return jupyterIcon;
|
|
162
|
+
}
|
|
163
|
+
return (spec.resources['logo-svg'] ||
|
|
164
|
+
spec.resources['logo-64x64'] ||
|
|
165
|
+
spec.resources['logo-32x32']);
|
|
166
|
+
}
|
|
167
|
+
label() {
|
|
168
|
+
const { _name, spec } = this;
|
|
169
|
+
return (spec === null || spec === void 0 ? void 0 : spec.display_name) || _name;
|
|
170
|
+
}
|
|
171
|
+
get children() {
|
|
172
|
+
return this._kernels;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
Private.KernelSpecItem = KernelSpecItem;
|
|
133
176
|
class RunningKernel {
|
|
134
177
|
constructor(options) {
|
|
135
|
-
this.className =
|
|
178
|
+
this.className = KERNEL_ITEM_CLASS;
|
|
136
179
|
this.commands = options.commands;
|
|
137
180
|
this.kernel = options.kernel;
|
|
138
181
|
this.context = this.kernel.id;
|
|
139
182
|
this.kernels = options.kernels;
|
|
140
183
|
this.sessions = options.sessions;
|
|
141
|
-
this.spec = options.spec || null;
|
|
142
184
|
this.trans = options.trans;
|
|
143
185
|
}
|
|
144
186
|
get children() {
|
|
@@ -150,7 +192,7 @@ var Private;
|
|
|
150
192
|
if (this.kernel.id === ((_a = session.kernel) === null || _a === void 0 ? void 0 : _a.id)) {
|
|
151
193
|
const { name, path, type } = session;
|
|
152
194
|
children.push({
|
|
153
|
-
className:
|
|
195
|
+
className: WIDGET_ITEM_CLASS,
|
|
154
196
|
context: this.kernel.id,
|
|
155
197
|
open: () => void commands.execute(open, { name, path, type }),
|
|
156
198
|
icon: () => type === 'console'
|
|
@@ -169,23 +211,24 @@ var Private;
|
|
|
169
211
|
return this.kernels.shutdown(this.kernel.id);
|
|
170
212
|
}
|
|
171
213
|
icon() {
|
|
172
|
-
|
|
173
|
-
if (!spec || !spec.resources) {
|
|
174
|
-
return jupyterIcon;
|
|
175
|
-
}
|
|
176
|
-
return (spec.resources['logo-svg'] ||
|
|
177
|
-
spec.resources['logo-64x64'] ||
|
|
178
|
-
spec.resources['logo-32x32']);
|
|
214
|
+
return kernelIcon;
|
|
179
215
|
}
|
|
180
216
|
label() {
|
|
181
|
-
const { kernel
|
|
182
|
-
|
|
217
|
+
const { kernel } = this;
|
|
218
|
+
const kernelIdPrefix = kernel.id.split('-')[0];
|
|
219
|
+
return (React.createElement(React.Fragment, null,
|
|
220
|
+
this._summary,
|
|
221
|
+
' ',
|
|
222
|
+
React.createElement("span", { className: KERNEL_LABEL_ID },
|
|
223
|
+
"(",
|
|
224
|
+
kernelIdPrefix,
|
|
225
|
+
")")));
|
|
183
226
|
}
|
|
184
227
|
labelTitle() {
|
|
185
228
|
var _a;
|
|
186
229
|
const { trans } = this;
|
|
187
230
|
const { id } = this.kernel;
|
|
188
|
-
const title = [`${this.
|
|
231
|
+
const title = [`${this._summary}: ${id}`];
|
|
189
232
|
for (const session of this.sessions.running()) {
|
|
190
233
|
if (this.kernel.id === ((_a = session.kernel) === null || _a === void 0 ? void 0 : _a.id)) {
|
|
191
234
|
const { path, type } = session;
|
|
@@ -194,6 +237,12 @@ var Private;
|
|
|
194
237
|
}
|
|
195
238
|
return title.join('\n\n');
|
|
196
239
|
}
|
|
240
|
+
get _summary() {
|
|
241
|
+
const children = this.children;
|
|
242
|
+
return children.length == 1
|
|
243
|
+
? children[0].label()
|
|
244
|
+
: this.trans.__('%1 and %2 more', children[0].label(), children.length - 1);
|
|
245
|
+
}
|
|
197
246
|
}
|
|
198
247
|
Private.RunningKernel = RunningKernel;
|
|
199
248
|
Private.runningChanged = new Signal({});
|
package/lib/kernels.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kernels.js","sourceRoot":"","sources":["../src/kernels.
|
|
1
|
+
{"version":3,"file":"kernels.js","sourceRoot":"","sources":["../src/kernels.tsx"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAG3D,OAAO,EAAE,O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aACF;YACD,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC5B,CAAC;QAED,IAAY,QAAQ;YAClB,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;YAC/B,OAAO,QAAQ,CAAC,MAAM,IAAI,CAAC;gBACzB,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE;gBACrB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CACX,gBAAgB,EAChB,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,EACnB,QAAQ,CAAC,MAAM,GAAG,CAAC,CACpB,CAAC;QACR,CAAC;KACF;IA5FY,qBAAa,gBA4FzB,CAAA;IAaY,sBAAc,GAAG,IAAI,MAAM,CAAmB,EAAE,CAAC,CAAC;AACjE,CAAC,EAjKS,OAAO,KAAP,OAAO,QAiKhB"}
|
package/lib/recents.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CommandRegistry } from '@lumino/commands';
|
|
2
|
+
import { IRunningSessionManagers } from '@jupyterlab/running';
|
|
3
|
+
import { ITranslator } from '@jupyterlab/translation';
|
|
4
|
+
import { IRecentsManager } from '@jupyterlab/docmanager';
|
|
5
|
+
import { DocumentRegistry } from '@jupyterlab/docregistry';
|
|
6
|
+
/**
|
|
7
|
+
* Add the 'recently closed' section to the running panel.
|
|
8
|
+
*
|
|
9
|
+
* @param managers - The IRunningSessionManagers used to register this section.
|
|
10
|
+
* @param recentsManager - The recent documents manager.
|
|
11
|
+
* @param commands - The command registry.
|
|
12
|
+
* @param docRegistry - Document registry.
|
|
13
|
+
* @param translator - The translator to use.
|
|
14
|
+
*/
|
|
15
|
+
export declare function addRecentlyClosedSessionManager(managers: IRunningSessionManagers, recentsManager: IRecentsManager, commands: CommandRegistry, docRegistry: DocumentRegistry, translator: ITranslator): void;
|
package/lib/recents.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// Copyright (c) Jupyter Development Team.
|
|
2
|
+
// Distributed under the terms of the Modified BSD License.
|
|
3
|
+
import { PathExt } from '@jupyterlab/coreutils';
|
|
4
|
+
import { fileIcon, LabIcon } from '@jupyterlab/ui-components';
|
|
5
|
+
/**
|
|
6
|
+
* Add the 'recently closed' section to the running panel.
|
|
7
|
+
*
|
|
8
|
+
* @param managers - The IRunningSessionManagers used to register this section.
|
|
9
|
+
* @param recentsManager - The recent documents manager.
|
|
10
|
+
* @param commands - The command registry.
|
|
11
|
+
* @param docRegistry - Document registry.
|
|
12
|
+
* @param translator - The translator to use.
|
|
13
|
+
*/
|
|
14
|
+
export function addRecentlyClosedSessionManager(managers, recentsManager, commands, docRegistry, translator) {
|
|
15
|
+
const trans = translator.load('jupyterlab');
|
|
16
|
+
managers.add({
|
|
17
|
+
name: trans.__('Recently Closed'),
|
|
18
|
+
running: () => {
|
|
19
|
+
return recentsManager.recentlyClosed.map((recent) => {
|
|
20
|
+
return new RecentItem(recent);
|
|
21
|
+
});
|
|
22
|
+
},
|
|
23
|
+
shutdownAll: () => {
|
|
24
|
+
for (const widget of recentsManager.recentlyClosed) {
|
|
25
|
+
recentsManager.removeRecent(widget, 'closed');
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
refreshRunning: () => {
|
|
29
|
+
return void 0;
|
|
30
|
+
},
|
|
31
|
+
runningChanged: recentsManager.changed,
|
|
32
|
+
shutdownLabel: trans.__('Forget'),
|
|
33
|
+
shutdownAllLabel: trans.__('Forget All'),
|
|
34
|
+
shutdownAllConfirmationText: trans.__('Are you sure you want to clear recently closed tabs?')
|
|
35
|
+
});
|
|
36
|
+
class RecentItem {
|
|
37
|
+
constructor(recent) {
|
|
38
|
+
this._recent = recent;
|
|
39
|
+
}
|
|
40
|
+
async open() {
|
|
41
|
+
const recent = this._recent;
|
|
42
|
+
const isValid = await recentsManager.validate(recent);
|
|
43
|
+
if (!isValid) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
await commands.execute('docmanager:open', {
|
|
47
|
+
path: recent.path,
|
|
48
|
+
factory: recent.factory
|
|
49
|
+
});
|
|
50
|
+
recentsManager.removeRecent(recent, 'closed');
|
|
51
|
+
}
|
|
52
|
+
shutdown() {
|
|
53
|
+
recentsManager.removeRecent(this._recent, 'closed');
|
|
54
|
+
}
|
|
55
|
+
icon() {
|
|
56
|
+
if (!this._recent.factory) {
|
|
57
|
+
return fileIcon;
|
|
58
|
+
}
|
|
59
|
+
// Prefer path inference as it is more granular.
|
|
60
|
+
const fileTypes = docRegistry.getFileTypesForPath(this._recent.path);
|
|
61
|
+
for (const fileType of fileTypes) {
|
|
62
|
+
const icon = fileType.icon;
|
|
63
|
+
if (icon instanceof LabIcon) {
|
|
64
|
+
return icon;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
// Fallback to factory-base inference.
|
|
68
|
+
const factory = docRegistry.getWidgetFactory(this._recent.factory);
|
|
69
|
+
if (factory) {
|
|
70
|
+
for (const fileTypeName of factory.fileTypes) {
|
|
71
|
+
const fileType = docRegistry.getFileType(fileTypeName);
|
|
72
|
+
const icon = fileType === null || fileType === void 0 ? void 0 : fileType.icon;
|
|
73
|
+
if (icon instanceof LabIcon) {
|
|
74
|
+
return icon;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return fileIcon;
|
|
79
|
+
}
|
|
80
|
+
label() {
|
|
81
|
+
return PathExt.basename(this._recent.path);
|
|
82
|
+
}
|
|
83
|
+
labelTitle() {
|
|
84
|
+
return this._recent.path;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=recents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recents.js","sourceRoot":"","sources":["../src/recents.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAG3D,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAKhD,OAAO,EAAE,QA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;QAC7C,CAAC;QACD,UAAU;YACR,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;QAC3B,CAAC;KAGF;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jupyterlab/running-extension",
|
|
3
|
-
"version": "4.2.0-alpha.
|
|
3
|
+
"version": "4.2.0-alpha.2",
|
|
4
4
|
"description": "JupyterLab - Running Sessions Extension",
|
|
5
5
|
"homepage": "https://github.com/jupyterlab/jupyterlab",
|
|
6
6
|
"bugs": {
|
|
@@ -38,18 +38,22 @@
|
|
|
38
38
|
"watch": "tsc -b --watch"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@jupyterlab/application": "^4.2.0-alpha.
|
|
42
|
-
"@jupyterlab/
|
|
43
|
-
"@jupyterlab/
|
|
44
|
-
"@jupyterlab/
|
|
45
|
-
"@jupyterlab/
|
|
46
|
-
"@jupyterlab/
|
|
47
|
-
"@jupyterlab/
|
|
48
|
-
"@jupyterlab/
|
|
41
|
+
"@jupyterlab/application": "^4.2.0-alpha.2",
|
|
42
|
+
"@jupyterlab/apputils": "^4.3.0-alpha.2",
|
|
43
|
+
"@jupyterlab/coreutils": "^6.2.0-alpha.2",
|
|
44
|
+
"@jupyterlab/docmanager": "^4.2.0-alpha.2",
|
|
45
|
+
"@jupyterlab/docregistry": "^4.2.0-alpha.2",
|
|
46
|
+
"@jupyterlab/rendermime-interfaces": "^3.10.0-alpha.2",
|
|
47
|
+
"@jupyterlab/running": "^4.2.0-alpha.2",
|
|
48
|
+
"@jupyterlab/services": "^7.2.0-alpha.2",
|
|
49
|
+
"@jupyterlab/statedb": "^4.2.0-alpha.2",
|
|
50
|
+
"@jupyterlab/translation": "^4.2.0-alpha.2",
|
|
51
|
+
"@jupyterlab/ui-components": "^4.2.0-alpha.2",
|
|
49
52
|
"@lumino/commands": "^2.2.0",
|
|
50
53
|
"@lumino/polling": "^2.1.2",
|
|
51
54
|
"@lumino/signaling": "^2.1.2",
|
|
52
|
-
"@lumino/widgets": "^2.3.1"
|
|
55
|
+
"@lumino/widgets": "^2.3.1",
|
|
56
|
+
"react": "^18.2.0"
|
|
53
57
|
},
|
|
54
58
|
"devDependencies": {
|
|
55
59
|
"rimraf": "~5.0.5",
|
package/schema/plugin.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -11,15 +11,25 @@ import {
|
|
|
11
11
|
JupyterFrontEnd,
|
|
12
12
|
JupyterFrontEndPlugin
|
|
13
13
|
} from '@jupyterlab/application';
|
|
14
|
+
import { Dialog, ICommandPalette } from '@jupyterlab/apputils';
|
|
14
15
|
import {
|
|
15
16
|
IRunningSessionManagers,
|
|
17
|
+
IRunningSessionSidebar,
|
|
16
18
|
RunningSessionManagers,
|
|
17
|
-
RunningSessions
|
|
19
|
+
RunningSessions,
|
|
20
|
+
SearchableSessions
|
|
18
21
|
} from '@jupyterlab/running';
|
|
22
|
+
import { IRecentsManager } from '@jupyterlab/docmanager';
|
|
23
|
+
import { IStateDB } from '@jupyterlab/statedb';
|
|
19
24
|
import { ITranslator } from '@jupyterlab/translation';
|
|
20
|
-
import {
|
|
25
|
+
import {
|
|
26
|
+
CommandToolbarButton,
|
|
27
|
+
launcherIcon,
|
|
28
|
+
runningIcon
|
|
29
|
+
} from '@jupyterlab/ui-components';
|
|
21
30
|
import { addKernelRunningSessionManager } from './kernels';
|
|
22
31
|
import { addOpenTabsSessionManager } from './opentabs';
|
|
32
|
+
import { addRecentlyClosedSessionManager } from './recents';
|
|
23
33
|
|
|
24
34
|
/**
|
|
25
35
|
* The command IDs used by the running plugin.
|
|
@@ -30,64 +40,163 @@ export namespace CommandIDs {
|
|
|
30
40
|
export const kernelOpenSession = 'running:kernel-open-session';
|
|
31
41
|
export const kernelShutDown = 'running:kernel-shut-down';
|
|
32
42
|
export const showPanel = 'running:show-panel';
|
|
43
|
+
export const showModal = 'running:show-modal';
|
|
33
44
|
}
|
|
34
45
|
|
|
35
46
|
/**
|
|
36
47
|
* The default running sessions extension.
|
|
37
48
|
*/
|
|
38
49
|
const plugin: JupyterFrontEndPlugin<IRunningSessionManagers> = {
|
|
39
|
-
activate,
|
|
40
50
|
id: '@jupyterlab/running-extension:plugin',
|
|
41
51
|
description: 'Provides the running session managers.',
|
|
42
52
|
provides: IRunningSessionManagers,
|
|
43
53
|
requires: [ITranslator],
|
|
44
|
-
optional: [
|
|
45
|
-
autoStart: true
|
|
54
|
+
optional: [ILabShell],
|
|
55
|
+
autoStart: true,
|
|
56
|
+
activate: (
|
|
57
|
+
app: JupyterFrontEnd,
|
|
58
|
+
translator: ITranslator,
|
|
59
|
+
labShell: ILabShell | null
|
|
60
|
+
): IRunningSessionManagers => {
|
|
61
|
+
const runningSessionManagers = new RunningSessionManagers();
|
|
62
|
+
|
|
63
|
+
if (labShell) {
|
|
64
|
+
addOpenTabsSessionManager(runningSessionManagers, translator, labShell);
|
|
65
|
+
}
|
|
66
|
+
void addKernelRunningSessionManager(
|
|
67
|
+
runningSessionManagers,
|
|
68
|
+
translator,
|
|
69
|
+
app
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
return runningSessionManagers;
|
|
73
|
+
}
|
|
46
74
|
};
|
|
47
75
|
|
|
48
76
|
/**
|
|
49
|
-
*
|
|
77
|
+
* The plugin enabling the running sidebar.
|
|
50
78
|
*/
|
|
51
|
-
|
|
79
|
+
const sidebarPlugin: JupyterFrontEndPlugin<IRunningSessionSidebar> = {
|
|
80
|
+
id: '@jupyterlab/running-extension:sidebar',
|
|
81
|
+
description: 'Provides the running session sidebar.',
|
|
82
|
+
provides: IRunningSessionSidebar,
|
|
83
|
+
requires: [IRunningSessionManagers, ITranslator],
|
|
84
|
+
optional: [ILayoutRestorer, IStateDB],
|
|
85
|
+
autoStart: true,
|
|
86
|
+
activate: (
|
|
87
|
+
app: JupyterFrontEnd,
|
|
88
|
+
manager: IRunningSessionManagers,
|
|
89
|
+
translator: ITranslator,
|
|
90
|
+
restorer: ILayoutRestorer | null,
|
|
91
|
+
state: IStateDB | null
|
|
92
|
+
): IRunningSessionSidebar => {
|
|
93
|
+
const trans = translator.load('jupyterlab');
|
|
94
|
+
const running = new RunningSessions(manager, translator, state);
|
|
95
|
+
running.id = 'jp-running-sessions';
|
|
96
|
+
running.title.caption = trans.__('Running Terminals and Kernels');
|
|
97
|
+
running.title.icon = runningIcon;
|
|
98
|
+
running.node.setAttribute('role', 'region');
|
|
99
|
+
running.node.setAttribute(
|
|
100
|
+
'aria-label',
|
|
101
|
+
trans.__('Running Sessions section')
|
|
102
|
+
);
|
|
52
103
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
running.node.setAttribute('aria-label', trans.__('Running Sessions section'));
|
|
104
|
+
// Let the application restorer track the running panel for restoration of
|
|
105
|
+
// application state (e.g. setting the running panel as the current side bar
|
|
106
|
+
// widget).
|
|
107
|
+
if (restorer) {
|
|
108
|
+
restorer.add(running, 'running-sessions');
|
|
109
|
+
}
|
|
110
|
+
// Rank has been chosen somewhat arbitrarily to give priority to the running
|
|
111
|
+
// sessions widget in the sidebar.
|
|
112
|
+
app.shell.add(running, 'left', { rank: 200, type: 'Sessions and Tabs' });
|
|
113
|
+
|
|
114
|
+
app.commands.addCommand(CommandIDs.showPanel, {
|
|
115
|
+
label: trans.__('Sessions and Tabs'),
|
|
116
|
+
execute: () => {
|
|
117
|
+
app.shell.activateById(running.id);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
70
120
|
|
|
71
|
-
|
|
72
|
-
// application state (e.g. setting the running panel as the current side bar
|
|
73
|
-
// widget).
|
|
74
|
-
if (restorer) {
|
|
75
|
-
restorer.add(running, 'running-sessions');
|
|
121
|
+
return running;
|
|
76
122
|
}
|
|
77
|
-
|
|
78
|
-
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* An optional adding recently closed tabs.
|
|
127
|
+
*/
|
|
128
|
+
const recentsPlugin: JupyterFrontEndPlugin<void> = {
|
|
129
|
+
id: '@jupyterlab/running-extension:recently-closed',
|
|
130
|
+
description: 'Adds recently closed documents list.',
|
|
131
|
+
requires: [IRunningSessionManagers, IRecentsManager, ITranslator],
|
|
132
|
+
autoStart: true,
|
|
133
|
+
activate: (
|
|
134
|
+
app: JupyterFrontEnd,
|
|
135
|
+
manager: IRunningSessionManagers,
|
|
136
|
+
recents: IRecentsManager,
|
|
137
|
+
translator: ITranslator
|
|
138
|
+
): void => {
|
|
139
|
+
addRecentlyClosedSessionManager(
|
|
140
|
+
manager,
|
|
141
|
+
recents,
|
|
142
|
+
app.commands,
|
|
143
|
+
app.docRegistry,
|
|
144
|
+
translator
|
|
145
|
+
);
|
|
79
146
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* An optional plugin allowing to among running items.
|
|
151
|
+
*/
|
|
152
|
+
const searchPlugin: JupyterFrontEndPlugin<void> = {
|
|
153
|
+
id: '@jupyterlab/running-extension:search-tabs',
|
|
154
|
+
description: 'Adds a widget to search open and closed tabs.',
|
|
155
|
+
requires: [IRunningSessionManagers, ITranslator],
|
|
156
|
+
optional: [ICommandPalette, IRunningSessionSidebar],
|
|
157
|
+
autoStart: true,
|
|
158
|
+
activate: (
|
|
159
|
+
app: JupyterFrontEnd,
|
|
160
|
+
manager: IRunningSessionManagers,
|
|
161
|
+
translator: ITranslator,
|
|
162
|
+
palette: ICommandPalette | null,
|
|
163
|
+
sidebar: IRunningSessionSidebar | null
|
|
164
|
+
): void => {
|
|
165
|
+
const trans = translator.load('jupyterlab');
|
|
84
166
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
167
|
+
app.commands.addCommand(CommandIDs.showModal, {
|
|
168
|
+
execute: () => {
|
|
169
|
+
const running = new SearchableSessions(manager, translator);
|
|
170
|
+
const dialog = new Dialog({
|
|
171
|
+
title: trans.__('Tabs and Running Sessions'),
|
|
172
|
+
body: running,
|
|
173
|
+
buttons: [Dialog.okButton({})],
|
|
174
|
+
hasClose: true
|
|
175
|
+
});
|
|
176
|
+
dialog.addClass('jp-SearchableSessions-modal');
|
|
177
|
+
return dialog.launch();
|
|
178
|
+
},
|
|
179
|
+
label: trans.__('Search Tabs and Running Sessions')
|
|
180
|
+
});
|
|
181
|
+
if (palette) {
|
|
182
|
+
palette.addItem({
|
|
183
|
+
command: CommandIDs.showModal,
|
|
184
|
+
category: trans.__('Running')
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
if (sidebar) {
|
|
188
|
+
const button = new CommandToolbarButton({
|
|
189
|
+
commands: app.commands,
|
|
190
|
+
id: CommandIDs.showModal,
|
|
191
|
+
icon: launcherIcon,
|
|
192
|
+
label: ''
|
|
193
|
+
});
|
|
194
|
+
sidebar.toolbar.addItem('open-as-modal', button);
|
|
89
195
|
}
|
|
90
|
-
}
|
|
196
|
+
}
|
|
197
|
+
};
|
|
91
198
|
|
|
92
|
-
|
|
93
|
-
|
|
199
|
+
/**
|
|
200
|
+
* Export the plugins.
|
|
201
|
+
*/
|
|
202
|
+
export default [plugin, sidebarPlugin, recentsPlugin, searchPlugin];
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
consoleIcon,
|
|
13
13
|
IDisposableMenuItem,
|
|
14
14
|
jupyterIcon,
|
|
15
|
+
kernelIcon,
|
|
15
16
|
LabIcon,
|
|
16
17
|
notebookIcon,
|
|
17
18
|
RankedMenu
|
|
@@ -20,8 +21,12 @@ import { CommandRegistry } from '@lumino/commands';
|
|
|
20
21
|
import { Throttler } from '@lumino/polling';
|
|
21
22
|
import { Signal } from '@lumino/signaling';
|
|
22
23
|
import { CommandIDs } from '.';
|
|
24
|
+
import React, { ReactNode } from 'react';
|
|
23
25
|
|
|
24
|
-
const
|
|
26
|
+
const KERNEL_ITEM_CLASS = 'jp-mod-kernel';
|
|
27
|
+
const KERNELSPEC_ITEM_CLASS = 'jp-mod-kernelspec';
|
|
28
|
+
const WIDGET_ITEM_CLASS = 'jp-mod-kernel-widget';
|
|
29
|
+
const KERNEL_LABEL_ID = 'jp-RunningSessions-item-label-kernel-id';
|
|
25
30
|
|
|
26
31
|
/**
|
|
27
32
|
* Add the running kernel manager (notebooks & consoles) to the running panel.
|
|
@@ -47,18 +52,33 @@ export async function addKernelRunningSessionManager(
|
|
|
47
52
|
// Add the kernels pane to the running sidebar.
|
|
48
53
|
managers.add({
|
|
49
54
|
name: trans.__('Kernels'),
|
|
50
|
-
running: () =>
|
|
51
|
-
|
|
52
|
-
|
|
55
|
+
running: () => {
|
|
56
|
+
const kernelsBySpec = new Map<string, Private.RunningKernel[]>();
|
|
57
|
+
|
|
58
|
+
for (const kernel of kernels.running()) {
|
|
59
|
+
const list = kernelsBySpec.get(kernel.name) ?? [];
|
|
60
|
+
kernelsBySpec.set(kernel.name, list);
|
|
61
|
+
list.push(
|
|
53
62
|
new RunningKernel({
|
|
54
63
|
commands,
|
|
55
64
|
kernel,
|
|
56
65
|
kernels,
|
|
57
66
|
sessions,
|
|
58
|
-
spec: kernelspecs.specs?.kernelspecs[kernel.name],
|
|
59
67
|
trans
|
|
60
68
|
})
|
|
61
|
-
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return Array.from(kernelsBySpec.entries()).map(
|
|
73
|
+
([spec, kernels]) =>
|
|
74
|
+
new Private.KernelSpecItem({
|
|
75
|
+
name: spec,
|
|
76
|
+
kernels,
|
|
77
|
+
spec: kernelspecs.specs?.kernelspecs[spec],
|
|
78
|
+
trans
|
|
79
|
+
})
|
|
80
|
+
);
|
|
81
|
+
},
|
|
62
82
|
shutdownAll: () => kernels.shutdownAll(),
|
|
63
83
|
refreshRunning: () =>
|
|
64
84
|
Promise.all([kernels.refreshRunning(), sessions.refreshRunning()]),
|
|
@@ -71,7 +91,8 @@ export async function addKernelRunningSessionManager(
|
|
|
71
91
|
});
|
|
72
92
|
|
|
73
93
|
// Add running kernels commands to the registry.
|
|
74
|
-
const test = (node: HTMLElement) =>
|
|
94
|
+
const test = (node: HTMLElement) =>
|
|
95
|
+
node.classList.contains(KERNEL_ITEM_CLASS);
|
|
75
96
|
commands.addCommand(CommandIDs.kernelNewConsole, {
|
|
76
97
|
icon: consoleIcon,
|
|
77
98
|
label: trans.__('New Console for Kernel'),
|
|
@@ -166,15 +187,68 @@ export async function addKernelRunningSessionManager(
|
|
|
166
187
|
}
|
|
167
188
|
|
|
168
189
|
namespace Private {
|
|
190
|
+
export class KernelSpecItem implements IRunningSessions.IRunningItem {
|
|
191
|
+
constructor(options: KernelSpecItem.IOptions) {
|
|
192
|
+
this._name = options.name;
|
|
193
|
+
this.className = KERNELSPEC_ITEM_CLASS;
|
|
194
|
+
this._kernels = options.kernels;
|
|
195
|
+
this.spec = options.spec || null;
|
|
196
|
+
this.trans = options.trans;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
readonly className: string;
|
|
200
|
+
|
|
201
|
+
readonly spec: KernelSpec.ISpecModel | null;
|
|
202
|
+
|
|
203
|
+
readonly trans: IRenderMime.TranslationBundle;
|
|
204
|
+
|
|
205
|
+
private _name: string;
|
|
206
|
+
private _kernels: RunningKernel[];
|
|
207
|
+
|
|
208
|
+
icon(): LabIcon | string {
|
|
209
|
+
const { spec } = this;
|
|
210
|
+
if (!spec || !spec.resources) {
|
|
211
|
+
return jupyterIcon;
|
|
212
|
+
}
|
|
213
|
+
return (
|
|
214
|
+
spec.resources['logo-svg'] ||
|
|
215
|
+
spec.resources['logo-64x64'] ||
|
|
216
|
+
spec.resources['logo-32x32']
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
label(): string {
|
|
221
|
+
const { _name, spec } = this;
|
|
222
|
+
return spec?.display_name || _name;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
get children(): IRunningSessions.IRunningItem[] {
|
|
226
|
+
return this._kernels;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export namespace KernelSpecItem {
|
|
231
|
+
export interface IOptions {
|
|
232
|
+
kernels: RunningKernel[];
|
|
233
|
+
name: string;
|
|
234
|
+
spec?: KernelSpec.ISpecModel;
|
|
235
|
+
trans: IRenderMime.TranslationBundle;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
type DocumentWidgetWithKernelItem = Omit<
|
|
240
|
+
IRunningSessions.IRunningItem,
|
|
241
|
+
'label'
|
|
242
|
+
> & { label(): string };
|
|
243
|
+
|
|
169
244
|
export class RunningKernel implements IRunningSessions.IRunningItem {
|
|
170
245
|
constructor(options: RunningKernel.IOptions) {
|
|
171
|
-
this.className =
|
|
246
|
+
this.className = KERNEL_ITEM_CLASS;
|
|
172
247
|
this.commands = options.commands;
|
|
173
248
|
this.kernel = options.kernel;
|
|
174
249
|
this.context = this.kernel.id;
|
|
175
250
|
this.kernels = options.kernels;
|
|
176
251
|
this.sessions = options.sessions;
|
|
177
|
-
this.spec = options.spec || null;
|
|
178
252
|
this.trans = options.trans;
|
|
179
253
|
}
|
|
180
254
|
|
|
@@ -190,19 +264,17 @@ namespace Private {
|
|
|
190
264
|
|
|
191
265
|
readonly sessions: Session.IManager;
|
|
192
266
|
|
|
193
|
-
readonly spec: KernelSpec.ISpecModel | null;
|
|
194
|
-
|
|
195
267
|
readonly trans: IRenderMime.TranslationBundle;
|
|
196
268
|
|
|
197
|
-
get children():
|
|
198
|
-
const children:
|
|
269
|
+
get children(): DocumentWidgetWithKernelItem[] {
|
|
270
|
+
const children: DocumentWidgetWithKernelItem[] = [];
|
|
199
271
|
const open = CommandIDs.kernelOpenSession;
|
|
200
272
|
const { commands } = this;
|
|
201
273
|
for (const session of this.sessions.running()) {
|
|
202
274
|
if (this.kernel.id === session.kernel?.id) {
|
|
203
275
|
const { name, path, type } = session;
|
|
204
276
|
children.push({
|
|
205
|
-
className:
|
|
277
|
+
className: WIDGET_ITEM_CLASS,
|
|
206
278
|
context: this.kernel.id,
|
|
207
279
|
open: () => void commands.execute(open, { name, path, type }),
|
|
208
280
|
icon: () =>
|
|
@@ -224,26 +296,24 @@ namespace Private {
|
|
|
224
296
|
}
|
|
225
297
|
|
|
226
298
|
icon(): LabIcon | string {
|
|
227
|
-
|
|
228
|
-
if (!spec || !spec.resources) {
|
|
229
|
-
return jupyterIcon;
|
|
230
|
-
}
|
|
231
|
-
return (
|
|
232
|
-
spec.resources['logo-svg'] ||
|
|
233
|
-
spec.resources['logo-64x64'] ||
|
|
234
|
-
spec.resources['logo-32x32']
|
|
235
|
-
);
|
|
299
|
+
return kernelIcon;
|
|
236
300
|
}
|
|
237
301
|
|
|
238
|
-
label():
|
|
239
|
-
const { kernel
|
|
240
|
-
|
|
302
|
+
label(): ReactNode {
|
|
303
|
+
const { kernel } = this;
|
|
304
|
+
const kernelIdPrefix = kernel.id.split('-')[0];
|
|
305
|
+
return (
|
|
306
|
+
<>
|
|
307
|
+
{this._summary}{' '}
|
|
308
|
+
<span className={KERNEL_LABEL_ID}>({kernelIdPrefix})</span>
|
|
309
|
+
</>
|
|
310
|
+
);
|
|
241
311
|
}
|
|
242
312
|
|
|
243
313
|
labelTitle(): string {
|
|
244
314
|
const { trans } = this;
|
|
245
315
|
const { id } = this.kernel;
|
|
246
|
-
const title = [`${this.
|
|
316
|
+
const title = [`${this._summary}: ${id}`];
|
|
247
317
|
for (const session of this.sessions.running()) {
|
|
248
318
|
if (this.kernel.id === session.kernel?.id) {
|
|
249
319
|
const { path, type } = session;
|
|
@@ -252,6 +322,17 @@ namespace Private {
|
|
|
252
322
|
}
|
|
253
323
|
return title.join('\n\n');
|
|
254
324
|
}
|
|
325
|
+
|
|
326
|
+
private get _summary(): string {
|
|
327
|
+
const children = this.children;
|
|
328
|
+
return children.length == 1
|
|
329
|
+
? children[0].label()
|
|
330
|
+
: this.trans.__(
|
|
331
|
+
'%1 and %2 more',
|
|
332
|
+
children[0].label(),
|
|
333
|
+
children.length - 1
|
|
334
|
+
);
|
|
335
|
+
}
|
|
255
336
|
}
|
|
256
337
|
|
|
257
338
|
export namespace RunningKernel {
|
package/src/recents.ts
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// Copyright (c) Jupyter Development Team.
|
|
2
|
+
// Distributed under the terms of the Modified BSD License.
|
|
3
|
+
|
|
4
|
+
import { CommandRegistry } from '@lumino/commands';
|
|
5
|
+
import { PathExt } from '@jupyterlab/coreutils';
|
|
6
|
+
import { IRunningSessionManagers, IRunningSessions } from '@jupyterlab/running';
|
|
7
|
+
import { ITranslator } from '@jupyterlab/translation';
|
|
8
|
+
import { IRecentsManager, RecentDocument } from '@jupyterlab/docmanager';
|
|
9
|
+
import { DocumentRegistry } from '@jupyterlab/docregistry';
|
|
10
|
+
import { fileIcon, LabIcon } from '@jupyterlab/ui-components';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Add the 'recently closed' section to the running panel.
|
|
14
|
+
*
|
|
15
|
+
* @param managers - The IRunningSessionManagers used to register this section.
|
|
16
|
+
* @param recentsManager - The recent documents manager.
|
|
17
|
+
* @param commands - The command registry.
|
|
18
|
+
* @param docRegistry - Document registry.
|
|
19
|
+
* @param translator - The translator to use.
|
|
20
|
+
*/
|
|
21
|
+
export function addRecentlyClosedSessionManager(
|
|
22
|
+
managers: IRunningSessionManagers,
|
|
23
|
+
recentsManager: IRecentsManager,
|
|
24
|
+
commands: CommandRegistry,
|
|
25
|
+
docRegistry: DocumentRegistry,
|
|
26
|
+
translator: ITranslator
|
|
27
|
+
): void {
|
|
28
|
+
const trans = translator.load('jupyterlab');
|
|
29
|
+
|
|
30
|
+
managers.add({
|
|
31
|
+
name: trans.__('Recently Closed'),
|
|
32
|
+
running: () => {
|
|
33
|
+
return recentsManager.recentlyClosed.map((recent: RecentDocument) => {
|
|
34
|
+
return new RecentItem(recent);
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
shutdownAll: () => {
|
|
38
|
+
for (const widget of recentsManager.recentlyClosed) {
|
|
39
|
+
recentsManager.removeRecent(widget, 'closed');
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
refreshRunning: () => {
|
|
43
|
+
return void 0;
|
|
44
|
+
},
|
|
45
|
+
runningChanged: recentsManager.changed,
|
|
46
|
+
shutdownLabel: trans.__('Forget'),
|
|
47
|
+
shutdownAllLabel: trans.__('Forget All'),
|
|
48
|
+
shutdownAllConfirmationText: trans.__(
|
|
49
|
+
'Are you sure you want to clear recently closed tabs?'
|
|
50
|
+
)
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
class RecentItem implements IRunningSessions.IRunningItem {
|
|
54
|
+
constructor(recent: RecentDocument) {
|
|
55
|
+
this._recent = recent;
|
|
56
|
+
}
|
|
57
|
+
async open() {
|
|
58
|
+
const recent = this._recent;
|
|
59
|
+
const isValid = await recentsManager.validate(recent);
|
|
60
|
+
if (!isValid) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
await commands.execute('docmanager:open', {
|
|
64
|
+
path: recent.path,
|
|
65
|
+
factory: recent.factory
|
|
66
|
+
});
|
|
67
|
+
recentsManager.removeRecent(recent, 'closed');
|
|
68
|
+
}
|
|
69
|
+
shutdown() {
|
|
70
|
+
recentsManager.removeRecent(this._recent, 'closed');
|
|
71
|
+
}
|
|
72
|
+
icon() {
|
|
73
|
+
if (!this._recent.factory) {
|
|
74
|
+
return fileIcon;
|
|
75
|
+
}
|
|
76
|
+
// Prefer path inference as it is more granular.
|
|
77
|
+
const fileTypes = docRegistry.getFileTypesForPath(this._recent.path);
|
|
78
|
+
for (const fileType of fileTypes) {
|
|
79
|
+
const icon = fileType.icon;
|
|
80
|
+
if (icon instanceof LabIcon) {
|
|
81
|
+
return icon;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
// Fallback to factory-base inference.
|
|
85
|
+
const factory = docRegistry.getWidgetFactory(this._recent.factory);
|
|
86
|
+
if (factory) {
|
|
87
|
+
for (const fileTypeName of factory.fileTypes) {
|
|
88
|
+
const fileType = docRegistry.getFileType(fileTypeName);
|
|
89
|
+
const icon = fileType?.icon;
|
|
90
|
+
if (icon instanceof LabIcon) {
|
|
91
|
+
return icon;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return fileIcon;
|
|
96
|
+
}
|
|
97
|
+
label() {
|
|
98
|
+
return PathExt.basename(this._recent.path);
|
|
99
|
+
}
|
|
100
|
+
labelTitle() {
|
|
101
|
+
return this._recent.path;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
private _recent: RecentDocument;
|
|
105
|
+
}
|
|
106
|
+
}
|
package/style/index.css
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
/* This file was auto-generated by ensurePackage() in @jupyterlab/buildutils */
|
|
7
7
|
@import url('~@lumino/widgets/style/index.css');
|
|
8
8
|
@import url('~@jupyterlab/ui-components/style/index.css');
|
|
9
|
+
@import url('~@jupyterlab/apputils/style/index.css');
|
|
9
10
|
@import url('~@jupyterlab/docregistry/style/index.css');
|
|
10
11
|
@import url('~@jupyterlab/application/style/index.css');
|
|
12
|
+
@import url('~@jupyterlab/docmanager/style/index.css');
|
|
11
13
|
@import url('~@jupyterlab/running/style/index.css');
|
package/style/index.js
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
/* This file was auto-generated by ensurePackage() in @jupyterlab/buildutils */
|
|
7
7
|
import '@lumino/widgets/style/index.js';
|
|
8
8
|
import '@jupyterlab/ui-components/style/index.js';
|
|
9
|
+
import '@jupyterlab/apputils/style/index.js';
|
|
9
10
|
import '@jupyterlab/docregistry/style/index.js';
|
|
10
11
|
import '@jupyterlab/application/style/index.js';
|
|
12
|
+
import '@jupyterlab/docmanager/style/index.js';
|
|
11
13
|
import '@jupyterlab/running/style/index.js';
|