mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
notebooks lgtm cleanup part 1 (#8280)
This commit is contained in:
@@ -302,7 +302,7 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
|
|||||||
findNextUntitledFileName(filePath: string): string {
|
findNextUntitledFileName(filePath: string): string {
|
||||||
const baseName = path.basename(filePath);
|
const baseName = path.basename(filePath);
|
||||||
let idx = 0;
|
let idx = 0;
|
||||||
let title = `${baseName}`;
|
let title;
|
||||||
do {
|
do {
|
||||||
const suffix = idx === 0 ? '' : `-${idx}`;
|
const suffix = idx === 0 ? '' : `-${idx}`;
|
||||||
title = `${baseName}${suffix}`;
|
title = `${baseName}${suffix}`;
|
||||||
|
|||||||
@@ -313,8 +313,8 @@ export class JupyterServerInstallation {
|
|||||||
/**
|
/**
|
||||||
* Installs Python and associated dependencies to the specified directory.
|
* Installs Python and associated dependencies to the specified directory.
|
||||||
* @param forceInstall Indicates whether an existing installation should be overwritten, if it exists.
|
* @param forceInstall Indicates whether an existing installation should be overwritten, if it exists.
|
||||||
* @param installationPath Optional parameter that specifies where to install python.
|
* @param installSettings Optional parameter that specifies where to install python, and whether the install targets an existing python install.
|
||||||
* The previous path (or the default) is used if a new path is not specified.
|
* The previous python path (or the default) is used if a new path is not specified.
|
||||||
*/
|
*/
|
||||||
public async startInstallProcess(forceInstall: boolean, installSettings?: { installPath: string, existingPython: boolean }): Promise<void> {
|
public async startInstallProcess(forceInstall: boolean, installSettings?: { installPath: string, existingPython: boolean }): Promise<void> {
|
||||||
let isPythonRunning: boolean;
|
let isPythonRunning: boolean;
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ export class PlaceholderCellComponent extends CellView implements OnInit, OnChan
|
|||||||
if (!type) {
|
if (!type) {
|
||||||
type = 'code';
|
type = 'code';
|
||||||
}
|
}
|
||||||
this._model.addCell(<CellType>cellType);
|
this._model.addCell(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public layout() {
|
public layout() {
|
||||||
|
|||||||
@@ -518,8 +518,8 @@ export class CellModel implements ICellModel {
|
|||||||
let gatewayEndpointInfo = this.getGatewayEndpoint(model.activeConnection);
|
let gatewayEndpointInfo = this.getGatewayEndpoint(model.activeConnection);
|
||||||
if (gatewayEndpointInfo) {
|
if (gatewayEndpointInfo) {
|
||||||
let hostAndIp = notebookUtils.getHostAndPortFromEndpoint(gatewayEndpointInfo.endpoint);
|
let hostAndIp = notebookUtils.getHostAndPortFromEndpoint(gatewayEndpointInfo.endpoint);
|
||||||
let host = gatewayEndpointInfo && hostAndIp.host ? hostAndIp.host : model.activeConnection.serverName;
|
let host = hostAndIp.host ? hostAndIp.host : model.activeConnection.serverName;
|
||||||
let port = gatewayEndpointInfo && hostAndIp.port ? ':' + hostAndIp.port : defaultPort;
|
let port = hostAndIp.port ? ':' + hostAndIp.port : defaultPort;
|
||||||
let html = result.data['text/html'];
|
let html = result.data['text/html'];
|
||||||
// CTP 3.1 and earlier Spark link
|
// CTP 3.1 and earlier Spark link
|
||||||
html = this.rewriteUrlUsingRegex(/(https?:\/\/master.*\/proxy)(.*)/g, html, host, port, yarnUi);
|
html = this.rewriteUrlUsingRegex(/(https?:\/\/master.*\/proxy)(.*)/g, html, host, port, yarnUi);
|
||||||
|
|||||||
@@ -229,7 +229,6 @@ export class ClientSession implements IClientSession {
|
|||||||
this._kernelChangeCompleted = new Deferred<void>();
|
this._kernelChangeCompleted = new Deferred<void>();
|
||||||
this._isReady = false;
|
this._isReady = false;
|
||||||
let oldKernel = oldValue ? oldValue : this.kernel;
|
let oldKernel = oldValue ? oldValue : this.kernel;
|
||||||
let newKernel = this.kernel;
|
|
||||||
|
|
||||||
let kernel = await this.doChangeKernel(options);
|
let kernel = await this.doChangeKernel(options);
|
||||||
try {
|
try {
|
||||||
@@ -240,7 +239,7 @@ export class ClientSession implements IClientSession {
|
|||||||
this._kernelChangeCompleted.resolve();
|
this._kernelChangeCompleted.resolve();
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
newKernel = this._session ? kernel : this._session.kernel;
|
let newKernel = this._session ? kernel : this._session.kernel;
|
||||||
this._isReady = kernel.isReady;
|
this._isReady = kernel.isReady;
|
||||||
await this.updateCachedKernelSpec();
|
await this.updateCachedKernelSpec();
|
||||||
// Send resolution events to listeners
|
// Send resolution events to listeners
|
||||||
|
|||||||
@@ -69,8 +69,9 @@ export class NotebookContexts {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all active contexts and sort them
|
* Get all active contexts and sort them
|
||||||
* @param apiWrapper ApiWrapper
|
* @param connectionService connection service
|
||||||
* @param profile current connection profile
|
* @param connProviderIds array of applicable connection providers to filter connections
|
||||||
|
* @param profile connection profile passed when launching notebook
|
||||||
*/
|
*/
|
||||||
public static getActiveContexts(connectionService: IConnectionManagementService, connProviderIds: string[], profile: IConnectionProfile): IDefaultConnection {
|
public static getActiveContexts(connectionService: IConnectionManagementService, connProviderIds: string[], profile: IConnectionProfile): IDefaultConnection {
|
||||||
let defaultConnection: ConnectionProfile = NotebookContexts.DefaultContext.defaultConnection;
|
let defaultConnection: ConnectionProfile = NotebookContexts.DefaultContext.defaultConnection;
|
||||||
@@ -141,9 +142,6 @@ export class NotebookContexts {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If no default kernel specified (should never happen), default to SQL
|
// If no default kernel specified (should never happen), default to SQL
|
||||||
if (!defaultKernel) {
|
return notebookConstants.sqlKernelSpec;
|
||||||
defaultKernel = notebookConstants.sqlKernelSpec;
|
|
||||||
}
|
|
||||||
return defaultKernel;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -304,7 +304,7 @@ export class NotebookModel extends Disposable implements INotebookModel {
|
|||||||
// if cells already exist, create them with language info (if it is saved)
|
// if cells already exist, create them with language info (if it is saved)
|
||||||
this._cells = [];
|
this._cells = [];
|
||||||
if (contents) {
|
if (contents) {
|
||||||
this._defaultLanguageInfo = contents && contents.metadata && contents.metadata.language_info;
|
this._defaultLanguageInfo = contents.metadata && contents.metadata.language_info;
|
||||||
this._savedKernelInfo = this.getSavedKernelInfo(contents);
|
this._savedKernelInfo = this.getSavedKernelInfo(contents);
|
||||||
if (contents.cells && contents.cells.length > 0) {
|
if (contents.cells && contents.cells.length > 0) {
|
||||||
this._cells = contents.cells.map(c => {
|
this._cells = contents.cells.map(c => {
|
||||||
@@ -443,7 +443,7 @@ export class NotebookModel extends Disposable implements INotebookModel {
|
|||||||
public async startSession(manager: INotebookManager, displayName?: string, setErrorStateOnFail?: boolean): Promise<void> {
|
public async startSession(manager: INotebookManager, displayName?: string, setErrorStateOnFail?: boolean): Promise<void> {
|
||||||
if (displayName && this._standardKernels) {
|
if (displayName && this._standardKernels) {
|
||||||
let standardKernel = find(this._standardKernels, kernel => kernel.displayName === displayName);
|
let standardKernel = find(this._standardKernels, kernel => kernel.displayName === displayName);
|
||||||
this._defaultKernel = displayName ? { name: standardKernel.name, display_name: standardKernel.displayName } : this._defaultKernel;
|
this._defaultKernel = { name: standardKernel.name, display_name: standardKernel.displayName };
|
||||||
}
|
}
|
||||||
if (this._defaultKernel) {
|
if (this._defaultKernel) {
|
||||||
let clientSession = this._notebookOptions.factory.createClientSession({
|
let clientSession = this._notebookOptions.factory.createClientSession({
|
||||||
|
|||||||
@@ -449,7 +449,7 @@ export class AttachToDropdown extends SelectBox {
|
|||||||
let connections = this.getConnections(model);
|
let connections = this.getConnections(model);
|
||||||
this.enable();
|
this.enable();
|
||||||
if (showSelectConnection) {
|
if (showSelectConnection) {
|
||||||
connections = this.loadWithSelectConnection(connections);
|
this.loadWithSelectConnection(connections);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (connections.length === 1 && connections[0] === msgAddNewConnection) {
|
if (connections.length === 1 && connections[0] === msgAddNewConnection) {
|
||||||
@@ -465,7 +465,7 @@ export class AttachToDropdown extends SelectBox {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private loadWithSelectConnection(connections: string[]): string[] {
|
private loadWithSelectConnection(connections: string[]): void {
|
||||||
if (connections && connections.length > 0) {
|
if (connections && connections.length > 0) {
|
||||||
if (!find(connections, x => x === msgSelectConnection)) {
|
if (!find(connections, x => x === msgSelectConnection)) {
|
||||||
connections.unshift(msgSelectConnection);
|
connections.unshift(msgSelectConnection);
|
||||||
@@ -476,7 +476,6 @@ export class AttachToDropdown extends SelectBox {
|
|||||||
}
|
}
|
||||||
this.setOptions(connections, 0);
|
this.setOptions(connections, 0);
|
||||||
}
|
}
|
||||||
return connections;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Get connections from context
|
//Get connections from context
|
||||||
|
|||||||
Reference in New Issue
Block a user