Skip to content

Commit cdf55f8

Browse files
authored
workspace trust - cleanup unused code (microsoft#210388)
1 parent b41db61 commit cdf55f8

File tree

2 files changed

+10
-24
lines changed

2 files changed

+10
-24
lines changed

src/vs/platform/workspace/common/workspaceTrust.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,13 @@
66
import { Event } from 'vs/base/common/event';
77
import { IDisposable } from 'vs/base/common/lifecycle';
88
import { URI } from 'vs/base/common/uri';
9-
import { localize } from 'vs/nls';
109
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
1110

1211
export enum WorkspaceTrustScope {
1312
Local = 0,
1413
Remote = 1
1514
}
1615

17-
export function workspaceTrustToString(trustState: boolean) {
18-
if (trustState) {
19-
return localize('trusted', "Trusted");
20-
} else {
21-
return localize('untrusted', "Restricted Mode");
22-
}
23-
}
24-
2516
export interface WorkspaceTrustRequestButton {
2617
readonly label: string;
2718
readonly type: 'ContinueWithTrust' | 'ContinueWithoutTrust' | 'Manage' | 'Cancel';

src/vs/workbench/contrib/workspace/browser/workspace.contribution.ts

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
1313
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
1414
import { Severity } from 'vs/platform/notification/common/notification';
1515
import { Registry } from 'vs/platform/registry/common/platform';
16-
import { IWorkspaceTrustEnablementService, IWorkspaceTrustManagementService, IWorkspaceTrustRequestService, workspaceTrustToString, WorkspaceTrustUriResponse } from 'vs/platform/workspace/common/workspaceTrust';
16+
import { IWorkspaceTrustEnablementService, IWorkspaceTrustManagementService, IWorkspaceTrustRequestService, WorkspaceTrustUriResponse } from 'vs/platform/workspace/common/workspaceTrust';
1717
import { Extensions as WorkbenchExtensions, IWorkbenchContribution, IWorkbenchContributionsRegistry, WorkbenchPhase, registerWorkbenchContribution2 } from 'vs/workbench/common/contributions';
1818
import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle';
1919
import { Codicon } from 'vs/base/common/codicons';
@@ -561,16 +561,13 @@ export class WorkspaceTrustUXHandler extends Disposable implements IWorkbenchCon
561561

562562
//#region Statusbar
563563

564-
private getStatusbarEntry(trusted: boolean): IStatusbarEntry {
565-
const text = workspaceTrustToString(trusted);
566-
564+
private getRestrictedModeStatusbarEntry(): IStatusbarEntry {
567565
let ariaLabel = '';
568566
let toolTip: IMarkdownString | string | undefined;
569567
switch (this.workspaceContextService.getWorkbenchState()) {
570568
case WorkbenchState.EMPTY: {
571-
ariaLabel = trusted ? localize('status.ariaTrustedWindow', "This window is trusted.") :
572-
localize('status.ariaUntrustedWindow', "Restricted Mode: Some features are disabled because this window is not trusted.");
573-
toolTip = trusted ? ariaLabel : {
569+
ariaLabel = localize('status.ariaUntrustedWindow', "Restricted Mode: Some features are disabled because this window is not trusted.");
570+
toolTip = {
574571
value: localize(
575572
{ key: 'status.tooltipUntrustedWindow2', comment: ['[abc]({n}) are links. Only translate `features are disabled` and `window is not trusted`. Do not change brackets and parentheses or {n}'] },
576573
"Running in Restricted Mode\n\nSome [features are disabled]({0}) because this [window is not trusted]({1}).",
@@ -583,9 +580,8 @@ export class WorkspaceTrustUXHandler extends Disposable implements IWorkbenchCon
583580
break;
584581
}
585582
case WorkbenchState.FOLDER: {
586-
ariaLabel = trusted ? localize('status.ariaTrustedFolder', "This folder is trusted.") :
587-
localize('status.ariaUntrustedFolder', "Restricted Mode: Some features are disabled because this folder is not trusted.");
588-
toolTip = trusted ? ariaLabel : {
583+
ariaLabel = localize('status.ariaUntrustedFolder', "Restricted Mode: Some features are disabled because this folder is not trusted.");
584+
toolTip = {
589585
value: localize(
590586
{ key: 'status.tooltipUntrustedFolder2', comment: ['[abc]({n}) are links. Only translate `features are disabled` and `folder is not trusted`. Do not change brackets and parentheses or {n}'] },
591587
"Running in Restricted Mode\n\nSome [features are disabled]({0}) because this [folder is not trusted]({1}).",
@@ -598,9 +594,8 @@ export class WorkspaceTrustUXHandler extends Disposable implements IWorkbenchCon
598594
break;
599595
}
600596
case WorkbenchState.WORKSPACE: {
601-
ariaLabel = trusted ? localize('status.ariaTrustedWorkspace', "This workspace is trusted.") :
602-
localize('status.ariaUntrustedWorkspace', "Restricted Mode: Some features are disabled because this workspace is not trusted.");
603-
toolTip = trusted ? ariaLabel : {
597+
ariaLabel = localize('status.ariaUntrustedWorkspace', "Restricted Mode: Some features are disabled because this workspace is not trusted.");
598+
toolTip = {
604599
value: localize(
605600
{ key: 'status.tooltipUntrustedWorkspace2', comment: ['[abc]({n}) are links. Only translate `features are disabled` and `workspace is not trusted`. Do not change brackets and parentheses or {n}'] },
606601
"Running in Restricted Mode\n\nSome [features are disabled]({0}) because this [workspace is not trusted]({1}).",
@@ -616,7 +611,7 @@ export class WorkspaceTrustUXHandler extends Disposable implements IWorkbenchCon
616611

617612
return {
618613
name: localize('status.WorkspaceTrust', "Workspace Trust"),
619-
text: trusted ? `$(shield)` : `$(shield) ${text}`,
614+
text: `$(shield) ${localize('untrusted', "Restricted Mode")}`,
620615
ariaLabel: ariaLabel,
621616
tooltip: toolTip,
622617
command: MANAGE_TRUST_COMMAND_ID,
@@ -631,7 +626,7 @@ export class WorkspaceTrustUXHandler extends Disposable implements IWorkbenchCon
631626
}
632627

633628
if (!trusted && !this.statusbarEntryAccessor.value) {
634-
const entry = this.getStatusbarEntry(trusted);
629+
const entry = this.getRestrictedModeStatusbarEntry();
635630
this.statusbarEntryAccessor.value = this.statusbarService.addEntry(entry, this.entryId, StatusbarAlignment.LEFT, 0.99 * Number.MAX_VALUE /* Right of remote indicator */);
636631
}
637632
}

0 commit comments

Comments
 (0)