@codingame/monaco-vscode-api 1.82.2 → 1.82.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/missing-services.js +17 -0
- package/monaco-editor-treemending.patch +551 -551
- package/package.json +1 -1
- package/service-override/quickaccess.js +1 -1
- package/service-override/tools/editor.d.ts +1 -1
- package/service-override/views.js +10 -0
- package/service-override/workspaceTrust.d.ts +5 -0
- package/service-override/workspaceTrust.js +13 -0
- package/services.d.ts +3 -0
- package/services.js +3 -0
- package/vscode/src/vs/base/common/htmlContent.d.ts +23 -2
- package/vscode/src/vs/platform/extensionManagement/common/extensionManagementUtil.js +16 -1
- package/vscode/src/vs/platform/opener/browser/link.d.ts +8 -0
- package/vscode/src/vs/platform/workspace/common/workspaceTrust.d.ts +34 -1
- package/vscode/src/vs/workbench/browser/parts/banner/bannerPart.js +228 -0
- package/vscode/src/vs/workbench/browser/parts/banner/media/bannerpart.css.js +4 -0
- package/vscode/src/vs/workbench/browser/parts/panel/panelActions.js +21 -0
- package/vscode/src/vs/workbench/browser/parts/titlebar/commandCenterControl.js +134 -0
- package/vscode/src/vs/workbench/browser/parts/titlebar/media/titlebarpart.css.js +4 -0
- package/vscode/src/vs/workbench/browser/parts/titlebar/titlebarPart.js +365 -0
- package/vscode/src/vs/workbench/browser/parts/titlebar/windowTitle.js +216 -0
- package/vscode/src/vs/workbench/common/contextkeys.js +2 -1
- package/vscode/src/vs/workbench/common/theme.js +6 -6
- package/vscode/src/vs/workbench/contrib/extensions/common/extensions.js +2 -1
- package/vscode/src/vs/workbench/contrib/preferences/browser/preferences.contribution.js +108 -4
- package/vscode/src/vs/workbench/contrib/workspace/browser/media/workspaceTrustEditor.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/workspace/browser/workspace.contribution.js +842 -0
- package/vscode/src/vs/workbench/contrib/workspace/browser/workspaceTrustEditor.js +1047 -0
- package/vscode/src/vs/workbench/contrib/workspace/common/workspace.js +14 -0
- package/vscode/src/vs/workbench/services/banner/browser/bannerService.d.ts +25 -0
- package/vscode/src/vs/workbench/services/banner/browser/bannerService.js +3 -0
- package/vscode/src/vs/workbench/services/title/common/titleService.d.ts +31 -0
- package/vscode/src/vs/workbench/services/title/common/titleService.js +3 -0
- package/vscode/src/vs/workbench/services/userDataProfile/common/userDataProfile.js +3 -1
- package/vscode/src/vs/workbench/services/workspaces/browser/workspaceTrustEditorInput.js +27 -0
- package/vscode/src/vs/workbench/services/workspaces/common/workspaceTrust.js +649 -1
|
@@ -0,0 +1,1047 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import { $, addDisposableListener, EventType, EventHelper, addStandardDisposableListener, clearNode, append, isAncestor } from 'monaco-editor/esm/vs/base/browser/dom.js';
|
|
3
|
+
import { ActionBar } from 'monaco-editor/esm/vs/base/browser/ui/actionbar/actionbar.js';
|
|
4
|
+
import { ButtonBar } from 'monaco-editor/esm/vs/base/browser/ui/button/button.js';
|
|
5
|
+
import { InputBox } from 'monaco-editor/esm/vs/base/browser/ui/inputbox/inputBox.js';
|
|
6
|
+
import { DomScrollableElement } from 'monaco-editor/esm/vs/base/browser/ui/scrollbar/scrollableElement.js';
|
|
7
|
+
import { Action } from 'monaco-editor/esm/vs/base/common/actions.js';
|
|
8
|
+
import { Codicon } from 'monaco-editor/esm/vs/base/common/codicons.js';
|
|
9
|
+
import { debounce } from 'monaco-editor/esm/vs/base/common/decorators.js';
|
|
10
|
+
import { Emitter } from 'monaco-editor/esm/vs/base/common/event.js';
|
|
11
|
+
import { normalizeDriveLetter } from 'monaco-editor/esm/vs/base/common/labels.js';
|
|
12
|
+
import { DisposableStore, Disposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
|
|
13
|
+
import { parseLinkedText } from 'monaco-editor/esm/vs/base/common/linkedText.js';
|
|
14
|
+
import { Schemas } from 'monaco-editor/esm/vs/base/common/network.js';
|
|
15
|
+
import { URI } from 'monaco-editor/esm/vs/base/common/uri.js';
|
|
16
|
+
import { localize } from 'monaco-editor/esm/vs/nls.js';
|
|
17
|
+
import { Extensions } from 'monaco-editor/esm/vs/platform/configuration/common/configurationRegistry.js';
|
|
18
|
+
import { IContextViewService } from 'monaco-editor/esm/vs/platform/contextview/browser/contextView.js';
|
|
19
|
+
import '../../../../../../../override/vs/platform/dialogs/common/dialogs.js';
|
|
20
|
+
import { IInstantiationService } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
|
|
21
|
+
import { ILabelService } from 'monaco-editor/esm/vs/platform/label/common/label.js';
|
|
22
|
+
import { WorkbenchTable } from 'monaco-editor/esm/vs/platform/list/browser/listService.js';
|
|
23
|
+
import { Link } from 'monaco-editor/esm/vs/platform/opener/browser/link.js';
|
|
24
|
+
import { Registry } from 'monaco-editor/esm/vs/platform/registry/common/platform.js';
|
|
25
|
+
import { isVirtualResource, isVirtualWorkspace } from '../../../../platform/workspace/common/virtualWorkspace.js';
|
|
26
|
+
import { IStorageService } from 'monaco-editor/esm/vs/platform/storage/common/storage.js';
|
|
27
|
+
import { ITelemetryService } from 'monaco-editor/esm/vs/platform/telemetry/common/telemetry.js';
|
|
28
|
+
import { asCssVariable, buttonBackground, buttonSecondaryBackground, editorErrorForeground } from 'monaco-editor/esm/vs/platform/theme/common/colorRegistry.js';
|
|
29
|
+
import { toWorkspaceIdentifier, IWorkspaceContextService } from 'monaco-editor/esm/vs/platform/workspace/common/workspace.js';
|
|
30
|
+
import { IThemeService } from 'monaco-editor/esm/vs/platform/theme/common/themeService.js';
|
|
31
|
+
import { ThemeIcon } from 'monaco-editor/esm/vs/base/common/themables.js';
|
|
32
|
+
import { IWorkspaceTrustManagementService } from 'monaco-editor/esm/vs/platform/workspace/common/workspaceTrust.js';
|
|
33
|
+
import { EditorPane } from '../../../browser/parts/editor/editorPane.js';
|
|
34
|
+
import { debugIconStartForeground } from '../../debug/browser/debugColors.js';
|
|
35
|
+
import { LIST_WORKSPACE_UNSUPPORTED_EXTENSIONS_COMMAND_ID, IExtensionsWorkbenchService } from '../../extensions/common/extensions.js';
|
|
36
|
+
import { IWorkbenchConfigurationService } from '../../../services/configuration/common/configuration.js';
|
|
37
|
+
import { IExtensionManifestPropertiesService } from '../../../services/extensions/common/extensionManifestPropertiesService.js';
|
|
38
|
+
import { IUriIdentityService } from 'monaco-editor/esm/vs/platform/uriIdentity/common/uriIdentity.js';
|
|
39
|
+
import { getExtensionDependencies } from '../../../../platform/extensionManagement/common/extensionManagementUtil.js';
|
|
40
|
+
import { IWorkbenchExtensionEnablementService } from '../../../services/extensionManagement/common/extensionManagement.js';
|
|
41
|
+
import { posix, win32 } from 'monaco-editor/esm/vs/base/common/path.js';
|
|
42
|
+
import { hasDriveLetter, toSlashes } from 'monaco-editor/esm/vs/base/common/extpath.js';
|
|
43
|
+
import { StandardKeyboardEvent } from 'monaco-editor/esm/vs/base/browser/keyboardEvent.js';
|
|
44
|
+
import { IProductService } from 'monaco-editor/esm/vs/platform/product/common/productService.js';
|
|
45
|
+
import { registerIcon } from 'monaco-editor/esm/vs/platform/theme/common/iconRegistry.js';
|
|
46
|
+
import { defaultButtonStyles, defaultInputBoxStyles } from 'monaco-editor/esm/vs/platform/theme/browser/defaultStyles.js';
|
|
47
|
+
import { isMacintosh } from 'monaco-editor/esm/vs/base/common/platform.js';
|
|
48
|
+
import { IKeybindingService } from 'monaco-editor/esm/vs/platform/keybinding/common/keybinding.js';
|
|
49
|
+
import { basename, dirname } from 'monaco-editor/esm/vs/base/common/resources.js';
|
|
50
|
+
import { IFileDialogService } from '../../../../platform/dialogs/common/dialogs.js';
|
|
51
|
+
var TrustedUriActionsColumnRenderer_1, TrustedUriPathColumnRenderer_1, TrustedUriHostColumnRenderer_1, WorkspaceTrustEditor_1;
|
|
52
|
+
const shieldIcon = registerIcon('workspace-trust-banner', Codicon.shield, ( (localize('shieldIcon', 'Icon for workspace trust ion the banner.'))));
|
|
53
|
+
const checkListIcon = registerIcon('workspace-trust-editor-check', Codicon.check, ( (localize('checkListIcon', 'Icon for the checkmark in the workspace trust editor.'))));
|
|
54
|
+
const xListIcon = registerIcon('workspace-trust-editor-cross', Codicon.x, ( (localize('xListIcon', 'Icon for the cross in the workspace trust editor.'))));
|
|
55
|
+
const folderPickerIcon = registerIcon('workspace-trust-editor-folder-picker', Codicon.folder, ( (localize(
|
|
56
|
+
'folderPickerIcon',
|
|
57
|
+
'Icon for the pick folder icon in the workspace trust editor.'
|
|
58
|
+
))));
|
|
59
|
+
const editIcon = registerIcon('workspace-trust-editor-edit-folder', Codicon.edit, ( (localize('editIcon', 'Icon for the edit folder icon in the workspace trust editor.'))));
|
|
60
|
+
const removeIcon = registerIcon('workspace-trust-editor-remove-folder', Codicon.close, ( (localize(
|
|
61
|
+
'removeIcon',
|
|
62
|
+
'Icon for the remove folder icon in the workspace trust editor.'
|
|
63
|
+
))));
|
|
64
|
+
let WorkspaceTrustedUrisTable = class WorkspaceTrustedUrisTable extends Disposable {
|
|
65
|
+
constructor(container, instantiationService, workspaceService, workspaceTrustManagementService, uriService, labelService, fileDialogService) {
|
|
66
|
+
super();
|
|
67
|
+
this.container = container;
|
|
68
|
+
this.instantiationService = instantiationService;
|
|
69
|
+
this.workspaceService = workspaceService;
|
|
70
|
+
this.workspaceTrustManagementService = workspaceTrustManagementService;
|
|
71
|
+
this.uriService = uriService;
|
|
72
|
+
this.labelService = labelService;
|
|
73
|
+
this.fileDialogService = fileDialogService;
|
|
74
|
+
this._onDidAcceptEdit = this._register(( (new Emitter())));
|
|
75
|
+
this.onDidAcceptEdit = this._onDidAcceptEdit.event;
|
|
76
|
+
this._onDidRejectEdit = this._register(( (new Emitter())));
|
|
77
|
+
this.onDidRejectEdit = this._onDidRejectEdit.event;
|
|
78
|
+
this._onEdit = this._register(( (new Emitter())));
|
|
79
|
+
this.onEdit = this._onEdit.event;
|
|
80
|
+
this._onDelete = this._register(( (new Emitter())));
|
|
81
|
+
this.onDelete = this._onDelete.event;
|
|
82
|
+
this.descriptionElement = container.appendChild($('.workspace-trusted-folders-description'));
|
|
83
|
+
const tableElement = container.appendChild($('.trusted-uris-table'));
|
|
84
|
+
const addButtonBarElement = container.appendChild($('.trusted-uris-button-bar'));
|
|
85
|
+
this.table = this.instantiationService.createInstance(WorkbenchTable, 'WorkspaceTrust', tableElement, ( (new TrustedUriTableVirtualDelegate())), [
|
|
86
|
+
{
|
|
87
|
+
label: ( (localize('hostColumnLabel', "Host"))),
|
|
88
|
+
tooltip: '',
|
|
89
|
+
weight: 1,
|
|
90
|
+
templateId: TrustedUriHostColumnRenderer.TEMPLATE_ID,
|
|
91
|
+
project(row) { return row; }
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
label: ( (localize('pathColumnLabel', "Path"))),
|
|
95
|
+
tooltip: '',
|
|
96
|
+
weight: 8,
|
|
97
|
+
templateId: TrustedUriPathColumnRenderer.TEMPLATE_ID,
|
|
98
|
+
project(row) { return row; }
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
label: '',
|
|
102
|
+
tooltip: '',
|
|
103
|
+
weight: 1,
|
|
104
|
+
minimumWidth: 75,
|
|
105
|
+
maximumWidth: 75,
|
|
106
|
+
templateId: TrustedUriActionsColumnRenderer.TEMPLATE_ID,
|
|
107
|
+
project(row) { return row; }
|
|
108
|
+
},
|
|
109
|
+
], [
|
|
110
|
+
this.instantiationService.createInstance(TrustedUriHostColumnRenderer),
|
|
111
|
+
this.instantiationService.createInstance(TrustedUriPathColumnRenderer, this),
|
|
112
|
+
this.instantiationService.createInstance(TrustedUriActionsColumnRenderer, this, this.currentWorkspaceUri),
|
|
113
|
+
], {
|
|
114
|
+
horizontalScrolling: false,
|
|
115
|
+
alwaysConsumeMouseWheel: false,
|
|
116
|
+
openOnSingleClick: false,
|
|
117
|
+
multipleSelectionSupport: false,
|
|
118
|
+
accessibilityProvider: {
|
|
119
|
+
getAriaLabel: (item) => {
|
|
120
|
+
const hostLabel = getHostLabel(this.labelService, item);
|
|
121
|
+
if (hostLabel === undefined || hostLabel.length === 0) {
|
|
122
|
+
return (
|
|
123
|
+
(localize(
|
|
124
|
+
'trustedFolderAriaLabel',
|
|
125
|
+
"{0}, trusted",
|
|
126
|
+
this.labelService.getUriLabel(item.uri)
|
|
127
|
+
))
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
return (
|
|
131
|
+
(localize(
|
|
132
|
+
'trustedFolderWithHostAriaLabel',
|
|
133
|
+
"{0} on {1}, trusted",
|
|
134
|
+
this.labelService.getUriLabel(item.uri),
|
|
135
|
+
hostLabel
|
|
136
|
+
))
|
|
137
|
+
);
|
|
138
|
+
},
|
|
139
|
+
getWidgetAriaLabel: () => ( (localize('trustedFoldersAndWorkspaces', "Trusted Folders & Workspaces")))
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
this._register(this.table.onDidOpen(item => {
|
|
143
|
+
if (item && item.element && !item.browserEvent?.defaultPrevented) {
|
|
144
|
+
this.edit(item.element, true);
|
|
145
|
+
}
|
|
146
|
+
}));
|
|
147
|
+
const buttonBar = this._register(( (new ButtonBar(addButtonBarElement))));
|
|
148
|
+
const addButton = this._register(buttonBar.addButton({ title: ( (localize('addButton', "Add Folder"))), ...defaultButtonStyles }));
|
|
149
|
+
addButton.label = ( (localize('addButton', "Add Folder")));
|
|
150
|
+
this._register(addButton.onDidClick(async () => {
|
|
151
|
+
const uri = await this.fileDialogService.showOpenDialog({
|
|
152
|
+
canSelectFiles: false,
|
|
153
|
+
canSelectFolders: true,
|
|
154
|
+
canSelectMany: false,
|
|
155
|
+
defaultUri: this.currentWorkspaceUri,
|
|
156
|
+
openLabel: ( (localize('trustUri', "Trust Folder"))),
|
|
157
|
+
title: ( (localize('selectTrustedUri', "Select Folder To Trust")))
|
|
158
|
+
});
|
|
159
|
+
if (uri) {
|
|
160
|
+
this.workspaceTrustManagementService.setUrisTrust(uri, true);
|
|
161
|
+
}
|
|
162
|
+
}));
|
|
163
|
+
this._register(this.workspaceTrustManagementService.onDidChangeTrustedFolders(() => {
|
|
164
|
+
this.updateTable();
|
|
165
|
+
}));
|
|
166
|
+
}
|
|
167
|
+
getIndexOfTrustedUriEntry(item) {
|
|
168
|
+
const index = this.trustedUriEntries.indexOf(item);
|
|
169
|
+
if (index === -1) {
|
|
170
|
+
for (let i = 0; i < this.trustedUriEntries.length; i++) {
|
|
171
|
+
if (this.trustedUriEntries[i].uri === item.uri) {
|
|
172
|
+
return i;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return index;
|
|
177
|
+
}
|
|
178
|
+
selectTrustedUriEntry(item, focus = true) {
|
|
179
|
+
const index = this.getIndexOfTrustedUriEntry(item);
|
|
180
|
+
if (index !== -1) {
|
|
181
|
+
if (focus) {
|
|
182
|
+
this.table.domFocus();
|
|
183
|
+
this.table.setFocus([index]);
|
|
184
|
+
}
|
|
185
|
+
this.table.setSelection([index]);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
get currentWorkspaceUri() {
|
|
189
|
+
return this.workspaceService.getWorkspace().folders[0]?.uri || URI.file('/');
|
|
190
|
+
}
|
|
191
|
+
get trustedUriEntries() {
|
|
192
|
+
const currentWorkspace = this.workspaceService.getWorkspace();
|
|
193
|
+
const currentWorkspaceUris = ( (currentWorkspace.folders.map(folder => folder.uri)));
|
|
194
|
+
if (currentWorkspace.configuration) {
|
|
195
|
+
currentWorkspaceUris.push(currentWorkspace.configuration);
|
|
196
|
+
}
|
|
197
|
+
const entries = ( (this.workspaceTrustManagementService.getTrustedUris().map(uri => {
|
|
198
|
+
let relatedToCurrentWorkspace = false;
|
|
199
|
+
for (const workspaceUri of currentWorkspaceUris) {
|
|
200
|
+
relatedToCurrentWorkspace = relatedToCurrentWorkspace || this.uriService.extUri.isEqualOrParent(workspaceUri, uri);
|
|
201
|
+
}
|
|
202
|
+
return {
|
|
203
|
+
uri,
|
|
204
|
+
parentOfWorkspaceItem: relatedToCurrentWorkspace
|
|
205
|
+
};
|
|
206
|
+
})));
|
|
207
|
+
const sortedEntries = entries.sort((a, b) => {
|
|
208
|
+
if (a.uri.scheme !== b.uri.scheme) {
|
|
209
|
+
if (a.uri.scheme === Schemas.file) {
|
|
210
|
+
return -1;
|
|
211
|
+
}
|
|
212
|
+
if (b.uri.scheme === Schemas.file) {
|
|
213
|
+
return 1;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
const aIsWorkspace = a.uri.path.endsWith('.code-workspace');
|
|
217
|
+
const bIsWorkspace = b.uri.path.endsWith('.code-workspace');
|
|
218
|
+
if (aIsWorkspace !== bIsWorkspace) {
|
|
219
|
+
if (aIsWorkspace) {
|
|
220
|
+
return 1;
|
|
221
|
+
}
|
|
222
|
+
if (bIsWorkspace) {
|
|
223
|
+
return -1;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return a.uri.fsPath.localeCompare(b.uri.fsPath);
|
|
227
|
+
});
|
|
228
|
+
return sortedEntries;
|
|
229
|
+
}
|
|
230
|
+
layout() {
|
|
231
|
+
this.table.layout((this.trustedUriEntries.length * TrustedUriTableVirtualDelegate.ROW_HEIGHT) + TrustedUriTableVirtualDelegate.HEADER_ROW_HEIGHT, undefined);
|
|
232
|
+
}
|
|
233
|
+
updateTable() {
|
|
234
|
+
const entries = this.trustedUriEntries;
|
|
235
|
+
this.container.classList.toggle('empty', entries.length === 0);
|
|
236
|
+
this.descriptionElement.innerText = entries.length ?
|
|
237
|
+
( (localize(
|
|
238
|
+
'trustedFoldersDescription',
|
|
239
|
+
"You trust the following folders, their subfolders, and workspace files."
|
|
240
|
+
))) :
|
|
241
|
+
( (localize(
|
|
242
|
+
'noTrustedFoldersDescriptions',
|
|
243
|
+
"You haven't trusted any folders or workspace files yet."
|
|
244
|
+
)));
|
|
245
|
+
this.table.splice(0, Number.POSITIVE_INFINITY, this.trustedUriEntries);
|
|
246
|
+
this.layout();
|
|
247
|
+
}
|
|
248
|
+
validateUri(path, item) {
|
|
249
|
+
if (!item) {
|
|
250
|
+
return null;
|
|
251
|
+
}
|
|
252
|
+
if (item.uri.scheme === 'vscode-vfs') {
|
|
253
|
+
const segments = path.split(posix.sep).filter(s => s.length);
|
|
254
|
+
if (segments.length === 0 && path.startsWith(posix.sep)) {
|
|
255
|
+
return {
|
|
256
|
+
type: 2 ,
|
|
257
|
+
content: ( (localize(
|
|
258
|
+
{ key: 'trustAll', comment: ['The {0} will be a host name where repositories are hosted.'] },
|
|
259
|
+
"You will trust all repositories on {0}.",
|
|
260
|
+
getHostLabel(this.labelService, item)
|
|
261
|
+
)))
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
if (segments.length === 1) {
|
|
265
|
+
return {
|
|
266
|
+
type: 2 ,
|
|
267
|
+
content: ( (localize(
|
|
268
|
+
{ key: 'trustOrg', comment: ['The {0} will be an organization or user name.', 'The {1} will be a host name where repositories are hosted.'] },
|
|
269
|
+
"You will trust all repositories and forks under '{0}' on {1}.",
|
|
270
|
+
segments[0],
|
|
271
|
+
getHostLabel(this.labelService, item)
|
|
272
|
+
)))
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
if (segments.length > 2) {
|
|
276
|
+
return {
|
|
277
|
+
type: 3 ,
|
|
278
|
+
content: ( (localize(
|
|
279
|
+
'invalidTrust',
|
|
280
|
+
"You cannot trust individual folders within a repository.",
|
|
281
|
+
path
|
|
282
|
+
)))
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
return null;
|
|
287
|
+
}
|
|
288
|
+
acceptEdit(item, uri) {
|
|
289
|
+
const trustedFolders = this.workspaceTrustManagementService.getTrustedUris();
|
|
290
|
+
const index = trustedFolders.findIndex(u => this.uriService.extUri.isEqual(u, item.uri));
|
|
291
|
+
if (index >= trustedFolders.length || index === -1) {
|
|
292
|
+
trustedFolders.push(uri);
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
trustedFolders[index] = uri;
|
|
296
|
+
}
|
|
297
|
+
this.workspaceTrustManagementService.setTrustedUris(trustedFolders);
|
|
298
|
+
this._onDidAcceptEdit.fire(item);
|
|
299
|
+
}
|
|
300
|
+
rejectEdit(item) {
|
|
301
|
+
this._onDidRejectEdit.fire(item);
|
|
302
|
+
}
|
|
303
|
+
async delete(item) {
|
|
304
|
+
await this.workspaceTrustManagementService.setUrisTrust([item.uri], false);
|
|
305
|
+
this._onDelete.fire(item);
|
|
306
|
+
}
|
|
307
|
+
async edit(item, usePickerIfPossible) {
|
|
308
|
+
const canUseOpenDialog = item.uri.scheme === Schemas.file ||
|
|
309
|
+
(item.uri.scheme === this.currentWorkspaceUri.scheme &&
|
|
310
|
+
this.uriService.extUri.isEqualAuthority(this.currentWorkspaceUri.authority, item.uri.authority) &&
|
|
311
|
+
!isVirtualResource(item.uri));
|
|
312
|
+
if (canUseOpenDialog && usePickerIfPossible) {
|
|
313
|
+
const uri = await this.fileDialogService.showOpenDialog({
|
|
314
|
+
canSelectFiles: false,
|
|
315
|
+
canSelectFolders: true,
|
|
316
|
+
canSelectMany: false,
|
|
317
|
+
defaultUri: item.uri,
|
|
318
|
+
openLabel: ( (localize('trustUri', "Trust Folder"))),
|
|
319
|
+
title: ( (localize('selectTrustedUri', "Select Folder To Trust")))
|
|
320
|
+
});
|
|
321
|
+
if (uri) {
|
|
322
|
+
this.acceptEdit(item, uri[0]);
|
|
323
|
+
}
|
|
324
|
+
else {
|
|
325
|
+
this.rejectEdit(item);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
else {
|
|
329
|
+
this.selectTrustedUriEntry(item);
|
|
330
|
+
this._onEdit.fire(item);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
WorkspaceTrustedUrisTable = ( (__decorate([
|
|
335
|
+
( (__param(1, IInstantiationService))),
|
|
336
|
+
( (__param(2, IWorkspaceContextService))),
|
|
337
|
+
( (__param(3, IWorkspaceTrustManagementService))),
|
|
338
|
+
( (__param(4, IUriIdentityService))),
|
|
339
|
+
( (__param(5, ILabelService))),
|
|
340
|
+
( (__param(6, IFileDialogService)))
|
|
341
|
+
], WorkspaceTrustedUrisTable)));
|
|
342
|
+
class TrustedUriTableVirtualDelegate {
|
|
343
|
+
constructor() {
|
|
344
|
+
this.headerRowHeight = TrustedUriTableVirtualDelegate.HEADER_ROW_HEIGHT;
|
|
345
|
+
}
|
|
346
|
+
static { this.HEADER_ROW_HEIGHT = 30; }
|
|
347
|
+
static { this.ROW_HEIGHT = 24; }
|
|
348
|
+
getHeight(item) {
|
|
349
|
+
return TrustedUriTableVirtualDelegate.ROW_HEIGHT;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
let TrustedUriActionsColumnRenderer = class TrustedUriActionsColumnRenderer {
|
|
353
|
+
static { TrustedUriActionsColumnRenderer_1 = this; }
|
|
354
|
+
static { this.TEMPLATE_ID = 'actions'; }
|
|
355
|
+
constructor(table, currentWorkspaceUri, uriService) {
|
|
356
|
+
this.table = table;
|
|
357
|
+
this.currentWorkspaceUri = currentWorkspaceUri;
|
|
358
|
+
this.uriService = uriService;
|
|
359
|
+
this.templateId = TrustedUriActionsColumnRenderer_1.TEMPLATE_ID;
|
|
360
|
+
}
|
|
361
|
+
renderTemplate(container) {
|
|
362
|
+
const element = container.appendChild($('.actions'));
|
|
363
|
+
const actionBar = ( (new ActionBar(element, { animated: false })));
|
|
364
|
+
return { actionBar };
|
|
365
|
+
}
|
|
366
|
+
renderElement(item, index, templateData, height) {
|
|
367
|
+
templateData.actionBar.clear();
|
|
368
|
+
const canUseOpenDialog = item.uri.scheme === Schemas.file ||
|
|
369
|
+
(item.uri.scheme === this.currentWorkspaceUri.scheme &&
|
|
370
|
+
this.uriService.extUri.isEqualAuthority(this.currentWorkspaceUri.authority, item.uri.authority) &&
|
|
371
|
+
!isVirtualResource(item.uri));
|
|
372
|
+
const actions = [];
|
|
373
|
+
if (canUseOpenDialog) {
|
|
374
|
+
actions.push(this.createPickerAction(item));
|
|
375
|
+
}
|
|
376
|
+
actions.push(this.createEditAction(item));
|
|
377
|
+
actions.push(this.createDeleteAction(item));
|
|
378
|
+
templateData.actionBar.push(actions, { icon: true });
|
|
379
|
+
}
|
|
380
|
+
createEditAction(item) {
|
|
381
|
+
return {
|
|
382
|
+
class: ThemeIcon.asClassName(editIcon),
|
|
383
|
+
enabled: true,
|
|
384
|
+
id: 'editTrustedUri',
|
|
385
|
+
tooltip: ( (localize('editTrustedUri', "Edit Path"))),
|
|
386
|
+
run: () => {
|
|
387
|
+
this.table.edit(item, false);
|
|
388
|
+
}
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
createPickerAction(item) {
|
|
392
|
+
return {
|
|
393
|
+
class: ThemeIcon.asClassName(folderPickerIcon),
|
|
394
|
+
enabled: true,
|
|
395
|
+
id: 'pickerTrustedUri',
|
|
396
|
+
tooltip: ( (localize('pickerTrustedUri', "Open File Picker"))),
|
|
397
|
+
run: () => {
|
|
398
|
+
this.table.edit(item, true);
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
createDeleteAction(item) {
|
|
403
|
+
return {
|
|
404
|
+
class: ThemeIcon.asClassName(removeIcon),
|
|
405
|
+
enabled: true,
|
|
406
|
+
id: 'deleteTrustedUri',
|
|
407
|
+
tooltip: ( (localize('deleteTrustedUri', "Delete Path"))),
|
|
408
|
+
run: async () => {
|
|
409
|
+
await this.table.delete(item);
|
|
410
|
+
}
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
disposeTemplate(templateData) {
|
|
414
|
+
templateData.actionBar.dispose();
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
TrustedUriActionsColumnRenderer = TrustedUriActionsColumnRenderer_1 = ( (__decorate([
|
|
418
|
+
( (__param(2, IUriIdentityService)))
|
|
419
|
+
], TrustedUriActionsColumnRenderer)));
|
|
420
|
+
let TrustedUriPathColumnRenderer = class TrustedUriPathColumnRenderer {
|
|
421
|
+
static { TrustedUriPathColumnRenderer_1 = this; }
|
|
422
|
+
static { this.TEMPLATE_ID = 'path'; }
|
|
423
|
+
constructor(table, contextViewService) {
|
|
424
|
+
this.table = table;
|
|
425
|
+
this.contextViewService = contextViewService;
|
|
426
|
+
this.templateId = TrustedUriPathColumnRenderer_1.TEMPLATE_ID;
|
|
427
|
+
}
|
|
428
|
+
renderTemplate(container) {
|
|
429
|
+
const element = container.appendChild($('.path'));
|
|
430
|
+
const pathLabel = element.appendChild($('div.path-label'));
|
|
431
|
+
const pathInput = ( (new InputBox(element, this.contextViewService, {
|
|
432
|
+
validationOptions: {
|
|
433
|
+
validation: value => this.table.validateUri(value, this.currentItem)
|
|
434
|
+
},
|
|
435
|
+
inputBoxStyles: defaultInputBoxStyles
|
|
436
|
+
})));
|
|
437
|
+
const disposables = ( (new DisposableStore()));
|
|
438
|
+
const renderDisposables = disposables.add(( (new DisposableStore())));
|
|
439
|
+
return {
|
|
440
|
+
element,
|
|
441
|
+
pathLabel,
|
|
442
|
+
pathInput,
|
|
443
|
+
disposables,
|
|
444
|
+
renderDisposables
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
renderElement(item, index, templateData, height) {
|
|
448
|
+
templateData.renderDisposables.clear();
|
|
449
|
+
this.currentItem = item;
|
|
450
|
+
templateData.renderDisposables.add(this.table.onEdit(async (e) => {
|
|
451
|
+
if (item === e) {
|
|
452
|
+
templateData.element.classList.add('input-mode');
|
|
453
|
+
templateData.pathInput.focus();
|
|
454
|
+
templateData.pathInput.select();
|
|
455
|
+
templateData.element.parentElement.style.paddingLeft = '0px';
|
|
456
|
+
}
|
|
457
|
+
}));
|
|
458
|
+
templateData.renderDisposables.add(addDisposableListener(templateData.pathInput.element, EventType.DBLCLICK, e => {
|
|
459
|
+
EventHelper.stop(e);
|
|
460
|
+
}));
|
|
461
|
+
const hideInputBox = () => {
|
|
462
|
+
templateData.element.classList.remove('input-mode');
|
|
463
|
+
templateData.element.parentElement.style.paddingLeft = '5px';
|
|
464
|
+
};
|
|
465
|
+
const accept = () => {
|
|
466
|
+
hideInputBox();
|
|
467
|
+
const pathToUse = templateData.pathInput.value;
|
|
468
|
+
const uri = hasDriveLetter(pathToUse) ? item.uri.with({ path: posix.sep + toSlashes(pathToUse) }) : item.uri.with({ path: pathToUse });
|
|
469
|
+
templateData.pathLabel.innerText = this.formatPath(uri);
|
|
470
|
+
if (uri) {
|
|
471
|
+
this.table.acceptEdit(item, uri);
|
|
472
|
+
}
|
|
473
|
+
};
|
|
474
|
+
const reject = () => {
|
|
475
|
+
hideInputBox();
|
|
476
|
+
templateData.pathInput.value = stringValue;
|
|
477
|
+
this.table.rejectEdit(item);
|
|
478
|
+
};
|
|
479
|
+
templateData.renderDisposables.add(addStandardDisposableListener(templateData.pathInput.inputElement, EventType.KEY_DOWN, e => {
|
|
480
|
+
let handled = false;
|
|
481
|
+
if (e.equals(3 )) {
|
|
482
|
+
accept();
|
|
483
|
+
handled = true;
|
|
484
|
+
}
|
|
485
|
+
else if (e.equals(9 )) {
|
|
486
|
+
reject();
|
|
487
|
+
handled = true;
|
|
488
|
+
}
|
|
489
|
+
if (handled) {
|
|
490
|
+
e.preventDefault();
|
|
491
|
+
e.stopPropagation();
|
|
492
|
+
}
|
|
493
|
+
}));
|
|
494
|
+
templateData.renderDisposables.add((addDisposableListener(templateData.pathInput.inputElement, EventType.BLUR, () => {
|
|
495
|
+
reject();
|
|
496
|
+
})));
|
|
497
|
+
const stringValue = this.formatPath(item.uri);
|
|
498
|
+
templateData.pathInput.value = stringValue;
|
|
499
|
+
templateData.pathLabel.innerText = stringValue;
|
|
500
|
+
templateData.element.classList.toggle('current-workspace-parent', item.parentOfWorkspaceItem);
|
|
501
|
+
}
|
|
502
|
+
disposeTemplate(templateData) {
|
|
503
|
+
templateData.disposables.dispose();
|
|
504
|
+
templateData.renderDisposables.dispose();
|
|
505
|
+
}
|
|
506
|
+
formatPath(uri) {
|
|
507
|
+
if (uri.scheme === Schemas.file) {
|
|
508
|
+
return normalizeDriveLetter(uri.fsPath);
|
|
509
|
+
}
|
|
510
|
+
if (uri.path.startsWith(posix.sep)) {
|
|
511
|
+
const pathWithoutLeadingSeparator = uri.path.substring(1);
|
|
512
|
+
const isWindowsPath = hasDriveLetter(pathWithoutLeadingSeparator, true);
|
|
513
|
+
if (isWindowsPath) {
|
|
514
|
+
return normalizeDriveLetter(win32.normalize(pathWithoutLeadingSeparator), true);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
return uri.path;
|
|
518
|
+
}
|
|
519
|
+
};
|
|
520
|
+
TrustedUriPathColumnRenderer = TrustedUriPathColumnRenderer_1 = ( (__decorate([
|
|
521
|
+
( (__param(1, IContextViewService)))
|
|
522
|
+
], TrustedUriPathColumnRenderer)));
|
|
523
|
+
function getHostLabel(labelService, item) {
|
|
524
|
+
return item.uri.authority ? labelService.getHostLabel(item.uri.scheme, item.uri.authority) : ( (localize('localAuthority', "Local")));
|
|
525
|
+
}
|
|
526
|
+
let TrustedUriHostColumnRenderer = class TrustedUriHostColumnRenderer {
|
|
527
|
+
static { TrustedUriHostColumnRenderer_1 = this; }
|
|
528
|
+
static { this.TEMPLATE_ID = 'host'; }
|
|
529
|
+
constructor(labelService) {
|
|
530
|
+
this.labelService = labelService;
|
|
531
|
+
this.templateId = TrustedUriHostColumnRenderer_1.TEMPLATE_ID;
|
|
532
|
+
}
|
|
533
|
+
renderTemplate(container) {
|
|
534
|
+
const disposables = ( (new DisposableStore()));
|
|
535
|
+
const renderDisposables = disposables.add(( (new DisposableStore())));
|
|
536
|
+
const element = container.appendChild($('.host'));
|
|
537
|
+
const hostContainer = element.appendChild($('div.host-label'));
|
|
538
|
+
const buttonBarContainer = element.appendChild($('div.button-bar'));
|
|
539
|
+
return {
|
|
540
|
+
element,
|
|
541
|
+
hostContainer,
|
|
542
|
+
buttonBarContainer,
|
|
543
|
+
disposables,
|
|
544
|
+
renderDisposables
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
renderElement(item, index, templateData, height) {
|
|
548
|
+
templateData.renderDisposables.clear();
|
|
549
|
+
templateData.renderDisposables.add({ dispose: () => { clearNode(templateData.buttonBarContainer); } });
|
|
550
|
+
templateData.hostContainer.innerText = getHostLabel(this.labelService, item);
|
|
551
|
+
templateData.element.classList.toggle('current-workspace-parent', item.parentOfWorkspaceItem);
|
|
552
|
+
templateData.hostContainer.style.display = '';
|
|
553
|
+
templateData.buttonBarContainer.style.display = 'none';
|
|
554
|
+
}
|
|
555
|
+
disposeTemplate(templateData) {
|
|
556
|
+
templateData.disposables.dispose();
|
|
557
|
+
}
|
|
558
|
+
};
|
|
559
|
+
TrustedUriHostColumnRenderer = TrustedUriHostColumnRenderer_1 = ( (__decorate([
|
|
560
|
+
( (__param(0, ILabelService)))
|
|
561
|
+
], TrustedUriHostColumnRenderer)));
|
|
562
|
+
let WorkspaceTrustEditor = class WorkspaceTrustEditor extends EditorPane {
|
|
563
|
+
static { WorkspaceTrustEditor_1 = this; }
|
|
564
|
+
static { this.ID = 'workbench.editor.workspaceTrust'; }
|
|
565
|
+
constructor(telemetryService, themeService, storageService, workspaceService, extensionWorkbenchService, extensionManifestPropertiesService, instantiationService, workspaceTrustManagementService, configurationService, extensionEnablementService, productService, keybindingService) {
|
|
566
|
+
super(WorkspaceTrustEditor_1.ID, telemetryService, themeService, storageService);
|
|
567
|
+
this.workspaceService = workspaceService;
|
|
568
|
+
this.extensionWorkbenchService = extensionWorkbenchService;
|
|
569
|
+
this.extensionManifestPropertiesService = extensionManifestPropertiesService;
|
|
570
|
+
this.instantiationService = instantiationService;
|
|
571
|
+
this.workspaceTrustManagementService = workspaceTrustManagementService;
|
|
572
|
+
this.configurationService = configurationService;
|
|
573
|
+
this.extensionEnablementService = extensionEnablementService;
|
|
574
|
+
this.productService = productService;
|
|
575
|
+
this.keybindingService = keybindingService;
|
|
576
|
+
this.rendering = false;
|
|
577
|
+
this.rerenderDisposables = this._register(( (new DisposableStore())));
|
|
578
|
+
this.layoutParticipants = [];
|
|
579
|
+
}
|
|
580
|
+
createEditor(parent) {
|
|
581
|
+
this.rootElement = append(parent, $('.workspace-trust-editor', { tabindex: '0' }));
|
|
582
|
+
this.createHeaderElement(this.rootElement);
|
|
583
|
+
const scrollableContent = $('.workspace-trust-editor-body');
|
|
584
|
+
this.bodyScrollBar = this._register(( (new DomScrollableElement(scrollableContent, {
|
|
585
|
+
horizontal: 2 ,
|
|
586
|
+
vertical: 1 ,
|
|
587
|
+
}))));
|
|
588
|
+
append(this.rootElement, this.bodyScrollBar.getDomNode());
|
|
589
|
+
this.createAffectedFeaturesElement(scrollableContent);
|
|
590
|
+
this.createConfigurationElement(scrollableContent);
|
|
591
|
+
this.rootElement.style.setProperty('--workspace-trust-selected-color', asCssVariable(buttonBackground));
|
|
592
|
+
this.rootElement.style.setProperty('--workspace-trust-unselected-color', asCssVariable(buttonSecondaryBackground));
|
|
593
|
+
this.rootElement.style.setProperty('--workspace-trust-check-color', asCssVariable(debugIconStartForeground));
|
|
594
|
+
this.rootElement.style.setProperty('--workspace-trust-x-color', asCssVariable(editorErrorForeground));
|
|
595
|
+
this._register(addDisposableListener(this.rootElement, EventType.KEY_DOWN, e => {
|
|
596
|
+
const event = ( (new StandardKeyboardEvent(e)));
|
|
597
|
+
if (event.equals(16 ) || event.equals(18 )) {
|
|
598
|
+
const navOrder = [this.headerContainer, this.trustedContainer, this.untrustedContainer, this.configurationContainer];
|
|
599
|
+
const currentIndex = navOrder.findIndex(element => {
|
|
600
|
+
return isAncestor(document.activeElement, element);
|
|
601
|
+
});
|
|
602
|
+
let newIndex = currentIndex;
|
|
603
|
+
if (event.equals(18 )) {
|
|
604
|
+
newIndex++;
|
|
605
|
+
}
|
|
606
|
+
else if (event.equals(16 )) {
|
|
607
|
+
newIndex = Math.max(0, newIndex);
|
|
608
|
+
newIndex--;
|
|
609
|
+
}
|
|
610
|
+
newIndex += navOrder.length;
|
|
611
|
+
newIndex %= navOrder.length;
|
|
612
|
+
navOrder[newIndex].focus();
|
|
613
|
+
}
|
|
614
|
+
else if (event.equals(9 )) {
|
|
615
|
+
this.rootElement.focus();
|
|
616
|
+
}
|
|
617
|
+
else if (event.equals(2048 | 3 )) {
|
|
618
|
+
if (this.workspaceTrustManagementService.canSetWorkspaceTrust()) {
|
|
619
|
+
this.workspaceTrustManagementService.setWorkspaceTrust(!this.workspaceTrustManagementService.isWorkspaceTrusted());
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
else if (event.equals(2048 | 1024 | 3 )) {
|
|
623
|
+
if (this.workspaceTrustManagementService.canSetParentFolderTrust()) {
|
|
624
|
+
this.workspaceTrustManagementService.setParentFolderTrust(true);
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
}));
|
|
628
|
+
}
|
|
629
|
+
focus() {
|
|
630
|
+
this.rootElement.focus();
|
|
631
|
+
}
|
|
632
|
+
async setInput(input, options, context, token) {
|
|
633
|
+
await super.setInput(input, options, context, token);
|
|
634
|
+
if (token.isCancellationRequested) {
|
|
635
|
+
return;
|
|
636
|
+
}
|
|
637
|
+
await this.workspaceTrustManagementService.workspaceTrustInitialized;
|
|
638
|
+
this.registerListeners();
|
|
639
|
+
await this.render();
|
|
640
|
+
}
|
|
641
|
+
registerListeners() {
|
|
642
|
+
this._register(this.extensionWorkbenchService.onChange(() => this.render()));
|
|
643
|
+
this._register(this.configurationService.onDidChangeRestrictedSettings(() => this.render()));
|
|
644
|
+
this._register(this.workspaceTrustManagementService.onDidChangeTrust(() => this.render()));
|
|
645
|
+
this._register(this.workspaceTrustManagementService.onDidChangeTrustedFolders(() => this.render()));
|
|
646
|
+
}
|
|
647
|
+
getHeaderContainerClass(trusted) {
|
|
648
|
+
if (trusted) {
|
|
649
|
+
return 'workspace-trust-header workspace-trust-trusted';
|
|
650
|
+
}
|
|
651
|
+
return 'workspace-trust-header workspace-trust-untrusted';
|
|
652
|
+
}
|
|
653
|
+
getHeaderTitleText(trusted) {
|
|
654
|
+
if (trusted) {
|
|
655
|
+
if (this.workspaceTrustManagementService.isWorkspaceTrustForced()) {
|
|
656
|
+
return (
|
|
657
|
+
(localize('trustedUnsettableWindow', "This window is trusted"))
|
|
658
|
+
);
|
|
659
|
+
}
|
|
660
|
+
switch (this.workspaceService.getWorkbenchState()) {
|
|
661
|
+
case 1 :
|
|
662
|
+
return (
|
|
663
|
+
(localize('trustedHeaderWindow', "You trust this window"))
|
|
664
|
+
);
|
|
665
|
+
case 2 :
|
|
666
|
+
return (
|
|
667
|
+
(localize('trustedHeaderFolder', "You trust this folder"))
|
|
668
|
+
);
|
|
669
|
+
case 3 :
|
|
670
|
+
return (
|
|
671
|
+
(localize('trustedHeaderWorkspace', "You trust this workspace"))
|
|
672
|
+
);
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
return (
|
|
676
|
+
(localize('untrustedHeader', "You are in Restricted Mode"))
|
|
677
|
+
);
|
|
678
|
+
}
|
|
679
|
+
getHeaderTitleIconClassNames(trusted) {
|
|
680
|
+
return ThemeIcon.asClassNameArray(shieldIcon);
|
|
681
|
+
}
|
|
682
|
+
getFeaturesHeaderText(trusted) {
|
|
683
|
+
let title = '';
|
|
684
|
+
let subTitle = '';
|
|
685
|
+
switch (this.workspaceService.getWorkbenchState()) {
|
|
686
|
+
case 1 : {
|
|
687
|
+
title = trusted ? ( (localize('trustedWindow', "In a Trusted Window"))) : ( (localize('untrustedWorkspace', "In Restricted Mode")));
|
|
688
|
+
subTitle = trusted ? ( (localize(
|
|
689
|
+
'trustedWindowSubtitle',
|
|
690
|
+
"You trust the authors of the files in the current window. All features are enabled:"
|
|
691
|
+
))) :
|
|
692
|
+
( (localize(
|
|
693
|
+
'untrustedWindowSubtitle',
|
|
694
|
+
"You do not trust the authors of the files in the current window. The following features are disabled:"
|
|
695
|
+
)));
|
|
696
|
+
break;
|
|
697
|
+
}
|
|
698
|
+
case 2 : {
|
|
699
|
+
title = trusted ? ( (localize('trustedFolder', "In a Trusted Folder"))) : ( (localize('untrustedWorkspace', "In Restricted Mode")));
|
|
700
|
+
subTitle = trusted ? ( (localize(
|
|
701
|
+
'trustedFolderSubtitle',
|
|
702
|
+
"You trust the authors of the files in the current folder. All features are enabled:"
|
|
703
|
+
))) :
|
|
704
|
+
( (localize(
|
|
705
|
+
'untrustedFolderSubtitle',
|
|
706
|
+
"You do not trust the authors of the files in the current folder. The following features are disabled:"
|
|
707
|
+
)));
|
|
708
|
+
break;
|
|
709
|
+
}
|
|
710
|
+
case 3 : {
|
|
711
|
+
title = trusted ? ( (localize('trustedWorkspace', "In a Trusted Workspace"))) : ( (localize('untrustedWorkspace', "In Restricted Mode")));
|
|
712
|
+
subTitle = trusted ? ( (localize(
|
|
713
|
+
'trustedWorkspaceSubtitle',
|
|
714
|
+
"You trust the authors of the files in the current workspace. All features are enabled:"
|
|
715
|
+
))) :
|
|
716
|
+
( (localize(
|
|
717
|
+
'untrustedWorkspaceSubtitle',
|
|
718
|
+
"You do not trust the authors of the files in the current workspace. The following features are disabled:"
|
|
719
|
+
)));
|
|
720
|
+
break;
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
return [title, subTitle];
|
|
724
|
+
}
|
|
725
|
+
async render() {
|
|
726
|
+
if (this.rendering) {
|
|
727
|
+
return;
|
|
728
|
+
}
|
|
729
|
+
this.rendering = true;
|
|
730
|
+
this.rerenderDisposables.clear();
|
|
731
|
+
const isWorkspaceTrusted = this.workspaceTrustManagementService.isWorkspaceTrusted();
|
|
732
|
+
this.rootElement.classList.toggle('trusted', isWorkspaceTrusted);
|
|
733
|
+
this.rootElement.classList.toggle('untrusted', !isWorkspaceTrusted);
|
|
734
|
+
this.headerTitleText.innerText = this.getHeaderTitleText(isWorkspaceTrusted);
|
|
735
|
+
this.headerTitleIcon.className = 'workspace-trust-title-icon';
|
|
736
|
+
this.headerTitleIcon.classList.add(...this.getHeaderTitleIconClassNames(isWorkspaceTrusted));
|
|
737
|
+
this.headerDescription.innerText = '';
|
|
738
|
+
const headerDescriptionText = append(this.headerDescription, $('div'));
|
|
739
|
+
headerDescriptionText.innerText = isWorkspaceTrusted ?
|
|
740
|
+
( (localize(
|
|
741
|
+
'trustedDescription',
|
|
742
|
+
"All features are enabled because trust has been granted to the workspace."
|
|
743
|
+
))) :
|
|
744
|
+
( (localize(
|
|
745
|
+
'untrustedDescription',
|
|
746
|
+
"{0} is in a restricted mode intended for safe code browsing.",
|
|
747
|
+
this.productService.nameShort
|
|
748
|
+
)));
|
|
749
|
+
const headerDescriptionActions = append(this.headerDescription, $('div'));
|
|
750
|
+
const headerDescriptionActionsText = ( (localize(
|
|
751
|
+
{ key: 'workspaceTrustEditorHeaderActions', comment: ['Please ensure the markdown link syntax is not broken up with whitespace [text block](link block)'] },
|
|
752
|
+
"[Configure your settings]({0}) or [learn more](https://aka.ms/vscode-workspace-trust).",
|
|
753
|
+
`command:workbench.trust.configure`
|
|
754
|
+
)));
|
|
755
|
+
for (const node of parseLinkedText(headerDescriptionActionsText).nodes) {
|
|
756
|
+
if (typeof node === 'string') {
|
|
757
|
+
append(headerDescriptionActions, document.createTextNode(node));
|
|
758
|
+
}
|
|
759
|
+
else {
|
|
760
|
+
this.rerenderDisposables.add(this.instantiationService.createInstance(Link, headerDescriptionActions, { ...node, tabIndex: -1 }, {}));
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
this.headerContainer.className = this.getHeaderContainerClass(isWorkspaceTrusted);
|
|
764
|
+
this.rootElement.setAttribute('aria-label', `${( ( localize('root element label', "Manage Workspace Trust")))}: ${this.headerContainer.innerText}`);
|
|
765
|
+
const restrictedSettings = this.configurationService.restrictedSettings;
|
|
766
|
+
const configurationRegistry = ( (Registry.as(Extensions.Configuration)));
|
|
767
|
+
const settingsRequiringTrustedWorkspaceCount = restrictedSettings.default.filter(key => {
|
|
768
|
+
const property = configurationRegistry.getConfigurationProperties()[key];
|
|
769
|
+
if (property.scope === 1 || property.scope === 2 ) {
|
|
770
|
+
return false;
|
|
771
|
+
}
|
|
772
|
+
if (property.deprecationMessage || property.markdownDeprecationMessage) {
|
|
773
|
+
if (restrictedSettings.workspace?.includes(key)) {
|
|
774
|
+
return true;
|
|
775
|
+
}
|
|
776
|
+
if (restrictedSettings.workspaceFolder) {
|
|
777
|
+
for (const workspaceFolderSettings of ( (restrictedSettings.workspaceFolder.values()))) {
|
|
778
|
+
if (workspaceFolderSettings.includes(key)) {
|
|
779
|
+
return true;
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
return false;
|
|
784
|
+
}
|
|
785
|
+
return true;
|
|
786
|
+
}).length;
|
|
787
|
+
this.renderAffectedFeatures(settingsRequiringTrustedWorkspaceCount, this.getExtensionCount());
|
|
788
|
+
this.workspaceTrustedUrisTable.updateTable();
|
|
789
|
+
this.bodyScrollBar.getDomNode().style.height = `calc(100% - ${this.headerContainer.clientHeight}px)`;
|
|
790
|
+
this.bodyScrollBar.scanDomNode();
|
|
791
|
+
this.rendering = false;
|
|
792
|
+
}
|
|
793
|
+
getExtensionCount() {
|
|
794
|
+
const set = ( (new Set()));
|
|
795
|
+
const inVirtualWorkspace = isVirtualWorkspace(this.workspaceService.getWorkspace());
|
|
796
|
+
const localExtensions = ( (this.extensionWorkbenchService.local.filter(ext => ext.local).map(ext => ext.local)));
|
|
797
|
+
for (const extension of localExtensions) {
|
|
798
|
+
const enablementState = this.extensionEnablementService.getEnablementState(extension);
|
|
799
|
+
if (enablementState !== 8 && enablementState !== 9 &&
|
|
800
|
+
enablementState !== 0 && enablementState !== 5 ) {
|
|
801
|
+
continue;
|
|
802
|
+
}
|
|
803
|
+
if (inVirtualWorkspace && this.extensionManifestPropertiesService.getExtensionVirtualWorkspaceSupportType(extension.manifest) === false) {
|
|
804
|
+
continue;
|
|
805
|
+
}
|
|
806
|
+
if (this.extensionManifestPropertiesService.getExtensionUntrustedWorkspaceSupportType(extension.manifest) !== true) {
|
|
807
|
+
set.add(extension.identifier.id);
|
|
808
|
+
continue;
|
|
809
|
+
}
|
|
810
|
+
const dependencies = getExtensionDependencies(localExtensions, extension);
|
|
811
|
+
if (( (dependencies.some(
|
|
812
|
+
ext => this.extensionManifestPropertiesService.getExtensionUntrustedWorkspaceSupportType(ext.manifest) === false
|
|
813
|
+
)))) {
|
|
814
|
+
set.add(extension.identifier.id);
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
return set.size;
|
|
818
|
+
}
|
|
819
|
+
createHeaderElement(parent) {
|
|
820
|
+
this.headerContainer = append(parent, $('.workspace-trust-header', { tabIndex: '0' }));
|
|
821
|
+
this.headerTitleContainer = append(this.headerContainer, $('.workspace-trust-title'));
|
|
822
|
+
this.headerTitleIcon = append(this.headerTitleContainer, $('.workspace-trust-title-icon'));
|
|
823
|
+
this.headerTitleText = append(this.headerTitleContainer, $('.workspace-trust-title-text'));
|
|
824
|
+
this.headerDescription = append(this.headerContainer, $('.workspace-trust-description'));
|
|
825
|
+
}
|
|
826
|
+
createConfigurationElement(parent) {
|
|
827
|
+
this.configurationContainer = append(parent, $('.workspace-trust-settings', { tabIndex: '0' }));
|
|
828
|
+
const configurationTitle = append(this.configurationContainer, $('.workspace-trusted-folders-title'));
|
|
829
|
+
configurationTitle.innerText = ( (localize('trustedFoldersAndWorkspaces', "Trusted Folders & Workspaces")));
|
|
830
|
+
this.workspaceTrustedUrisTable = this._register(this.instantiationService.createInstance(WorkspaceTrustedUrisTable, this.configurationContainer));
|
|
831
|
+
}
|
|
832
|
+
createAffectedFeaturesElement(parent) {
|
|
833
|
+
this.affectedFeaturesContainer = append(parent, $('.workspace-trust-features'));
|
|
834
|
+
this.trustedContainer = append(this.affectedFeaturesContainer, $('.workspace-trust-limitations.trusted', { tabIndex: '0' }));
|
|
835
|
+
this.untrustedContainer = append(this.affectedFeaturesContainer, $('.workspace-trust-limitations.untrusted', { tabIndex: '0' }));
|
|
836
|
+
}
|
|
837
|
+
async renderAffectedFeatures(numSettings, numExtensions) {
|
|
838
|
+
clearNode(this.trustedContainer);
|
|
839
|
+
clearNode(this.untrustedContainer);
|
|
840
|
+
const [trustedTitle, trustedSubTitle] = this.getFeaturesHeaderText(true);
|
|
841
|
+
this.renderLimitationsHeaderElement(this.trustedContainer, trustedTitle, trustedSubTitle);
|
|
842
|
+
const trustedContainerItems = this.workspaceService.getWorkbenchState() === 1 ?
|
|
843
|
+
[
|
|
844
|
+
( (localize('trustedTasks', "Tasks are allowed to run"))),
|
|
845
|
+
( (localize('trustedDebugging', "Debugging is enabled"))),
|
|
846
|
+
( (localize('trustedExtensions', "All enabled extensions are activated")))
|
|
847
|
+
] :
|
|
848
|
+
[
|
|
849
|
+
( (localize('trustedTasks', "Tasks are allowed to run"))),
|
|
850
|
+
( (localize('trustedDebugging', "Debugging is enabled"))),
|
|
851
|
+
( (localize('trustedSettings', "All workspace settings are applied"))),
|
|
852
|
+
( (localize('trustedExtensions', "All enabled extensions are activated")))
|
|
853
|
+
];
|
|
854
|
+
this.renderLimitationsListElement(this.trustedContainer, trustedContainerItems, ThemeIcon.asClassNameArray(checkListIcon));
|
|
855
|
+
const [untrustedTitle, untrustedSubTitle] = this.getFeaturesHeaderText(false);
|
|
856
|
+
this.renderLimitationsHeaderElement(this.untrustedContainer, untrustedTitle, untrustedSubTitle);
|
|
857
|
+
const untrustedContainerItems = this.workspaceService.getWorkbenchState() === 1 ?
|
|
858
|
+
[
|
|
859
|
+
( (localize('untrustedTasks', "Tasks are not allowed to run"))),
|
|
860
|
+
( (localize('untrustedDebugging', "Debugging is disabled"))),
|
|
861
|
+
fixBadLocalizedLinks(( (localize(
|
|
862
|
+
{ key: 'untrustedExtensions', comment: ['Please ensure the markdown link syntax is not broken up with whitespace [text block](link block)'] },
|
|
863
|
+
"[{0} extensions]({1}) are disabled or have limited functionality",
|
|
864
|
+
numExtensions,
|
|
865
|
+
`command:${LIST_WORKSPACE_UNSUPPORTED_EXTENSIONS_COMMAND_ID}`
|
|
866
|
+
))))
|
|
867
|
+
] :
|
|
868
|
+
[
|
|
869
|
+
( (localize('untrustedTasks', "Tasks are not allowed to run"))),
|
|
870
|
+
( (localize('untrustedDebugging', "Debugging is disabled"))),
|
|
871
|
+
fixBadLocalizedLinks(numSettings ? ( (localize(
|
|
872
|
+
{ key: 'untrustedSettings', comment: ['Please ensure the markdown link syntax is not broken up with whitespace [text block](link block)'] },
|
|
873
|
+
"[{0} workspace settings]({1}) are not applied",
|
|
874
|
+
numSettings,
|
|
875
|
+
'command:settings.filterUntrusted'
|
|
876
|
+
))) : ( (localize(
|
|
877
|
+
'no untrustedSettings',
|
|
878
|
+
"Workspace settings requiring trust are not applied"
|
|
879
|
+
)))),
|
|
880
|
+
fixBadLocalizedLinks(( (localize(
|
|
881
|
+
{ key: 'untrustedExtensions', comment: ['Please ensure the markdown link syntax is not broken up with whitespace [text block](link block)'] },
|
|
882
|
+
"[{0} extensions]({1}) are disabled or have limited functionality",
|
|
883
|
+
numExtensions,
|
|
884
|
+
`command:${LIST_WORKSPACE_UNSUPPORTED_EXTENSIONS_COMMAND_ID}`
|
|
885
|
+
))))
|
|
886
|
+
];
|
|
887
|
+
this.renderLimitationsListElement(this.untrustedContainer, untrustedContainerItems, ThemeIcon.asClassNameArray(xListIcon));
|
|
888
|
+
if (this.workspaceTrustManagementService.isWorkspaceTrusted()) {
|
|
889
|
+
if (this.workspaceTrustManagementService.canSetWorkspaceTrust()) {
|
|
890
|
+
this.addDontTrustButtonToElement(this.untrustedContainer);
|
|
891
|
+
}
|
|
892
|
+
else {
|
|
893
|
+
this.addTrustedTextToElement(this.untrustedContainer);
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
else {
|
|
897
|
+
if (this.workspaceTrustManagementService.canSetWorkspaceTrust()) {
|
|
898
|
+
this.addTrustButtonToElement(this.trustedContainer);
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
createButtonRow(parent, buttonInfo, enabled) {
|
|
903
|
+
const buttonRow = append(parent, $('.workspace-trust-buttons-row'));
|
|
904
|
+
const buttonContainer = append(buttonRow, $('.workspace-trust-buttons'));
|
|
905
|
+
const buttonBar = this.rerenderDisposables.add(( (new ButtonBar(buttonContainer))));
|
|
906
|
+
for (const { action, keybinding } of buttonInfo) {
|
|
907
|
+
const button = buttonBar.addButtonWithDescription(defaultButtonStyles);
|
|
908
|
+
button.label = action.label;
|
|
909
|
+
button.enabled = enabled !== undefined ? enabled : action.enabled;
|
|
910
|
+
button.description = keybinding.getLabel();
|
|
911
|
+
button.element.ariaLabel = action.label + ', ' + ( (localize('keyboardShortcut', "Keyboard Shortcut: {0}", keybinding.getAriaLabel())));
|
|
912
|
+
this.rerenderDisposables.add(button.onDidClick(e => {
|
|
913
|
+
if (e) {
|
|
914
|
+
EventHelper.stop(e, true);
|
|
915
|
+
}
|
|
916
|
+
action.run();
|
|
917
|
+
}));
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
addTrustButtonToElement(parent) {
|
|
921
|
+
const trustAction = ( (new Action(
|
|
922
|
+
'workspace.trust.button.action.grant',
|
|
923
|
+
(localize('trustButton', "Trust")),
|
|
924
|
+
undefined,
|
|
925
|
+
true,
|
|
926
|
+
async () => {
|
|
927
|
+
await this.workspaceTrustManagementService.setWorkspaceTrust(true);
|
|
928
|
+
}
|
|
929
|
+
)));
|
|
930
|
+
const trustActions = [{ action: trustAction, keybinding: this.keybindingService.resolveUserBinding(isMacintosh ? 'Cmd+Enter' : 'Ctrl+Enter')[0] }];
|
|
931
|
+
if (this.workspaceTrustManagementService.canSetParentFolderTrust()) {
|
|
932
|
+
const workspaceIdentifier = toWorkspaceIdentifier(this.workspaceService.getWorkspace());
|
|
933
|
+
const name = basename(dirname(workspaceIdentifier.uri));
|
|
934
|
+
const trustMessageElement = append(parent, $('.trust-message-box'));
|
|
935
|
+
trustMessageElement.innerText = ( (localize(
|
|
936
|
+
'trustMessage',
|
|
937
|
+
"Trust the authors of all files in the current folder or its parent '{0}'.",
|
|
938
|
+
name
|
|
939
|
+
)));
|
|
940
|
+
const trustParentAction = ( (new Action(
|
|
941
|
+
'workspace.trust.button.action.grantParent',
|
|
942
|
+
(localize('trustParentButton', "Trust Parent")),
|
|
943
|
+
undefined,
|
|
944
|
+
true,
|
|
945
|
+
async () => {
|
|
946
|
+
await this.workspaceTrustManagementService.setParentFolderTrust(true);
|
|
947
|
+
}
|
|
948
|
+
)));
|
|
949
|
+
trustActions.push({ action: trustParentAction, keybinding: this.keybindingService.resolveUserBinding(isMacintosh ? 'Cmd+Shift+Enter' : 'Ctrl+Shift+Enter')[0] });
|
|
950
|
+
}
|
|
951
|
+
this.createButtonRow(parent, trustActions);
|
|
952
|
+
}
|
|
953
|
+
addDontTrustButtonToElement(parent) {
|
|
954
|
+
this.createButtonRow(parent, [{
|
|
955
|
+
action: ( (new Action(
|
|
956
|
+
'workspace.trust.button.action.deny',
|
|
957
|
+
(localize('dontTrustButton', "Don't Trust")),
|
|
958
|
+
undefined,
|
|
959
|
+
true,
|
|
960
|
+
async () => {
|
|
961
|
+
await this.workspaceTrustManagementService.setWorkspaceTrust(false);
|
|
962
|
+
}
|
|
963
|
+
))),
|
|
964
|
+
keybinding: this.keybindingService.resolveUserBinding(isMacintosh ? 'Cmd+Enter' : 'Ctrl+Enter')[0]
|
|
965
|
+
}]);
|
|
966
|
+
}
|
|
967
|
+
addTrustedTextToElement(parent) {
|
|
968
|
+
if (this.workspaceService.getWorkbenchState() === 1 ) {
|
|
969
|
+
return;
|
|
970
|
+
}
|
|
971
|
+
const textElement = append(parent, $('.workspace-trust-untrusted-description'));
|
|
972
|
+
if (!this.workspaceTrustManagementService.isWorkspaceTrustForced()) {
|
|
973
|
+
textElement.innerText = this.workspaceService.getWorkbenchState() === 3 ? ( (localize(
|
|
974
|
+
'untrustedWorkspaceReason',
|
|
975
|
+
"This workspace is trusted via the bolded entries in the trusted folders below."
|
|
976
|
+
))) : ( (localize(
|
|
977
|
+
'untrustedFolderReason',
|
|
978
|
+
"This folder is trusted via the bolded entries in the the trusted folders below."
|
|
979
|
+
)));
|
|
980
|
+
}
|
|
981
|
+
else {
|
|
982
|
+
textElement.innerText = ( (localize(
|
|
983
|
+
'trustedForcedReason',
|
|
984
|
+
"This window is trusted by nature of the workspace that is opened."
|
|
985
|
+
)));
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
renderLimitationsHeaderElement(parent, headerText, subtitleText) {
|
|
989
|
+
const limitationsHeaderContainer = append(parent, $('.workspace-trust-limitations-header'));
|
|
990
|
+
const titleElement = append(limitationsHeaderContainer, $('.workspace-trust-limitations-title'));
|
|
991
|
+
const textElement = append(titleElement, $('.workspace-trust-limitations-title-text'));
|
|
992
|
+
const subtitleElement = append(limitationsHeaderContainer, $('.workspace-trust-limitations-subtitle'));
|
|
993
|
+
textElement.innerText = headerText;
|
|
994
|
+
subtitleElement.innerText = subtitleText;
|
|
995
|
+
}
|
|
996
|
+
renderLimitationsListElement(parent, limitations, iconClassNames) {
|
|
997
|
+
const listContainer = append(parent, $('.workspace-trust-limitations-list-container'));
|
|
998
|
+
const limitationsList = append(listContainer, $('ul'));
|
|
999
|
+
for (const limitation of limitations) {
|
|
1000
|
+
const limitationListItem = append(limitationsList, $('li'));
|
|
1001
|
+
const icon = append(limitationListItem, $('.list-item-icon'));
|
|
1002
|
+
const text = append(limitationListItem, $('.list-item-text'));
|
|
1003
|
+
icon.classList.add(...iconClassNames);
|
|
1004
|
+
const linkedText = parseLinkedText(limitation);
|
|
1005
|
+
for (const node of linkedText.nodes) {
|
|
1006
|
+
if (typeof node === 'string') {
|
|
1007
|
+
append(text, document.createTextNode(node));
|
|
1008
|
+
}
|
|
1009
|
+
else {
|
|
1010
|
+
this.rerenderDisposables.add(this.instantiationService.createInstance(Link, text, { ...node, tabIndex: -1 }, {}));
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
layout(dimension) {
|
|
1016
|
+
if (!this.isVisible()) {
|
|
1017
|
+
return;
|
|
1018
|
+
}
|
|
1019
|
+
this.workspaceTrustedUrisTable.layout();
|
|
1020
|
+
this.layoutParticipants.forEach(participant => {
|
|
1021
|
+
participant.layout();
|
|
1022
|
+
});
|
|
1023
|
+
this.bodyScrollBar.scanDomNode();
|
|
1024
|
+
}
|
|
1025
|
+
};
|
|
1026
|
+
WorkspaceTrustEditor.__decorator = ( (__decorate([
|
|
1027
|
+
debounce(100)
|
|
1028
|
+
], WorkspaceTrustEditor.prototype, "render", null)));
|
|
1029
|
+
WorkspaceTrustEditor = WorkspaceTrustEditor_1 = ( (__decorate([
|
|
1030
|
+
( (__param(0, ITelemetryService))),
|
|
1031
|
+
( (__param(1, IThemeService))),
|
|
1032
|
+
( (__param(2, IStorageService))),
|
|
1033
|
+
( (__param(3, IWorkspaceContextService))),
|
|
1034
|
+
( (__param(4, IExtensionsWorkbenchService))),
|
|
1035
|
+
( (__param(5, IExtensionManifestPropertiesService))),
|
|
1036
|
+
( (__param(6, IInstantiationService))),
|
|
1037
|
+
( (__param(7, IWorkspaceTrustManagementService))),
|
|
1038
|
+
( (__param(8, IWorkbenchConfigurationService))),
|
|
1039
|
+
( (__param(9, IWorkbenchExtensionEnablementService))),
|
|
1040
|
+
( (__param(10, IProductService))),
|
|
1041
|
+
( (__param(11, IKeybindingService)))
|
|
1042
|
+
], WorkspaceTrustEditor)));
|
|
1043
|
+
function fixBadLocalizedLinks(badString) {
|
|
1044
|
+
const regex = /(.*)\[(.+)\]\s*\((.+)\)(.*)/;
|
|
1045
|
+
return badString.replace(regex, '$1[$2]($3)$4');
|
|
1046
|
+
}
|
|
1047
|
+
export { WorkspaceTrustEditor, shieldIcon };
|