Skip to content

Commit 12547c1

Browse files
authored
remove virtual workspace information from banner (microsoft#125512)
1 parent 6de86dc commit 12547c1

File tree

1 file changed

+25
-105
lines changed

1 file changed

+25
-105
lines changed

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

Lines changed: 25 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { Registry } from 'vs/platform/registry/common/platform';
1616
import { IWorkspaceTrustManagementService, IWorkspaceTrustRequestService, workspaceTrustToString } from 'vs/platform/workspace/common/workspaceTrust';
1717
import { Extensions as WorkbenchExtensions, IWorkbenchContribution, IWorkbenchContributionsRegistry } from 'vs/workbench/common/contributions';
1818
import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle';
19-
import { Codicon, registerCodicon } from 'vs/base/common/codicons';
19+
import { Codicon } from 'vs/base/common/codicons';
2020
import { ThemeColor } from 'vs/workbench/api/common/extHostTypes';
2121
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
2222
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
@@ -48,13 +48,8 @@ import { EditorInput } from 'vs/workbench/common/editor/editorInput';
4848
import { LIST_WORKSPACE_UNSUPPORTED_EXTENSIONS_COMMAND_ID } from 'vs/workbench/contrib/extensions/common/extensions';
4949

5050
const BANNER_RESTRICTED_MODE = 'workbench.banner.restrictedMode';
51-
const BANNER_VIRTUAL_WORKSPACE = 'workbench.banner.virtualWorkspace';
52-
const BANNER_VIRTUAL_AND_RESTRICTED = 'workbench.banner.virtualAndRestricted';
5351
const STARTUP_PROMPT_SHOWN_KEY = 'workspace.trust.startupPrompt.shown';
5452
const BANNER_RESTRICTED_MODE_DISMISSED_KEY = 'workbench.banner.restrictedMode.dismissed';
55-
const BANNER_VIRTUAL_WORKSPACE_DISMISSED_KEY = 'workbench.banner.virtualWorkspace.dismissed';
56-
57-
const infoIcon = registerCodicon('workspace-banner-warning-icon', Codicon.info);
5853

5954
/*
6055
* Trust Request via Service UX handler
@@ -126,7 +121,7 @@ export class WorkspaceTrustRequestHandler extends Disposable implements IWorkben
126121
break;
127122
case 'Manage':
128123
this.workspaceTrustRequestService.cancelRequest();
129-
await this.commandService.executeCommand('workbench.trust.manage');
124+
await this.commandService.executeCommand(MANAGE_TRUST_COMMAND_ID);
130125
break;
131126
case 'Cancel':
132127
this.workspaceTrustRequestService.cancelRequest();
@@ -310,130 +305,60 @@ export class WorkspaceTrustUXHandler extends Disposable implements IWorkbenchCon
310305
this.statusbarService.updateEntryVisibility(this.entryId, false);
311306
}
312307

313-
private getBannerItem(isInVirtualWorkspace: boolean, restrictedMode: boolean): IBannerItem | undefined {
308+
private getBannerItem(restrictedMode: boolean): IBannerItem | undefined {
314309

315-
const dismissedVirtual = this.storageService.getBoolean(BANNER_VIRTUAL_WORKSPACE_DISMISSED_KEY, StorageScope.WORKSPACE, false);
316310
const dismissedRestricted = this.storageService.getBoolean(BANNER_RESTRICTED_MODE_DISMISSED_KEY, StorageScope.WORKSPACE, false);
317311

318-
// all important info has been dismissed
319-
if (dismissedVirtual && dismissedRestricted) {
320-
return undefined;
321-
}
322-
323-
// don't show restricted mode only banner
324-
if (dismissedRestricted && !isInVirtualWorkspace) {
312+
// info has been dismissed
313+
if (dismissedRestricted) {
325314
return undefined;
326315
}
327316

328-
// don't show virtual workspace only banner
329-
if (dismissedVirtual && !restrictedMode) {
330-
return undefined;
331-
}
332-
333-
const choose = (virtual: any, restricted: any, virtualAndRestricted: any) => {
334-
return (isInVirtualWorkspace && !dismissedVirtual) && (restrictedMode && !dismissedRestricted) ? virtualAndRestricted : ((isInVirtualWorkspace && !dismissedVirtual) ? virtual : restricted);
335-
};
336-
337-
const id = choose(BANNER_VIRTUAL_WORKSPACE, BANNER_RESTRICTED_MODE, BANNER_VIRTUAL_AND_RESTRICTED);
338-
const icon = choose(infoIcon, shieldIcon, infoIcon);
339-
340-
341-
const [virtualAriaLabel, restrictedModeAriaLabel, virtualAndRestrictedModeAriaLabel] = this.getBannerItemAriaLabels();
342-
const ariaLabel = choose(virtualAriaLabel, restrictedModeAriaLabel, virtualAndRestrictedModeAriaLabel);
343-
344-
const [virtualMessage, restrictedModeMessage, virtualAndRestrictedModeMessage] = this.getBannerItemMessages();
345-
const message = choose(virtualMessage, restrictedModeMessage, virtualAndRestrictedModeMessage);
346-
347-
const actions = choose(
348-
[
349-
{
350-
label: localize('virtualBannerLearnMore', "Learn More"),
351-
href: 'https://aka.ms/vscode-virtual-workspaces'
352-
}
353-
],
317+
const actions =
354318
[
355319
{
356320
label: localize('restrictedModeBannerManage', "Manage"),
357-
href: 'command:workbench.trust.manage'
321+
href: 'command:' + MANAGE_TRUST_COMMAND_ID
358322
},
359323
{
360324
label: localize('restrictedModeBannerLearnMore', "Learn More"),
361325
href: 'https://aka.ms/vscode-workspace-trust'
362326
}
363-
],
364-
[
365-
{
366-
label: localize('virtualAndRestrictedModeBannerManage', "Manage Trust"),
367-
href: 'command:workbench.trust.manage'
368-
},
369-
{
370-
label: localize('virtualBannerLearnMore', "Learn More"),
371-
href: 'https://aka.ms/vscode-virtual-workspaces'
372-
}
373-
]
374-
);
327+
];
375328

376329
return {
377-
id,
378-
icon,
379-
ariaLabel,
380-
message,
330+
id: BANNER_RESTRICTED_MODE,
331+
icon: shieldIcon,
332+
ariaLabel: this.getBannerItemAriaLabels(),
333+
message: this.getBannerItemMessages(),
381334
actions,
382335
onClose: () => {
383-
if (isInVirtualWorkspace) {
384-
this.storageService.store(BANNER_VIRTUAL_WORKSPACE_DISMISSED_KEY, true, StorageScope.WORKSPACE, StorageTarget.MACHINE);
385-
}
386-
387336
if (restrictedMode) {
388337
this.storageService.store(BANNER_RESTRICTED_MODE_DISMISSED_KEY, true, StorageScope.WORKSPACE, StorageTarget.MACHINE);
389338
}
390339
}
391340
};
392341
}
393342

394-
private getBannerItemAriaLabels(): [string, string, string] {
343+
private getBannerItemAriaLabels(): string {
395344
switch (this.workspaceContextService.getWorkbenchState()) {
396345
case WorkbenchState.EMPTY:
397-
return [
398-
localize('virtualBannerAriaLabelWindow', "Some features are not available because the current window is backed by a virtual file system. Use navigation keys to access banner actions."),
399-
localize('restrictedModeBannerAriaLabelWindow', "Restricted Mode is intended for safe code browsing. Trust this window to enable all features. Use navigation keys to access banner actions."),
400-
localize('virtualAndRestrictedModeBannerAriaLabelWindow', "Some features are not available because the current window is backed by a virtual file system and is not trusted. You can trust this window to enable some of these features. Use navigation keys to access banner actions.")
401-
];
346+
return localize('restrictedModeBannerAriaLabelWindow', "Restricted Mode is intended for safe code browsing. Trust this window to enable all features. Use navigation keys to access banner actions.");
402347
case WorkbenchState.FOLDER:
403-
return [
404-
localize('virtualBannerAriaLabelFolder', "Some features are not available because the current folder is backed by a virtual file system. Use navigation keys to access banner actions."),
405-
localize('restrictedModeBannerAriaLabelFolder', "Restricted Mode is intended for safe code browsing. Trust this folder to enable all features. Use navigation keys to access banner actions."),
406-
localize('virtualAndRestrictedModeBannerAriaLabelFolder', "Some features are not available because the current folder is backed by a virtual file system and is not trusted. You can trust this folder to enable some of these features. Use navigation keys to access banner actions.")
407-
];
348+
return localize('restrictedModeBannerAriaLabelFolder', "Restricted Mode is intended for safe code browsing. Trust this folder to enable all features. Use navigation keys to access banner actions.");
408349
case WorkbenchState.WORKSPACE:
409-
return [
410-
localize('virtualBannerAriaLabelWorkspace', "Some features are not available because the current workspace is backed by a virtual file system. Use navigation keys to access banner actions."),
411-
localize('restrictedModeBannerAriaLabelWorkspace', "Restricted Mode is intended for safe code browsing. Trust this workspace to enable all features. Use navigation keys to access banner actions."),
412-
localize('virtualAndRestrictedModeBannerAriaLabelWorkspace', "Some features are not available because the current workspace is backed by a virtual file system and is not trusted. You can trust this workspace to enable some of these features. Use navigation keys to access banner actions.")
413-
];
350+
return localize('restrictedModeBannerAriaLabelWorkspace', "Restricted Mode is intended for safe code browsing. Trust this workspace to enable all features. Use navigation keys to access banner actions.");
414351
}
415352
}
416353

417-
private getBannerItemMessages(): [string, string, string] {
354+
private getBannerItemMessages(): string {
418355
switch (this.workspaceContextService.getWorkbenchState()) {
419356
case WorkbenchState.EMPTY:
420-
return [
421-
localize('virtualBannerMessageWindow', "Some features are not available because the current workspace is backed by a virtual file system."),
422-
localize('restrictedModeBannerMessageWindow', "Restricted Mode is intended for safe code browsing. Trust this window to enable all features."),
423-
localize('virtualAndRestrictedModeBannerMessageWindow', "Some features are not available because the current window is backed by a virtual file system and is not trusted. You can trust this window to enable some of these features.")
424-
];
357+
return localize('restrictedModeBannerMessageWindow', "Restricted Mode is intended for safe code browsing. Trust this window to enable all features.");
425358
case WorkbenchState.FOLDER:
426-
return [
427-
localize('virtualBannerMessageFolder', "Some features are not available because the current folder is backed by a virtual file system."),
428-
localize('restrictedModeBannerMessageFolder', "Restricted Mode is intended for safe code browsing. Trust this folder to enable all features."),
429-
localize('virtualAndRestrictedModeBannerMessageFolder', "Some features are not available because the current folder is backed by a virtual file system and is not trusted. You can trust this folder to enable some of these features.")
430-
];
359+
return localize('restrictedModeBannerMessageFolder', "Restricted Mode is intended for safe code browsing. Trust this folder to enable all features.");
431360
case WorkbenchState.WORKSPACE:
432-
return [
433-
localize('virtualBannerMessageWorkspace', "Some features are not available because the current workspace is backed by a virtual file system."),
434-
localize('restrictedModeBannerMessageWorkspace', "Restricted Mode is intended for safe code browsing. Trust this workspace to enable all features."),
435-
localize('virtualAndRestrictedModeBannerMessageWorkspace', "Some features are not available because the current workspace is backed by a virtual file system and is not trusted. You can trust this workspace to enable some of these features.")
436-
];
361+
return localize('restrictedModeBannerMessageWorkspace', "Restricted Mode is intended for safe code browsing. Trust this workspace to enable all features.");
437362
}
438363
}
439364

@@ -482,7 +407,7 @@ export class WorkspaceTrustUXHandler extends Disposable implements IWorkbenchCon
482407
text: trusted ? `$(shield)` : `$(shield) ${text}`,
483408
ariaLabel: ariaLabel,
484409
tooltip: toolTip,
485-
command: 'workbench.trust.manage',
410+
command: MANAGE_TRUST_COMMAND_ID,
486411
backgroundColor,
487412
color
488413
};
@@ -532,22 +457,17 @@ export class WorkspaceTrustUXHandler extends Disposable implements IWorkbenchCon
532457
}
533458

534459
private updateWorkbenchIndicators(trusted: boolean): void {
535-
const isInVirtualWorkspace = isVirtualWorkspace(this.workspaceContextService.getWorkspace());
536460
const isEmptyWorkspace = this.workspaceContextService.getWorkbenchState() === WorkbenchState.EMPTY;
537-
const bannerItem = this.getBannerItem(isInVirtualWorkspace, !trusted);
461+
const bannerItem = this.getBannerItem(!trusted);
538462

539463
if (!isEmptyWorkspace || this.showIndicatorsInEmptyWindow) {
540464
this.updateStatusbarEntry(trusted);
541465

542466
if (bannerItem) {
543-
if (!isInVirtualWorkspace) {
544-
if (!trusted) {
545-
this.bannerService.show(bannerItem);
546-
} else {
547-
this.bannerService.hide(BANNER_RESTRICTED_MODE);
548-
}
549-
} else {
467+
if (!trusted) {
550468
this.bannerService.show(bannerItem);
469+
} else {
470+
this.bannerService.hide(BANNER_RESTRICTED_MODE);
551471
}
552472
}
553473
}

0 commit comments

Comments
 (0)