Fix/controller ad (#7445)

Reapply my previous commit
add kerberos to excludes in the webpack for the extension
Fixes #7443
Verified on Windows and MacOS
This commit is contained in:
Kevin Cunnane
2019-10-01 14:52:09 -07:00
committed by GitHub
parent 7162272f1e
commit ee98ce5c18
16 changed files with 2245 additions and 107 deletions

View File

@@ -10,7 +10,7 @@ import * as azdata from 'azdata';
import * as nls from 'vscode-nls';
import { IControllerTreeChangeHandler } from './controllerTreeChangeHandler';
import { TreeNode } from './treeNode';
import { IconPathHelper, BdcItemType, IconPath } from '../constants';
import { IconPathHelper, BdcItemType, IconPath, AuthType } from '../constants';
const localize = nls.loadMessageBundle();
@@ -108,27 +108,28 @@ export class ControllerRootNode extends ControllerTreeNode {
public addControllerNode(
url: string,
auth: AuthType,
username: string,
password: string,
rememberPassword: boolean
): void {
let controllerNode = this.getExistingControllerNode(url, username);
let controllerNode = this.getExistingControllerNode(url, auth, username);
if (controllerNode) {
controllerNode.password = password;
controllerNode.rememberPassword = rememberPassword;
controllerNode.clearChildren();
} else {
controllerNode = new ControllerNode(url, username, password, rememberPassword, undefined, this, this.treeChangeHandler, undefined);
controllerNode = new ControllerNode(url, auth, username, password, rememberPassword, undefined, this, this.treeChangeHandler, undefined);
this.addChild(controllerNode);
}
}
public deleteControllerNode(url: string, username: string): ControllerNode {
if (!url || !username) {
public deleteControllerNode(url: string, auth: AuthType, username: string): ControllerNode {
if (!url || (auth === 'basic' && !username)) {
return undefined;
}
let nodes = this.children as ControllerNode[];
let index = nodes.findIndex(e => e.url === url && e.username === username);
let index = nodes.findIndex(e => isControllerMatch(e, url, auth, username));
let deleted = undefined;
if (index >= 0) {
deleted = nodes.splice(index, 1);
@@ -136,12 +137,12 @@ export class ControllerRootNode extends ControllerTreeNode {
return deleted;
}
private getExistingControllerNode(url: string, username: string): ControllerNode {
private getExistingControllerNode(url: string, auth: AuthType, username: string): ControllerNode {
if (!url || !username) {
return undefined;
}
let nodes = this.children as ControllerNode[];
return nodes.find(e => e.url === url && e.username === username);
return nodes.find(e => isControllerMatch(e, url, auth, username));
}
}
@@ -149,6 +150,7 @@ export class ControllerNode extends ControllerTreeNode {
constructor(
private _url: string,
private _auth: AuthType,
private _username: string,
private _password: string,
private _rememberPassword: boolean,
@@ -177,26 +179,24 @@ export class ControllerNode extends ControllerTreeNode {
if (!url) {
return;
}
return url.trim().replace(/ /g, '').replace(/^.+\:\/\//, '').replace(/:(\d+)$/, ',$1');
return url.trim().replace(/ /g, '').replace(/^.+\:\/\//, '');
}
public get url() {
public get url(): string {
return this._url;
}
public set url(url: string) {
this._url = url;
public get auth(): AuthType {
return this._auth;
}
public get username() {
public get username(): string {
return this._username;
}
public set username(username: string) {
this._username = username;
}
public get password() {
public get password(): string {
return this._password;
}
@@ -213,7 +213,15 @@ export class ControllerNode extends ControllerTreeNode {
}
public set label(label: string) {
super.label = label || `controller: ${ControllerNode.toIpAndPort(this._url)} (${this._username})`;
super.label = label || this.generateLabel();
}
private generateLabel(): string {
let label = `controller: ${ControllerNode.toIpAndPort(this._url)}`;
if (this._auth === 'basic') {
label += ` (${this._username})`;
}
return label;
}
public get label(): string {
@@ -229,3 +237,7 @@ export class ControllerNode extends ControllerTreeNode {
}
}
function isControllerMatch(node: ControllerNode, url: string, auth: string, username: string): unknown {
return node.url === url && node.auth === auth && node.username === username;
}