* fixed initial connection prompt and disconnect

* nodes now show database name if no profile has no name

* remove dead code

* server labels now match ADS behavior

* rename show connections

* added expand deferred promise mapping before the expand request
This commit is contained in:
Aditya Bist 2019-09-26 13:51:28 -07:00 коммит произвёл GitHub
Родитель 4a132937be
Коммит a6e78bce32
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
8 изменённых файлов: 182 добавлений и 176 удалений

Просмотреть файл

@ -170,8 +170,7 @@
"objectExplorer": [
{
"id": "objectExplorer",
"name": "%extension.connections%",
"when": "enablePreviewFeatures"
"name": "%extension.connections%"
}
]
},
@ -211,56 +210,55 @@
{
"command": "extension.addObjectExplorer",
"title": "%extension.addObjectExplorer%",
"group": "navigation",
"when": "enablePreviewFeatures"
"group": "navigation"
}
],
"view/item/context": [
{
"command": "extension.objectExplorerNewQuery",
"when": "enablePreviewFeatures && viewItem =~ /^(disconnectedServer|Server|Database|Table)$/",
"when": "viewItem =~ /^(disconnectedServer|Server|Database|Table)$/",
"group": "MS_SQL@1"
},
{
"command": "extension.removeObjectExplorerNode",
"when": "enablePreviewFeatures && viewItem =~ /^(disconnectedServer|Server)$/",
"when": "viewItem =~ /^(disconnectedServer|Server)$/",
"group": "MS_SQL@3"
},
{
"command": "extension.refreshObjectExplorerNode",
"when": "enablePreviewFeatures && view == objectExplorer",
"when": "view == objectExplorer",
"group": "MS_SQL@2"
},
{
"command": "extension.disconnectObjectExplorerNode",
"when": "enablePreviewFeatures && viewItem == Server",
"when": "viewItem == Server",
"group": "MS_SQL@4"
},
{
"command": "extension.scriptSelect",
"when": "enablePreviewFeatures && viewItem == Table"
"when": "viewItem == Table"
}
],
"commandPalette": [
{
"command": "extension.objectExplorerNewQuery",
"when": "enablePreviewFeatures && view == objectExplorer"
"when": "view == objectExplorer"
},
{
"command": "extension.removeObjectExplorerNode",
"when": "enablePreviewFeatures && viewItem != null"
"when": "viewItem != null"
},
{
"command": "extension.refreshObjectExplorerNode",
"when": "enablePreviewFeatures && viewItem != null"
"when": "viewItem != null"
},
{
"command": "extension.scriptSelect",
"when": "enablePreviewFeatures && viewItem == Table"
"when": "viewItem == Table"
},
{
"command": "extension.disconnectObjectExplorerNode",
"when": "enablePreviewFeatures && viewItem != null"
"when": "viewItem != null"
}
]
},
@ -383,7 +381,7 @@
"command": "extension.addObjectExplorer",
"key": "ctrl+shift+o",
"mac": "cmd+shift+o",
"when": "enablePreviewFeatures && view == objectExplorer"
"when": "view == objectExplorer"
}
],
"configuration": {
@ -402,11 +400,6 @@
"description": "%mssql.maxRecentConnections%",
"scope": "window"
},
"mssql.enablePreviewFeatures": {
"type": "boolean",
"default": false,
"description": "%mssql.enablePreviewFeatures%"
},
"mssql.connections": {
"type": "array",
"default": [

Просмотреть файл

@ -17,7 +17,6 @@
"extension.objectExplorerNewQuery":"New Query",
"extension.toggleSqlCmd":"Toggle SQLCMD Mode",
"extension.rebuildIntelliSenseCache":"Refresh IntelliSense Cache",
"mssql.enablePreviewFeatures":"Enable Preview Features",
"mssql.logDebugInfo":"[Optional] Log debug output to the VS Code console (Help -> Toggle Developer Tools)",
"mssql.maxRecentConnections":"The maximum number of recently used connections to store in the connection list.",
"mssql.connections":"Connection profiles defined in 'User Settings' are shown under 'MS SQL: Connect' command in the command palette.",

Просмотреть файл

@ -74,7 +74,6 @@ export const changelogLink = 'https://aka.ms/vscode-mssql-changelog';
export const integratedAuthHelpLink = 'https://aka.ms/vscode-mssql-integratedauth';
export const sqlToolsServiceCrashLink = 'https://github.com/Microsoft/vscode-mssql/wiki/SqlToolsService-Known-Issues';
export const databaseString = 'Database';
export const localizedTexts = 'localizedTexts';
// Configuration Constants

Просмотреть файл

@ -50,7 +50,6 @@ export default class MainController implements vscode.Disposable {
private _untitledSqlDocumentService: UntitledSqlDocumentService;
private _objectExplorerProvider: ObjectExplorerProvider;
private _scriptingService: ScriptingService;
private _previewEnabled: boolean = false;
/**
* The main controller constructor
@ -141,93 +140,90 @@ export default class MainController implements vscode.Disposable {
this._event.on(Constants.cmdToggleSqlCmd, async () => { await self.onToggleSqlCmd(); });
// register the object explorer tree provider
if (this._previewEnabled) {
this._objectExplorerProvider = new ObjectExplorerProvider(this._connectionMgr);
this._context.subscriptions.push(
vscode.window.registerTreeDataProvider('objectExplorer', this._objectExplorerProvider)
);
this.registerCommand(Constants.cmdAddObjectExplorer);
this._event.on(Constants.cmdAddObjectExplorer, async () => {
if (!self._objectExplorerProvider.objectExplorerExists) {
self._objectExplorerProvider.objectExplorerExists = true;
this._objectExplorerProvider = new ObjectExplorerProvider(this._connectionMgr);
this._context.subscriptions.push(
vscode.window.registerTreeDataProvider('objectExplorer', this._objectExplorerProvider)
);
this.registerCommand(Constants.cmdAddObjectExplorer);
this._event.on(Constants.cmdAddObjectExplorer, async () => {
if (!self._objectExplorerProvider.objectExplorerExists) {
self._objectExplorerProvider.objectExplorerExists = true;
}
let promise = new Deferred<TreeNodeInfo>();
await self._objectExplorerProvider.createSession(promise);
return promise.then(() => {
this._objectExplorerProvider.refresh(undefined);
});
});
this._context.subscriptions.push(
vscode.commands.registerCommand(
Constants.cmdObjectExplorerNewQuery, async (treeNodeInfo: TreeNodeInfo) => {
const connectionCredentials = treeNodeInfo.connectionCredentials;
if (connectionCredentials) {
const databaseName = `${escapeCharacters(self.getDatabaseName(treeNodeInfo))}`;
if (databaseName !== connectionCredentials.database) {
connectionCredentials.database = databaseName;
}
}
await self.onNewQuery(treeNodeInfo);
await this._connectionMgr.changeDatabase(connectionCredentials);
}));
this._context.subscriptions.push(
vscode.commands.registerCommand(
Constants.cmdRemoveObjectExplorerNode, async (treeNodeInfo: TreeNodeInfo) => {
await this._objectExplorerProvider.removeObjectExplorerNode(treeNodeInfo);
let profile = <IConnectionProfile>treeNodeInfo.connectionCredentials;
await this._connectionMgr.connectionStore.removeProfile(profile, false);
return this._objectExplorerProvider.refresh(undefined);
}));
this.registerCommand(Constants.cmdRefreshObjectExplorerNode);
this._event.on(Constants.cmdRefreshObjectExplorerNode, () => {
return this._objectExplorerProvider.refreshNode(this._objectExplorerProvider.currentNode);
});
// initiate the scripting service
this._scriptingService = new ScriptingService(this._connectionMgr, this._vscodeWrapper);
this._context.subscriptions.push(
vscode.commands.registerCommand(
Constants.cmdScriptSelect, async (node: TreeNodeInfo) => {
const uri = await this._untitledSqlDocumentService.newQuery();
if (!this.connectionManager.isConnected(uri.toString())) {
const connectionCreds = node.connectionCredentials;
const databaseName = `${escapeCharacters(self.getDatabaseName(node))}`;
node.connectionCredentials.database = databaseName;
this._statusview.languageFlavorChanged(uri.toString(), Constants.mssqlProviderName);
await this.connectionManager.connect(uri.toString(), connectionCreds);
this._statusview.sqlCmdModeChanged(uri.toString(), false);
const selectStatement = await this._scriptingService.scriptSelect(node, uri.toString());
let editor = this._vscodeWrapper.activeTextEditor;
editor.edit(editBuilder => {
editBuilder.replace(editor.selection, selectStatement);
}).then(() => this.onRunQuery());
}
}));
this._context.subscriptions.push(
vscode.commands.registerCommand(
Constants.cmdObjectExplorerNodeSignIn, async (node: AccountSignInTreeNode) => {
this._objectExplorerProvider.signInNodeServer(node.parentNode);
return this._objectExplorerProvider.refresh(undefined);
}));
this._context.subscriptions.push(
vscode.commands.registerCommand(
Constants.cmdConnectObjectExplorerNode, async (node: ConnectTreeNode) => {
let promise = new Deferred<TreeNodeInfo>();
await self._objectExplorerProvider.createSession(promise);
await self._objectExplorerProvider.createSession(promise, node.parentNode.connectionCredentials);
return promise.then(() => {
this._objectExplorerProvider.refresh(undefined);
});
});
this._context.subscriptions.push(
vscode.commands.registerCommand(
Constants.cmdObjectExplorerNewQuery, async (treeNodeInfo: TreeNodeInfo) => {
const connectionCredentials = treeNodeInfo.connectionCredentials;
if (connectionCredentials) {
const databaseName = `${escapeCharacters(self.getDatabaseName(treeNodeInfo))}`;
if (databaseName !== connectionCredentials.database) {
connectionCredentials.database = databaseName;
}
}
await self.onNewQuery(treeNodeInfo);
await this._connectionMgr.changeDatabase(connectionCredentials);
}));
this._context.subscriptions.push(
vscode.commands.registerCommand(
Constants.cmdRemoveObjectExplorerNode, async (treeNodeInfo: TreeNodeInfo) => {
await this._objectExplorerProvider.removeObjectExplorerNode(treeNodeInfo);
let profile = <IConnectionProfile>treeNodeInfo.connectionCredentials;
await this._connectionMgr.connectionStore.removeProfile(profile, false);
return this._objectExplorerProvider.refresh(undefined);
}));
this.registerCommand(Constants.cmdRefreshObjectExplorerNode);
this._event.on(Constants.cmdRefreshObjectExplorerNode, () => {
return this._objectExplorerProvider.refreshNode(this._objectExplorerProvider.currentNode);
});
// initiate the scripting service
this._scriptingService = new ScriptingService(this._connectionMgr, this._vscodeWrapper);
this._context.subscriptions.push(
vscode.commands.registerCommand(
Constants.cmdScriptSelect, async (node: TreeNodeInfo) => {
const uri = await this._untitledSqlDocumentService.newQuery();
if (!this.connectionManager.isConnected(uri.toString())) {
const connectionCreds = node.connectionCredentials;
const databaseName = `${escapeCharacters(self.getDatabaseName(node))}`;
node.connectionCredentials.database = databaseName;
this._statusview.languageFlavorChanged(uri.toString(), Constants.mssqlProviderName);
await this.connectionManager.connect(uri.toString(), connectionCreds);
this._statusview.sqlCmdModeChanged(uri.toString(), false);
const selectStatement = await this._scriptingService.scriptSelect(node, uri.toString());
let editor = this._vscodeWrapper.activeTextEditor;
editor.edit(editBuilder => {
editBuilder.replace(editor.selection, selectStatement);
}).then(() => this.onRunQuery());
}
}));
this._context.subscriptions.push(
vscode.commands.registerCommand(
Constants.cmdObjectExplorerNodeSignIn, async (node: AccountSignInTreeNode) => {
this._objectExplorerProvider.signInNodeServer(node.parentNode);
return this._objectExplorerProvider.refresh(undefined);
}));
this._context.subscriptions.push(
vscode.commands.registerCommand(
Constants.cmdConnectObjectExplorerNode, async (node: ConnectTreeNode) => {
let promise = new Deferred<TreeNodeInfo>();
await self._objectExplorerProvider.createSession(promise, node.parentNode.connectionCredentials);
return promise.then(() => {
this._objectExplorerProvider.refresh(undefined);
});
}));
this._context.subscriptions.push(
vscode.commands.registerCommand(
Constants.cmdDisconnectObjectExplorerNode, async (node: TreeNodeInfo) => {
await this._objectExplorerProvider.removeObjectExplorerNode(node, true);
}));
}
}));
this._context.subscriptions.push(
vscode.commands.registerCommand(
Constants.cmdDisconnectObjectExplorerNode, async (node: TreeNodeInfo) => {
await this._objectExplorerProvider.removeObjectExplorerNode(node, true);
}));
// Add handlers for VS Code generated commands
this._vscodeWrapper.onDidCloseTextDocument(params => this.onDidCloseTextDocument(params));
@ -357,7 +353,7 @@ export default class MainController implements vscode.Disposable {
}
node = node.parentNode;
}
return 'master';
return Constants.defaultDatabase;
}
/**
@ -419,10 +415,8 @@ export default class MainController implements vscode.Disposable {
if (this.canRunCommand() && this.validateTextDocumentHasFocus()) {
this._connectionMgr.onNewConnection().then((result) => {
if (result) {
if (this._previewEnabled) {
this._objectExplorerProvider.objectExplorerExists = false;
this._objectExplorerProvider.refresh(undefined);
}
this._objectExplorerProvider.objectExplorerExists = false;
this._objectExplorerProvider.refresh(undefined);
return true;
}
});
@ -679,7 +673,7 @@ export default class MainController implements vscode.Disposable {
public async onNewQuery(node?: TreeNodeInfo, content?: string): Promise<boolean> {
if (this.canRunCommand()) {
// from the object explorer context menu
if (node && this._previewEnabled) {
if (node) {
const uri = await this._untitledSqlDocumentService.newQuery(content);
// connect to the node if the command came from the context
if (!this.connectionManager.isConnected(uri.toString())) {
@ -690,7 +684,7 @@ export default class MainController implements vscode.Disposable {
if (ConnectionCredentials.shouldPromptForPassword(connectionCreds)) {
// lookup saved password
const password = await this.connectionManager.connectionStore.
lookupPassword(connectionCreds)
lookupPassword(connectionCreds);
connectionCreds.password = password;
}
}
@ -705,7 +699,7 @@ export default class MainController implements vscode.Disposable {
const credentials = await this._connectionMgr.onNewConnection();
// initiate a new OE with same connection
if (credentials && this._previewEnabled) {
if (credentials) {
this._objectExplorerProvider.refresh(undefined);
}
this._statusview.sqlCmdModeChanged(uri.toString(), false);
@ -832,11 +826,4 @@ export default class MainController implements vscode.Disposable {
this._lastSavedTimer.start();
this._lastSavedUri = savedDocumentUri;
}
/**
* set enable preview mode for testing only
*/
public setEnablePreviewMode(): void {
this._previewEnabled = false;
}
}

Просмотреть файл

@ -49,11 +49,11 @@ export class ObjectExplorerProvider implements vscode.TreeDataProvider<any> {
return undefined;
}
public removeObjectExplorerNode(node: TreeNodeInfo, isDisconnect: boolean = false): Promise<void> {
public async removeObjectExplorerNode(node: TreeNodeInfo, isDisconnect: boolean = false): Promise<void> {
return this._objectExplorerService.removeObjectExplorerNode(node, isDisconnect);
}
public refreshNode(node: TreeNodeInfo): Promise<void> {
public async refreshNode(node: TreeNodeInfo): Promise<void> {
return this._objectExplorerService.refreshNode(node);
}

Просмотреть файл

@ -28,7 +28,7 @@ export class ObjectExplorerService {
private _client: SqlToolsServiceClient;
private _currentNode: TreeNodeInfo;
private _treeNodeToChildrenMap: Map<vscode.TreeItem, vscode.TreeItem[]>;
private _nodePathToNodeLabelMap: Map<string, string>;
private _serverToNodeLabelMap: Map<string, string>;
private _rootTreeNodeArray: Array<TreeNodeInfo>;
private _sessionIdToConnectionCredentialsMap: Map<string, ConnectionCredentials>;
@ -43,7 +43,7 @@ export class ObjectExplorerService {
this._treeNodeToChildrenMap = new Map<vscode.TreeItem, vscode.TreeItem[]>();
this._rootTreeNodeArray = new Array<TreeNodeInfo>();
this._sessionIdToConnectionCredentialsMap = new Map<string, ConnectionCredentials>();
this._nodePathToNodeLabelMap = new Map<string, string>();
this._serverToNodeLabelMap = new Map<string, string>();
this._sessionIdToPromiseMap = new Map<string, Deferred<vscode.TreeItem>>();
this._expandParamsToPromiseMap = new Map<ExpandParams, Deferred<TreeNodeInfo[]>>();
@ -57,7 +57,7 @@ export class ObjectExplorerService {
const self = this;
const handler = (result: SessionCreatedParameters) => {
if (result.success) {
let nodeLabel = this._nodePathToNodeLabelMap.get(result.rootNode.nodePath);
let nodeLabel = this._serverToNodeLabelMap.get(result.rootNode.nodePath);
// if no node label, check if it has a name in saved profiles
// in case this call came from new query
let savedConnections = this._connectionManager.connectionStore.loadAllConnections();
@ -68,14 +68,17 @@ export class ObjectExplorerService {
}
}
// set connection and other things
if (self._currentNode) {
if (self._currentNode && (self._currentNode.sessionId === result.sessionId)) {
nodeLabel = nodeLabel === result.rootNode.nodePath ?
self.createNodeLabel(self._currentNode.connectionCredentials) : nodeLabel;
self._currentNode = TreeNodeInfo.fromNodeInfo(result.rootNode, result.sessionId,
self._currentNode, self._currentNode.connectionCredentials,
nodeLabel ? nodeLabel : result.rootNode.nodePath);
undefined, self._currentNode.connectionCredentials, nodeLabel);
} else {
const credentials = this._sessionIdToConnectionCredentialsMap.get(result.sessionId);
self._currentNode = TreeNodeInfo.fromNodeInfo(result.rootNode, result.sessionId, self._currentNode,
credentials, nodeLabel ? nodeLabel : result.rootNode.nodePath);
nodeLabel = nodeLabel === result.rootNode.nodePath ?
self.createNodeLabel(credentials) : nodeLabel;
self._currentNode = TreeNodeInfo.fromNodeInfo(result.rootNode, result.sessionId,
undefined, credentials, nodeLabel);
}
self.updateNode(self._currentNode);
self._objectExplorerProvider.objectExplorerExists = true;
@ -107,13 +110,13 @@ export class ObjectExplorerService {
const self = this;
const handler = (result: ExpandResponse) => {
if (result && result.nodes) {
const children = result.nodes.map(node => TreeNodeInfo.fromNodeInfo(node, self._currentNode.sessionId,
const children = result.nodes.map(node => TreeNodeInfo.fromNodeInfo(node, result.sessionId,
self._currentNode, self._currentNode.connectionCredentials));
self._treeNodeToChildrenMap.set(self._currentNode, children);
const expandParams: ExpandParams = {
sessionId: result.sessionId,
nodePath: result.nodePath
}
};
for (let key of self._expandParamsToPromiseMap.keys()) {
if (key.sessionId === expandParams.sessionId &&
key.nodePath === expandParams.nodePath) {
@ -131,9 +134,10 @@ export class ObjectExplorerService {
sessionId: sessionId,
nodePath: node.nodePath
};
this._expandParamsToPromiseMap.set(expandParams, promise);
const response = await this._connectionManager.client.sendRequest(ExpandRequest.type, expandParams);
if (promise) {
this._expandParamsToPromiseMap.set(expandParams, promise);
if (!response) {
this._expandParamsToPromiseMap.delete(expandParams);
}
return response;
}
@ -169,8 +173,8 @@ export class ObjectExplorerService {
this._currentNode = element;
}
// get cached children
if (this._treeNodeToChildrenMap.has(this._currentNode)) {
return this._treeNodeToChildrenMap.get(this._currentNode);
if (this._treeNodeToChildrenMap.has(element)) {
return this._treeNodeToChildrenMap.get(element);
} else {
// check if session exists
if (element.sessionId) {
@ -179,34 +183,34 @@ export class ObjectExplorerService {
// node expansion
let promise = new Deferred<TreeNodeInfo[]>();
this.expandNode(element, element.sessionId, promise);
return promise.then((children) => {
if (children) {
// clean expand session promise
for (const key of this._expandParamsToPromiseMap.keys()) {
if (key.sessionId === element.sessionId &&
key.nodePath === element.nodePath) {
this._expandParamsToPromiseMap.delete(key);
}
await this.expandNode(element, element.sessionId, promise);
let children = await promise;
if (children) {
// clean expand session promise
for (const key of this._expandParamsToPromiseMap.keys()) {
if (key.sessionId === element.sessionId &&
key.nodePath === element.nodePath) {
this._expandParamsToPromiseMap.delete(key);
}
return children;
}
});
return children;
} else {
return undefined;
}
} else {
// start node session
let promise = new Deferred<TreeNodeInfo>();
this.createSession(promise, element.connectionCredentials);
return promise.then((node) => {
// If password wasn't given
if (!node) {
const signInNode = new AccountSignInTreeNode(element);
this._treeNodeToChildrenMap.set(element, [signInNode]);
return [signInNode];
}
// otherwise expand the node by refreshing the root
// to add connected context key
this._objectExplorerProvider.refresh(undefined);
});
await this.createSession(promise, element.connectionCredentials);
let node = await promise;
// If node create session failed
if (!node) {
const signInNode = new AccountSignInTreeNode(element);
this._treeNodeToChildrenMap.set(element, [signInNode]);
return [signInNode];
}
// otherwise expand the node by refreshing the root
// to add connected context key
this._objectExplorerProvider.refresh(undefined);
}
}
} else {
@ -218,11 +222,14 @@ export class ObjectExplorerService {
savedConnections.length > 0) {
this._rootTreeNodeArray = [];
savedConnections.forEach((conn) => {
this._nodePathToNodeLabelMap.set(conn.connectionCreds.server, conn.label);
let node = new TreeNodeInfo(conn.label, Constants.disconnectedServerLabel,
let nodeLabel = conn.label === conn.connectionCreds.server ?
this.createNodeLabel(conn.connectionCreds) : conn.label;
this._serverToNodeLabelMap.set(conn.connectionCreds.server, nodeLabel);
let node = new TreeNodeInfo(nodeLabel,
Constants.disconnectedServerLabel,
TreeItemCollapsibleState.Collapsed,
undefined, undefined, Constants.serverLabel,
undefined, conn.connectionCreds, undefined);
undefined, undefined, Constants.serverLabel,
undefined, conn.connectionCreds, undefined);
this._rootTreeNodeArray.push(node);
});
this._objectExplorerProvider.objectExplorerExists = true;
@ -246,7 +253,7 @@ export class ObjectExplorerService {
public async createSession(promise: Deferred<vscode.TreeItem>, connectionCredentials?: IConnectionCredentials): Promise<void> {
if (!connectionCredentials) {
const connectionUI = this._connectionManager.connectionUI;
connectionCredentials = await connectionUI.showConnections();
connectionCredentials = await connectionUI.showConnections(false);
}
if (connectionCredentials) {
// show password prompt if SQL Login and password isn't saved
@ -255,7 +262,7 @@ export class ObjectExplorerService {
// look up saved password
let password = await this._connectionManager.connectionStore.lookupPassword(connectionCredentials);
if (!password) {
let password = await this._connectionManager.connectionUI.promptForPassword();
password = await this._connectionManager.connectionUI.promptForPassword();
if (!password) {
return promise.resolve(undefined);
}
@ -289,14 +296,8 @@ export class ObjectExplorerService {
}
const nodeUri = ObjectExplorerUtils.getNodeUri(node);
this._connectionManager.disconnect(nodeUri);
this._serverToNodeLabelMap.delete(node.connectionCredentials.server);
this.cleanNodeChildren(node);
this._nodePathToNodeLabelMap.delete(node.nodePath);
this._sessionIdToConnectionCredentialsMap.delete(node.sessionId);
if (this._sessionIdToPromiseMap.has(node.sessionId)) {
this._sessionIdToPromiseMap.delete(node.sessionId);
}
this._treeNodeToChildrenMap.delete(node);
this._currentNode = undefined;
if (isDisconnect) {
this._treeNodeToChildrenMap.set(node, [new ConnectTreeNode(node)]);
this.updateNode(node);
@ -319,6 +320,24 @@ export class ObjectExplorerService {
}
}
private createNodeLabel(credentials: IConnectionCredentials): string {
let database = credentials.database;
const server = credentials.server;
const authType = credentials.authenticationType;
let userOrAuthType = authType;
if (authType === Constants.sqlAuthentication) {
userOrAuthType = credentials.user;
}
if (!database || database === '') {
database = Constants.defaultDatabase;
}
return `${server}, ${database} (${userOrAuthType})`;
}
/**
* Sends a close session request
* @param node
*/
public async closeSession(node: TreeNodeInfo): Promise<void> {
if (node.sessionId) {
const closeSessionParams: CloseSessionParams = {
@ -328,11 +347,12 @@ export class ObjectExplorerService {
closeSessionParams);
if (response && response.success) {
this._sessionIdToConnectionCredentialsMap.delete(response.sessionId);
if (this._sessionIdToPromiseMap.has(node.sessionId)) {
this._sessionIdToPromiseMap.delete(node.sessionId);
}
node.nodeType = Constants.disconnectedServerLabel;
node.sessionId = undefined;
this.updateNode(node);
this._currentNode = node;
this._treeNodeToChildrenMap.set(this._currentNode, undefined);
return;
}
}

Просмотреть файл

@ -17,6 +17,9 @@ export class ObjectExplorerUtils {
}
}
public static getNodeUri(node: TreeNodeInfo): string {
if (node.nodeType === Constants.disconnectedServerLabel) {
return undefined;
}
while (node) {
if (node.nodeType === Constants.serverLabel) {
break;

Просмотреть файл

@ -73,10 +73,15 @@ export class ConnectionUI {
// Helper to let user choose a connection from a picklist
// Return the ConnectionInfo for the user's choice
public showConnections(): Promise<IConnectionCredentials> {
public showConnections(showExistingConnections: boolean = true): Promise<IConnectionCredentials> {
const self = this;
return new Promise<IConnectionCredentials>((resolve, reject) => {
let picklist: IConnectionCredentialsQuickPickItem[] = self._connectionStore.getPickListItems();
let picklist: IConnectionCredentialsQuickPickItem[];
if (!showExistingConnections) {
picklist = self._connectionStore.getPickListItems();
} else {
picklist = [];
}
if (picklist.length === 0) {
// No connections - go to the create profile workflow
self.createAndSaveProfile().then(resolvedProfile => {