From f7d620bc7115509d69d8f05e8d1436b2f9530acf Mon Sep 17 00:00:00 2001 From: Dennis Huebner Date: Wed, 18 Sep 2024 12:50:48 +0200 Subject: [PATCH] Handle only user workspace trust settings (#14147) --- .../browser/workspace-trust-preferences.ts | 3 ++- .../src/browser/workspace-trust-service.ts | 22 ++++++++++--------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/packages/workspace/src/browser/workspace-trust-preferences.ts b/packages/workspace/src/browser/workspace-trust-preferences.ts index 228c10ca55768..7657545e37760 100644 --- a/packages/workspace/src/browser/workspace-trust-preferences.ts +++ b/packages/workspace/src/browser/workspace-trust-preferences.ts @@ -15,7 +15,7 @@ // ***************************************************************************** import { - createPreferenceProxy, PreferenceContribution, PreferenceProxy, PreferenceSchema, PreferenceService + createPreferenceProxy, PreferenceContribution, PreferenceProxy, PreferenceSchema, PreferenceScope, PreferenceService } from '@theia/core/lib/browser/preferences'; import { nls } from '@theia/core/lib/common/nls'; import { interfaces } from '@theia/core/shared/inversify'; @@ -32,6 +32,7 @@ export enum WorkspaceTrustPrompt { export const workspaceTrustPreferenceSchema: PreferenceSchema = { type: 'object', + scope: PreferenceScope.User, properties: { [WORKSPACE_TRUST_ENABLED]: { description: nls.localize('theia/workspace/trustEnabled', 'Controls whether or not workspace trust is enabled. If disabled, all workspaces are trusted.'), diff --git a/packages/workspace/src/browser/workspace-trust-service.ts b/packages/workspace/src/browser/workspace-trust-service.ts index c7ed506edb7b9..6aaa7a7e7b6ad 100644 --- a/packages/workspace/src/browser/workspace-trust-service.ts +++ b/packages/workspace/src/browser/workspace-trust-service.ts @@ -15,7 +15,7 @@ // ***************************************************************************** import { ConfirmDialog, Dialog, PreferenceChange, StorageService } from '@theia/core/lib/browser'; -import { PreferenceService } from '@theia/core/lib/browser/preferences/preference-service'; +import { PreferenceScope, PreferenceService } from '@theia/core/lib/browser/preferences/preference-service'; import { MessageService } from '@theia/core/lib/common/message-service'; import { nls } from '@theia/core/lib/common/nls'; import { Deferred } from '@theia/core/lib/common/promise-util'; @@ -115,17 +115,19 @@ export class WorkspaceTrustService { } protected async handlePreferenceChange(change: PreferenceChange): Promise { - if (change.preferenceName === WORKSPACE_TRUST_STARTUP_PROMPT && change.newValue !== WorkspaceTrustPrompt.ONCE) { - this.storage.setData(STORAGE_TRUSTED, undefined); - } + if (change.scope === PreferenceScope.User) { + if (change.preferenceName === WORKSPACE_TRUST_STARTUP_PROMPT && change.newValue !== WorkspaceTrustPrompt.ONCE) { + this.storage.setData(STORAGE_TRUSTED, undefined); + } - if (change.preferenceName === WORKSPACE_TRUST_ENABLED && this.isWorkspaceTrustResolved() && await this.confirmRestart()) { - this.windowService.setSafeToShutDown(); - this.windowService.reload(); - } + if (change.preferenceName === WORKSPACE_TRUST_ENABLED && this.isWorkspaceTrustResolved() && await this.confirmRestart()) { + this.windowService.setSafeToShutDown(); + this.windowService.reload(); + } - if (change.preferenceName === WORKSPACE_TRUST_ENABLED || change.preferenceName === WORKSPACE_TRUST_EMPTY_WINDOW) { - this.resolveWorkspaceTrust(); + if (change.preferenceName === WORKSPACE_TRUST_ENABLED || change.preferenceName === WORKSPACE_TRUST_EMPTY_WINDOW) { + this.resolveWorkspaceTrust(); + } } }