I have a boolean setting that is added to a new file menu as well as the command pallette. When I change the setting on either menu or command pallette, the value is changed correctly in both places and in the JSON settings editor but is not updated in the new settings UI. Is there a notify event that I have not registered to get the setting updated in the new UI?
const sqSettingsPlugin: JupyterFrontEndPlugin<void> = {
id: Plugins.sqSettings,
autoStart: true,
requires: [ISettingRegistry, ICommandPalette],
activate: (app: JupyterFrontEnd, settingRegistry: ISettingRegistry, commandPalette: ICommandPalette) => {
console.log(`extension ${Plugins.sqSettings} is activated!`);
const { commands } = app;
let labView = false;
/**
* Load the settings for this extension
*
* @param settings Extension settings
*/
function onSettingsUpdated(settings: ISettingRegistry.ISettings): void {
// Get current labView setting
const currentLabView = settings.get('labView').composite as boolean | null;
labView = currentLabView === true || currentLabView === false ? currentLabView : false;
app.commands.notifyCommandChanged(CommandIDs.toggleLabView);
console.log(`extension ${Plugins.sqSettings}: labView is '${labView}'`);
}
// Wait for the application to be restored and
// for the settings for this plugin to be loaded
Promise.all([app.restored, settingRegistry.load(Plugins.sqSettings)])
.then(([, settings]) => {
// add the command
commands.addCommand(CommandIDs.toggleLabView, {
label: 'JupyterLab Lab View as default',
caption: 'Enable JupyterLab Lab View as default view"',
isToggled: () => labView,
execute: () => {
// Programmatically change a setting
Promise.all([
settings.set('labView', !labView),
])
.then(() => {
const newLabView = settings.get('labView').composite as boolean;
console.log(`extension ${Plugins.sqSettings}: labView set to '${newLabView}'`);
})
.catch((reason) => {
console.error(`extension ${Plugins.sqSettings}: error setting labView: ${reason}`);
});
},
});
// Add the command to the command palette
commandPalette.addItem({ command: CommandIDs.toggleLabView, category: 'Settings' });
// Read the settings
onSettingsUpdated(settings);
// Listen for plugin setting changes using Signal
settings.changed.connect(onSettingsUpdated);
})
.catch((reason) => {
console.error(`extension ${Plugins.sqSettings}: error reading settings: ${reason}`);
});
},
};
Here is my settings file
{
"jupyter.lab.setting-icon": "MyExtension:datalab-icon",
"jupyter.lab.setting-icon-label": "My Lab",
"title": "My Lab",
"description": "Settings for My Lab.",
"properties": {
"labView": {
"type": "boolean",
"title": "JupyterLab Lab View",
"description": "Enable JupyterLab Lab View as default view",
"default": false
}
},
"jupyter.lab.menus": {
"main": [
{
"id": "jp-mainmenu-mymenu",
"label": "My Menu",
"rank": 1001,
"items": [
{
"command": "MyExtension:toggle-labView",
"args": {
"origin": "from the menu"
}
}
]
}
]
},
"additionalProperties": false,
"type": "object"
}