add Encryption related welcome msg (#21048)

This commit is contained in:
Hai Cao
2022-11-01 09:42:16 -07:00
committed by GitHub
parent bb24eb29c5
commit 7ee9a22f03
4 changed files with 92 additions and 1 deletions

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 { NotifyEncryptionDialog } from 'sql/workbench/contrib/welcome/notifyEncryption/notifyEncryptionDialog'
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
export class NotifyEncryption extends Disposable implements IWorkbenchContribution {
constructor(
@IInstantiationService private readonly _instantiationService: IInstantiationService,
) {
super();
const dialog = this._instantiationService.createInstance(NotifyEncryptionDialog);
dialog.render();
dialog.open();
}
}
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(NotifyEncryption, LifecyclePhase.Starting);

View File

@@ -0,0 +1,61 @@
/*---------------------------------------------------------------------------------------------
* 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';
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,
@IClipboardService clipboardService: IClipboardService,
@ILayoutService layoutService: ILayoutService,
@IAdsTelemetryService telemetryService: IAdsTelemetryService,
@IContextKeyService contextKeyService: IContextKeyService,
@ILogService logService: ILogService,
@ITextResourcePropertiesService textResourcePropertiesService: ITextResourcePropertiesService,
@IInstantiationService private _instantiationService: IInstantiationService,
@IStorageService private _storageService: IStorageService
) {
super(themeService, clipboardService, layoutService, telemetryService, contextKeyService, logService, textResourcePropertiesService);
}
public override open(): void {
if (this._storageService.get(NotifyEncryptionDialog.NOTIFY_ENCRYPT_SHOWN, StorageScope.GLOBAL)) {
return;
}
super.open(Severity.Info,
localize('notifyEncryption.title', 'Important Update'),
localize('notifyEncryption.message', 'Azure Data Studio now has encryption enabled by default for all SQL Server connections. This may result in your existing connections no longer working.{0}We recommend you review the link below for more details.', '\n\n'),
null,
null);
this._storageService.store(NotifyEncryptionDialog.NOTIFY_ENCRYPT_SHOWN, true, StorageScope.GLOBAL, StorageTarget.MACHINE);
}
protected override updateDialogBody(): void {
super.updateDialogBody();
let moreInfoLink = DOM.append(this.getBody()!, DOM.$('.more-info'));
this._instantiationService.createInstance(Link, moreInfoLink,
{
label: localize('notifyEncryption.moreInfoLink', 'More information'),
href: NotifyEncryptionDialog.NOTIFY_ENCRYPT_LINK
}, undefined);
}
}

View File

@@ -106,11 +106,15 @@ export class ErrorMessageDialog extends Modal {
// Nothing to re-layout
}
private updateDialogBody(): void {
protected updateDialogBody(): void {
DOM.clearNode(this._body!);
DOM.append(this._body!, DOM.$('div.error-message')).innerText = this._message!;
}
protected getBody(): HTMLElement {
return this._body;
}
private updateIconTitle(): void {
switch (this._severity) {
case Severity.Error: