@jupyter-notebook/notebook-extension 7.6.0-alpha.4 → 7.6.0-beta.0
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.js +61 -5
- package/package.json +11 -11
- package/schema/close-tab.json +14 -0
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Copyright (c) Jupyter Development Team.
|
|
2
2
|
// Distributed under the terms of the Modified BSD License.
|
|
3
|
-
import { DOMUtils, IToolbarWidgetRegistry, ICommandPalette, } from '@jupyterlab/apputils';
|
|
3
|
+
import { Dialog, DOMUtils, IToolbarWidgetRegistry, ICommandPalette, showDialog, } from '@jupyterlab/apputils';
|
|
4
4
|
import { PageConfig, Text, Time, URLExt } from '@jupyterlab/coreutils';
|
|
5
5
|
import { IDebuggerSidebar } from '@jupyterlab/debugger';
|
|
6
6
|
import { IDocumentManager } from '@jupyterlab/docmanager';
|
|
@@ -169,19 +169,57 @@ const closeTab = {
|
|
|
169
169
|
description: 'Add a command to close the browser tab when clicking on "Close and Shut Down".',
|
|
170
170
|
autoStart: true,
|
|
171
171
|
requires: [IMainMenu],
|
|
172
|
-
optional: [ITranslator],
|
|
173
|
-
activate: (app, menu, translator) => {
|
|
172
|
+
optional: [INotebookTracker, ISettingRegistry, ITranslator],
|
|
173
|
+
activate: (app, menu, tracker, settingRegistry, translator) => {
|
|
174
174
|
const { commands } = app;
|
|
175
175
|
translator = translator !== null && translator !== void 0 ? translator : nullTranslator;
|
|
176
176
|
const trans = translator.load('notebook');
|
|
177
|
+
let promptForConfirmation = true;
|
|
178
|
+
if (settingRegistry) {
|
|
179
|
+
const loadSettings = settingRegistry.load(closeTab.id);
|
|
180
|
+
const updateSettings = (settings) => {
|
|
181
|
+
promptForConfirmation = settings.get('promptForConfirmation')
|
|
182
|
+
.composite;
|
|
183
|
+
};
|
|
184
|
+
Promise.all([loadSettings, app.restored])
|
|
185
|
+
.then(([settings]) => {
|
|
186
|
+
updateSettings(settings);
|
|
187
|
+
settings.changed.connect(updateSettings);
|
|
188
|
+
})
|
|
189
|
+
.catch((reason) => {
|
|
190
|
+
console.error(`Failed to load settings for ${closeTab.id}: ${reason.message}`);
|
|
191
|
+
});
|
|
192
|
+
}
|
|
177
193
|
const id = 'notebook:close-and-halt';
|
|
178
194
|
commands.addCommand(id, {
|
|
179
|
-
label:
|
|
195
|
+
label: () => promptForConfirmation
|
|
196
|
+
? trans.__('Close and Shut Down Notebook…')
|
|
197
|
+
: trans.__('Close and Shut Down Notebook'),
|
|
180
198
|
execute: async () => {
|
|
181
|
-
|
|
199
|
+
var _a, _b;
|
|
200
|
+
if (promptForConfirmation) {
|
|
201
|
+
const fileName = (_b = (_a = tracker === null || tracker === void 0 ? void 0 : tracker.currentWidget) === null || _a === void 0 ? void 0 : _a.title.label) !== null && _b !== void 0 ? _b : trans.__('the notebook');
|
|
202
|
+
const result = await showDialog({
|
|
203
|
+
title: trans.__('Shut down the notebook?'),
|
|
204
|
+
body: trans.__('Are you sure you want to close "%1"?', fileName),
|
|
205
|
+
buttons: [
|
|
206
|
+
Dialog.cancelButton(),
|
|
207
|
+
Dialog.warnButton({ label: trans.__('Shut Down') }),
|
|
208
|
+
],
|
|
209
|
+
});
|
|
210
|
+
if (!result.button.accept) {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
182
214
|
await commands.execute('notebook:shutdown-kernel', { activate: false });
|
|
183
215
|
window.close();
|
|
184
216
|
},
|
|
217
|
+
describedBy: {
|
|
218
|
+
args: {
|
|
219
|
+
type: 'object',
|
|
220
|
+
properties: {},
|
|
221
|
+
},
|
|
222
|
+
},
|
|
185
223
|
});
|
|
186
224
|
menu.fileMenu.closeAndCleaners.add({
|
|
187
225
|
id,
|
|
@@ -210,6 +248,12 @@ const openTreeTab = {
|
|
|
210
248
|
const url = URLExt.join(PageConfig.getBaseUrl(), 'tree');
|
|
211
249
|
window.open(url);
|
|
212
250
|
},
|
|
251
|
+
describedBy: {
|
|
252
|
+
args: {
|
|
253
|
+
type: 'object',
|
|
254
|
+
properties: {},
|
|
255
|
+
},
|
|
256
|
+
},
|
|
213
257
|
});
|
|
214
258
|
},
|
|
215
259
|
};
|
|
@@ -266,6 +310,12 @@ const fullWidthNotebook = {
|
|
|
266
310
|
},
|
|
267
311
|
isEnabled: () => tracker.currentWidget !== null,
|
|
268
312
|
isToggled: () => fullWidth,
|
|
313
|
+
describedBy: {
|
|
314
|
+
args: {
|
|
315
|
+
type: 'object',
|
|
316
|
+
properties: {},
|
|
317
|
+
},
|
|
318
|
+
},
|
|
269
319
|
});
|
|
270
320
|
if (palette) {
|
|
271
321
|
palette.addItem({
|
|
@@ -582,6 +632,12 @@ const editNotebookMetadata = {
|
|
|
582
632
|
},
|
|
583
633
|
isVisible: () => shell.currentWidget !== null &&
|
|
584
634
|
shell.currentWidget instanceof NotebookPanel,
|
|
635
|
+
describedBy: {
|
|
636
|
+
args: {
|
|
637
|
+
type: 'object',
|
|
638
|
+
properties: {},
|
|
639
|
+
},
|
|
640
|
+
},
|
|
585
641
|
});
|
|
586
642
|
if (palette) {
|
|
587
643
|
palette.addItem({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jupyter-notebook/notebook-extension",
|
|
3
|
-
"version": "7.6.0-
|
|
3
|
+
"version": "7.6.0-beta.0",
|
|
4
4
|
"description": "Jupyter Notebook - Notebook Extension",
|
|
5
5
|
"homepage": "https://github.com/jupyter/notebook",
|
|
6
6
|
"bugs": {
|
|
@@ -38,16 +38,16 @@
|
|
|
38
38
|
"watch": "tsc -b --watch"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@jupyter-notebook/application": "^7.6.0-
|
|
42
|
-
"@jupyterlab/application": "~4.6.0-
|
|
43
|
-
"@jupyterlab/apputils": "~4.7.0-
|
|
44
|
-
"@jupyterlab/cells": "~4.6.0-
|
|
45
|
-
"@jupyterlab/debugger": "~4.6.0-
|
|
46
|
-
"@jupyterlab/docmanager": "~4.6.0-
|
|
47
|
-
"@jupyterlab/notebook": "~4.6.0-
|
|
48
|
-
"@jupyterlab/settingregistry": "~4.6.0-
|
|
49
|
-
"@jupyterlab/toc": "~6.6.0-
|
|
50
|
-
"@jupyterlab/translation": "~4.6.0-
|
|
41
|
+
"@jupyter-notebook/application": "^7.6.0-beta.0",
|
|
42
|
+
"@jupyterlab/application": "~4.6.0-beta.0",
|
|
43
|
+
"@jupyterlab/apputils": "~4.7.0-beta.0",
|
|
44
|
+
"@jupyterlab/cells": "~4.6.0-beta.0",
|
|
45
|
+
"@jupyterlab/debugger": "~4.6.0-beta.0",
|
|
46
|
+
"@jupyterlab/docmanager": "~4.6.0-beta.0",
|
|
47
|
+
"@jupyterlab/notebook": "~4.6.0-beta.0",
|
|
48
|
+
"@jupyterlab/settingregistry": "~4.6.0-beta.0",
|
|
49
|
+
"@jupyterlab/toc": "~6.6.0-beta.0",
|
|
50
|
+
"@jupyterlab/translation": "~4.6.0-beta.0",
|
|
51
51
|
"@lumino/algorithm": "2.0.4",
|
|
52
52
|
"@lumino/polling": "^2.1.5",
|
|
53
53
|
"@lumino/widgets": "^2.7.2",
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"title": "Close and Shut Down Notebook",
|
|
3
|
+
"description": "Settings for the \"Close and Shut Down Notebook\" command.",
|
|
4
|
+
"properties": {
|
|
5
|
+
"promptForConfirmation": {
|
|
6
|
+
"type": "boolean",
|
|
7
|
+
"title": "Prompt for confirmation before closing and shutting down",
|
|
8
|
+
"description": "Whether to prompt the user for confirmation before closing the browser tab and shutting down the kernel.",
|
|
9
|
+
"default": true
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"additionalProperties": false,
|
|
13
|
+
"type": "object"
|
|
14
|
+
}
|