Skip to content

Commit

Permalink
feat: enable conda complete depending presence of quetzUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
mariobuikhuizen committed Jul 7, 2021
1 parent cfbe405 commit 72a2f70
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion mamba_gator/navigator/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class MambaNavigator(LabServerApp):
workspaces_dir = os.path.join(HERE, "workspaces")

quetz_url = Unicode(
'http://localhost:8000',
'',
config=True,
help="The Quetz server to use for creating new environments"
)
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/components/CondaEnvList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export interface IEnvListProps {
/**
* Environment solve handler
*/
onSolve(): void;
onSolve?: (() => void) | false;
}

/**
Expand Down
14 changes: 8 additions & 6 deletions packages/common/src/components/CondaEnvToolBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export interface ICondaEnvToolBarProps {
/**
* Solve environment handler
*/
onSolve(): void;
onSolve?: (() => void) | false;
}

export const CondaEnvToolBar = (props: ICondaEnvToolBarProps): JSX.Element => {
Expand Down Expand Up @@ -85,11 +85,13 @@ export const CondaEnvToolBar = (props: ICondaEnvToolBarProps): JSX.Element => {
tooltip="Create"
onClick={props.onCreate}
/>
<ToolbarButtonComponent
icon={buildIcon}
tooltip="Solve new"
onClick={props.onSolve}
/>
{props.onSolve && (
<ToolbarButtonComponent
icon={buildIcon}
tooltip="Solve new"
onClick={props.onSolve}
/>
)}
<Button
className="jp-ToolbarButtonComponent"
disabled={props.isBase}
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/components/NbConda.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ export class NbConda extends React.Component<ICondaEnvProps, ICondaEnvState> {
onExport={this.handleExportEnvironment}
onRefresh={this.handleRefreshEnvironment}
onRemove={this.handleRemoveEnvironment}
onSolve={this.handleSolveEnvironment}
onSolve={this.props.model.quetzUrl && this.handleSolveEnvironment}
/>
<CondaPkgPanel
height={this.props.height}
Expand Down
4 changes: 1 addition & 3 deletions packages/common/src/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ export interface ICancellableAction {
export class CondaEnvironments implements IEnvironmentManager {
constructor(settings?: ISettingRegistry.ISettings) {
this._environments = new Array<Conda.IEnvironment>();

if (settings) {
this._updateSettings(settings);
settings.changed.connect(this._updateSettings, this);
Expand Down Expand Up @@ -453,8 +452,7 @@ export class CondaEnvironments implements IEnvironmentManager {
private _packageManager = new CondaPackage();
private _whitelist =
PageConfig.getOption('whitelist').toLowerCase() === 'true';
private _quetzUrl =
PageConfig.getOption('quetzUrl') || 'http://localhost:8000';
private _quetzUrl = PageConfig.getOption('quetzUrl');
private _quetzSolverUrl = PageConfig.getOption('quetzSolverUrl');
}

Expand Down
2 changes: 1 addition & 1 deletion packages/labextension/schema/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"type": "string",
"title": "Quetz package server",
"description": "The Quetz server to use for creating new environments",
"default": "http://localhost:8000"
"default": ""
},
"quetzSolverUrl": {
"type": "string",
Expand Down
4 changes: 4 additions & 0 deletions packages/labextension/src/CondaCompleteEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ function activate(
const namespace = 'conda';
const tracker = new WidgetTracker<DocumentWidget>({ namespace });

if (!environmentManager.quetzUrl) {
return tracker;
}

restorer.restore(tracker, {
command: 'docmanager:open',
args: widget => ({ path: widget.context.path, factory: FACTORY }),
Expand Down

0 comments on commit 72a2f70

Please sign in to comment.