notebooks lgtm cleanup part 1 (#8280)

This commit is contained in:
Chris LaFreniere
2019-11-11 13:40:48 -05:00
committed by GitHub
parent 8b17b77010
commit 0520870754
8 changed files with 15 additions and 19 deletions

View File

@@ -76,7 +76,7 @@ export class PlaceholderCellComponent extends CellView implements OnInit, OnChan
if (!type) {
type = 'code';
}
this._model.addCell(<CellType>cellType);
this._model.addCell(type);
}
public layout() {

View File

@@ -518,8 +518,8 @@ export class CellModel implements ICellModel {
let gatewayEndpointInfo = this.getGatewayEndpoint(model.activeConnection);
if (gatewayEndpointInfo) {
let hostAndIp = notebookUtils.getHostAndPortFromEndpoint(gatewayEndpointInfo.endpoint);
let host = gatewayEndpointInfo && hostAndIp.host ? hostAndIp.host : model.activeConnection.serverName;
let port = gatewayEndpointInfo && hostAndIp.port ? ':' + hostAndIp.port : defaultPort;
let host = hostAndIp.host ? hostAndIp.host : model.activeConnection.serverName;
let port = hostAndIp.port ? ':' + hostAndIp.port : defaultPort;
let html = result.data['text/html'];
// CTP 3.1 and earlier Spark link
html = this.rewriteUrlUsingRegex(/(https?:\/\/master.*\/proxy)(.*)/g, html, host, port, yarnUi);

View File

@@ -229,7 +229,6 @@ export class ClientSession implements IClientSession {
this._kernelChangeCompleted = new Deferred<void>();
this._isReady = false;
let oldKernel = oldValue ? oldValue : this.kernel;
let newKernel = this.kernel;
let kernel = await this.doChangeKernel(options);
try {
@@ -240,7 +239,7 @@ export class ClientSession implements IClientSession {
this._kernelChangeCompleted.resolve();
throw error;
}
newKernel = this._session ? kernel : this._session.kernel;
let newKernel = this._session ? kernel : this._session.kernel;
this._isReady = kernel.isReady;
await this.updateCachedKernelSpec();
// Send resolution events to listeners

View File

@@ -69,8 +69,9 @@ export class NotebookContexts {
/**
* Get all active contexts and sort them
* @param apiWrapper ApiWrapper
* @param profile current connection profile
* @param connectionService connection service
* @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 {
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 (!defaultKernel) {
defaultKernel = notebookConstants.sqlKernelSpec;
}
return defaultKernel;
return notebookConstants.sqlKernelSpec;
}
}

View File

@@ -304,7 +304,7 @@ export class NotebookModel extends Disposable implements INotebookModel {
// if cells already exist, create them with language info (if it is saved)
this._cells = [];
if (contents) {
this._defaultLanguageInfo = contents && contents.metadata && contents.metadata.language_info;
this._defaultLanguageInfo = contents.metadata && contents.metadata.language_info;
this._savedKernelInfo = this.getSavedKernelInfo(contents);
if (contents.cells && contents.cells.length > 0) {
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> {
if (displayName && this._standardKernels) {
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) {
let clientSession = this._notebookOptions.factory.createClientSession({

View File

@@ -449,7 +449,7 @@ export class AttachToDropdown extends SelectBox {
let connections = this.getConnections(model);
this.enable();
if (showSelectConnection) {
connections = this.loadWithSelectConnection(connections);
this.loadWithSelectConnection(connections);
}
else {
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 (!find(connections, x => x === msgSelectConnection)) {
connections.unshift(msgSelectConnection);
@@ -476,7 +476,6 @@ export class AttachToDropdown extends SelectBox {
}
this.setOptions(connections, 0);
}
return connections;
}
//Get connections from context