Skip to content
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
7 changes: 1 addition & 6 deletions schema/drives-file-browser.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,9 @@
},
{
"name": "toggle-file-filter",
"command": "filebrowser:toggle-file-filter",
"command": "drives:toggle-file-filter",
"label": "",
"rank": 40
},
{
"name": "file-name-searcher",
"label": "",
"rank": 50
}
]
},
Expand Down
34 changes: 28 additions & 6 deletions src/plugins/driveBrowserPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ import {
Dialog
} from '@jupyterlab/apputils';
import { ISettingRegistry } from '@jupyterlab/settingregistry';
import { FilenameSearcher, IScore } from '@jupyterlab/ui-components';
import {
filterIcon,
FilenameSearcher,
IScore
} from '@jupyterlab/ui-components';
import { CommandRegistry } from '@lumino/commands';
import { Widget } from '@lumino/widgets';

Expand Down Expand Up @@ -143,7 +147,10 @@ export const driveFileBrowser: JupyterFrontEndPlugin<void> = {
}
);

// connect the filebrowser toolbar to the settings registry for the plugin
// Add commands
Private.addCommands(app, drive, driveBrowser);

// Connect the filebrowser toolbar to the settings registry for the plugin.
setToolbar(
driveBrowser,
createToolbarFactory(
Expand Down Expand Up @@ -176,9 +183,6 @@ export const driveFileBrowser: JupyterFrontEndPlugin<void> = {

// Listen for your plugin setting changes using Signal
setting.changed.connect(loadSetting);

// Add commands
Private.addCommands(app, drive);
})
.catch(reason => {
console.error(
Expand Down Expand Up @@ -308,7 +312,11 @@ namespace Private {
}
}

export function addCommands(app: JupyterFrontEnd, drive: Drive): void {
export function addCommands(
app: JupyterFrontEnd,
drive: Drive,
browser: FileBrowser
): void {
app.commands.addCommand(CommandIDs.createNewDrive, {
execute: async () => {
return showDialog({
Expand Down Expand Up @@ -337,5 +345,19 @@ namespace Private {
selector: '#drive-file-browser.jp-SidePanel .jp-DirListing-content',
rank: 100
});

app.commands.addCommand(CommandIDs.toggleFileFilter, {
execute: () => {
// Update toggled state, then let the toolbar button update
browser.showFileFilter = !browser.showFileFilter;
app.commands.notifyCommandChanged(CommandIDs.toggleFileFilter);
},
isToggled: () => {
const toggled = browser.showFileFilter;
return toggled;
},
icon: filterIcon.bindprops({ stylesheet: 'menuItem' }),
label: 'Toggle File Filter'
});
}
}
1 change: 1 addition & 0 deletions src/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export namespace CommandIDs {
export const toggleBrowser = 'drives:toggle-main';
export const createNewDrive = 'drives:create-new-drive';
export const launcher = 'launcher:create';
export const toggleFileFilter = 'drives:toggle-file-filter';
}

/**
Expand Down
Loading