Add confirmation for workspace trust state transition

This commit is contained in:
Ladislau Szomoru 2021-03-27 21:12:01 +01:00
parent c2b5d3d471
commit c4eb927231
No known key found for this signature in database
GPG key ID: 2B88287CB9DB080B

View file

@ -16,6 +16,7 @@ import { ScrollbarVisibility } from 'vs/base/common/scrollable';
import { isArray } from 'vs/base/common/types';
import { URI } from 'vs/base/common/uri';
import { localize } from 'vs/nls';
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
import { ExtensionWorkspaceTrustRequirement, getExtensionWorkspaceTrustRequirement } from 'vs/platform/extensions/common/extensions';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { Link } from 'vs/platform/opener/browser/link';
@ -77,7 +78,8 @@ export class WorkspaceTrustEditor extends EditorPane {
@IStorageService storageService: IStorageService,
@IWorkspaceContextService private readonly workspaceService: IWorkspaceContextService,
@IExtensionsWorkbenchService private readonly extensionWorkbenchService: IExtensionsWorkbenchService,
@IInstantiationService private readonly instantiationService: IInstantiationService
@IInstantiationService private readonly instantiationService: IInstantiationService,
@IDialogService private readonly dialogService: IDialogService
) { super(WorkspaceTrustEditor.ID, telemetryService, themeService, storageService); }
protected createEditor(parent: HTMLElement): void {
@ -214,8 +216,19 @@ export class WorkspaceTrustEditor extends EditorPane {
this.rerenderDisposables.add(attachButtonStyler(button, this.themeService));
};
const setTrustState = async (state: WorkspaceTrustState) => {
if (state !== WorkspaceTrustState.Trusted) {
const message = localize('workspaceTrustTransitionMessage', "Deny Workspace Trust");
const detail = localize('workspaceTrustTransitionDetail', "In order to safely complete this action, all affected windows will have to be reloaded. Are you sure you want to proceed with this action?");
const primaryButton = localize('workspaceTrustTransitionPrimaryButton', "Yes");
const secondaryButton = localize('workspaceTrustTransitionSecondaryButton', "No");
const result = await this.dialogService.confirm({ type: 'info', message, detail, primaryButton, secondaryButton });
if (!result.confirmed) {
return;
}
}
const setTrustState = (state: WorkspaceTrustState) => {
this.workspaceService.getWorkspace().folders.forEach(folder => {
this.workspaceTrustEditorModel.dataModel.setFolderTrustState(folder.uri, state);
});