Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the file filter button to the file browser toolbar #7479

Merged
merged 7 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
@@ -1,7 +1,7 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.

import { IJupyterLabPage, expect, galata } from '@jupyterlab/galata';

Check warning on line 4 in ui-tests/test/mobile.spec.ts

View workflow job for this annotation

GitHub Actions / Test Lint

'IJupyterLabPage' is defined but never used

import { test } from './fixtures';

Expand Down Expand Up @@ -36,7 +36,7 @@
await page.waitForSelector('#top-panel-wrapper', { state: 'hidden' });

expect(await page.screenshot()).toMatchSnapshot('tree.png', {
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.
Loading