mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-24 17:23:05 -05:00
Hide tenant dropdown from Connection Dialog (#22973)
This commit is contained in:
@@ -57,7 +57,7 @@ import { VIEWLET_ID as ExtensionsViewletID } from 'vs/workbench/contrib/extensio
|
||||
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
|
||||
import { IErrorDiagnosticsService } from 'sql/workbench/services/diagnostics/common/errorDiagnosticsService';
|
||||
import { PasswordChangeDialog } from 'sql/workbench/services/connection/browser/passwordChangeDialog';
|
||||
import { enableSqlAuthenticationProviderConfig, mssqlProviderName } from 'sql/platform/connection/common/constants';
|
||||
import { isMssqlAuthProviderEnabled } from 'sql/workbench/services/connection/browser/utils';
|
||||
|
||||
export class ConnectionManagementService extends Disposable implements IConnectionManagementService {
|
||||
|
||||
@@ -1141,7 +1141,7 @@ export class ConnectionManagementService extends Disposable implements IConnecti
|
||||
if (connectionProfile && connectionProfile.authenticationType === Constants.AuthenticationType.AzureMFA) {
|
||||
// We do not need to reconnect for MSSQL Provider, if 'SQL Authentication Provider' setting is enabled.
|
||||
// Update the token in case it needs refreshing/reauthentication.
|
||||
if (connectionProfile.providerName === mssqlProviderName && this.getEnableSqlAuthenticationProviderConfig()) {
|
||||
if (isMssqlAuthProviderEnabled(connectionProfile.providerName, this._configurationService)) {
|
||||
await this.fillInOrClearToken(connectionProfile);
|
||||
return true;
|
||||
}
|
||||
@@ -1181,10 +1181,6 @@ export class ConnectionManagementService extends Disposable implements IConnecti
|
||||
}
|
||||
}
|
||||
|
||||
private getEnableSqlAuthenticationProviderConfig(): boolean {
|
||||
return this._configurationService.getValue(enableSqlAuthenticationProviderConfig) ?? true;
|
||||
}
|
||||
|
||||
// Request Senders
|
||||
private async sendConnectRequest(connection: interfaces.IConnectionProfile, uri: string): Promise<boolean> {
|
||||
let connectionInfo = Object.assign({}, {
|
||||
|
||||
@@ -43,6 +43,7 @@ import { AdsWidget } from 'sql/base/browser/ui/adsWidget';
|
||||
import { createCSSRule } from 'vs/base/browser/dom';
|
||||
import { AuthLibrary, getAuthLibrary } from 'sql/workbench/services/accountManagement/utils';
|
||||
import { adjustForMssqlAppName } from 'sql/platform/connection/common/utils';
|
||||
import { isMssqlAuthProviderEnabled } from 'sql/workbench/services/connection/browser/utils';
|
||||
import { RequiredIndicatorClassName } from 'sql/base/browser/ui/label/label';
|
||||
|
||||
const ConnectionStringText = localize('connectionWidget.connectionString', "Connection string");
|
||||
@@ -75,6 +76,7 @@ export class ConnectionWidget extends lifecycle.Disposable {
|
||||
private _trueInputValue: string = localize('boolean.true', 'True');
|
||||
private _falseInputValue: string = localize('boolean.false', 'False');
|
||||
private _token: string;
|
||||
private _mssqlAuthProviderEnabled: boolean;
|
||||
private _connectionStringOptions: ConnectionStringOptions;
|
||||
protected _container: HTMLElement;
|
||||
protected _serverGroupSelectBox: SelectBox;
|
||||
@@ -144,6 +146,7 @@ export class ConnectionWidget extends lifecycle.Disposable {
|
||||
this._register(this._authTypeSelectBox);
|
||||
}
|
||||
this._providerName = providerName;
|
||||
this._mssqlAuthProviderEnabled = isMssqlAuthProviderEnabled(this._providerName, this._configurationService)
|
||||
this._connectionStringOptions = this._connectionManagementService.getProviderProperties(this._providerName).connectionStringOptions;
|
||||
}
|
||||
|
||||
@@ -648,6 +651,9 @@ export class ConnectionWidget extends lifecycle.Disposable {
|
||||
this._passwordInputBox.hideMessage();
|
||||
this._azureAccountDropdown.hideMessage();
|
||||
this._azureTenantDropdown.hideMessage();
|
||||
if (this._mssqlAuthProviderEnabled) {
|
||||
this._tableContainer.classList.add('hide-azure-tenants');
|
||||
}
|
||||
this._tableContainer.classList.add('hide-username');
|
||||
this._tableContainer.classList.add('hide-password');
|
||||
this._tableContainer.classList.add('hide-azure-accounts');
|
||||
@@ -795,7 +801,9 @@ export class ConnectionWidget extends lifecycle.Disposable {
|
||||
// There are multiple tenants available so let the user select one
|
||||
let options = selectedAccount.properties.tenants.map(tenant => tenant.displayName);
|
||||
this._azureTenantDropdown.setOptions(options);
|
||||
this._tableContainer.classList.remove(hideTenantsClassName);
|
||||
if (!this._mssqlAuthProviderEnabled) {
|
||||
this._tableContainer.classList.remove(hideTenantsClassName);
|
||||
}
|
||||
|
||||
// If we have a tenant ID available, select that instead of the first one
|
||||
if (this._azureTenantId) {
|
||||
@@ -820,7 +828,9 @@ export class ConnectionWidget extends lifecycle.Disposable {
|
||||
this._azureTenantId = selectedAccount.properties.tenants[0].id;
|
||||
this.onAzureTenantSelected(0);
|
||||
}
|
||||
this._tableContainer.classList.add(hideTenantsClassName);
|
||||
if (!this._mssqlAuthProviderEnabled) {
|
||||
this._tableContainer.classList.add(hideTenantsClassName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -972,6 +982,9 @@ export class ConnectionWidget extends lifecycle.Disposable {
|
||||
account = this._azureAccountList?.find(account => account.key.accountId === this.getModelValue(accountName)
|
||||
|| account.key.accountId.split('.')[0] === this.getModelValue(accountName));
|
||||
if (account) {
|
||||
if (!account.properties.tenants?.find(tenant => tenant.id === this._azureTenantId)) {
|
||||
this._azureTenantId = account.properties.tenants[0].id;
|
||||
}
|
||||
this._azureAccountDropdown.selectWithOptionName(account.key.accountId);
|
||||
}
|
||||
}
|
||||
|
||||
18
src/sql/workbench/services/connection/browser/utils.ts
Normal file
18
src/sql/workbench/services/connection/browser/utils.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { enableSqlAuthenticationProviderConfig, mssqlProviderName } from 'sql/platform/connection/common/constants';
|
||||
|
||||
/**
|
||||
* Reads setting 'mssql.enableSqlAuthenticationProvider' returns true if it's enabled.
|
||||
* Returns false for other providers.
|
||||
* @param provider Connection provider name
|
||||
* @param configService Configuration service instance
|
||||
* @returns True if provider is MSSQL and Sql Auth provider is enabled.
|
||||
*/
|
||||
export function isMssqlAuthProviderEnabled(provider: string, configService: IConfigurationService): boolean {
|
||||
return provider === mssqlProviderName && (configService?.getValue(enableSqlAuthenticationProviderConfig) ?? true);
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import { getErrorMessage, onUnexpectedError } from 'vs/base/common/errors';
|
||||
import { AsyncServerTree, ConnectionError as AsyncTreeConnectionError, ServerTreeElement } from 'sql/workbench/services/objectExplorer/browser/asyncServerTree';
|
||||
import { ObjectExplorerRequestStatus } from 'sql/workbench/services/objectExplorer/browser/treeSelectionHandler';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { localize } from 'vs/nls';
|
||||
|
||||
export interface IExpandableTree extends ITree {
|
||||
/**
|
||||
@@ -217,11 +218,11 @@ export class TreeUpdateUtils {
|
||||
}
|
||||
|
||||
const result = await connectionManagementService.connect(connection, undefined, options, callbacks);
|
||||
if (result.connected) {
|
||||
if (result?.connected) {
|
||||
let existingConnection = connectionManagementService.findExistingConnection(connection);
|
||||
return existingConnection;
|
||||
} else {
|
||||
throw new Error(result.errorMessage);
|
||||
throw new Error(result ? result.errorMessage : localize('connectionFailedError', 'Failed to connect, please try again.'));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user