diff --git a/extensions/cms/package.json b/extensions/cms/package.json index ab642bd498..7ff5f8e31d 100644 --- a/extensions/cms/package.json +++ b/extensions/cms/package.json @@ -86,17 +86,9 @@ "defaultValue": null, "objectType": null, "categoryValues": [ - { - "displayName": "%cms.connectionOptions.authType.categoryValues.sqlLogin%", - "name": "SqlLogin" - }, { "displayName": "%cms.connectionOptions.authType.categoryValues.integrated%", "name": "Integrated" - }, - { - "displayName": "%cms.connectionOptions.authType.categoryValues.azureMFA%", - "name": "AzureMFA" } ], "isRequired": true, diff --git a/extensions/cms/src/cmsResource/tree/cmsResourceTreeNode.ts b/extensions/cms/src/cmsResource/tree/cmsResourceTreeNode.ts index 0885d32335..9ba6de8413 100644 --- a/extensions/cms/src/cmsResource/tree/cmsResourceTreeNode.ts +++ b/extensions/cms/src/cmsResource/tree/cmsResourceTreeNode.ts @@ -78,7 +78,7 @@ export class CmsResourceTreeNode extends CmsResourceTreeNodeBase { } }, (error) => { let errorText = localize('cms.errors.expandCmsFail', 'The Central Management Server {0} could not be found or is offline', this.name); - this.appContext.apiWrapper.showErrorMessage(errorText); + this.appContext.apiWrapper.showErrorMessage(error ? error : errorText); return []; }); } catch { diff --git a/extensions/cms/src/cmsUtils.ts b/extensions/cms/src/cmsUtils.ts index 06aa8cf825..5651f29035 100644 --- a/extensions/cms/src/cmsUtils.ts +++ b/extensions/cms/src/cmsUtils.ts @@ -143,9 +143,7 @@ export class CmsUtils { providerName: undefined, saveProfile: undefined, id: undefined, - options: { - authTypeChanged: true - } + options: {} }; return this.openConnectionDialog([cmsProvider], initialProfile, { saveConnection: false }).then(async (connection) => { if (connection && connection.options) { diff --git a/extensions/mssql/src/cms/cmsService.ts b/extensions/mssql/src/cms/cmsService.ts index 8b732be461..9037148c3e 100644 --- a/extensions/mssql/src/cms/cmsService.ts +++ b/extensions/mssql/src/cms/cmsService.ts @@ -16,7 +16,6 @@ import { ListRegisteredServersResult } from '../api/mssqlapis'; export class CmsService { constructor(private appContext: AppContext, private client: SqlOpsDataClient) { - this.appContext.registerService(constants.CmsService, this); } @@ -30,7 +29,7 @@ export class CmsService { }, e => { this.client.logFailedRequest(contracts.CreateCentralManagementServerRequest.type, e); - return Promise.resolve(undefined); + return Promise.reject(e.message); } ); } @@ -43,7 +42,7 @@ export class CmsService { }, e => { this.client.logFailedRequest(contracts.ListRegisteredServersRequest.type, e); - return Promise.resolve(undefined); + return Promise.reject(e.message); } ); } @@ -56,7 +55,7 @@ export class CmsService { }, e => { this.client.logFailedRequest(contracts.AddRegisteredServerRequest.type, e); - return Promise.resolve(undefined); + return Promise.reject(e.message); } ); } @@ -69,7 +68,7 @@ export class CmsService { }, e => { this.client.logFailedRequest(contracts.RemoveRegisteredServerRequest.type, e); - return Promise.resolve(undefined); + return Promise.reject(e.message); } ); } @@ -82,7 +81,7 @@ export class CmsService { }, e => { this.client.logFailedRequest(contracts.AddServerGroupRequest.type, e); - return Promise.resolve(undefined); + return Promise.reject(e.message); } ); } @@ -95,7 +94,7 @@ export class CmsService { }, e => { this.client.logFailedRequest(contracts.RemoveServerGroupRequest.type, e); - return Promise.resolve(undefined); + return Promise.reject(e.message); } ); } diff --git a/src/sql/workbench/services/connection/browser/cmsConnectionController.ts b/src/sql/workbench/services/connection/browser/cmsConnectionController.ts index 9c251b8b36..98fef9df02 100644 --- a/src/sql/workbench/services/connection/browser/cmsConnectionController.ts +++ b/src/sql/workbench/services/connection/browser/cmsConnectionController.ts @@ -20,7 +20,6 @@ export class CmsConnectionController extends ConnectionController { connectionProperties: ConnectionProviderProperties, callback: IConnectionComponentCallbacks, providerName: string, - authTypeChanged: boolean = false, @IInstantiationService _instantiationService: IInstantiationService) { super(connectionManagementService, connectionProperties, callback, providerName, _instantiationService); let specialOptions = this._providerOptions.filter( @@ -34,11 +33,11 @@ export class CmsConnectionController extends ConnectionController { serverName, authenticationType, userName, password).then(result => { return result; }) - }, providerName, authTypeChanged); + }, providerName); } - public showUiComponent(container: HTMLElement, authTypeChanged: boolean = false): void { + public showUiComponent(container: HTMLElement): void { this._databaseCache = new Map(); - this._connectionWidget.createConnectionWidget(container, authTypeChanged); + this._connectionWidget.createConnectionWidget(container); } } \ No newline at end of file diff --git a/src/sql/workbench/services/connection/browser/cmsConnectionWidget.ts b/src/sql/workbench/services/connection/browser/cmsConnectionWidget.ts index 359b14d589..d3de23907c 100644 --- a/src/sql/workbench/services/connection/browser/cmsConnectionWidget.ts +++ b/src/sql/workbench/services/connection/browser/cmsConnectionWidget.ts @@ -35,13 +35,12 @@ export class CmsConnectionWidget extends ConnectionWidget { private _serverDescriptionInputBox: InputBox; protected _authTypeMap: { [providerName: string]: AuthenticationType[] } = { - [Constants.cmsProviderName]: [AuthenticationType.SqlLogin, AuthenticationType.Integrated, AuthenticationType.AzureMFA] + [Constants.cmsProviderName]: [AuthenticationType.Integrated] }; constructor(options: azdata.ConnectionOption[], callbacks: IConnectionComponentCallbacks, providerName: string, - authTypeChanged: boolean = false, @IThemeService _themeService: IThemeService, @IContextViewService _contextViewService: IContextViewService, @ILayoutService _layoutService: ILayoutService, @@ -54,14 +53,8 @@ export class CmsConnectionWidget extends ConnectionWidget { super(options, callbacks, providerName, _themeService, _contextViewService, _connectionManagementService, _capabilitiesService, _clipboardService, _configurationService, _accountManagementService); let authTypeOption = this._optionsMaps[ConnectionOptionSpecialType.authType]; - if (authTypeOption) { - if (OS === OperatingSystem.Windows || authTypeChanged) { - authTypeOption.defaultValue = this.getAuthTypeDisplayName(AuthenticationType.Integrated); - } else { - authTypeOption.defaultValue = this.getAuthTypeDisplayName(AuthenticationType.SqlLogin); - } - this._authTypeSelectBox = new SelectBox(authTypeOption.categoryValues.map(c => c.displayName), authTypeOption.defaultValue, this._contextViewService, undefined, { ariaLabel: authTypeOption.displayName }); - } + authTypeOption.defaultValue = this.getAuthTypeDisplayName(AuthenticationType.Integrated); + this._authTypeSelectBox = new SelectBox(authTypeOption.categoryValues.map(c => c.displayName), authTypeOption.defaultValue, this._contextViewService, undefined, { ariaLabel: authTypeOption.displayName }); } protected registerListeners(): void { @@ -71,12 +64,12 @@ export class CmsConnectionWidget extends ConnectionWidget { } } - protected fillInConnectionForm(authTypeChanged: boolean = false): void { + protected fillInConnectionForm(): void { // Server Name this.addServerNameOption(); // Authentication type - this.addAuthenticationTypeOption(authTypeChanged); + this.addAuthenticationTypeOption(); // Login Options this.addLoginOptions(); @@ -91,25 +84,16 @@ export class CmsConnectionWidget extends ConnectionWidget { this.addAdvancedOptions(); } - protected addAuthenticationTypeOption(authTypeChanged: boolean = false): void { - super.addAuthenticationTypeOption(authTypeChanged); + protected addAuthenticationTypeOption(): void { + super.addAuthenticationTypeOption(); let authTypeOption = this._optionsMaps[ConnectionOptionSpecialType.authType]; let newAuthTypes = authTypeOption.categoryValues; - // True when opening a CMS dialog to add a registered server - if (authTypeChanged) { - // Registered Servers only support Integrated Auth - newAuthTypes = authTypeOption.categoryValues.filter((option) => option.name === AuthenticationType.Integrated); - this._authTypeSelectBox.setOptions(newAuthTypes.map(c => c.displayName), 0); - authTypeOption.defaultValue = AuthenticationType.Integrated; - } else { - // CMS supports all auth types - if (OS === OperatingSystem.Windows) { - authTypeOption.defaultValue = this.getAuthTypeDisplayName(AuthenticationType.Integrated); - } else { - authTypeOption.defaultValue = this.getAuthTypeDisplayName(AuthenticationType.SqlLogin); - } - this._authTypeSelectBox.setOptions(authTypeOption.categoryValues.map(c => c.displayName), 1); - } + + // CMS only supports Integrated Auth + newAuthTypes = authTypeOption.categoryValues.filter((option) => option.name === AuthenticationType.Integrated); + this._authTypeSelectBox.setOptions(newAuthTypes.map(c => c.displayName), 0); + authTypeOption.defaultValue = AuthenticationType.Integrated; + this._authTypeSelectBox.setOptions(authTypeOption.categoryValues.map(c => c.displayName), 1); } private addServerDescriptionOption(): void { @@ -123,10 +107,10 @@ export class CmsConnectionWidget extends ConnectionWidget { } } - public createConnectionWidget(container: HTMLElement, authTypeChanged: boolean = false): void { + public createConnectionWidget(container: HTMLElement): void { this._container = DOM.append(container, DOM.$('div.connection-table')); this._tableContainer = DOM.append(this._container, DOM.$('table.connection-table-content')); - this.fillInConnectionForm(authTypeChanged); + this.fillInConnectionForm(); this.registerListeners(); if (this._authTypeSelectBox) { this.onAuthTypeSelected(this._authTypeSelectBox.value); diff --git a/src/sql/workbench/services/connection/browser/connectionDialogService.ts b/src/sql/workbench/services/connection/browser/connectionDialogService.ts index b5098fd07e..c2712a08de 100644 --- a/src/sql/workbench/services/connection/browser/connectionDialogService.ts +++ b/src/sql/workbench/services/connection/browser/connectionDialogService.ts @@ -284,7 +284,7 @@ export class ConnectionDialogService implements IConnectionDialogService { this._connectionManagementService, this._capabilitiesService.getCapabilities(providerName).connection, { onSetConnectButton: (enable: boolean) => this.handleSetConnectButtonEnable(enable) - }, providerName, this._inputModel ? this._inputModel.options.authTypeChanged : false); + }, providerName); } else { this._connectionControllerMap[providerName] = this._instantiationService.createInstance(ConnectionController, @@ -322,12 +322,8 @@ export class ConnectionDialogService implements IConnectionDialogService { this._model.providerName = this._currentProviderType; this._model = new ConnectionProfile(this._capabilitiesService, this._model); - if (this._inputModel && this._inputModel.options) { - this.uiController.showUiComponent(input.container, - this._inputModel.options.authTypeChanged); - } else { - this.uiController.showUiComponent(input.container); - } + this.uiController.showUiComponent(input.container); + } private handleInitDialog() { diff --git a/src/sql/workbench/services/connection/browser/connectionWidget.ts b/src/sql/workbench/services/connection/browser/connectionWidget.ts index 580f9e0bdf..baef874b5f 100644 --- a/src/sql/workbench/services/connection/browser/connectionWidget.ts +++ b/src/sql/workbench/services/connection/browser/connectionWidget.ts @@ -123,13 +123,13 @@ export class ConnectionWidget { this._providerName = providerName; } - public createConnectionWidget(container: HTMLElement, authTypeChanged: boolean = false): void { + public createConnectionWidget(container: HTMLElement): void { this._serverGroupOptions = [this.DefaultServerGroup]; this._serverGroupSelectBox = new SelectBox(this._serverGroupOptions.map(g => g.name), this.DefaultServerGroup.name, this._contextViewService, undefined, { ariaLabel: this._serverGroupDisplayString }); this._previousGroupOption = this._serverGroupSelectBox.value; this._container = DOM.append(container, DOM.$('div.connection-table')); this._tableContainer = DOM.append(this._container, DOM.$('table.connection-table-content')); - this.fillInConnectionForm(authTypeChanged); + this.fillInConnectionForm(); this.registerListeners(); if (this._authTypeSelectBox) { this.onAuthTypeSelected(this._authTypeSelectBox.value); @@ -155,12 +155,12 @@ export class ConnectionWidget { } } - protected fillInConnectionForm(authTypeChanged: boolean = false): void { + protected fillInConnectionForm(): void { // Server Name this.addServerNameOption(); // Authentication type - this.addAuthenticationTypeOption(authTypeChanged); + this.addAuthenticationTypeOption(); // Login Options this.addLoginOptions(); @@ -178,7 +178,7 @@ export class ConnectionWidget { this.addAdvancedOptions(); } - protected addAuthenticationTypeOption(authTypeChanged: boolean = false): void { + protected addAuthenticationTypeOption(): void { if (this._optionsMaps[ConnectionOptionSpecialType.authType]) { let authType = DialogHelper.appendRow(this._tableContainer, this._optionsMaps[ConnectionOptionSpecialType.authType].displayName, 'connection-label', 'connection-input'); DialogHelper.appendInputSelectBox(authType, this._authTypeSelectBox);