Skip to content

Commit 2475a53

Browse files
authored
Filter settings with app.hasPlugin() (jupyterlab#11938)
* Filter settings menus with `app.hasPlugin` * Filter in context menu * Pass `isPluginAvailable` * Pass app to private function only * Fix unused import * Filter in the init list instead * Add comment about the filtering of plugins
1 parent 877e702 commit 2475a53

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

packages/apputils-extension/src/settingsplugin.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,17 @@ export const settingsPlugin: JupyterFrontEndPlugin<ISettingRegistry> = {
2020
const { isDisabled } = PageConfig.Extension;
2121
const connector = new SettingConnector(app.serviceManager.settings);
2222

23+
// On startup, check if a plugin is available in the application.
24+
// This helps avoid loading plugin files from other lab-based applications
25+
// that have placed their schemas next to the JupyterLab schemas. Different lab-based
26+
// applications might not have the same set of plugins loaded on the page.
27+
// As an example this helps prevent having new toolbar items added by another application
28+
// appear in JupyterLab as a side-effect when they are defined via the settings system.
2329
const registry = new SettingRegistry({
2430
connector,
25-
plugins: (await connector.list('active')).values
31+
plugins: (await connector.list('active')).values.filter(value =>
32+
app.hasPlugin(value.id)
33+
)
2634
});
2735

2836
// If there are plugins that have schemas that are not in the setting
@@ -32,7 +40,7 @@ export const settingsPlugin: JupyterFrontEndPlugin<ISettingRegistry> = {
3240
void app.restored.then(async () => {
3341
const plugins = await connector.list('all');
3442
plugins.ids.forEach(async (id, index) => {
35-
if (isDisabled(id) || id in registry.plugins) {
43+
if (!app.hasPlugin(id) || isDisabled(id) || id in registry.plugins) {
3644
return;
3745
}
3846

0 commit comments

Comments
 (0)