Skip to content

Commit

Permalink
Handle only user workspace trust settings (#14147)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhuebner authored Sep 18, 2024
1 parent bdbe90e commit f7d620b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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.'),
Expand Down
22 changes: 12 additions & 10 deletions packages/workspace/src/browser/workspace-trust-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -115,17 +115,19 @@ export class WorkspaceTrustService {
}

protected async handlePreferenceChange(change: PreferenceChange): Promise<void> {
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();
}
}
}

Expand Down

0 comments on commit f7d620b

Please sign in to comment.