New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix setting connector to re-enable saving user settings (cf. #7147) #7601
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -40,5 +40,9 @@ export class SettingConnector extends DataConnector< | |||
}; | ||||
} | ||||
|
||||
async save(id: string, raw: string): Promise<void> { | ||||
await this._connector.save(id, raw); | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have a slight preference toward There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was going to say "I'm happy to change it just because you asked, @afshin", but then I looked and saw that the function it's wrapping is also
so for consistency's sake, I think To be 100% sure, the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there an extra promise getting wrapped up in here? Basically I'm wondering if these three are equivalent or if they return a different level of nesting. save(id: string, raw: string): Promise<void> {
return this._connector.save(id, raw);
} async save(id: string, raw: string): Promise<void> {
return this._connector.save(id, raw);
} async save(id: string, raw: string): Promise<void> {
await this._connector.save(id, raw);
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've read over the
So at least I can confidently say that no, there's no extra promise getting wrapped up here. I can also say that for our purposes there are no important distinctions between 1/2/3. @afshin Do you still think I should change it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, so I think if we are exporting ES2015, 1 is the best answer, based on this experiment. Does that look right to you? You can play with the playground link to confirm. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (This is all very pedantic, but it's good to know what JS we are actually generating.) |
||||
} | ||||
|
||||
private _connector: IDataConnector<ISettingRegistry.IPlugin, string>; | ||||
} |
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 | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🍳 🥚 on my face. Thanks for the fix 👍