Skip to content

Commit

Permalink
Add uploader
Browse files Browse the repository at this point in the history
  • Loading branch information
jtpio committed Oct 20, 2023
1 parent fd47b9f commit 7cead28
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
5 changes: 4 additions & 1 deletion schema/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
"title": "File System Access Widget",
"description": "File Browser widget settings.",
"jupyter.lab.toolbars": {
"FileSystemAccess": [{ "name": "open-folder", "rank": 0 }]
"FileSystemAccess": [
{ "name": "open-folder", "rank": 0 },
{ "name": "uploader", "rank": 10 }
]
},
"jupyter.lab.transform": true,
"properties": {
Expand Down
24 changes: 19 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import {
ToolbarButton
} from '@jupyterlab/apputils';

import { IFileBrowserFactory, FileBrowser } from '@jupyterlab/filebrowser';
import {
IFileBrowserFactory,
FileBrowser,
Uploader
} from '@jupyterlab/filebrowser';

import { ISettingRegistry } from '@jupyterlab/settingregistry';

Expand All @@ -21,9 +25,9 @@ import { listIcon, folderIcon } from '@jupyterlab/ui-components';
import { FileSystemDrive } from './drive';

/**
* The file browser factory
* The file system access factory
*/
const FILE_BROWSER_FACTORY = 'FileSystemAccess';
const FILE_SYSTEM_ACCESS_FACTORY = 'FileSystemAccess';

/**
* Initialization data for the jupyterlab-filesystem-access extension.
Expand Down Expand Up @@ -75,15 +79,15 @@ const plugin: JupyterFrontEndPlugin<void> = {
createToolbarFactory(
toolbarRegistry,
settingRegistry,
FILE_BROWSER_FACTORY,
FILE_SYSTEM_ACCESS_FACTORY,
plugin.id,
translator ?? nullTranslator
),
toolbar
);

toolbarRegistry.addFactory(
FILE_BROWSER_FACTORY,
FILE_SYSTEM_ACCESS_FACTORY,
'open-folder',
(browser: FileBrowser) => {
const openDirectoryButton = new ToolbarButton({
Expand All @@ -103,6 +107,16 @@ const plugin: JupyterFrontEndPlugin<void> = {
return openDirectoryButton;
}
);

toolbarRegistry.addFactory(
FILE_SYSTEM_ACCESS_FACTORY,
'uploader',
(browser: FileBrowser) =>
new Uploader({
model: browser.model,
translator
})
);
}

app.shell.add(widget, 'left', { type: 'FileSystemAccess' });
Expand Down

0 comments on commit 7cead28

Please sign in to comment.