diff --git a/packages/tree-extension/schema/widget.json b/packages/tree-extension/schema/widget.json index e62f7c358d..60cefd4b36 100644 --- a/packages/tree-extension/schema/widget.json +++ b/packages/tree-extension/schema/widget.json @@ -4,6 +4,12 @@ "jupyter.lab.toolbars": { "FileBrowser": [ { "name": "spacer", "type": "spacer", "rank": 900 }, + { + "name": "toggle-file-filter", + "label": "", + "command": "filebrowser:toggle-file-filter", + "rank": 990 + }, { "name": "new-dropdown", "rank": 1000 }, { "name": "uploader", "rank": 1010 }, { "name": "refresh", "command": "filebrowser:refresh", "rank": 1020 } diff --git a/packages/tree-extension/src/index.ts b/packages/tree-extension/src/index.ts index 6504f58a3f..2fb092bfa2 100644 --- a/packages/tree-extension/src/index.ts +++ b/packages/tree-extension/src/index.ts @@ -7,6 +7,7 @@ import { } from '@jupyterlab/application'; import { + ICommandPalette, IToolbarWidgetRegistry, createToolbarFactory, setToolbar, @@ -45,7 +46,6 @@ import { Menu, MenuBar } from '@lumino/widgets'; import { NotebookTreeWidget, INotebookTree } from '@jupyter-notebook/tree'; import { FilesActionButtons } from './fileactions'; -import { IStateDB } from '@jupyterlab/statedb'; /** * The file browser factory. @@ -64,6 +64,7 @@ namespace CommandIDs { // The command to activate the filebrowser widget in tree view. export const activate = 'filebrowser:activate'; + // Activate the file filter in the file browser export const toggleFileFilter = 'filebrowser:toggle-file-filter'; } @@ -185,6 +186,24 @@ const fileActions: JupyterFrontEndPlugin = { }, }; +/** + * A plugin to add the file filter toggle command to the palette + */ +const fileFilterCommand: JupyterFrontEndPlugin = { + id: '@jupyter-notebook/tree-extension:file-filter-command', + description: 'A plugin to add file filter command to the palette.', + autoStart: true, + optional: [ICommandPalette], + activate: (app: JupyterFrontEnd, palette: ICommandPalette | null) => { + if (palette) { + palette.addItem({ + command: CommandIDs.toggleFileFilter, + category: 'File Browser', + }); + } + }, +}; + /** * Plugin to load the default plugins that are loaded on all the Notebook pages * (tree, edit, view, etc.) so they are visible in the settings editor. @@ -278,7 +297,6 @@ const notebookTreeWidget: JupyterFrontEndPlugin = { ISettingRegistry, IToolbarWidgetRegistry, IFileBrowserFactory, - IStateDB, ], optional: [ IRunningSessionManagers, @@ -294,7 +312,6 @@ const notebookTreeWidget: JupyterFrontEndPlugin = { settingRegistry: ISettingRegistry, toolbarRegistry: IToolbarWidgetRegistry, factory: IFileBrowserFactory, - stateDB: IStateDB, manager: IRunningSessionManagers | null, settingEditorTracker: ISettingEditorTracker | null, jsonSettingEditorTracker: IJSONSettingEditorTracker | null @@ -402,6 +419,7 @@ const notebookTreeWidget: JupyterFrontEndPlugin = { const plugins: JupyterFrontEndPlugin[] = [ createNew, fileActions, + fileFilterCommand, loadPlugins, openFileBrowser, notebookTreeWidget, diff --git a/packages/tree-extension/style/base.css b/packages/tree-extension/style/base.css index da2dd64595..f52480114d 100644 --- a/packages/tree-extension/style/base.css +++ b/packages/tree-extension/style/base.css @@ -32,15 +32,6 @@ background: inherit; } -.jp-FileBrowser-filterBox { - padding: 0; - flex: 0 0 auto; -} - -.jp-FileBrowser-filterBox input { - line-height: 24px; -} - .jp-DirListing-content .jp-DirListing-checkboxWrapper { visibility: visible; } @@ -66,3 +57,7 @@ margin: 1px; min-height: var(--jp-private-toolbar-height); } + +body[data-format='mobile'] #fileAction-placeholder { + display: none; +} diff --git a/ui-tests/test/mobile.spec.ts b/ui-tests/test/mobile.spec.ts index 4158f09cb5..c4979f6795 100644 --- a/ui-tests/test/mobile.spec.ts +++ b/ui-tests/test/mobile.spec.ts @@ -36,7 +36,7 @@ test.describe('Mobile', () => { await page.waitForSelector('#top-panel-wrapper', { state: 'hidden' }); expect(await page.screenshot()).toMatchSnapshot('tree.png', { - maxDiffPixels: 500, + maxDiffPixels: 300, }); }); diff --git a/ui-tests/test/mobile.spec.ts-snapshots/tree-chromium-linux.png b/ui-tests/test/mobile.spec.ts-snapshots/tree-chromium-linux.png index 059e96c60f..08bcadf701 100644 Binary files a/ui-tests/test/mobile.spec.ts-snapshots/tree-chromium-linux.png and b/ui-tests/test/mobile.spec.ts-snapshots/tree-chromium-linux.png differ diff --git a/ui-tests/test/mobile.spec.ts-snapshots/tree-firefox-linux.png b/ui-tests/test/mobile.spec.ts-snapshots/tree-firefox-linux.png index 3fbcaae810..2c7b073ca6 100644 Binary files a/ui-tests/test/mobile.spec.ts-snapshots/tree-firefox-linux.png and b/ui-tests/test/mobile.spec.ts-snapshots/tree-firefox-linux.png differ diff --git a/ui-tests/test/settings.spec.ts b/ui-tests/test/settings.spec.ts index 227240aea5..67e4abcb9b 100644 --- a/ui-tests/test/settings.spec.ts +++ b/ui-tests/test/settings.spec.ts @@ -34,7 +34,7 @@ test.describe('Settings', () => { await page.reload({ waitUntil: 'networkidle' }); await page.menu.getMenuItem(showHeaderPath); expect(await page.screenshot()).toMatchSnapshot('top-hidden.png', { - maxDiffPixels: 500, + maxDiffPixels: 300, }); await page.waitForSelector('#top-panel', { state: 'hidden' }); @@ -43,7 +43,7 @@ test.describe('Settings', () => { await page.reload({ waitUntil: 'networkidle' }); await page.menu.getMenuItem(showHeaderPath); expect(await page.screenshot()).toMatchSnapshot('top-visible.png', { - maxDiffPixels: 500, + maxDiffPixels: 300, }); }); }); diff --git a/ui-tests/test/settings.spec.ts-snapshots/top-hidden-chromium-linux.png b/ui-tests/test/settings.spec.ts-snapshots/top-hidden-chromium-linux.png index 94e8834ad4..cbc7356bd7 100644 Binary files a/ui-tests/test/settings.spec.ts-snapshots/top-hidden-chromium-linux.png and b/ui-tests/test/settings.spec.ts-snapshots/top-hidden-chromium-linux.png differ diff --git a/ui-tests/test/settings.spec.ts-snapshots/top-hidden-firefox-linux.png b/ui-tests/test/settings.spec.ts-snapshots/top-hidden-firefox-linux.png index cf645a2aac..63c63cdcf1 100644 Binary files a/ui-tests/test/settings.spec.ts-snapshots/top-hidden-firefox-linux.png and b/ui-tests/test/settings.spec.ts-snapshots/top-hidden-firefox-linux.png differ diff --git a/ui-tests/test/settings.spec.ts-snapshots/top-visible-firefox-linux.png b/ui-tests/test/settings.spec.ts-snapshots/top-visible-firefox-linux.png index d35673514d..fe443828ce 100644 Binary files a/ui-tests/test/settings.spec.ts-snapshots/top-visible-firefox-linux.png and b/ui-tests/test/settings.spec.ts-snapshots/top-visible-firefox-linux.png differ