@@ -19,7 +19,11 @@ import {
1919 Dialog
2020} from '@jupyterlab/apputils' ;
2121import { 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' ;
2327import { CommandRegistry } from '@lumino/commands' ;
2428import { 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}
0 commit comments