-
Notifications
You must be signed in to change notification settings - Fork 506
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Create tree plugin * Update style * Add classic tree setting * Update UI test * Update Playwright Snapshots * Apply suggestions from code review Co-authored-by: Jeremy Tuloup <[email protected]> * Update test * Pin pyzmq * Update snapshot * [skip ci] Update voila/configuration.py Co-authored-by: Jeremy Tuloup <[email protected]> * Fix leakage contents --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Jeremy Tuloup <[email protected]>
- Loading branch information
1 parent
3ac569a
commit 8a46a25
Showing
27 changed files
with
492 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { FileBrowser, DirListing } from '@jupyterlab/filebrowser'; | ||
import { VoilaDirListing } from './listing'; | ||
|
||
export class VoilaFileBrowser extends FileBrowser { | ||
/** | ||
* Create the underlying DirListing instance. | ||
* | ||
* @param options - The DirListing constructor options. | ||
* | ||
* @returns The created DirListing instance. | ||
*/ | ||
protected createDirListing(options: DirListing.IOptions): DirListing { | ||
return new VoilaDirListing(options); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/*************************************************************************** | ||
* Copyright (c) 2023, Voilà contributors * | ||
* Copyright (c) 2023, QuantStack * | ||
* * | ||
* Distributed under the terms of the BSD 3-Clause License. * | ||
* * | ||
* The full license is in the file LICENSE, distributed with this software. * | ||
****************************************************************************/ | ||
import { | ||
JupyterFrontEnd, | ||
JupyterFrontEndPlugin | ||
} from '@jupyterlab/application'; | ||
import { DocumentManager } from '@jupyterlab/docmanager'; | ||
import { DocumentRegistry } from '@jupyterlab/docregistry'; | ||
import { FilterFileBrowserModel } from '@jupyterlab/filebrowser'; | ||
|
||
import { VoilaFileBrowser } from './browser'; | ||
import { Widget } from '@lumino/widgets'; | ||
|
||
/** | ||
* The voila file browser provider. | ||
*/ | ||
export const treeWidgetPlugin: JupyterFrontEndPlugin<void> = { | ||
id: '@voila-dashboards/voila:tree-widget', | ||
description: 'Provides the file browser.', | ||
activate: (app: JupyterFrontEnd): void => { | ||
const docRegistry = new DocumentRegistry(); | ||
const docManager = new DocumentManager({ | ||
registry: docRegistry, | ||
manager: app.serviceManager, | ||
opener | ||
}); | ||
const fbModel = new FilterFileBrowserModel({ | ||
manager: docManager, | ||
refreshInterval: 2147483646 | ||
}); | ||
const fb = new VoilaFileBrowser({ | ||
id: 'filebrowser', | ||
model: fbModel | ||
}); | ||
|
||
fb.addClass('voila-FileBrowser'); | ||
fb.showFileCheckboxes = false; | ||
fb.showLastModifiedColumn = false; | ||
|
||
const title = new Widget(); | ||
title.node.innerText = 'Select items to open with Voilà.'; | ||
fb.toolbar.addItem('title', title); | ||
|
||
const spacerTop = new Widget(); | ||
spacerTop.addClass('spacer-top-widget'); | ||
app.shell.add(spacerTop, 'main'); | ||
|
||
app.shell.add(fb, 'main'); | ||
|
||
const spacerBottom = new Widget(); | ||
spacerBottom.addClass('spacer-bottom-widget'); | ||
app.shell.add(spacerBottom, 'main'); | ||
}, | ||
|
||
autoStart: true | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { DirListing } from '@jupyterlab/filebrowser'; | ||
import { Contents } from '@jupyterlab/services'; | ||
import { showErrorMessage } from '@jupyterlab/apputils'; | ||
import { PageConfig, URLExt } from '@jupyterlab/coreutils'; | ||
|
||
export class VoilaDirListing extends DirListing { | ||
/** | ||
* Handle the opening of an item. | ||
*/ | ||
protected handleOpen(item: Contents.IModel): void { | ||
if (item.type === 'directory') { | ||
const localPath = this.model.manager.services.contents.localPath( | ||
item.path | ||
); | ||
this.model | ||
.cd(`/${localPath}`) | ||
.catch((error) => showErrorMessage('Open directory', error)); | ||
} else { | ||
const path = item.path; | ||
const baseUrl = PageConfig.getBaseUrl(); | ||
const frontend = PageConfig.getOption('frontend'); | ||
const query = PageConfig.getOption('query'); | ||
const url = URLExt.join(baseUrl, frontend, 'render', path) + `?${query}`; | ||
window.open(url, '_blank'); | ||
} | ||
} | ||
|
||
handleEvent(event: Event): void { | ||
if (event.type === 'click') { | ||
this.evtDblClick(event as MouseEvent); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
{% extends "page.html" %} | ||
|
||
{% block title %}{{ page_title }}{% endblock %} | ||
|
||
{% block stylesheets %} | ||
{{ super() }} | ||
|
||
<style> | ||
body { | ||
background-color: var(--jp-layout-color0); | ||
} | ||
|
||
.list-header { | ||
width: 80%; | ||
margin-top: 50px; | ||
margin-left: auto; | ||
margin-right: auto; | ||
padding: 0px; | ||
border-style: solid; | ||
border-width: var(--jp-border-width); | ||
border-color: var(--jp-border-color2); | ||
border-bottom: none; | ||
background-color: var(--jp-layout-color2) | ||
} | ||
|
||
.list-header-text { | ||
color: var(--jp-ui-font-color0); | ||
font-size: var(--jp-ui-font-size1); | ||
padding: 10px | ||
} | ||
|
||
.voila-notebooks { | ||
background-color: var(--jp-layout-color1); | ||
width: 80%; | ||
margin: auto; | ||
padding: 0px; | ||
border-style: solid; | ||
border-width: var(--jp-border-width); | ||
border-color: var(--jp-border-color0); | ||
border-radius: var(--jp-border-radius); | ||
} | ||
|
||
.voila-notebooks > li { | ||
color: var(--jp-ui-font-color1); | ||
list-style: none; | ||
border-bottom-style: solid; | ||
border-bottom-width: var(--jp-border-width); | ||
border-bottom-color: var(--jp-border-color0); | ||
} | ||
|
||
.voila-notebooks > li:hover { | ||
background-color: var(--jp-layout-color2); | ||
} | ||
|
||
.voila-notebooks > li:last-child { | ||
border: none | ||
} | ||
|
||
.voila-notebooks > li > a { | ||
display: block; | ||
width: 100%; | ||
height: 100%; | ||
padding: 10px; | ||
} | ||
|
||
.voila-notebooks > li > a > i { | ||
padding: 0 10px | ||
} | ||
</style> | ||
{% endblock %} | ||
|
||
{% block body %} | ||
|
||
{% set openInNewTab = 'target=_blank' %} | ||
<script id="jupyter-config-data" type="application/json"> | ||
{{ page_config | tojson }} | ||
</script> | ||
|
||
<script src="{{ page_config['fullStaticUrl'] | e }}/treepage.js"></script> | ||
{% set mainStyle = 'style="display: None;"' %} | ||
|
||
<div id="voila-tree-main" {{mainStyle | safe}}> | ||
|
||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.