Skip to content

Commit

Permalink
Add the file filter button to the file browser toolbar (#7479)
Browse files Browse the repository at this point in the history
* Add the file filter button to the file browser toolbar

* update snapshot

* lower maxDiffPixels

* more updates

* update

* hide placeholder text on mobile

* update tree snapshot
  • Loading branch information
jtpio authored Oct 15, 2024
1 parent faee9e4 commit 676a0fe
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 15 deletions.
6 changes: 6 additions & 0 deletions packages/tree-extension/schema/widget.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
24 changes: 21 additions & 3 deletions packages/tree-extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
} from '@jupyterlab/application';

import {
ICommandPalette,
IToolbarWidgetRegistry,
createToolbarFactory,
setToolbar,
Expand Down Expand Up @@ -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.
Expand All @@ -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';
}

Expand Down Expand Up @@ -185,6 +186,24 @@ const fileActions: JupyterFrontEndPlugin<void> = {
},
};

/**
* A plugin to add the file filter toggle command to the palette
*/
const fileFilterCommand: JupyterFrontEndPlugin<void> = {
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.
Expand Down Expand Up @@ -278,7 +297,6 @@ const notebookTreeWidget: JupyterFrontEndPlugin<INotebookTree> = {
ISettingRegistry,
IToolbarWidgetRegistry,
IFileBrowserFactory,
IStateDB,
],
optional: [
IRunningSessionManagers,
Expand All @@ -294,7 +312,6 @@ const notebookTreeWidget: JupyterFrontEndPlugin<INotebookTree> = {
settingRegistry: ISettingRegistry,
toolbarRegistry: IToolbarWidgetRegistry,
factory: IFileBrowserFactory,
stateDB: IStateDB,
manager: IRunningSessionManagers | null,
settingEditorTracker: ISettingEditorTracker | null,
jsonSettingEditorTracker: IJSONSettingEditorTracker | null
Expand Down Expand Up @@ -402,6 +419,7 @@ const notebookTreeWidget: JupyterFrontEndPlugin<INotebookTree> = {
const plugins: JupyterFrontEndPlugin<any>[] = [
createNew,
fileActions,
fileFilterCommand,
loadPlugins,
openFileBrowser,
notebookTreeWidget,
Expand Down
13 changes: 4 additions & 9 deletions packages/tree-extension/style/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -66,3 +57,7 @@
margin: 1px;
min-height: var(--jp-private-toolbar-height);
}

body[data-format='mobile'] #fileAction-placeholder {
display: none;
}
2 changes: 1 addition & 1 deletion ui-tests/test/mobile.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ test.describe('Mobile', () => {
await page.waitForSelector('#top-panel-wrapper', { state: 'hidden' });

expect(await page.screenshot()).toMatchSnapshot('tree.png', {

Check failure on line 38 in ui-tests/test/mobile.spec.ts

View workflow job for this annotation

GitHub Actions / ui-tests (chromium)

[chromium] › test/mobile.spec.ts:30:7 › Mobile › The layout should be more compact on the file browser page

2) [chromium] › test/mobile.spec.ts:30:7 › Mobile › The layout should be more compact on the file browser page Error: Screenshot comparison failed: 405 pixels (ratio 0.01 of all image pixels) are different. Expected: /home/runner/work/notebook/notebook/ui-tests/test/mobile.spec.ts-snapshots/tree-chromium-linux.png Received: /home/runner/work/notebook/notebook/ui-tests/test-results/test-mobile-Mobile-The-lay-60036-ct-on-the-file-browser-page-chromium/tree-actual.png Diff: /home/runner/work/notebook/notebook/ui-tests/test-results/test-mobile-Mobile-The-lay-60036-ct-on-the-file-browser-page-chromium/tree-diff.png 36 | await page.waitForSelector('#top-panel-wrapper', { state: 'hidden' }); 37 | > 38 | expect(await page.screenshot()).toMatchSnapshot('tree.png', { | ^ 39 | maxDiffPixels: 300, 40 | }); 41 | }); at /home/runner/work/notebook/notebook/ui-tests/test/mobile.spec.ts:38:37
maxDiffPixels: 500,
maxDiffPixels: 300,
});
});

Expand Down
Binary file modified ui-tests/test/mobile.spec.ts-snapshots/tree-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ui-tests/test/mobile.spec.ts-snapshots/tree-firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions ui-tests/test/settings.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' });
Expand All @@ -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,
});
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 676a0fe

Please sign in to comment.