mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-20 17:22:51 -05:00
handle unsupported connections in OE/Recent connections view (#20588)
* handle unknown provider in OE * more update * add comment * test
This commit is contained in:
@@ -108,7 +108,7 @@ export class ConnectionProfileGroup extends Disposable implements IConnectionPro
|
||||
* Returns true if all connections in the tree have valid options using the correct capabilities
|
||||
*/
|
||||
public get hasValidConnections(): boolean {
|
||||
let invalidConnections = this._childConnections.find(c => !c.isConnectionOptionsValid);
|
||||
let invalidConnections = this._childConnections.find(c => c.serverCapabilities === undefined);
|
||||
if (invalidConnections !== undefined) {
|
||||
return false;
|
||||
} else {
|
||||
|
||||
@@ -10,6 +10,7 @@ import * as azdata from 'azdata';
|
||||
import * as Constants from 'sql/platform/connection/common/constants';
|
||||
import { ICapabilitiesService, ConnectionProviderProperties } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||
import { ConnectionOptionSpecialType, ServiceOptionType } from 'sql/platform/connection/common/interfaces';
|
||||
import { localize } from 'vs/nls';
|
||||
|
||||
type SettableProperty = 'serverName' | 'authenticationType' | 'databaseName' | 'password' | 'connectionName' | 'userName';
|
||||
|
||||
@@ -145,12 +146,15 @@ export class ProviderConnectionInfo extends Disposable implements azdata.Connect
|
||||
}
|
||||
|
||||
private getServerInfo() {
|
||||
let title = this.serverName;
|
||||
// Only show database name if the provider supports it.
|
||||
if (this.serverCapabilities?.connectionOptions?.find(option => option.specialValueType === ConnectionOptionSpecialType.databaseName)) {
|
||||
title += `, ${this.databaseName || '<default>'}`;
|
||||
let title = '';
|
||||
if (this.serverCapabilities) {
|
||||
title = this.serverName;
|
||||
// Only show database name if the provider supports it.
|
||||
if (this.serverCapabilities.connectionOptions?.find(option => option.specialValueType === ConnectionOptionSpecialType.databaseName)) {
|
||||
title += `, ${this.databaseName || '<default>'}`;
|
||||
}
|
||||
title += ` (${this.userName || this.authenticationType})`;
|
||||
}
|
||||
title += ` (${this.userName || this.authenticationType})`;
|
||||
return title;
|
||||
}
|
||||
|
||||
@@ -160,10 +164,18 @@ export class ProviderConnectionInfo extends Disposable implements azdata.Connect
|
||||
public get title(): string {
|
||||
let label = '';
|
||||
|
||||
if (this.connectionName) {
|
||||
label = this.connectionName;
|
||||
if (this.serverCapabilities) {
|
||||
if (this.connectionName) {
|
||||
label = this.connectionName;
|
||||
} else {
|
||||
label = this.getServerInfo();
|
||||
}
|
||||
}
|
||||
// The provider capabilities are registered at the same time at load time, we can assume all providers are registered as long as the collection is not empty.
|
||||
else if (Object.keys(this.capabilitiesService.providers).length > 0) {
|
||||
return localize('connection.unsupported', "Unsupported connection");
|
||||
} else {
|
||||
label = this.getServerInfo();
|
||||
return localize('loading', "Loading...");
|
||||
}
|
||||
return label;
|
||||
}
|
||||
@@ -172,13 +184,6 @@ export class ProviderConnectionInfo extends Disposable implements azdata.Connect
|
||||
return this.getServerInfo();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
// if there is no provider capabilities metadata assume a password is not required
|
||||
if (!this.serverCapabilities) {
|
||||
|
||||
Reference in New Issue
Block a user