-
-
Notifications
You must be signed in to change notification settings - Fork 385
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
Custom python environment support #317
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
64ef5bf
initial work on supporting custom python environment
mbektas 896455c
env statusbar item, get env info via py script, refactoring
mbektas d091407
update yarn.lock
mbektas 1089909
fix env info get on windows
mbektas 32f3597
refactor additional path includes for python
mbektas 82f490a
prevent browser window creation during launch if no python env available
mbektas fe36955
handle python select cancel
mbektas 3e468fa
show a message and requirements list in env select dialog
mbektas fcc0f5e
handle invalid python path selection
mbektas 13c4ac8
disable launch animation
mbektas d79e22c
fix double server launch
mbektas 425f170
clean-up
mbektas 2817ede
use ejs templates to escape html input
mbektas cd93afe
fix quote rendering issue
mbektas 668ae06
update yarn.lock
mbektas f4cbdc9
handle initial launch without settings, fix other windows launch issues
mbektas 0fd494c
Update yarn.lock
mbektas 1b2bcf4
remove unnecessary handleReleasesLink method
mbektas 60f7405
set defaultPath for python path selector dialog
mbektas 5f6dfbc
add info on prebuilt extensions
mbektas 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
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,145 @@ | ||
// Copyright (c) Jupyter Development Team. | ||
// Distributed under the terms of the Modified BSD License. | ||
|
||
import { VDomModel, VDomRenderer } from '@jupyterlab/apputils'; | ||
import React from 'react'; | ||
import { GroupItem, interactiveItem, TextItem } from '@jupyterlab/statusbar'; | ||
import { | ||
pythonIcon | ||
} from '@jupyterlab/ui-components'; | ||
|
||
/** | ||
* A pure functional component for rendering environment status. | ||
*/ | ||
function EnvironmentStatusComponent( | ||
props: EnvironmentStatusComponent.IProps | ||
): React.ReactElement<EnvironmentStatusComponent.IProps> { | ||
return ( | ||
<GroupItem onClick={props.handleClick} spacing={2} title={props.description}> | ||
<pythonIcon.react title={''} top={'2px'} stylesheet={'statusBar'} /> | ||
<TextItem source={props.name} /> | ||
</GroupItem> | ||
); | ||
} | ||
|
||
/** | ||
* A namespace for EnvironmentStatusComponent statics. | ||
*/ | ||
namespace EnvironmentStatusComponent { | ||
/** | ||
* Props for the environment status component. | ||
*/ | ||
export interface IProps { | ||
/** | ||
* A click handler for the environment status component. By default | ||
* we have it bring up the environment change dialog. | ||
*/ | ||
handleClick: () => void; | ||
|
||
/** | ||
* The name the environment. | ||
*/ | ||
name: string; | ||
|
||
/** | ||
* The description of the environment. | ||
*/ | ||
description: string; | ||
} | ||
} | ||
|
||
/** | ||
* A VDomRenderer widget for displaying the environment. | ||
*/ | ||
export class EnvironmentStatus extends VDomRenderer<EnvironmentStatus.Model> { | ||
/** | ||
* Construct the environment status widget. | ||
*/ | ||
constructor(opts: EnvironmentStatus.IOptions) { | ||
super(new EnvironmentStatus.Model()); | ||
this.model.name = opts.name; | ||
this.model.description = opts.description; | ||
this._handleClick = opts.onClick; | ||
this.addClass(interactiveItem); | ||
} | ||
|
||
/** | ||
* Render the environment status item. | ||
*/ | ||
render() { | ||
if (this.model === null) { | ||
return null; | ||
} else { | ||
return ( | ||
<EnvironmentStatusComponent | ||
name={this.model.name} | ||
description={this.model.description} | ||
handleClick={this._handleClick} | ||
/> | ||
); | ||
} | ||
} | ||
|
||
private _handleClick: () => void; | ||
} | ||
|
||
/** | ||
* A namespace for EnvironmentStatus statics. | ||
*/ | ||
export namespace EnvironmentStatus { | ||
export class Model extends VDomModel { | ||
constructor() { | ||
super(); | ||
|
||
this._name = 'env'; | ||
this._description = ''; | ||
} | ||
|
||
get name() { | ||
return this._name; | ||
} | ||
|
||
set name(val: string) { | ||
const oldVal = this._name; | ||
if (oldVal === val) { | ||
return; | ||
} | ||
this._name = val; | ||
this.stateChanged.emit(void 0); | ||
} | ||
|
||
get description(): string { | ||
return this._description; | ||
} | ||
set description(val: string) { | ||
const oldVal = this._description; | ||
if (oldVal === val) { | ||
return; | ||
} | ||
this._description = val; | ||
this.stateChanged.emit(void 0); | ||
} | ||
|
||
private _name: string; | ||
private _description: string; | ||
} | ||
|
||
/** | ||
* Options for creating a EnvironmentStatus object. | ||
*/ | ||
export interface IOptions { | ||
/** | ||
* Environment name | ||
*/ | ||
name: string; | ||
/** | ||
* Environment description | ||
*/ | ||
description: string; | ||
/** | ||
* A click handler for the item. By default | ||
* we launch an environment selection dialog. | ||
*/ | ||
onClick: () => void; | ||
} | ||
} |
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.
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.
I was thinking more
renderToString
style fromreact-dom
(which already is a dependency), but I guess that would work too. I don't thinkyarn.lock
was updated, how much does inclusion ofejs
costs us in terms of extra dependencies?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.
ejs was already included through another dependency. I will also check out react-dom renderToString you mentioned.
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.
@krassowski I looked into ReactDOMServer.renderToString. it doesn't look like an easy integration for our use case. we generate the HTML of the dialogs on the app backend using node.js. Dialog front-ends are quite basic HTML and JS. We would need to use react for dialog front-ends which would be significant overhead just for sanitize purposes. Also, sanitization would happen on the front-end which may not be as secure as intended.
Please let me know if I missed something and if you see an easier integration of ReactDOMServer.renderToString.