-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Description
Description
Currently the file browser sets its own default config here:
jupyterlab/packages/filebrowser-extension/src/index.ts
Lines 219 to 247 in d98ef15
| const fileBrowserConfig = { | |
| navigateToCurrentDirectory: false, | |
| showLastModifiedColumn: true, | |
| showFileSizeColumn: false, | |
| showHiddenFiles: false, | |
| showFileCheckboxes: false, | |
| sortNotebooksFirst: false | |
| }; | |
| const fileBrowserModelConfig = { | |
| filterDirectories: true | |
| }; | |
| function onSettingsChanged( | |
| settings: ISettingRegistry.ISettings | |
| ): void { | |
| let key: keyof typeof fileBrowserConfig; | |
| for (key in fileBrowserConfig) { | |
| const value = settings.get(key).composite as boolean; | |
| fileBrowserConfig[key] = value; | |
| browser[key] = value; | |
| } | |
| const value = settings.get('filterDirectories') | |
| .composite as boolean; | |
| fileBrowserModelConfig.filterDirectories = value; | |
| browser.model.filterDirectories = value; | |
| } | |
| settings.changed.connect(onSettingsChanged); | |
| onSettingsChanged(settings); |
Since this happens at application startup, it can override other configuration set in different plugins.
Reproduce
In a separate plugin (for example in a custom third-party extension), use browser.showFileCheckboxes = true to show the file browser checkboxes by default on application startup.
However because of the current logic with the code snippet above the default configuration will be applied again when the plugin activates.
In the following screencast we see how the checkboxes first appear and then quickly disappear:
file-browser-defaults.mp4
Expected behavior
Other plugins should be allowed to use public setters like browser.showFileCheckboxes = true to customize the behavior of the file browser, when there is no user setting available.
If there is a value in the settings, then it takes precedence.
Context
This is an issue in Notebook 7 which has to use the settings to store its default values for the file browser (checkboxes, file size column, sort notebooks first). For example: jupyter/notebook#6892
However since these settings are also shared with JupyterLab, they also apply in the JupyterLab interface.
The idea would be for Notebook 7 to be able to customize with the following without having the configuration being overridden by the default lab plugin:
browser.showFileCheckboxes = true
browser.sortNotebookFirst = true
browser.showFileSizeColumn = true