Disable Manage Packages button if python is not installed (#6008)

This commit is contained in:
Cory Rivera
2019-06-17 18:28:16 -07:00
committed by GitHub
parent 59b0e6737f
commit cecc899949
5 changed files with 16 additions and 17 deletions

View File

@@ -224,7 +224,7 @@
"notebook/toolbar": [ "notebook/toolbar": [
{ {
"command": "jupyter.cmd.managePackages", "command": "jupyter.cmd.managePackages",
"when": "providerId == jupyter" "when": "providerId == jupyter && notebook:pythonInstalled"
} }
] ]
}, },

View File

@@ -5,6 +5,7 @@
import * as vscode from 'vscode'; import * as vscode from 'vscode';
import * as azdata from 'azdata'; import * as azdata from 'azdata';
import { CommandContext, BuiltInCommands } from './constants';
/** /**
* Wrapper class to act as a facade over VSCode and Data APIs and allow us to test / mock callbacks into * Wrapper class to act as a facade over VSCode and Data APIs and allow us to test / mock callbacks into
@@ -56,6 +57,10 @@ export class ApiWrapper {
azdata.tasks.startBackgroundOperation(operationInfo); azdata.tasks.startBackgroundOperation(operationInfo);
} }
public setCommandContext(key: CommandContext | string, value: any): Thenable<any> {
return vscode.commands.executeCommand(BuiltInCommands.SetContext, key, value);
}
/** /**
* Get the configuration for a extensionName * Get the configuration for a extensionName
* @param extensionName The string name of the extension to get the configuration for * @param extensionName The string name of the extension to get the configuration for

View File

@@ -6,37 +6,23 @@
'use strict'; 'use strict';
// CONFIG VALUES /////////////////////////////////////////////////////////// // CONFIG VALUES ///////////////////////////////////////////////////////////
export const extensionConfigSectionName = 'dataManagement';
export const extensionOutputChannel = 'Notebooks'; export const extensionOutputChannel = 'Notebooks';
export const configLogDebugInfo = 'logDebugInfo';
// JUPYTER CONFIG ////////////////////////////////////////////////////////// // JUPYTER CONFIG //////////////////////////////////////////////////////////
export const pythonBundleVersion = '0.0.1'; export const pythonBundleVersion = '0.0.1';
export const pythonVersion = '3.6.6'; export const pythonVersion = '3.6.6';
export const sparkMagicVersion = '0.12.6.1'; export const sparkMagicVersion = '0.12.6.1';
export const python3 = 'python3';
export const pysparkkernel = 'pysparkkernel';
export const sparkkernel = 'sparkkernel';
export const pyspark3kernel = 'pyspark3kernel';
export const python3DisplayName = 'Python 3';
export const defaultSparkKernel = 'pyspark3kernel';
export const pythonPathConfigKey = 'pythonPath'; export const pythonPathConfigKey = 'pythonPath';
export const existingPythonConfigKey = 'useExistingPython'; export const existingPythonConfigKey = 'useExistingPython';
export const notebookConfigKey = 'notebook'; export const notebookConfigKey = 'notebook';
export const hdfsHost = 'host';
export const hdfsUser = 'user';
export const winPlatform = 'win32'; export const winPlatform = 'win32';
export const jupyterNotebookProviderId = 'jupyter'; export const jupyterNotebookProviderId = 'jupyter';
export const jupyterConfigRootFolder = 'jupyter_config'; export const jupyterConfigRootFolder = 'jupyter_config';
export const jupyterKernelsMasterFolder = 'kernels_master';
export const jupyterNewNotebookTask = 'jupyter.task.newNotebook'; export const jupyterNewNotebookTask = 'jupyter.task.newNotebook';
export const jupyterOpenNotebookTask = 'jupyter.task.openNotebook'; export const jupyterOpenNotebookTask = 'jupyter.task.openNotebook';
export const jupyterNewNotebookCommand = 'jupyter.cmd.newNotebook'; export const jupyterNewNotebookCommand = 'jupyter.cmd.newNotebook';
export const jupyterCommandSetContext = 'jupyter.setContext';
export const jupyterCommandSetKernel = 'jupyter.setKernel';
export const jupyterReinstallDependenciesCommand = 'jupyter.reinstallDependencies'; export const jupyterReinstallDependenciesCommand = 'jupyter.reinstallDependencies';
export const jupyterAnalyzeCommand = 'jupyter.cmd.analyzeNotebook'; export const jupyterAnalyzeCommand = 'jupyter.cmd.analyzeNotebook';
export const jupyterManagePackages = 'jupyter.cmd.managePackages'; export const jupyterManagePackages = 'jupyter.cmd.managePackages';
@@ -47,7 +33,7 @@ export enum BuiltInCommands {
} }
export enum CommandContext { export enum CommandContext {
WizardServiceEnabled = 'wizardservice:enabled' NotebookPythonInstalled = 'notebook:pythonInstalled'
} }
export const pythonOfflinePipPackagesUrl = 'https://go.microsoft.com/fwlink/?linkid=2092867'; export const pythonOfflinePipPackagesUrl = 'https://go.microsoft.com/fwlink/?linkid=2092867';

View File

@@ -17,6 +17,7 @@ import JupyterServerInstallation from './jupyterServerInstallation';
import * as utils from '../common/utils'; import * as utils from '../common/utils';
import { IServerInstance } from './common'; import { IServerInstance } from './common';
import { PerNotebookServerInstance, IInstanceOptions } from './serverInstance'; import { PerNotebookServerInstance, IInstanceOptions } from './serverInstance';
import { CommandContext } from '../common/constants';
export interface IServerManagerOptions { export interface IServerManagerOptions {
documentPath: string; documentPath: string;
@@ -101,9 +102,10 @@ export class LocalJupyterServerManager implements nb.ServerManager, vscode.Dispo
return this.options.documentPath; return this.options.documentPath;
} }
private async doStartServer(): Promise<IServerInstance> { // We can't find or create servers until the installation is complete private async doStartServer(): Promise<IServerInstance> { // We can't find or create servers until the installation is complete
let installation = this.options.jupyterInstallation; let installation = this.options.jupyterInstallation;
await installation.promptForPythonInstall(); await installation.promptForPythonInstall();
this.apiWrapper.setCommandContext(CommandContext.NotebookPythonInstalled, true);
// Calculate the path to use as the notebook-dir for Jupyter based on the path of the uri of the // Calculate the path to use as the notebook-dir for Jupyter based on the path of the uri of the
// notebook to open. This will be the workspace folder if the notebook uri is inside a workspace // notebook to open. This will be the workspace folder if the notebook uri is inside a workspace

View File

@@ -3,6 +3,7 @@
* Licensed under the Source EULA. See License.txt in the project root for license information. * Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import { nb } from 'azdata';
import { OnInit, Component, Inject, forwardRef, ElementRef, ChangeDetectorRef, ViewChild, OnDestroy } from '@angular/core'; import { OnInit, Component, Inject, forwardRef, ElementRef, ChangeDetectorRef, ViewChild, OnDestroy } from '@angular/core';
import { IColorTheme, IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService'; import { IColorTheme, IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
@@ -288,6 +289,7 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
await model.requestModelLoad(trusted); await model.requestModelLoad(trusted);
model.contentChanged((change) => this.handleContentChanged(change)); model.contentChanged((change) => this.handleContentChanged(change));
model.onProviderIdChange((provider) => this.handleProviderIdChanged(provider)); model.onProviderIdChange((provider) => this.handleProviderIdChanged(provider));
model.kernelChanged((kernelArgs) => this.handleKernelChanged(kernelArgs));
this._model = this._register(model); this._model = this._register(model);
this.updateToolbarComponents(this._model.trustedMode); this.updateToolbarComponents(this._model.trustedMode);
this._modelRegisteredDeferred.resolve(this._model); this._modelRegisteredDeferred.resolve(this._model);
@@ -372,6 +374,10 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
this.fillInActionsForCurrentContext(); this.fillInActionsForCurrentContext();
} }
private handleKernelChanged(kernelArgs: nb.IKernelChangedArgs) {
this.fillInActionsForCurrentContext();
}
findCellIndex(cellModel: ICellModel): number { findCellIndex(cellModel: ICellModel): number {
return this._model.cells.findIndex((cell) => cell.id === cellModel.id); return this._model.cells.findIndex((cell) => cell.id === cellModel.id);
} }