Hide tenant dropdown from Connection Dialog (#22973)

This commit is contained in:
Cheena Malhotra
2023-05-05 10:40:00 -07:00
committed by GitHub
parent 876a4a24f6
commit 0dc05a6a4c
10 changed files with 153 additions and 15 deletions

View File

@@ -0,0 +1,10 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
export const NOTIFY_ENCRYPT_SHOWN = 'workbench.notifyEncryptionShown';
export const NOTIFY_HIDETENANT_SHOWN = 'workbench.notifyHiddenTenantShown';
// Link is regularly updated with new information from release.
export const NOTIFY_READMORE_LINK = 'https://aka.ms/azuredatastudio-connection';

View File

@@ -21,10 +21,9 @@ import { IOpenerService } from 'vs/platform/opener/common/opener';
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
import { TelemetryView } from 'sql/platform/telemetry/common/telemetryKeys';
import { NOTIFY_ENCRYPT_SHOWN, NOTIFY_READMORE_LINK } from 'sql/workbench/contrib/welcome/constants';
export class NotifyEncryptionDialog extends ErrorMessageDialog {
private static NOTIFY_ENCRYPT_SHOWN = 'workbench.notifyEncryptionShown';
private static NOTIFY_ENCRYPT_LINK = 'https://aka.ms/azuredatastudio-connection';
constructor(
@IThemeService themeService: IThemeService,
@@ -43,11 +42,11 @@ export class NotifyEncryptionDialog extends ErrorMessageDialog {
}
public override open(): void {
if (this._storageService.get(NotifyEncryptionDialog.NOTIFY_ENCRYPT_SHOWN, StorageScope.APPLICATION)) {
if (this._storageService.get(NOTIFY_ENCRYPT_SHOWN, StorageScope.APPLICATION)) {
return;
}
this._storageService.store(NotifyEncryptionDialog.NOTIFY_ENCRYPT_SHOWN, true, StorageScope.APPLICATION, StorageTarget.MACHINE);
this._storageService.store(NOTIFY_ENCRYPT_SHOWN, true, StorageScope.APPLICATION, StorageTarget.MACHINE);
if (!this._connectionManagementService.getConnections()?.some(conn => conn.providerName === mssqlProviderName)) {
return;
@@ -64,7 +63,7 @@ export class NotifyEncryptionDialog extends ErrorMessageDialog {
this._instantiationService.createInstance(Link, moreInfoLink,
{
label: localize('notifyEncryption.moreInfoLink', 'More information'),
href: NotifyEncryptionDialog.NOTIFY_ENCRYPT_LINK
href: NOTIFY_READMORE_LINK
}, undefined);
}
}

View File

@@ -0,0 +1,25 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Registry } from 'vs/platform/registry/common/platform';
import { Extensions as WorkbenchExtensions, IWorkbenchContributionsRegistry, IWorkbenchContribution } from 'vs/workbench/common/contributions';
import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle';
import { Disposable } from 'vs/base/common/lifecycle';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { NotifyHiddenTenantDialog } from 'sql/workbench/contrib/welcome/notifyHiddenTenant/notifyHiddenTenantDialog';
export class NotifyHiddenTenant extends Disposable implements IWorkbenchContribution {
constructor(
@IInstantiationService private readonly _instantiationService: IInstantiationService,
) {
super();
const dialog = this._instantiationService.createInstance(NotifyHiddenTenantDialog);
dialog.render();
dialog.open();
}
}
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(NotifyHiddenTenant, LifecyclePhase.Starting);

View File

@@ -0,0 +1,74 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import Severity from 'vs/base/common/severity';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
import { localize } from 'vs/nls';
import * as DOM from 'vs/base/browser/dom';
import { ILogService } from 'vs/platform/log/common/log';
import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry';
import { ILayoutService } from 'vs/platform/layout/browser/layoutService';
import { ITextResourcePropertiesService } from 'vs/editor/common/services/textResourceConfiguration';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ErrorMessageDialog } from 'sql/workbench/services/errorMessage/browser/errorMessageDialog';
import { Link } from 'vs/platform/opener/browser/link';
import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
import { IOpenerService } from 'vs/platform/opener/common/opener';
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
import { TelemetryView } from 'sql/platform/telemetry/common/telemetryKeys';
import { NOTIFY_HIDETENANT_SHOWN, NOTIFY_READMORE_LINK } from 'sql/workbench/contrib/welcome/constants';
import { IAccountManagementService } from 'sql/platform/accounts/common/interfaces';
export class NotifyHiddenTenantDialog extends ErrorMessageDialog {
constructor(
@IThemeService themeService: IThemeService,
@IClipboardService clipboardService: IClipboardService,
@ILayoutService layoutService: ILayoutService,
@IAdsTelemetryService telemetryService: IAdsTelemetryService,
@IContextKeyService contextKeyService: IContextKeyService,
@ILogService logService: ILogService,
@ITextResourcePropertiesService textResourcePropertiesService: ITextResourcePropertiesService,
@IOpenerService openerService: IOpenerService,
@IInstantiationService private _instantiationService: IInstantiationService,
@IStorageService private _storageService: IStorageService,
@IConnectionManagementService private _connectionManagementService: IConnectionManagementService,
@IAccountManagementService private _accountManagementService: IAccountManagementService
) {
super(themeService, clipboardService, layoutService, telemetryService, contextKeyService, logService, textResourcePropertiesService, openerService);
}
public override open(): void {
if (this._storageService.get(NOTIFY_HIDETENANT_SHOWN, StorageScope.APPLICATION)) {
return;
}
this._storageService.store(NOTIFY_HIDETENANT_SHOWN, true, StorageScope.APPLICATION, StorageTarget.MACHINE);
this._accountManagementService.getAccounts().then(accounts => {
// Do not notify users who don't have any Azure connection in their list of connections and no Azure accounts registered.
if (!this._connectionManagementService.getConnections()?.some(conn => conn.providerName === mssqlProviderName
&& conn.authenticationType === 'AzureMFA') && (!accounts || accounts.length === 0)) {
return;
}
super.open(TelemetryView.NotifyHiddenTenantDialog, Severity.Info,
localize('notifyHiddenTenant.title', 'Important Update'),
localize('notifyHiddenTenant.message', `Connections using Azure Active Directory authentication will now retrieve tenant information from the server during login. The 'Azure AD Tenant' entry no longer needs to be provided when connecting to Azure SQL instances.`, '\n\n'));
});
}
protected override updateDialogBody(): void {
super.updateDialogBody();
let moreInfoLink = DOM.append(this.getBody()!, DOM.$('.more-info'));
this._instantiationService.createInstance(Link, moreInfoLink,
{
label: localize('notifyHiddenTenant.moreInfoLink', 'More information'),
href: NOTIFY_READMORE_LINK
}, undefined);
}
}