From 392211777128d34eb8bc7b2bbd6a0ea255d33166 Mon Sep 17 00:00:00 2001 From: Cheena Malhotra <13396919+cheenamalhotra@users.noreply.github.com> Date: Wed, 9 Nov 2022 15:50:25 -0800 Subject: [PATCH] Fix custom option support in CMS + update providername in provided profile (#21183) --- .../browser/cmsConnectionController.ts | 2 +- .../connection/browser/cmsConnectionWidget.ts | 3 ++ .../browser/connectionDialogService.ts | 28 +++++++++++-------- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/sql/workbench/services/connection/browser/cmsConnectionController.ts b/src/sql/workbench/services/connection/browser/cmsConnectionController.ts index 3acf66b9c5..79e544f120 100644 --- a/src/sql/workbench/services/connection/browser/cmsConnectionController.ts +++ b/src/sql/workbench/services/connection/browser/cmsConnectionController.ts @@ -28,7 +28,7 @@ export class CmsConnectionController extends ConnectionController { ) { super(connectionProperties, callback, providerName, _connectionManagementService, _instantiationService, _serverGroupController, _logService); let specialOptions = this._providerOptions.filter( - (property) => (property.specialValueType !== null && property.specialValueType !== undefined)); + (property) => (property.specialValueType !== null && property.specialValueType !== undefined || property.showOnConnectionDialog)); this._connectionWidget = this._instantiationService.createInstance(CmsConnectionWidget, specialOptions, { onSetConnectButton: (enable: boolean) => this._callback.onSetConnectButton(enable), onCreateNewServerGroup: () => this.onCreateNewServerGroup(), diff --git a/src/sql/workbench/services/connection/browser/cmsConnectionWidget.ts b/src/sql/workbench/services/connection/browser/cmsConnectionWidget.ts index 3ca17cd1a0..248ddb59be 100644 --- a/src/sql/workbench/services/connection/browser/cmsConnectionWidget.ts +++ b/src/sql/workbench/services/connection/browser/cmsConnectionWidget.ts @@ -74,6 +74,9 @@ export class CmsConnectionWidget extends ConnectionWidget { // Login Options this.addLoginOptions(); + // Add Custom connection options + this.addCustomConnectionOptions(); + // Connection Name this.addConnectionNameOptions(); diff --git a/src/sql/workbench/services/connection/browser/connectionDialogService.ts b/src/sql/workbench/services/connection/browser/connectionDialogService.ts index 68a785131c..18d5c0e6b1 100644 --- a/src/sql/workbench/services/connection/browser/connectionDialogService.ts +++ b/src/sql/workbench/services/connection/browser/connectionDialogService.ts @@ -181,18 +181,7 @@ export class ConnectionDialogService implements IConnectionDialogService { } profile = result.connection; profile.serverName = trim(profile.serverName); - - // append the port to the server name for SQL Server connections - if (this._currentProviderType === Constants.mssqlProviderName || - this._currentProviderType === Constants.cmsProviderName) { - let portPropertyName: string = 'port'; - let portOption: string = profile.options[portPropertyName]; - if (portOption && portOption.indexOf(',') === -1) { - profile.serverName = profile.serverName + ',' + portOption; - } - profile.options[portPropertyName] = undefined; - profile.providerName = Constants.mssqlProviderName; - } + this.updatePortAndProvider(profile); // Disable password prompt during reconnect if connected with an empty password if (profile.password === '' && profile.savePassword === false) { @@ -202,6 +191,7 @@ export class ConnectionDialogService implements IConnectionDialogService { this.handleDefaultOnConnect(params, profile).catch(err => onUnexpectedError(err)); } else { profile.serverName = trim(profile.serverName); + this.updatePortAndProvider(profile); this._connectionManagementService.addSavedPassword(profile).then(async (connectionWithPassword) => { await this.handleDefaultOnConnect(params, connectionWithPassword); }).catch(err => onUnexpectedError(err)); @@ -209,6 +199,20 @@ export class ConnectionDialogService implements IConnectionDialogService { } } + private updatePortAndProvider(profile: IConnectionProfile): void { + // append the port to the server name for SQL Server connections + if (this._currentProviderType === Constants.mssqlProviderName || + this._currentProviderType === Constants.cmsProviderName) { + let portPropertyName: string = 'port'; + let portOption: string = profile.options[portPropertyName]; + if (portOption && portOption.indexOf(',') === -1) { + profile.serverName = profile.serverName + ',' + portOption; + } + profile.options[portPropertyName] = undefined; + profile.providerName = Constants.mssqlProviderName; + } + } + private handleOnCancel(params: INewConnectionParams): void { if (this.ignoreNextConnect) { this._connectionDialog.resetConnection();