From 758804e9cd093076ccc6e2ffaab521a99a378cca Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Wed, 10 Jul 2019 15:36:38 -0700 Subject: [PATCH] Change getCurrentConnection to return full ConnectionProfile (#6270) --- src/sql/workbench/api/node/extHostConnectionManagement.ts | 8 +------- .../workbench/api/node/mainThreadConnectionManagement.ts | 6 +++++- src/sql/workbench/api/node/sqlExtHost.protocol.ts | 1 + 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/sql/workbench/api/node/extHostConnectionManagement.ts b/src/sql/workbench/api/node/extHostConnectionManagement.ts index 09f4d6808c..080f9e6d53 100644 --- a/src/sql/workbench/api/node/extHostConnectionManagement.ts +++ b/src/sql/workbench/api/node/extHostConnectionManagement.ts @@ -19,13 +19,7 @@ export class ExtHostConnectionManagement extends ExtHostConnectionManagementShap } public $getCurrentConnection(): Thenable { - let connection: any = this._proxy.$getCurrentConnection(); - connection.then((conn) => { - if (conn) { - conn.providerId = conn.providerName; - } - }); - return connection; + return this._proxy.$getCurrentConnectionProfile(); } public $getConnections(activeConnectionsOnly?: boolean): Thenable { diff --git a/src/sql/workbench/api/node/mainThreadConnectionManagement.ts b/src/sql/workbench/api/node/mainThreadConnectionManagement.ts index 3454dabeee..b9266143c9 100644 --- a/src/sql/workbench/api/node/mainThreadConnectionManagement.ts +++ b/src/sql/workbench/api/node/mainThreadConnectionManagement.ts @@ -56,6 +56,10 @@ export class MainThreadConnectionManagement implements MainThreadConnectionManag return Promise.resolve(this.convertConnection(TaskUtilities.getCurrentGlobalConnection(this._objectExplorerService, this._connectionManagementService, this._workbenchEditorService, true))); } + public $getCurrentConnectionProfile(): Thenable { + return Promise.resolve(this.convertToConnectionProfile(TaskUtilities.getCurrentGlobalConnection(this._objectExplorerService, this._connectionManagementService, this._workbenchEditorService, true))); + } + public $getCredentials(connectionId: string): Thenable<{ [name: string]: string }> { return Promise.resolve(this._connectionManagementService.getActiveConnectionCredentials(connectionId)); } @@ -120,7 +124,7 @@ export class MainThreadConnectionManagement implements MainThreadConnectionManag let connection: azdata.connection.Connection = { providerName: profile.providerName, connectionId: profile.id, - options: profile.options + options: deepClone(profile.options) }; return connection; } diff --git a/src/sql/workbench/api/node/sqlExtHost.protocol.ts b/src/sql/workbench/api/node/sqlExtHost.protocol.ts index 4a10753bc4..9889e52bb0 100644 --- a/src/sql/workbench/api/node/sqlExtHost.protocol.ts +++ b/src/sql/workbench/api/node/sqlExtHost.protocol.ts @@ -609,6 +609,7 @@ export interface MainThreadConnectionManagementShape extends IDisposable { $getConnections(activeConnectionsOnly?: boolean): Thenable; $getActiveConnections(): Thenable; $getCurrentConnection(): Thenable; + $getCurrentConnectionProfile(): Thenable; $getCredentials(connectionId: string): Thenable<{ [name: string]: string }>; $getServerInfo(connectedId: string): Thenable; $openConnectionDialog(providers: string[], initialConnectionProfile?: azdata.IConnectionProfile, connectionCompletionOptions?: azdata.IConnectionCompletionOptions): Thenable;