diff --git a/src/sql/parts/connection/common/connectionConfig.ts b/src/sql/parts/connection/common/connectionConfig.ts index df28c31fe4..40b4d1c442 100644 --- a/src/sql/parts/connection/common/connectionConfig.ts +++ b/src/sql/parts/connection/common/connectionConfig.ts @@ -41,6 +41,11 @@ export class ConnectionConfig implements IConnectionConfig { ) { this._providerCapabilitiesMap = {}; this.setCachedMetadata(cachedMetadata); + if (this._capabilitiesService && this._capabilitiesService.onCapabilitiesReady()) { + this._capabilitiesService.onCapabilitiesReady().then(() => { + this.setCachedMetadata(this._capabilitiesService.getCapabilities()); + }); + } } public setCachedMetadata(cachedMetadata: data.DataProtocolServerCapabilities[]): void { diff --git a/src/sql/parts/connection/common/connectionProfileGroup.ts b/src/sql/parts/connection/common/connectionProfileGroup.ts index 4744a0320e..3e9aa1708b 100644 --- a/src/sql/parts/connection/common/connectionProfileGroup.ts +++ b/src/sql/parts/connection/common/connectionProfileGroup.ts @@ -79,9 +79,12 @@ export class ConnectionProfileGroup implements IConnectionProfileGroup { return false; } + /** + * Returns true if all connections in the tree have valid options using the correct capabilities + */ public get hasValidConnections(): boolean { if (this.connections) { - let invalidConnections = this.connections.find(c => c.serverCapabilities === undefined); + let invalidConnections = this.connections.find(c => !c.isConnectionOptionsValid); if (invalidConnections !== undefined) { return false; } else { diff --git a/src/sql/parts/connection/common/providerConnectionInfo.ts b/src/sql/parts/connection/common/providerConnectionInfo.ts index 72c7a3d40f..bd61622552 100644 --- a/src/sql/parts/connection/common/providerConnectionInfo.ts +++ b/src/sql/parts/connection/common/providerConnectionInfo.ts @@ -104,6 +104,23 @@ export class ProviderConnectionInfo implements data.ConnectionInfo { this.options[name] = value; } + /** + * Returns the title of the connection + */ + public get title(): string { + let databaseName = this.databaseName ? this.databaseName : ''; + let userName = this.userName ? this.userName : 'Windows Authentication'; + let label = this.serverName + ', ' + databaseName + ' (' + userName + ')'; + return label; + } + + /** + * Returns true if the capabilities and options are loaded correctly + */ + public get isConnectionOptionsValid(): boolean { + return this.serverCapabilities && this.title.indexOf('undefined') < 0; + } + public isPasswordRequired(): boolean { let optionMetadata = this._serverCapabilities.connectionProvider.options.find( option => option.specialValueType === ConnectionOptionSpecialType.password); diff --git a/src/sql/parts/registeredServer/viewlet/serverTreeRenderer.ts b/src/sql/parts/registeredServer/viewlet/serverTreeRenderer.ts index 8d333e477b..f3f1a660dc 100644 --- a/src/sql/parts/registeredServer/viewlet/serverTreeRenderer.ts +++ b/src/sql/parts/registeredServer/viewlet/serverTreeRenderer.ts @@ -8,6 +8,7 @@ import 'vs/css!sql/media/objectTypes/objecttypes'; import 'vs/css!sql/media/icons/common-icons'; import * as dom from 'vs/base/browser/dom'; +import { localize } from 'vs/nls'; import { ConnectionProfileGroup } from 'sql/parts/connection/common/connectionProfileGroup'; import { ConnectionProfile } from 'sql/parts/connection/common/connectionProfile'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; @@ -146,9 +147,10 @@ export class ServerTreeRenderer implements IRenderer { } } - let databaseName = connection.databaseName ? connection.databaseName : ''; - let userName = connection.userName ? connection.userName : "Windows Authentication"; - let label = connection.serverName + ', ' + databaseName + ' (' + userName + ')'; + let label = connection.title; + if (!connection.isConnectionOptionsValid) { + label = localize('loading', 'Loading...'); + } templateData.label.textContent = label; templateData.root.title = label; diff --git a/src/sql/parts/registeredServer/viewlet/serverTreeView.ts b/src/sql/parts/registeredServer/viewlet/serverTreeView.ts index 5b74bf5322..f7faa4b585 100644 --- a/src/sql/parts/registeredServer/viewlet/serverTreeView.ts +++ b/src/sql/parts/registeredServer/viewlet/serverTreeView.ts @@ -59,6 +59,12 @@ export class ServerTreeView { this); this._treeSelectionHandler = this._instantiationService.createInstance(TreeSelectionHandler); this._onSelectionOrFocusChange = new Emitter(); + if (this._capabilitiesService) { + this._capabilitiesService.onCapabilitiesReady().then(() => { + this.refreshTree(); + this._treeSelectionHandler.onTreeActionStateChange(false); + }); + } } /** @@ -134,23 +140,9 @@ export class ServerTreeView { self.refreshTree(); let root = this._tree.getInput(); if (root && !root.hasValidConnections) { - this._treeSelectionHandler.onTreeActionStateChange(true); - if (this._capabilitiesService) { - this._capabilitiesService.onCapabilitiesReady().then(() => { - self.refreshTree(); - this._treeSelectionHandler.onTreeActionStateChange(false); - resolve(); - - }, error => { - reject(error); - }); - } else { - self.refreshTree(); - resolve(); - } + resolve(); } else { - resolve(); } });