Skip to content

Commit f68b161

Browse files
authored
Merge pull request #83 from DenisaCG/toggleFilter
Fix toggle file filter button for drive browser
2 parents 8e6c949 + fb90756 commit f68b161

File tree

3 files changed

+30
-12
lines changed

3 files changed

+30
-12
lines changed

schema/drives-file-browser.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,9 @@
2424
},
2525
{
2626
"name": "toggle-file-filter",
27-
"command": "filebrowser:toggle-file-filter",
27+
"command": "drives:toggle-file-filter",
2828
"label": "",
2929
"rank": 40
30-
},
31-
{
32-
"name": "file-name-searcher",
33-
"label": "",
34-
"rank": 50
3530
}
3631
]
3732
},

src/plugins/driveBrowserPlugin.ts

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ import {
1919
Dialog
2020
} from '@jupyterlab/apputils';
2121
import { ISettingRegistry } from '@jupyterlab/settingregistry';
22-
import { FilenameSearcher, IScore } from '@jupyterlab/ui-components';
22+
import {
23+
filterIcon,
24+
FilenameSearcher,
25+
IScore
26+
} from '@jupyterlab/ui-components';
2327
import { CommandRegistry } from '@lumino/commands';
2428
import { Widget } from '@lumino/widgets';
2529

@@ -143,7 +147,10 @@ export const driveFileBrowser: JupyterFrontEndPlugin<void> = {
143147
}
144148
);
145149

146-
// connect the filebrowser toolbar to the settings registry for the plugin
150+
// Add commands
151+
Private.addCommands(app, drive, driveBrowser);
152+
153+
// Connect the filebrowser toolbar to the settings registry for the plugin.
147154
setToolbar(
148155
driveBrowser,
149156
createToolbarFactory(
@@ -176,9 +183,6 @@ export const driveFileBrowser: JupyterFrontEndPlugin<void> = {
176183

177184
// Listen for your plugin setting changes using Signal
178185
setting.changed.connect(loadSetting);
179-
180-
// Add commands
181-
Private.addCommands(app, drive);
182186
})
183187
.catch(reason => {
184188
console.error(
@@ -308,7 +312,11 @@ namespace Private {
308312
}
309313
}
310314

311-
export function addCommands(app: JupyterFrontEnd, drive: Drive): void {
315+
export function addCommands(
316+
app: JupyterFrontEnd,
317+
drive: Drive,
318+
browser: FileBrowser
319+
): void {
312320
app.commands.addCommand(CommandIDs.createNewDrive, {
313321
execute: async () => {
314322
return showDialog({
@@ -337,5 +345,19 @@ namespace Private {
337345
selector: '#drive-file-browser.jp-SidePanel .jp-DirListing-content',
338346
rank: 100
339347
});
348+
349+
app.commands.addCommand(CommandIDs.toggleFileFilter, {
350+
execute: () => {
351+
// Update toggled state, then let the toolbar button update
352+
browser.showFileFilter = !browser.showFileFilter;
353+
app.commands.notifyCommandChanged(CommandIDs.toggleFileFilter);
354+
},
355+
isToggled: () => {
356+
const toggled = browser.showFileFilter;
357+
return toggled;
358+
},
359+
icon: filterIcon.bindprops({ stylesheet: 'menuItem' }),
360+
label: 'Toggle File Filter'
361+
});
340362
}
341363
}

src/token.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export namespace CommandIDs {
99
export const toggleBrowser = 'drives:toggle-main';
1010
export const createNewDrive = 'drives:create-new-drive';
1111
export const launcher = 'launcher:create';
12+
export const toggleFileFilter = 'drives:toggle-file-filter';
1213
}
1314

1415
/**

0 commit comments

Comments
 (0)