Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7601 from telamonian/implement-save-settingconnector
followup #7147: adds SettingConnector.save, reenables saving of user settings
- Loading branch information
Showing
3 changed files
with
69 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/*----------------------------------------------------------------------------- | ||
| Copyright (c) Jupyter Development Team. | ||
| Distributed under the terms of the Modified BSD License. | ||
|----------------------------------------------------------------------------*/ | ||
|
||
import { | ||
JupyterFrontEnd, | ||
JupyterFrontEndPlugin | ||
} from '@jupyterlab/application'; | ||
import { | ||
ISettingRegistry, | ||
PageConfig, | ||
SettingRegistry | ||
} from '@jupyterlab/coreutils'; | ||
|
||
import { SettingConnector } from './settingconnector'; | ||
|
||
/** | ||
* The default setting registry provider. | ||
*/ | ||
export const settingsPlugin: JupyterFrontEndPlugin<ISettingRegistry> = { | ||
id: '@jupyterlab/apputils-extension:settings', | ||
activate: async (app: JupyterFrontEnd): Promise<ISettingRegistry> => { | ||
const { isDisabled } = PageConfig.Extension; | ||
const connector = new SettingConnector(app.serviceManager.settings); | ||
|
||
const registry = new SettingRegistry({ | ||
connector, | ||
plugins: (await connector.list('active')).values | ||
}); | ||
|
||
// If there are plugins that have schemas that are not in the setting | ||
// registry after the application has restored, try to load them manually | ||
// because otherwise, its settings will never become available in the | ||
// setting registry. | ||
void app.restored.then(async () => { | ||
const plugins = await connector.list('all'); | ||
plugins.ids.forEach(async (id, index) => { | ||
if (isDisabled(id) || id in registry.plugins) { | ||
return; | ||
} | ||
|
||
try { | ||
await registry.load(id); | ||
} catch (error) { | ||
console.warn(`Settings failed to load for (${id})`, error); | ||
if (plugins.values[index].schema['jupyter.lab.transform']) { | ||
console.warn( | ||
`This may happen if {autoStart: false} in (${id}) ` + | ||
`or if it is one of the deferredExtensions in page config.` | ||
); | ||
} | ||
} | ||
}); | ||
}); | ||
|
||
return registry; | ||
}, | ||
autoStart: true, | ||
provides: ISettingRegistry | ||
}; |