-
Notifications
You must be signed in to change notification settings - Fork 504
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create tree plugin #1374
Merged
Merged
Create tree plugin #1374
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
c7082ad
Create tree plugin
trungleduc 9e2e567
Update style
trungleduc 8ef7f49
Add classic tree setting
trungleduc cf122ea
Update UI test
trungleduc 83b21a5
Update Playwright Snapshots
github-actions[bot] 9819466
Apply suggestions from code review
trungleduc ab0786b
Update test
trungleduc ec256cd
Pin pyzmq
trungleduc 2742e05
Update snapshot
trungleduc 98ddec3
[skip ci] Update voila/configuration.py
trungleduc 9c48666
Fix leakage contents
trungleduc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we can make this part configurable in JupyterLab: |
||
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the issue with
pyzmq
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
25.1.1
is not available as wheel yet on Mac OSThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah ok, maybe mentioning this in the comment could be useful for later when we get back to it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant next to the TODO, or in a new issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#1380