mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-12 19:18:32 -05:00
Initial LiveShare extension scaffolding (#7170)
* LiveShare initial shared connection * Various cleanups * Fix type * Fix hygiene
This commit is contained in:
@@ -277,6 +277,8 @@ export interface IConnectionManagementService {
|
||||
* @returns array of connections
|
||||
*/
|
||||
getConnections(activeConnectionsOnly?: boolean): ConnectionProfile[];
|
||||
|
||||
getConnection(uri: string): ConnectionProfile;
|
||||
}
|
||||
|
||||
export enum RunQueryOnConnectionMode {
|
||||
|
||||
@@ -156,8 +156,6 @@ export class ConnectionManagementService extends Disposable implements IConnecti
|
||||
return this._onLanguageFlavorChanged.event;
|
||||
}
|
||||
|
||||
private _providerCount: number = 0;
|
||||
|
||||
// Connection Provider Registration
|
||||
public registerProvider(providerId: string, provider: azdata.ConnectionProvider): void {
|
||||
if (!this._providers.has(providerId)) {
|
||||
@@ -1337,7 +1335,6 @@ export class ConnectionManagementService extends Disposable implements IConnecti
|
||||
* @returns array of connections
|
||||
**/
|
||||
public getConnections(activeConnectionsOnly?: boolean): ConnectionProfile[] {
|
||||
|
||||
// 1. Active Connections
|
||||
const connections = this.getActiveConnections();
|
||||
|
||||
@@ -1368,6 +1365,20 @@ export class ConnectionManagementService extends Disposable implements IConnecti
|
||||
return connections;
|
||||
}
|
||||
|
||||
public getConnection(uri: string): ConnectionProfile {
|
||||
const connections = this.getActiveConnections();
|
||||
if (connections) {
|
||||
for (let connection of connections) {
|
||||
let connectionUri = this.getConnectionUriFromId(connection.id);
|
||||
if (connectionUri === uri) {
|
||||
return connection;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
private getConnectionsInGroup(group: ConnectionProfileGroup): ConnectionProfile[] {
|
||||
const connections = [];
|
||||
if (group) {
|
||||
|
||||
@@ -33,8 +33,7 @@ export class ConnectionProfile extends ProviderConnectionInfo implements interfa
|
||||
|
||||
public constructor(
|
||||
capabilitiesService: ICapabilitiesService,
|
||||
model: string | azdata.IConnectionProfile
|
||||
) {
|
||||
model: string | azdata.IConnectionProfile) {
|
||||
super(capabilitiesService, model);
|
||||
if (model && !isString(model)) {
|
||||
this.groupId = model.groupId;
|
||||
|
||||
@@ -189,7 +189,14 @@ export class ConnectionStatusManager {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
private isSharedSession(fileUri: string): boolean {
|
||||
return fileUri && fileUri.startsWith('vsls:');
|
||||
}
|
||||
|
||||
public isConnected(id: string): boolean {
|
||||
if (this.isSharedSession(id)) {
|
||||
return true;
|
||||
}
|
||||
return (id in this._connections && this._connections[id].connectionId && !!this._connections[id].connectionId);
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ export class ProviderConnectionInfo extends Disposable implements azdata.Connect
|
||||
|
||||
public set providerName(name: string) {
|
||||
this._providerName = name;
|
||||
if (!this._serverCapabilities) {
|
||||
if (!this._serverCapabilities && this.capabilitiesService) {
|
||||
let capabilities = this.capabilitiesService.getCapabilities(this.providerName);
|
||||
if (capabilities) {
|
||||
this._serverCapabilities = capabilities.connection;
|
||||
@@ -192,6 +192,11 @@ export class ProviderConnectionInfo extends Disposable implements azdata.Connect
|
||||
}
|
||||
|
||||
public isPasswordRequired(): boolean {
|
||||
// if there is no provider capabilities metadata assume a password is not required
|
||||
if (!this._serverCapabilities) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let optionMetadata = this._serverCapabilities.connectionOptions.find(
|
||||
option => option.specialValueType === ConnectionOptionSpecialType.password);
|
||||
let isPasswordRequired: boolean = optionMetadata.isRequired;
|
||||
|
||||
Reference in New Issue
Block a user