Skip to content

Commit 06c4f7c

Browse files
committed
fix toggle file filter for drive browser
1 parent c896f93 commit 06c4f7c

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
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: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ import {
1919
Dialog
2020
} from '@jupyterlab/apputils';
2121
import { ISettingRegistry } from '@jupyterlab/settingregistry';
22-
import { FilenameSearcher, IScore } from '@jupyterlab/ui-components';
22+
import {
23+
FilenameSearcher,
24+
IScore
25+
} from '@jupyterlab/ui-components';
2326
import { CommandRegistry } from '@lumino/commands';
2427
import { Widget } from '@lumino/widgets';
2528

@@ -178,7 +181,7 @@ export const driveFileBrowser: JupyterFrontEndPlugin<void> = {
178181
setting.changed.connect(loadSetting);
179182

180183
// Add commands
181-
Private.addCommands(app, drive);
184+
Private.addCommands(app, drive, driveBrowser);
182185
})
183186
.catch(reason => {
184187
console.error(
@@ -308,7 +311,11 @@ namespace Private {
308311
}
309312
}
310313

311-
export function addCommands(app: JupyterFrontEnd, drive: Drive): void {
314+
export function addCommands(
315+
app: JupyterFrontEnd,
316+
drive: Drive,
317+
browser: FileBrowser
318+
): void {
312319
app.commands.addCommand(CommandIDs.createNewDrive, {
313320
execute: async () => {
314321
return showDialog({
@@ -337,5 +344,19 @@ namespace Private {
337344
selector: '#drive-file-browser.jp-SidePanel .jp-DirListing-content',
338345
rank: 100
339346
});
347+
348+
app.commands.addCommand(CommandIDs.toggleFileFilter, {
349+
execute: () => {
350+
// Update toggled state, then let the toolbar button update
351+
browser.showFileFilter = !browser.showFileFilter;
352+
app.commands.notifyCommandChanged(CommandIDs.toggleFileFilter);
353+
},
354+
isToggled: () => {
355+
const toggled = browser.showFileFilter;
356+
return toggled;
357+
},
358+
icon: driveBrowserIcon.bindprops({ stylesheet: 'menuItem' }),
359+
label: 'Toggle File Filter'
360+
});
340361
}
341362
}

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)