diff --git a/schema/plugin.json b/schema/plugin.json index 396dd60..fe053ad 100644 --- a/schema/plugin.json +++ b/schema/plugin.json @@ -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": { diff --git a/src/index.ts b/src/index.ts index 8d217c3..ae3f034 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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'; @@ -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. @@ -75,7 +79,7 @@ const plugin: JupyterFrontEndPlugin = { createToolbarFactory( toolbarRegistry, settingRegistry, - FILE_BROWSER_FACTORY, + FILE_SYSTEM_ACCESS_FACTORY, plugin.id, translator ?? nullTranslator ), @@ -83,7 +87,7 @@ const plugin: JupyterFrontEndPlugin = { ); toolbarRegistry.addFactory( - FILE_BROWSER_FACTORY, + FILE_SYSTEM_ACCESS_FACTORY, 'open-folder', (browser: FileBrowser) => { const openDirectoryButton = new ToolbarButton({ @@ -103,6 +107,16 @@ const plugin: JupyterFrontEndPlugin = { return openDirectoryButton; } ); + + toolbarRegistry.addFactory( + FILE_SYSTEM_ACCESS_FACTORY, + 'uploader', + (browser: FileBrowser) => + new Uploader({ + model: browser.model, + translator + }) + ); } app.shell.add(widget, 'left', { type: 'FileSystemAccess' });