Introduce connection API (#598)

Including getCurrentConnection, getActiveConnections, and getCredentials
This commit is contained in:
Matt Irvine
2018-02-06 15:56:49 -08:00
committed by GitHub
parent f5aa49ebb9
commit 3df522536f
15 changed files with 264 additions and 3 deletions

View File

@@ -56,6 +56,7 @@ import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { IStatusbarService } from 'vs/platform/statusbar/common/statusbar';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { Deferred } from 'sql/base/common/promise';
import { ConnectionOptionSpecialType } from 'sql/workbench/api/common/sqlExtHostTypes';
export class ConnectionManagementService implements IConnectionManagementService {
@@ -659,7 +660,7 @@ export class ConnectionManagementService implements IConnectionManagementService
}
public getActiveConnections(): ConnectionProfile[] {
return this._connectionStore.getActiveConnections();
return this._connectionStatusManager.getActiveConnectionProfiles();
}
public saveProfileGroup(profile: IConnectionProfileGroup): Promise<string> {
@@ -1351,4 +1352,26 @@ export class ConnectionManagementService implements IConnectionManagementService
this._editorGroupService.refreshEditorTitles();
}
}
public removeConnectionProfileCredentials(originalProfile: IConnectionProfile): IConnectionProfile {
return this._connectionStore.getProfileWithoutPassword(originalProfile);
}
public getActiveConnectionCredentials(profileId: string): { [name: string]: string } {
let profile = this.getActiveConnections().find(connectionProfile => connectionProfile.id === profileId);
if (!profile) {
return undefined;
}
// Find the password option for the connection provider
let passwordOption = this._capabilitiesService.getCapabilities().find(capability => capability.providerName === profile.providerName).connectionProvider.options.find(
option => option.specialValueType === ConnectionOptionSpecialType.password);
if (!passwordOption) {
return undefined;
}
let credentials = {};
credentials[passwordOption.name] = profile.options[passwordOption.name];
return credentials;
}
}