Skip to content

Commit 676a0fe

Browse files
authored
Add the file filter button to the file browser toolbar (#7479)
* 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
1 parent faee9e4 commit 676a0fe

File tree

10 files changed

+34
-15
lines changed

10 files changed

+34
-15
lines changed

packages/tree-extension/schema/widget.json

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
"jupyter.lab.toolbars": {
55
"FileBrowser": [
66
{ "name": "spacer", "type": "spacer", "rank": 900 },
7+
{
8+
"name": "toggle-file-filter",
9+
"label": "",
10+
"command": "filebrowser:toggle-file-filter",
11+
"rank": 990
12+
},
713
{ "name": "new-dropdown", "rank": 1000 },
814
{ "name": "uploader", "rank": 1010 },
915
{ "name": "refresh", "command": "filebrowser:refresh", "rank": 1020 }

packages/tree-extension/src/index.ts

+21-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
} from '@jupyterlab/application';
88

99
import {
10+
ICommandPalette,
1011
IToolbarWidgetRegistry,
1112
createToolbarFactory,
1213
setToolbar,
@@ -45,7 +46,6 @@ import { Menu, MenuBar } from '@lumino/widgets';
4546
import { NotebookTreeWidget, INotebookTree } from '@jupyter-notebook/tree';
4647

4748
import { FilesActionButtons } from './fileactions';
48-
import { IStateDB } from '@jupyterlab/statedb';
4949

5050
/**
5151
* The file browser factory.
@@ -64,6 +64,7 @@ namespace CommandIDs {
6464
// The command to activate the filebrowser widget in tree view.
6565
export const activate = 'filebrowser:activate';
6666

67+
// Activate the file filter in the file browser
6768
export const toggleFileFilter = 'filebrowser:toggle-file-filter';
6869
}
6970

@@ -185,6 +186,24 @@ const fileActions: JupyterFrontEndPlugin<void> = {
185186
},
186187
};
187188

189+
/**
190+
* A plugin to add the file filter toggle command to the palette
191+
*/
192+
const fileFilterCommand: JupyterFrontEndPlugin<void> = {
193+
id: '@jupyter-notebook/tree-extension:file-filter-command',
194+
description: 'A plugin to add file filter command to the palette.',
195+
autoStart: true,
196+
optional: [ICommandPalette],
197+
activate: (app: JupyterFrontEnd, palette: ICommandPalette | null) => {
198+
if (palette) {
199+
palette.addItem({
200+
command: CommandIDs.toggleFileFilter,
201+
category: 'File Browser',
202+
});
203+
}
204+
},
205+
};
206+
188207
/**
189208
* Plugin to load the default plugins that are loaded on all the Notebook pages
190209
* (tree, edit, view, etc.) so they are visible in the settings editor.
@@ -278,7 +297,6 @@ const notebookTreeWidget: JupyterFrontEndPlugin<INotebookTree> = {
278297
ISettingRegistry,
279298
IToolbarWidgetRegistry,
280299
IFileBrowserFactory,
281-
IStateDB,
282300
],
283301
optional: [
284302
IRunningSessionManagers,
@@ -294,7 +312,6 @@ const notebookTreeWidget: JupyterFrontEndPlugin<INotebookTree> = {
294312
settingRegistry: ISettingRegistry,
295313
toolbarRegistry: IToolbarWidgetRegistry,
296314
factory: IFileBrowserFactory,
297-
stateDB: IStateDB,
298315
manager: IRunningSessionManagers | null,
299316
settingEditorTracker: ISettingEditorTracker | null,
300317
jsonSettingEditorTracker: IJSONSettingEditorTracker | null
@@ -402,6 +419,7 @@ const notebookTreeWidget: JupyterFrontEndPlugin<INotebookTree> = {
402419
const plugins: JupyterFrontEndPlugin<any>[] = [
403420
createNew,
404421
fileActions,
422+
fileFilterCommand,
405423
loadPlugins,
406424
openFileBrowser,
407425
notebookTreeWidget,

packages/tree-extension/style/base.css

+4-9
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,6 @@
3232
background: inherit;
3333
}
3434

35-
.jp-FileBrowser-filterBox {
36-
padding: 0;
37-
flex: 0 0 auto;
38-
}
39-
40-
.jp-FileBrowser-filterBox input {
41-
line-height: 24px;
42-
}
43-
4435
.jp-DirListing-content .jp-DirListing-checkboxWrapper {
4536
visibility: visible;
4637
}
@@ -66,3 +57,7 @@
6657
margin: 1px;
6758
min-height: var(--jp-private-toolbar-height);
6859
}
60+
61+
body[data-format='mobile'] #fileAction-placeholder {
62+
display: none;
63+
}

ui-tests/test/mobile.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ test.describe('Mobile', () => {
3636
await page.waitForSelector('#top-panel-wrapper', { state: 'hidden' });
3737

3838
expect(await page.screenshot()).toMatchSnapshot('tree.png', {
39-
maxDiffPixels: 500,
39+
maxDiffPixels: 300,
4040
});
4141
});
4242

Loading
Loading

ui-tests/test/settings.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ test.describe('Settings', () => {
3434
await page.reload({ waitUntil: 'networkidle' });
3535
await page.menu.getMenuItem(showHeaderPath);
3636
expect(await page.screenshot()).toMatchSnapshot('top-hidden.png', {
37-
maxDiffPixels: 500,
37+
maxDiffPixels: 300,
3838
});
3939

4040
await page.waitForSelector('#top-panel', { state: 'hidden' });
@@ -43,7 +43,7 @@ test.describe('Settings', () => {
4343
await page.reload({ waitUntil: 'networkidle' });
4444
await page.menu.getMenuItem(showHeaderPath);
4545
expect(await page.screenshot()).toMatchSnapshot('top-visible.png', {
46-
maxDiffPixels: 500,
46+
maxDiffPixels: 300,
4747
});
4848
});
4949
});
Loading
Loading
Loading

0 commit comments

Comments
 (0)