mirror of
https://github.com/jupyter/notebook.git
synced 2024-12-03 03:41:14 +08:00
Handle disabled plugins
This commit is contained in:
parent
ca6ee3d7f4
commit
50546f8af2
31
app/index.js
31
app/index.js
@ -68,6 +68,7 @@ async function main() {
|
||||
const App = require('@jupyterlab-classic/application').App;
|
||||
const app = new App();
|
||||
|
||||
const disabled = [];
|
||||
// TODO: formalize the way the set of initial extensions and plugins are specified
|
||||
let mods = [
|
||||
// @jupyterlab-classic plugins
|
||||
@ -150,6 +151,32 @@ async function main() {
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterate over active plugins in an extension.
|
||||
*
|
||||
* #### Notes
|
||||
* This also populates the disabled
|
||||
*/
|
||||
function* activePlugins(extension) {
|
||||
// Handle commonjs or es2015 modules
|
||||
let exports;
|
||||
if (Object.prototype.hasOwnProperty.call(extension, '__esModule')) {
|
||||
exports = extension.default;
|
||||
} else {
|
||||
// CommonJS exports.
|
||||
exports = extension;
|
||||
}
|
||||
|
||||
let plugins = Array.isArray(exports) ? exports : [exports];
|
||||
for (let plugin of plugins) {
|
||||
if (PageConfig.Extension.isDisabled(plugin.id)) {
|
||||
disabled.push(plugin.id);
|
||||
continue;
|
||||
}
|
||||
yield plugin;
|
||||
}
|
||||
}
|
||||
|
||||
const extension_data = JSON.parse(
|
||||
PageConfig.getOption('federated_extensions')
|
||||
);
|
||||
@ -200,7 +227,9 @@ async function main() {
|
||||
);
|
||||
federatedExtensions.forEach(p => {
|
||||
if (p.status === 'fulfilled') {
|
||||
mods.push(p.value);
|
||||
for (let plugin of activePlugins(p.value)) {
|
||||
mods.push(plugin);
|
||||
}
|
||||
} else {
|
||||
console.error(p.reason);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user