jupyterlab-emrys
Version:
A computational environment for Jupyter. Powered by Emrys
34 lines (33 loc) • 959 B
JavaScript
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
;
var dialog_1 = require('../dialog');
/**
* Restart a kernel after presenting a dialog.
*
* @param kernel - The kernel to restart.
*
* @param host - The optional host element for the dialog.
*
* @returns A promise that resolves to `true` the user elects to restart.
*
* #### Notes
* This is a no-op if there is no kernel.
*/
function restartKernel(kernel, host) {
if (!kernel) {
return Promise.resolve(false);
}
return dialog_1.showDialog({
title: 'Restart Kernel?',
body: 'Do you want to restart the current kernel? All variables will be lost.'
}).then(function (result) {
if (result.text === 'OK') {
return kernel.restart().then(function () { return true; });
}
else {
return false;
}
});
}
exports.restartKernel = restartKernel;