From e32f185248a768a074658eb12d377bd0a1337b71 Mon Sep 17 00:00:00 2001 From: Jeremy Tuloup Date: Wed, 16 Oct 2024 09:54:15 +0200 Subject: [PATCH 01/10] Move handling of the file browser settings to a separate plugin --- packages/tree-extension/src/index.ts | 70 ++++++++++++++++++++-------- 1 file changed, 51 insertions(+), 19 deletions(-) diff --git a/packages/tree-extension/src/index.ts b/packages/tree-extension/src/index.ts index 2fb092bfa2..b2f5582c96 100644 --- a/packages/tree-extension/src/index.ts +++ b/packages/tree-extension/src/index.ts @@ -186,6 +186,56 @@ const fileActions: JupyterFrontEndPlugin = { }, }; +/** + * A plugin to set the default file browser settings. + */ +const fileBrowserSettings: JupyterFrontEndPlugin = { + id: '@jupyter-notebook/tree-extension:settings', + description: 'Set up the default file browser settings', + requires: [IDefaultFileBrowser, ISettingRegistry], + autoStart: true, + activate: ( + app: JupyterFrontEnd, + browser: IDefaultFileBrowser, + settingRegistry: ISettingRegistry + ) => { + /** + * File browser default configuration. + */ + const defaultFileBrowserConfig = { + navigateToCurrentDirectory: false, + singleClickNavigation: true, + showLastModifiedColumn: true, + showFileSizeColumn: true, + showHiddenFiles: false, + showFileCheckboxes: true, + sortNotebooksFirst: true, + showFullPath: false, + }; + + // apply defaults + let key: keyof typeof defaultFileBrowserConfig; + for (key in defaultFileBrowserConfig) { + browser[key] = defaultFileBrowserConfig[key]; + } + + void settingRegistry.load(FILE_BROWSER_PLUGIN_ID).then((settings) => { + function onSettingsChanged(settings: ISettingRegistry.ISettings): void { + let key: keyof typeof defaultFileBrowserConfig; + for (key in defaultFileBrowserConfig) { + const value = settings.get(key).user as boolean; + // only set the setting if it is defined by the user + if (value === undefined) { + browser[key] = value; + } + } + } + settings.changed.connect(onSettingsChanged); + onSettingsChanged(settings); + }); + }, +}; + /** * A plugin to add the file filter toggle command to the palette */ @@ -360,25 +410,6 @@ const notebookTreeWidget: JupyterFrontEndPlugin = { nbTreeWidget.tabBar.addTab(running.title); } - const settings = settingRegistry.load(FILE_BROWSER_PLUGIN_ID); - Promise.all([settings, app.restored]) - .then(([settings]) => { - // Set Notebook 7 defaults if there is no user setting override - [ - 'showFileCheckboxes', - 'showFileSizeColumn', - 'sortNotebooksFirst', - 'showFullPath', - ].forEach((setting) => { - if (settings.user[setting] === undefined) { - void settings.set(setting, true); - } - }); - }) - .catch((reason: Error) => { - console.error(reason.message); - }); - app.shell.add(nbTreeWidget, 'main', { rank: 100 }); // add a separate tab for each setting editor @@ -419,6 +450,7 @@ const notebookTreeWidget: JupyterFrontEndPlugin = { const plugins: JupyterFrontEndPlugin[] = [ createNew, fileActions, + fileBrowserSettings, fileFilterCommand, loadPlugins, openFileBrowser, From 95d8f12b7d3e1f64ea3a41742d45e3b94497d0d0 Mon Sep 17 00:00:00 2001 From: Jeremy Tuloup Date: Wed, 16 Oct 2024 10:00:20 +0200 Subject: [PATCH 02/10] fix typo --- packages/tree-extension/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tree-extension/src/index.ts b/packages/tree-extension/src/index.ts index b2f5582c96..32d9a4b42b 100644 --- a/packages/tree-extension/src/index.ts +++ b/packages/tree-extension/src/index.ts @@ -225,7 +225,7 @@ const fileBrowserSettings: JupyterFrontEndPlugin = { for (key in defaultFileBrowserConfig) { const value = settings.get(key).user as boolean; // only set the setting if it is defined by the user - if (value === undefined) { + if (value !== undefined) { browser[key] = value; } } From 59e4a052695ad83d1c6d3a9c6e2acd14ef7596bf Mon Sep 17 00:00:00 2001 From: Jeremy Tuloup Date: Wed, 16 Oct 2024 10:15:05 +0200 Subject: [PATCH 03/10] optional settingregistry --- packages/tree-extension/src/index.ts | 31 +++++++++++++++------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/packages/tree-extension/src/index.ts b/packages/tree-extension/src/index.ts index 32d9a4b42b..a73f0f74a6 100644 --- a/packages/tree-extension/src/index.ts +++ b/packages/tree-extension/src/index.ts @@ -192,12 +192,13 @@ const fileActions: JupyterFrontEndPlugin = { const fileBrowserSettings: JupyterFrontEndPlugin = { id: '@jupyter-notebook/tree-extension:settings', description: 'Set up the default file browser settings', - requires: [IDefaultFileBrowser, ISettingRegistry], + requires: [IDefaultFileBrowser], + optional: [ISettingRegistry], autoStart: true, activate: ( app: JupyterFrontEnd, browser: IDefaultFileBrowser, - settingRegistry: ISettingRegistry + settingRegistry: ISettingRegistry | null ) => { /** * File browser default configuration. @@ -219,20 +220,22 @@ const fileBrowserSettings: JupyterFrontEndPlugin = { browser[key] = defaultFileBrowserConfig[key]; } - void settingRegistry.load(FILE_BROWSER_PLUGIN_ID).then((settings) => { - function onSettingsChanged(settings: ISettingRegistry.ISettings): void { - let key: keyof typeof defaultFileBrowserConfig; - for (key in defaultFileBrowserConfig) { - const value = settings.get(key).user as boolean; - // only set the setting if it is defined by the user - if (value !== undefined) { - browser[key] = value; + if (settingRegistry) { + void settingRegistry.load(FILE_BROWSER_PLUGIN_ID).then((settings) => { + function onSettingsChanged(settings: ISettingRegistry.ISettings): void { + let key: keyof typeof defaultFileBrowserConfig; + for (key in defaultFileBrowserConfig) { + const value = settings.get(key).user as boolean; + // only set the setting if it is defined by the user + if (value !== undefined) { + browser[key] = value; + } } } - } - settings.changed.connect(onSettingsChanged); - onSettingsChanged(settings); - }); + settings.changed.connect(onSettingsChanged); + onSettingsChanged(settings); + }); + } }, }; From 31e2bcdf5327a99828977edb1854268862d2d335 Mon Sep 17 00:00:00 2001 From: Jeremy Tuloup Date: Thu, 24 Oct 2024 08:12:00 +0000 Subject: [PATCH 04/10] remove upstream filebrowser plugin --- app/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/app/package.json b/app/package.json index b8c509a150..e64523e9fe 100644 --- a/app/package.json +++ b/app/package.json @@ -310,7 +310,6 @@ "@jupyterlab/filebrowser-extension:file-upload-status", "@jupyterlab/filebrowser-extension:open-with", "@jupyterlab/filebrowser-extension:search", - "@jupyterlab/filebrowser-extension:settings", "@jupyterlab/filebrowser-extension:share-file" ], "@jupyter-notebook/tree-extension": true, From 17613bccb5ab861c3826ea262ef155d8bfa5c42e Mon Sep 17 00:00:00 2001 From: Jeremy Tuloup Date: Thu, 24 Oct 2024 08:41:08 +0000 Subject: [PATCH 05/10] fix file actions buttons --- packages/tree-extension/src/index.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/tree-extension/src/index.ts b/packages/tree-extension/src/index.ts index a73f0f74a6..e5ffdabe3e 100644 --- a/packages/tree-extension/src/index.ts +++ b/packages/tree-extension/src/index.ts @@ -170,6 +170,10 @@ const fileActions: JupyterFrontEndPlugin = { selectionChanged.emit(void 0); }; }); + browser.model.pathChanged.connect(() => { + console.log('path changed'); + selectionChanged.emit(void 0); + }); // Create a toolbar item that adds buttons to the file browser toolbar // to perform actions on the files From ccd78cbd6fa6b56f30daa623ad23a632928c43dd Mon Sep 17 00:00:00 2001 From: Jeremy Tuloup Date: Thu, 24 Oct 2024 09:01:48 +0000 Subject: [PATCH 06/10] hold ctrl --- ui-tests/test/filebrowser.spec.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ui-tests/test/filebrowser.spec.ts b/ui-tests/test/filebrowser.spec.ts index df99fc3f5d..dd10752565 100644 --- a/ui-tests/test/filebrowser.spec.ts +++ b/ui-tests/test/filebrowser.spec.ts @@ -20,6 +20,7 @@ test.describe('File Browser', () => { test('Select one folder', async ({ page, tmpPath }) => { await page.filebrowser.refresh(); + await page.keyboard.down('Control'); await page.getByText('folder1').last().click(); const toolbar = page.getByRole('toolbar'); @@ -31,6 +32,7 @@ test.describe('File Browser', () => { test('Select one file', async ({ page, tmpPath }) => { await page.filebrowser.refresh(); + await page.keyboard.down('Control'); await page.getByText('empty.ipynb').last().click(); const toolbar = page.getByRole('toolbar'); From 99a3a2d52f7f0afe323399795f2cdb4ef77972d8 Mon Sep 17 00:00:00 2001 From: Jeremy Tuloup Date: Thu, 24 Oct 2024 12:02:06 +0000 Subject: [PATCH 07/10] update changelog --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 412836d758..1c2c252007 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,11 +40,13 @@ The file browser now: - supports resizing the columns and remembers the column sizes after reloading JupyterLab - supports uploading folders by drag-and-drop -- supports navigation with a single click (opt-in) +- supports navigation with a single click - adds a file filter collapsed by default (funnel icon) ![a screenshot showing that it's now possible to resize the file browser columns](https://github.com/user-attachments/assets/b0d9cd0a-2828-43f7-a922-e8b271e5f7fc) +In Jupyter Notebook, the single click navigation is enabled by default. If you would like to disable it to get the same experience as in JupyterLab, go to `Settings → File Browser` and make sure "Navigate files and directories with single click" is disabled. + ### Improved kernel and server interactions The previous release enabled connecting to external kernels, such as those spawned by a third-party application like Blender. In this release the kernel selector dialog was improved to also show the external kernels. From ccefc18cc05a6a6034b68962ed325f685c0465f3 Mon Sep 17 00:00:00 2001 From: Jeremy Tuloup Date: Thu, 24 Oct 2024 12:14:26 +0000 Subject: [PATCH 08/10] wording --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c2c252007..f99316278b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,7 +45,7 @@ The file browser now: ![a screenshot showing that it's now possible to resize the file browser columns](https://github.com/user-attachments/assets/b0d9cd0a-2828-43f7-a922-e8b271e5f7fc) -In Jupyter Notebook, the single click navigation is enabled by default. If you would like to disable it to get the same experience as in JupyterLab, go to `Settings → File Browser` and make sure "Navigate files and directories with single click" is disabled. +In Jupyter Notebook, the single click navigation is enabled by default. If you would like to disable it to get the same experience as in JupyterLab, go to `Settings → File Browser` and make sure "Navigate files and directories with single click" is unchecked. ### Improved kernel and server interactions From 8117fc875602dfa02965fba08f86a60cea8bcac5 Mon Sep 17 00:00:00 2001 From: Jeremy Tuloup Date: Thu, 24 Oct 2024 15:57:18 +0000 Subject: [PATCH 09/10] remove console.log --- packages/tree-extension/src/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/tree-extension/src/index.ts b/packages/tree-extension/src/index.ts index e5ffdabe3e..2fd2ff2d86 100644 --- a/packages/tree-extension/src/index.ts +++ b/packages/tree-extension/src/index.ts @@ -171,7 +171,6 @@ const fileActions: JupyterFrontEndPlugin = { }; }); browser.model.pathChanged.connect(() => { - console.log('path changed'); selectionChanged.emit(void 0); }); From c84235da873cb9acf89abb7dcf5291bce5223b31 Mon Sep 17 00:00:00 2001 From: Jeremy Tuloup Date: Thu, 24 Oct 2024 15:59:05 +0000 Subject: [PATCH 10/10] fix comments --- packages/tree-extension/src/index.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/tree-extension/src/index.ts b/packages/tree-extension/src/index.ts index 2fd2ff2d86..da80df842e 100644 --- a/packages/tree-extension/src/index.ts +++ b/packages/tree-extension/src/index.ts @@ -203,9 +203,8 @@ const fileBrowserSettings: JupyterFrontEndPlugin = { browser: IDefaultFileBrowser, settingRegistry: ISettingRegistry | null ) => { - /** - * File browser default configuration. - */ + // Default config for notebook. + // This is a different set of defaults than JupyterLab. const defaultFileBrowserConfig = { navigateToCurrentDirectory: false, singleClickNavigation: true, @@ -217,7 +216,7 @@ const fileBrowserSettings: JupyterFrontEndPlugin = { showFullPath: false, }; - // apply defaults + // Apply defaults on plugin activation let key: keyof typeof defaultFileBrowserConfig; for (key in defaultFileBrowserConfig) { browser[key] = defaultFileBrowserConfig[key];