|
| 1 | +/*************************************************************************** |
| 2 | + * Copyright (c) 2023, Voilà contributors * |
| 3 | + * Copyright (c) 2023, QuantStack * |
| 4 | + * * |
| 5 | + * Distributed under the terms of the BSD 3-Clause License. * |
| 6 | + * * |
| 7 | + * The full license is in the file LICENSE, distributed with this software. * |
| 8 | + ****************************************************************************/ |
| 9 | +import { |
| 10 | + JupyterFrontEnd, |
| 11 | + JupyterFrontEndPlugin |
| 12 | +} from '@jupyterlab/application'; |
| 13 | +import { DocumentManager } from '@jupyterlab/docmanager'; |
| 14 | +import { DocumentRegistry } from '@jupyterlab/docregistry'; |
| 15 | +import { FilterFileBrowserModel } from '@jupyterlab/filebrowser'; |
| 16 | + |
| 17 | +import { VoilaFileBrowser } from './browser'; |
| 18 | +import { Widget } from '@lumino/widgets'; |
| 19 | + |
| 20 | +/** |
| 21 | + * The voila file browser provider. |
| 22 | + */ |
| 23 | +export const treeWidgetPlugin: JupyterFrontEndPlugin<void> = { |
| 24 | + id: '@voila-dashboards/voila:tree-widget', |
| 25 | + description: 'Provides the file browser.', |
| 26 | + activate: (app: JupyterFrontEnd): void => { |
| 27 | + const docRegistry = new DocumentRegistry(); |
| 28 | + const docManager = new DocumentManager({ |
| 29 | + registry: docRegistry, |
| 30 | + manager: app.serviceManager, |
| 31 | + opener |
| 32 | + }); |
| 33 | + const fbModel = new FilterFileBrowserModel({ |
| 34 | + manager: docManager, |
| 35 | + refreshInterval: 2147483646 |
| 36 | + }); |
| 37 | + const fb = new VoilaFileBrowser({ |
| 38 | + id: 'filebrowser', |
| 39 | + model: fbModel |
| 40 | + }); |
| 41 | + |
| 42 | + fb.addClass('voila-FileBrowser'); |
| 43 | + fb.showFileCheckboxes = false; |
| 44 | + fb.showLastModifiedColumn = false; |
| 45 | + |
| 46 | + const title = new Widget(); |
| 47 | + title.node.innerText = 'Select items to open with Voilà.'; |
| 48 | + fb.toolbar.addItem('title', title); |
| 49 | + |
| 50 | + const spacerTop = new Widget(); |
| 51 | + spacerTop.addClass('spacer-top-widget'); |
| 52 | + app.shell.add(spacerTop, 'main'); |
| 53 | + |
| 54 | + app.shell.add(fb, 'main'); |
| 55 | + |
| 56 | + const spacerBottom = new Widget(); |
| 57 | + spacerBottom.addClass('spacer-bottom-widget'); |
| 58 | + app.shell.add(spacerBottom, 'main'); |
| 59 | + }, |
| 60 | + |
| 61 | + autoStart: true |
| 62 | +}; |
0 commit comments