mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-12 11:08:31 -05:00
Fixes the 'undefined' in connection tree when capabilities not loaded (#617)
* fixed the bug with loading the connection tree when capabilities not loaded
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 : '<default>';
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user