mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-04-08 13:00:30 -04:00
Merge from vscode aba87f135229c17c4624341b7a2499dcedafcb87 (#6430)
* Merge from vscode aba87f135229c17c4624341b7a2499dcedafcb87 * fix compile errors
This commit is contained in:
@@ -166,7 +166,7 @@ export class CommentNode extends Disposable {
|
||||
secondaryActions.push(...secondary);
|
||||
}
|
||||
|
||||
if (actions.length) {
|
||||
if (actions.length || secondaryActions.length) {
|
||||
this.toolbar = new ToolBar(this._actionsToolbarContainer, this.contextMenuService, {
|
||||
actionViewItemProvider: action => {
|
||||
if (action.id === ToggleReactionsAction.ID) {
|
||||
@@ -318,18 +318,18 @@ export class CommentNode extends Disposable {
|
||||
let toggleReactionAction = this.createReactionPicker2(this.comment.commentReactions || []);
|
||||
this._reactionsActionBar.push(toggleReactionAction, { label: false, icon: true });
|
||||
} else {
|
||||
let reactionGroup = this.commentService.getReactionGroup(this.owner);
|
||||
if (reactionGroup && reactionGroup.length) {
|
||||
let toggleReactionAction = this.createReactionPicker2(reactionGroup || []);
|
||||
this._reactionsActionBar.push(toggleReactionAction, { label: false, icon: true });
|
||||
}
|
||||
// let reactionGroup = this.commentService.getReactionGroup(this.owner);
|
||||
// if (reactionGroup && reactionGroup.length) {
|
||||
// let toggleReactionAction = this.createReactionPicker2(reactionGroup || []);
|
||||
// this._reactionsActionBar.push(toggleReactionAction, { label: false, icon: true });
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
private createCommentEditor(): void {
|
||||
const container = dom.append(this._commentEditContainer, dom.$('.edit-textarea'));
|
||||
this._commentEditor = this.instantiationService.createInstance(SimpleCommentEditor, container, SimpleCommentEditor.getEditorOptions(), this.parentEditor, this.parentThread);
|
||||
const resource = URI.parse(`comment:commentinput-${this.comment.commentId}-${Date.now()}.md`);
|
||||
const resource = URI.parse(`comment:commentinput-${this.comment.uniqueIdInThread}-${Date.now()}.md`);
|
||||
this._commentEditorModel = this.modelService.createModel('', this.modeService.createByFilepathOrFirstLine(resource), resource, false);
|
||||
|
||||
this._commentEditor.setModel(this._commentEditorModel);
|
||||
|
||||
@@ -54,7 +54,6 @@ export interface ICommentService {
|
||||
disposeCommentThread(ownerId: string, threadId: string): void;
|
||||
getComments(resource: URI): Promise<(ICommentInfo | null)[]>;
|
||||
getCommentingRanges(resource: URI): Promise<IRange[]>;
|
||||
getReactionGroup(owner: string): CommentReaction[] | undefined;
|
||||
hasReactionHandler(owner: string): boolean;
|
||||
toggleReaction(owner: string, resource: URI, thread: CommentThread, comment: Comment, reaction: CommentReaction): Promise<void>;
|
||||
setActiveCommentThread(commentThread: CommentThread | null): void;
|
||||
@@ -183,22 +182,6 @@ export class CommentService extends Disposable implements ICommentService {
|
||||
}
|
||||
}
|
||||
|
||||
getReactionGroup(owner: string): CommentReaction[] | undefined {
|
||||
const commentProvider = this._commentControls.get(owner);
|
||||
|
||||
if (commentProvider) {
|
||||
return commentProvider.getReactionGroup();
|
||||
}
|
||||
|
||||
const commentController = this._commentControls.get(owner);
|
||||
|
||||
if (commentController) {
|
||||
return commentController.getReactionGroup();
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
hasReactionHandler(owner: string): boolean {
|
||||
const commentProvider = this._commentControls.get(owner);
|
||||
|
||||
|
||||
@@ -161,14 +161,14 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
|
||||
// we don't do anything here as we always do the reveal ourselves.
|
||||
}
|
||||
|
||||
public reveal(commentId?: string) {
|
||||
public reveal(commentUniqueId?: number) {
|
||||
if (!this._isExpanded) {
|
||||
this.show({ lineNumber: this._commentThread.range.startLineNumber, column: 1 }, 2);
|
||||
}
|
||||
|
||||
if (commentId) {
|
||||
if (commentUniqueId !== undefined) {
|
||||
let height = this.editor.getLayoutInfo().height;
|
||||
let matchedNode = this._commentElements.filter(commentNode => commentNode.comment.commentId === commentId);
|
||||
let matchedNode = this._commentElements.filter(commentNode => commentNode.comment.uniqueIdInThread === commentUniqueId);
|
||||
if (matchedNode && matchedNode.length) {
|
||||
const commentThreadCoords = dom.getDomNodePagePosition(this._commentElements[0].domNode);
|
||||
const commentCoords = dom.getDomNodePagePosition(matchedNode[0].domNode);
|
||||
@@ -247,9 +247,14 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
|
||||
this._actionbarWidget.push([...groups, this._collapseAction], { label: false, icon: true });
|
||||
}
|
||||
|
||||
private deleteCommentThread(): void {
|
||||
this.dispose();
|
||||
this.commentService.disposeCommentThread(this.owner, this._commentThread.threadId);
|
||||
}
|
||||
|
||||
public collapse(): Promise<void> {
|
||||
if (this._commentThread.comments && this._commentThread.comments.length === 0) {
|
||||
this.dispose();
|
||||
this.deleteCommentThread();
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
@@ -268,7 +273,7 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
|
||||
if (this._isExpanded) {
|
||||
this.hide();
|
||||
if (!this._commentThread.comments || !this._commentThread.comments.length) {
|
||||
this.dispose();
|
||||
this.deleteCommentThread();
|
||||
}
|
||||
} else {
|
||||
this.show({ lineNumber: lineNumber, column: 1 }, 2);
|
||||
@@ -284,7 +289,7 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
|
||||
let commentElementsToDelIndex: number[] = [];
|
||||
for (let i = 0; i < oldCommentsLen; i++) {
|
||||
let comment = this._commentElements[i].comment;
|
||||
let newComment = commentThread.comments ? commentThread.comments.filter(c => c.commentId === comment.commentId) : [];
|
||||
let newComment = commentThread.comments ? commentThread.comments.filter(c => c.uniqueIdInThread === comment.uniqueIdInThread) : [];
|
||||
|
||||
if (newComment.length) {
|
||||
this._commentElements[i].update(newComment[0]);
|
||||
@@ -304,7 +309,7 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
|
||||
let newCommentNodeList: CommentNode[] = [];
|
||||
for (let i = newCommentsLen - 1; i >= 0; i--) {
|
||||
let currentComment = commentThread.comments![i];
|
||||
let oldCommentNode = this._commentElements.filter(commentNode => commentNode.comment.commentId === currentComment.commentId);
|
||||
let oldCommentNode = this._commentElements.filter(commentNode => commentNode.comment.uniqueIdInThread === currentComment.uniqueIdInThread);
|
||||
if (oldCommentNode.length) {
|
||||
oldCommentNode[0].update(currentComment);
|
||||
lastCommentElement = oldCommentNode[0].domNode;
|
||||
@@ -601,13 +606,13 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
|
||||
|
||||
this._disposables.add(newCommentNode);
|
||||
this._disposables.add(newCommentNode.onDidDelete(deletedNode => {
|
||||
const deletedNodeId = deletedNode.comment.commentId;
|
||||
const deletedElementIndex = arrays.firstIndex(this._commentElements, commentNode => commentNode.comment.commentId === deletedNodeId);
|
||||
const deletedNodeId = deletedNode.comment.uniqueIdInThread;
|
||||
const deletedElementIndex = arrays.firstIndex(this._commentElements, commentNode => commentNode.comment.uniqueIdInThread === deletedNodeId);
|
||||
if (deletedElementIndex > -1) {
|
||||
this._commentElements.splice(deletedElementIndex, 1);
|
||||
}
|
||||
|
||||
const deletedCommentIndex = arrays.firstIndex(this._commentThread.comments!, comment => comment.commentId === deletedNodeId);
|
||||
const deletedCommentIndex = arrays.firstIndex(this._commentThread.comments!, comment => comment.uniqueIdInThread === deletedNodeId);
|
||||
if (deletedCommentIndex > -1) {
|
||||
this._commentThread.comments!.splice(deletedCommentIndex, 1);
|
||||
}
|
||||
|
||||
@@ -247,18 +247,18 @@ export class ReviewController implements IEditorContribution {
|
||||
return editor.getContribution<ReviewController>(ID);
|
||||
}
|
||||
|
||||
public revealCommentThread(threadId: string, commentId: string, fetchOnceIfNotExist: boolean): void {
|
||||
public revealCommentThread(threadId: string, commentUniqueId: number, fetchOnceIfNotExist: boolean): void {
|
||||
const commentThreadWidget = this._commentWidgets.filter(widget => widget.commentThread.threadId === threadId);
|
||||
if (commentThreadWidget.length === 1) {
|
||||
commentThreadWidget[0].reveal(commentId);
|
||||
commentThreadWidget[0].reveal(commentUniqueId);
|
||||
} else if (fetchOnceIfNotExist) {
|
||||
if (this._computePromise) {
|
||||
this._computePromise.then(_ => {
|
||||
this.revealCommentThread(threadId, commentId, false);
|
||||
this.revealCommentThread(threadId, commentUniqueId, false);
|
||||
});
|
||||
} else {
|
||||
this.beginCompute().then(_ => {
|
||||
this.revealCommentThread(threadId, commentId, false);
|
||||
this.revealCommentThread(threadId, commentUniqueId, false);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ export class CommentsPanel extends Panel {
|
||||
let currentActiveResource = activeEditor ? activeEditor.getResource() : undefined;
|
||||
if (currentActiveResource && currentActiveResource.toString() === element.resource.toString()) {
|
||||
const threadToReveal = element instanceof ResourceWithCommentThreads ? element.commentThreads[0].threadId : element.threadId;
|
||||
const commentToReveal = element instanceof ResourceWithCommentThreads ? element.commentThreads[0].comment.commentId : element.comment.commentId;
|
||||
const commentToReveal = element instanceof ResourceWithCommentThreads ? element.commentThreads[0].comment.uniqueIdInThread : element.comment.uniqueIdInThread;
|
||||
const control = this.editorService.activeTextEditorWidget;
|
||||
if (threadToReveal && isCodeEditor(control)) {
|
||||
const controller = ReviewController.get(control);
|
||||
@@ -200,7 +200,7 @@ export class CommentsPanel extends Panel {
|
||||
const control = editor.getControl();
|
||||
if (threadToReveal && isCodeEditor(control)) {
|
||||
const controller = ReviewController.get(control);
|
||||
controller.revealCommentThread(threadToReveal, commentToReveal.commentId, true);
|
||||
controller.revealCommentThread(threadToReveal, commentToReveal.uniqueIdInThread, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -23,7 +23,7 @@ export class CommentsDataSource implements IDataSource {
|
||||
return element.id;
|
||||
}
|
||||
if (element instanceof CommentNode) {
|
||||
return `${element.resource.toString()}-${element.comment.commentId}`;
|
||||
return `${element.resource.toString()}-${element.comment.uniqueIdInThread}`;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M8 8.70714L11.6464 12.3536L12.3536 11.6465L8.70711 8.00004L12.3536 4.35359L11.6464 3.64648L8 7.29293L4.35355 3.64648L3.64645 4.35359L7.29289 8.00004L3.64645 11.6465L4.35355 12.3536L8 8.70714Z" fill="#C5C5C5"/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 362 B |
@@ -1,3 +0,0 @@
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M8 8.70714L11.6464 12.3536L12.3536 11.6465L8.70711 8.00004L12.3536 4.35359L11.6464 3.64648L8 7.29293L4.35355 3.64648L3.64645 4.35359L7.29289 8.00004L3.64645 11.6465L4.35355 12.3536L8 8.70714Z" fill="#C5C5C5"/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 362 B |
@@ -1,3 +0,0 @@
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M8 8.70714L11.6464 12.3536L12.3536 11.6465L8.70711 8.00004L12.3536 4.35359L11.6464 3.64648L8 7.29293L4.35355 3.64648L3.64645 4.35359L7.29289 8.00004L3.64645 11.6465L4.35355 12.3536L8 8.70714Z" fill="#424242"/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 362 B |
@@ -1,4 +0,0 @@
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M2.40706 15L1 13.5929L3.35721 9.46781L3.52339 9.25025L11.7736 1L13.2321 1L15 2.76791V4.22636L6.74975 12.4766L6.53219 12.6428L2.40706 15ZM2.40706 13.5929L6.02053 11.7474L14.2708 3.49714L12.5029 1.72923L4.25262 9.97947L2.40706 13.5929Z" fill="#C5C5C5"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M5.64645 12.3536L3.64645 10.3536L4.35355 9.64648L6.35355 11.6465L5.64645 12.3536Z" fill="#C5C5C5"/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 553 B |
@@ -1,4 +0,0 @@
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M2.40706 15L1 13.5929L3.35721 9.46781L3.52339 9.25025L11.7736 1L13.2321 1L15 2.76791V4.22636L6.74975 12.4766L6.53219 12.6428L2.40706 15ZM2.40706 13.5929L6.02053 11.7474L14.2708 3.49714L12.5029 1.72923L4.25262 9.97947L2.40706 13.5929Z" fill="white"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M5.64645 12.3536L3.64645 10.3536L4.35355 9.64648L6.35355 11.6465L5.64645 12.3536Z" fill="white"/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 549 B |
@@ -1,4 +0,0 @@
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M2.40706 15L1 13.5929L3.35721 9.46781L3.52339 9.25025L11.7736 1L13.2321 1L15 2.76791V4.22636L6.74975 12.4766L6.53219 12.6428L2.40706 15ZM2.40706 13.5929L6.02053 11.7474L14.2708 3.49714L12.5029 1.72923L4.25262 9.97947L2.40706 13.5929Z" fill="#424242"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M5.64645 12.3536L3.64645 10.3536L4.35355 9.64648L6.35355 11.6465L5.64645 12.3536Z" fill="#424242"/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 553 B |
@@ -29,10 +29,6 @@
|
||||
height: 21px;
|
||||
}
|
||||
|
||||
.monaco-editor .review-widget .body .review-comment .comment-actions .action-item {
|
||||
width: 22px;
|
||||
}
|
||||
|
||||
.monaco-editor .review-widget .body .review-comment .comment-title {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
@@ -148,10 +144,6 @@
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
||||
.monaco-editor .review-widget .body .review-comment .review-comment-contents .comment-reactions .action-item a.action-label {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.monaco-editor .review-widget .head .review-actions > .monaco-action-bar .icon.expand-review-action {
|
||||
background-image: url("./close-light.svg");
|
||||
background-size: 16px;
|
||||
@@ -165,32 +157,6 @@
|
||||
background-image: url("./close-hc.svg");
|
||||
}
|
||||
|
||||
.monaco-editor .review-widget .body .review-comment .comment-title .icon.edit {
|
||||
background-image: url("./edit-light.svg");
|
||||
background-size: 16px;
|
||||
}
|
||||
|
||||
.monaco-editor.vs-dark .review-widget .body .review-comment .comment-title .icon.edit {
|
||||
background-image: url("./edit-dark.svg");
|
||||
}
|
||||
|
||||
.monaco-editor.hc-black .review-widget .body .review-comment .comment-title .icon.edit {
|
||||
background-image: url("./edit-hc.svg");
|
||||
}
|
||||
|
||||
.monaco-editor .review-widget .body .review-comment .comment-title .icon.delete {
|
||||
background-image: url("./delete-light.svg");
|
||||
background-size: 16px;
|
||||
}
|
||||
|
||||
.monaco-editor.vs-dark .review-widget .body .review-comment .comment-title .icon.delete {
|
||||
background-image: url("./delete-dark.svg");
|
||||
}
|
||||
|
||||
.monaco-editor.hc-black .review-widget .body .review-comment .comment-title .icon.delete {
|
||||
background-image: url("./delete-hc.svg");
|
||||
}
|
||||
|
||||
.monaco-editor .review-widget .body .review-comment .review-comment-contents .comment-reactions .action-item a.action-label.toolbar-toggle-pickReactions {
|
||||
display: none;
|
||||
background-image: url("./reaction-light.svg");
|
||||
@@ -220,7 +186,6 @@
|
||||
display: block;
|
||||
height: 16px;
|
||||
line-height: 16px;
|
||||
min-width: 28px;
|
||||
background-size: 16px;
|
||||
background-position: center center;
|
||||
background-repeat: no-repeat;
|
||||
@@ -433,7 +398,8 @@
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.monaco-editor .review-widget .head .review-actions > .monaco-action-bar .action-item {
|
||||
.monaco-editor .review-widget .action-item {
|
||||
min-width: 16px;
|
||||
margin-left: 4px;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ import { IDebugService, State, IDebugSession, CONTEXT_DEBUG_TYPE, CONTEXT_DEBUG_
|
||||
import { isExtensionHostDebugging } from 'vs/workbench/contrib/debug/common/debugUtils';
|
||||
import { isErrorWithActions, createErrorWithActions } from 'vs/base/common/errorsWithActions';
|
||||
import { RunOnceScheduler } from 'vs/base/common/async';
|
||||
import { IExtensionHostDebugService } from 'vs/workbench/services/extensions/common/extensionHostDebug';
|
||||
import { IExtensionHostDebugService } from 'vs/platform/debug/common/extensionHostDebug';
|
||||
import { isCodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
|
||||
const DEBUG_BREAKPOINTS_KEY = 'debug.breakpoint';
|
||||
|
||||
@@ -220,12 +220,10 @@ export class ExperimentService extends Disposable implements IExperimentService
|
||||
|
||||
});
|
||||
return Promise.all(promises).then(() => {
|
||||
/* __GDPR__
|
||||
"experiments" : {
|
||||
"experiments" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
|
||||
}
|
||||
*/
|
||||
this.telemetryService.publicLog('experiments', { experiments: this._experiments });
|
||||
type ExperimentsClassification = {
|
||||
experiments: { classification: 'SystemMetaData', purpose: 'FeatureInsight' };
|
||||
};
|
||||
this.telemetryService.publicLog2<{ experiments: IExperiment[] }, ExperimentsClassification>('experiments', { experiments: this._experiments });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -10,9 +10,9 @@ import { TestInstantiationService } from 'vs/platform/instantiation/test/common/
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { TestLifecycleService } from 'vs/workbench/test/workbenchTestServices';
|
||||
import {
|
||||
IExtensionManagementService, DidInstallExtensionEvent, DidUninstallExtensionEvent, InstallExtensionEvent, IExtensionIdentifier,
|
||||
IExtensionEnablementService, ILocalExtension
|
||||
IExtensionManagementService, DidInstallExtensionEvent, DidUninstallExtensionEvent, InstallExtensionEvent, IExtensionIdentifier, ILocalExtension
|
||||
} from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { IExtensionEnablementService } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
|
||||
import { ExtensionManagementService } from 'vs/platform/extensionManagement/node/extensionManagementService';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
import { TestExtensionEnablementService } from 'vs/workbench/services/extensionManagement/test/electron-browser/extensionEnablementService.test';
|
||||
|
||||
@@ -20,7 +20,7 @@ import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor';
|
||||
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IExtensionTipsService } from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { IExtensionTipsService } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
|
||||
import { IExtensionManifest, IKeyBinding, IView, IViewContainer, ExtensionType } from 'vs/platform/extensions/common/extensions';
|
||||
import { ResolvedKeybinding, KeyMod, KeyCode } from 'vs/base/common/keyCodes';
|
||||
import { ExtensionsInput } from 'vs/workbench/contrib/extensions/common/extensionsInput';
|
||||
@@ -498,6 +498,13 @@ export class ExtensionEditor extends BaseEditor {
|
||||
}));
|
||||
}
|
||||
|
||||
clearInput(): void {
|
||||
this.contentDisposables.clear();
|
||||
this.transientDisposables.clear();
|
||||
|
||||
super.clearInput();
|
||||
}
|
||||
|
||||
focus(): void {
|
||||
if (this.activeElement) {
|
||||
this.activeElement.focus();
|
||||
@@ -621,8 +628,7 @@ export class ExtensionEditor extends BaseEditor {
|
||||
this.renderViewContainers(content, manifest, layout),
|
||||
this.renderViews(content, manifest, layout),
|
||||
this.renderLocalizations(content, manifest, layout),
|
||||
// {{SQL CARBON EDIT}}
|
||||
renderDashboardContributions(content, manifest, layout)
|
||||
renderDashboardContributions(content, manifest, layout) // {{SQL CARBON EDIT}}
|
||||
];
|
||||
|
||||
scrollableContent.scanDomNode();
|
||||
@@ -860,7 +866,7 @@ export class ExtensionEditor extends BaseEditor {
|
||||
const contributes = manifest.contributes;
|
||||
const colors = contributes && contributes.colors;
|
||||
|
||||
if (!colors || !colors.length) {
|
||||
if (!(colors && colors.length)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -943,12 +949,12 @@ export class ExtensionEditor extends BaseEditor {
|
||||
menus[context].forEach(menu => {
|
||||
let command = byId[menu.command];
|
||||
|
||||
if (!command) {
|
||||
if (command) {
|
||||
command.menus.push(context);
|
||||
} else {
|
||||
command = { id: menu.command, title: '', keybindings: [], menus: [context] };
|
||||
byId[command.id] = command;
|
||||
commands.push(command);
|
||||
} else {
|
||||
command.menus.push(context);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -964,12 +970,12 @@ export class ExtensionEditor extends BaseEditor {
|
||||
|
||||
let command = byId[rawKeybinding.command];
|
||||
|
||||
if (!command) {
|
||||
if (command) {
|
||||
command.keybindings.push(keybinding);
|
||||
} else {
|
||||
command = { id: rawKeybinding.command, title: '', keybindings: [keybinding], menus: [] };
|
||||
byId[command.id] = command;
|
||||
commands.push(command);
|
||||
} else {
|
||||
command.keybindings.push(keybinding);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1023,12 +1029,12 @@ export class ExtensionEditor extends BaseEditor {
|
||||
grammars.forEach(grammar => {
|
||||
let language = byId[grammar.language];
|
||||
|
||||
if (!language) {
|
||||
if (language) {
|
||||
language.hasGrammar = true;
|
||||
} else {
|
||||
language = { id: grammar.language, name: grammar.language, extensions: [], hasGrammar: true, hasSnippets: false };
|
||||
byId[language.id] = language;
|
||||
languages.push(language);
|
||||
} else {
|
||||
language.hasGrammar = true;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1037,12 +1043,12 @@ export class ExtensionEditor extends BaseEditor {
|
||||
snippets.forEach(snippet => {
|
||||
let language = byId[snippet.language];
|
||||
|
||||
if (!language) {
|
||||
if (language) {
|
||||
language.hasSnippets = true;
|
||||
} else {
|
||||
language = { id: snippet.language, name: snippet.language, extensions: [], hasGrammar: false, hasSnippets: true };
|
||||
byId[language.id] = language;
|
||||
languages.push(language);
|
||||
} else {
|
||||
language.hasSnippets = true;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1084,11 +1090,11 @@ export class ExtensionEditor extends BaseEditor {
|
||||
}
|
||||
|
||||
const keyBinding = KeybindingParser.parseKeybinding(key || rawKeyBinding.key, OS);
|
||||
if (!keyBinding) {
|
||||
return null;
|
||||
}
|
||||
if (keyBinding) {
|
||||
return this.keybindingService.resolveKeybinding(keyBinding)[0];
|
||||
|
||||
return this.keybindingService.resolveKeybinding(keyBinding)[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private loadContents<T>(loadingTask: () => CacheResult<T>): Promise<T> {
|
||||
|
||||
@@ -0,0 +1,373 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import 'vs/css!./media/extensions';
|
||||
import { localize } from 'vs/nls';
|
||||
import { KeyMod, KeyChord, KeyCode } from 'vs/base/common/keyCodes';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { SyncActionDescriptor, MenuRegistry, MenuId } from 'vs/platform/actions/common/actions';
|
||||
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
import { ExtensionsLabel, ExtensionsChannelId, PreferencesLabel, IExtensionManagementService, IExtensionGalleryService } from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { IExtensionManagementServerService } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
|
||||
import { IWorkbenchActionRegistry, Extensions as WorkbenchActionExtensions } from 'vs/workbench/common/actions';
|
||||
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions, IWorkbenchContribution } from 'vs/workbench/common/contributions';
|
||||
import { IOutputChannelRegistry, Extensions as OutputExtensions } from 'vs/workbench/contrib/output/common/output';
|
||||
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
import { VIEWLET_ID, IExtensionsWorkbenchService } from 'vs/workbench/contrib/extensions/common/extensions';
|
||||
import { ExtensionsWorkbenchService } from 'vs/workbench/contrib/extensions/browser/extensionsWorkbenchService';
|
||||
import {
|
||||
OpenExtensionsViewletAction, InstallExtensionsAction, ShowOutdatedExtensionsAction, ShowRecommendedExtensionsAction, ShowRecommendedKeymapExtensionsAction, ShowPopularExtensionsAction,
|
||||
ShowEnabledExtensionsAction, ShowInstalledExtensionsAction, ShowDisabledExtensionsAction, ShowBuiltInExtensionsAction, UpdateAllAction,
|
||||
EnableAllAction, EnableAllWorkpsaceAction, DisableAllAction, DisableAllWorkpsaceAction, CheckForUpdatesAction, ShowLanguageExtensionsAction, ShowAzureExtensionsAction, EnableAutoUpdateAction, DisableAutoUpdateAction, ConfigureRecommendedExtensionsCommandsContributor, OpenExtensionsFolderAction, InstallVSIXAction, ReinstallAction, InstallSpecificVersionOfExtensionAction
|
||||
} from 'vs/workbench/contrib/extensions/browser/extensionsActions';
|
||||
import { ExtensionsInput } from 'vs/workbench/contrib/extensions/common/extensionsInput';
|
||||
import { ViewletRegistry, Extensions as ViewletExtensions, ViewletDescriptor } from 'vs/workbench/browser/viewlet';
|
||||
import { ExtensionEditor } from 'vs/workbench/contrib/extensions/browser/extensionEditor';
|
||||
import { StatusUpdater, ExtensionsViewlet, MaliciousExtensionChecker, ExtensionsViewletViewsContribution } from 'vs/workbench/contrib/extensions/browser/extensionsViewlet';
|
||||
import { IQuickOpenRegistry, Extensions, QuickOpenHandlerDescriptor } from 'vs/workbench/browser/quickopen';
|
||||
import { IConfigurationRegistry, Extensions as ConfigurationExtensions, ConfigurationScope } from 'vs/platform/configuration/common/configurationRegistry';
|
||||
import * as jsonContributionRegistry from 'vs/platform/jsonschemas/common/jsonContributionRegistry';
|
||||
import { ExtensionsConfigurationSchema, ExtensionsConfigurationSchemaId } from 'vs/workbench/contrib/extensions/common/extensionsFileTemplate';
|
||||
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { KeymapExtensions } from 'vs/workbench/contrib/extensions/common/extensionsUtils';
|
||||
import { areSameExtensions } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
|
||||
import { GalleryExtensionsHandler, ExtensionsHandler } from 'vs/workbench/contrib/extensions/browser/extensionsQuickOpen';
|
||||
import { EditorDescriptor, IEditorRegistry, Extensions as EditorExtensions } from 'vs/workbench/browser/editor';
|
||||
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
|
||||
import { URI, UriComponents } from 'vs/base/common/uri';
|
||||
import { ExtensionActivationProgress } from 'vs/workbench/contrib/extensions/browser/extensionsActivationProgress';
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
import { ExtensionDependencyChecker } from 'vs/workbench/contrib/extensions/browser/extensionsDependencyChecker';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { ExtensionType } from 'vs/platform/extensions/common/extensions';
|
||||
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
|
||||
|
||||
// Singletons
|
||||
registerSingleton(IExtensionsWorkbenchService, ExtensionsWorkbenchService);
|
||||
|
||||
Registry.as<IOutputChannelRegistry>(OutputExtensions.OutputChannels)
|
||||
.registerChannel({ id: ExtensionsChannelId, label: ExtensionsLabel, log: false });
|
||||
|
||||
// Quickopen
|
||||
Registry.as<IQuickOpenRegistry>(Extensions.Quickopen).registerQuickOpenHandler(
|
||||
new QuickOpenHandlerDescriptor(
|
||||
ExtensionsHandler,
|
||||
ExtensionsHandler.ID,
|
||||
'ext ',
|
||||
undefined,
|
||||
localize('extensionsCommands', "Manage Extensions"),
|
||||
true
|
||||
)
|
||||
);
|
||||
|
||||
// Editor
|
||||
const editorDescriptor = new EditorDescriptor(
|
||||
ExtensionEditor,
|
||||
ExtensionEditor.ID,
|
||||
localize('extension', "Extension")
|
||||
);
|
||||
|
||||
Registry.as<IEditorRegistry>(EditorExtensions.Editors)
|
||||
.registerEditor(editorDescriptor, [new SyncDescriptor(ExtensionsInput)]);
|
||||
|
||||
// Viewlet
|
||||
const viewletDescriptor = new ViewletDescriptor(
|
||||
ExtensionsViewlet,
|
||||
VIEWLET_ID,
|
||||
localize('extensions', "Extensions"),
|
||||
'extensions',
|
||||
4
|
||||
);
|
||||
|
||||
Registry.as<ViewletRegistry>(ViewletExtensions.Viewlets)
|
||||
.registerViewlet(viewletDescriptor);
|
||||
|
||||
// Global actions
|
||||
const actionRegistry = Registry.as<IWorkbenchActionRegistry>(WorkbenchActionExtensions.WorkbenchActions);
|
||||
|
||||
const openViewletActionDescriptor = new SyncActionDescriptor(OpenExtensionsViewletAction, OpenExtensionsViewletAction.ID, OpenExtensionsViewletAction.LABEL, { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_X });
|
||||
actionRegistry.registerWorkbenchAction(openViewletActionDescriptor, 'View: Show Extensions', localize('view', "View"));
|
||||
|
||||
const installActionDescriptor = new SyncActionDescriptor(InstallExtensionsAction, InstallExtensionsAction.ID, InstallExtensionsAction.LABEL);
|
||||
actionRegistry.registerWorkbenchAction(installActionDescriptor, 'Extensions: Install Extensions', ExtensionsLabel);
|
||||
|
||||
const listOutdatedActionDescriptor = new SyncActionDescriptor(ShowOutdatedExtensionsAction, ShowOutdatedExtensionsAction.ID, ShowOutdatedExtensionsAction.LABEL);
|
||||
actionRegistry.registerWorkbenchAction(listOutdatedActionDescriptor, 'Extensions: Show Outdated Extensions', ExtensionsLabel);
|
||||
|
||||
const recommendationsActionDescriptor = new SyncActionDescriptor(ShowRecommendedExtensionsAction, ShowRecommendedExtensionsAction.ID, ShowRecommendedExtensionsAction.LABEL);
|
||||
actionRegistry.registerWorkbenchAction(recommendationsActionDescriptor, 'Extensions: Show Recommended Extensions', ExtensionsLabel);
|
||||
|
||||
const keymapRecommendationsActionDescriptor = new SyncActionDescriptor(ShowRecommendedKeymapExtensionsAction, ShowRecommendedKeymapExtensionsAction.ID, ShowRecommendedKeymapExtensionsAction.SHORT_LABEL, { primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_M) });
|
||||
actionRegistry.registerWorkbenchAction(keymapRecommendationsActionDescriptor, 'Preferences: Keymaps', PreferencesLabel);
|
||||
|
||||
const languageExtensionsActionDescriptor = new SyncActionDescriptor(ShowLanguageExtensionsAction, ShowLanguageExtensionsAction.ID, ShowLanguageExtensionsAction.SHORT_LABEL);
|
||||
actionRegistry.registerWorkbenchAction(languageExtensionsActionDescriptor, 'Preferences: Language Extensions', PreferencesLabel);
|
||||
|
||||
const azureExtensionsActionDescriptor = new SyncActionDescriptor(ShowAzureExtensionsAction, ShowAzureExtensionsAction.ID, ShowAzureExtensionsAction.SHORT_LABEL);
|
||||
actionRegistry.registerWorkbenchAction(azureExtensionsActionDescriptor, 'Preferences: Azure Extensions', PreferencesLabel);
|
||||
|
||||
const popularActionDescriptor = new SyncActionDescriptor(ShowPopularExtensionsAction, ShowPopularExtensionsAction.ID, ShowPopularExtensionsAction.LABEL);
|
||||
actionRegistry.registerWorkbenchAction(popularActionDescriptor, 'Extensions: Show Popular Extensions', ExtensionsLabel);
|
||||
|
||||
const enabledActionDescriptor = new SyncActionDescriptor(ShowEnabledExtensionsAction, ShowEnabledExtensionsAction.ID, ShowEnabledExtensionsAction.LABEL);
|
||||
actionRegistry.registerWorkbenchAction(enabledActionDescriptor, 'Extensions: Show Enabled Extensions', ExtensionsLabel);
|
||||
|
||||
const installedActionDescriptor = new SyncActionDescriptor(ShowInstalledExtensionsAction, ShowInstalledExtensionsAction.ID, ShowInstalledExtensionsAction.LABEL);
|
||||
actionRegistry.registerWorkbenchAction(installedActionDescriptor, 'Extensions: Show Installed Extensions', ExtensionsLabel);
|
||||
|
||||
const disabledActionDescriptor = new SyncActionDescriptor(ShowDisabledExtensionsAction, ShowDisabledExtensionsAction.ID, ShowDisabledExtensionsAction.LABEL);
|
||||
actionRegistry.registerWorkbenchAction(disabledActionDescriptor, 'Extensions: Show Disabled Extensions', ExtensionsLabel);
|
||||
|
||||
const builtinActionDescriptor = new SyncActionDescriptor(ShowBuiltInExtensionsAction, ShowBuiltInExtensionsAction.ID, ShowBuiltInExtensionsAction.LABEL);
|
||||
actionRegistry.registerWorkbenchAction(builtinActionDescriptor, 'Extensions: Show Built-in Extensions', ExtensionsLabel);
|
||||
|
||||
const updateAllActionDescriptor = new SyncActionDescriptor(UpdateAllAction, UpdateAllAction.ID, UpdateAllAction.LABEL);
|
||||
actionRegistry.registerWorkbenchAction(updateAllActionDescriptor, 'Extensions: Update All Extensions', ExtensionsLabel);
|
||||
|
||||
const installVSIXActionDescriptor = new SyncActionDescriptor(InstallVSIXAction, InstallVSIXAction.ID, InstallVSIXAction.LABEL);
|
||||
actionRegistry.registerWorkbenchAction(installVSIXActionDescriptor, 'Extensions: Install from VSIX...', ExtensionsLabel);
|
||||
|
||||
const disableAllAction = new SyncActionDescriptor(DisableAllAction, DisableAllAction.ID, DisableAllAction.LABEL);
|
||||
actionRegistry.registerWorkbenchAction(disableAllAction, 'Extensions: Disable All Installed Extensions', ExtensionsLabel);
|
||||
|
||||
const disableAllWorkspaceAction = new SyncActionDescriptor(DisableAllWorkpsaceAction, DisableAllWorkpsaceAction.ID, DisableAllWorkpsaceAction.LABEL);
|
||||
actionRegistry.registerWorkbenchAction(disableAllWorkspaceAction, 'Extensions: Disable All Installed Extensions for this Workspace', ExtensionsLabel);
|
||||
|
||||
const enableAllAction = new SyncActionDescriptor(EnableAllAction, EnableAllAction.ID, EnableAllAction.LABEL);
|
||||
actionRegistry.registerWorkbenchAction(enableAllAction, 'Extensions: Enable All Extensions', ExtensionsLabel);
|
||||
|
||||
const enableAllWorkspaceAction = new SyncActionDescriptor(EnableAllWorkpsaceAction, EnableAllWorkpsaceAction.ID, EnableAllWorkpsaceAction.LABEL);
|
||||
actionRegistry.registerWorkbenchAction(enableAllWorkspaceAction, 'Extensions: Enable All Extensions for this Workspace', ExtensionsLabel);
|
||||
|
||||
const checkForUpdatesAction = new SyncActionDescriptor(CheckForUpdatesAction, CheckForUpdatesAction.ID, CheckForUpdatesAction.LABEL);
|
||||
actionRegistry.registerWorkbenchAction(checkForUpdatesAction, `Extensions: Check for Extension Updates`, ExtensionsLabel);
|
||||
|
||||
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(EnableAutoUpdateAction, EnableAutoUpdateAction.ID, EnableAutoUpdateAction.LABEL), `Extensions: Enable Auto Updating Extensions`, ExtensionsLabel);
|
||||
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(DisableAutoUpdateAction, DisableAutoUpdateAction.ID, DisableAutoUpdateAction.LABEL), `Extensions: Disable Auto Updating Extensions`, ExtensionsLabel);
|
||||
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(InstallSpecificVersionOfExtensionAction, InstallSpecificVersionOfExtensionAction.ID, InstallSpecificVersionOfExtensionAction.LABEL), 'Install Specific Version of Extension...', ExtensionsLabel);
|
||||
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(ReinstallAction, ReinstallAction.ID, ReinstallAction.LABEL), 'Reinstall Extension...', localize('developer', "Developer"));
|
||||
|
||||
Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration)
|
||||
.registerConfiguration({
|
||||
id: 'extensions',
|
||||
order: 30,
|
||||
title: localize('extensionsConfigurationTitle', "Extensions"),
|
||||
type: 'object',
|
||||
properties: {
|
||||
'extensions.autoUpdate': {
|
||||
type: 'boolean',
|
||||
description: localize('extensionsAutoUpdate', "When enabled, automatically installs updates for extensions. The updates are fetched from a Microsoft online service."),
|
||||
default: true,
|
||||
scope: ConfigurationScope.APPLICATION,
|
||||
tags: ['usesOnlineServices']
|
||||
},
|
||||
'extensions.autoCheckUpdates': {
|
||||
type: 'boolean',
|
||||
description: localize('extensionsCheckUpdates', "When enabled, automatically checks extensions for updates. If an extension has an update, it is marked as outdated in the Extensions view. The updates are fetched from a Microsoft online service."),
|
||||
default: true,
|
||||
scope: ConfigurationScope.APPLICATION,
|
||||
tags: ['usesOnlineServices']
|
||||
},
|
||||
'extensions.ignoreRecommendations': {
|
||||
type: 'boolean',
|
||||
description: localize('extensionsIgnoreRecommendations', "When enabled, the notifications for extension recommendations will not be shown."),
|
||||
default: false
|
||||
},
|
||||
'extensions.showRecommendationsOnlyOnDemand': {
|
||||
type: 'boolean',
|
||||
description: localize('extensionsShowRecommendationsOnlyOnDemand', "When enabled, recommendations will not be fetched or shown unless specifically requested by the user. Some recommendations are fetched from a Microsoft online service."),
|
||||
default: false,
|
||||
tags: ['usesOnlineServices']
|
||||
},
|
||||
'extensions.closeExtensionDetailsOnViewChange': {
|
||||
type: 'boolean',
|
||||
description: localize('extensionsCloseExtensionDetailsOnViewChange', "When enabled, editors with extension details will be automatically closed upon navigating away from the Extensions View."),
|
||||
default: false
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const jsonRegistry = <jsonContributionRegistry.IJSONContributionRegistry>Registry.as(jsonContributionRegistry.Extensions.JSONContribution);
|
||||
jsonRegistry.registerSchema(ExtensionsConfigurationSchemaId, ExtensionsConfigurationSchema);
|
||||
|
||||
// Register Commands
|
||||
CommandsRegistry.registerCommand('_extensions.manage', (accessor: ServicesAccessor, extensionId: string) => {
|
||||
const extensionService = accessor.get(IExtensionsWorkbenchService);
|
||||
const extension = extensionService.local.filter(e => areSameExtensions(e.identifier, { id: extensionId }));
|
||||
if (extension.length === 1) {
|
||||
extensionService.open(extension[0]);
|
||||
}
|
||||
});
|
||||
|
||||
CommandsRegistry.registerCommand('extension.open', (accessor: ServicesAccessor, extensionId: string) => {
|
||||
const extensionService = accessor.get(IExtensionsWorkbenchService);
|
||||
|
||||
return extensionService.queryGallery({ names: [extensionId], pageSize: 1 }, CancellationToken.None).then(pager => {
|
||||
if (pager.total !== 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
extensionService.open(pager.firstPage[0]);
|
||||
});
|
||||
});
|
||||
|
||||
CommandsRegistry.registerCommand({
|
||||
id: 'workbench.extensions.installExtension',
|
||||
description: {
|
||||
description: localize('workbench.extensions.installExtension.description', "Install the given extension"),
|
||||
args: [
|
||||
{
|
||||
name: localize('workbench.extensions.installExtension.arg.name', "Extension id or VSIX resource uri"),
|
||||
schema: {
|
||||
'type': ['object', 'string']
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
handler: async (accessor, arg: string | UriComponents) => {
|
||||
const extensionManagementService = accessor.get(IExtensionManagementService);
|
||||
const extensionGalleryService = accessor.get(IExtensionGalleryService);
|
||||
try {
|
||||
if (typeof arg === 'string') {
|
||||
const extension = await extensionGalleryService.getCompatibleExtension({ id: arg });
|
||||
if (extension) {
|
||||
await extensionManagementService.installFromGallery(extension);
|
||||
} else {
|
||||
throw new Error(localize('notFound', "Extension '{0}' not found.", arg));
|
||||
}
|
||||
} else {
|
||||
const vsix = URI.revive(arg);
|
||||
await extensionManagementService.install(vsix);
|
||||
}
|
||||
} catch (e) {
|
||||
onUnexpectedError(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
CommandsRegistry.registerCommand({
|
||||
id: 'workbench.extensions.uninstallExtension',
|
||||
description: {
|
||||
description: localize('workbench.extensions.uninstallExtension.description', "Uninstall the given extension"),
|
||||
args: [
|
||||
{
|
||||
name: localize('workbench.extensions.uninstallExtension.arg.name', "Id of the extension to uninstall"),
|
||||
schema: {
|
||||
'type': 'string'
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
handler: async (accessor, id: string) => {
|
||||
if (!id) {
|
||||
throw new Error(localize('id required', "Extension id required."));
|
||||
}
|
||||
const extensionManagementService = accessor.get(IExtensionManagementService);
|
||||
try {
|
||||
const installed = await extensionManagementService.getInstalled(ExtensionType.User);
|
||||
const [extensionToUninstall] = installed.filter(e => areSameExtensions(e.identifier, { id }));
|
||||
if (!extensionToUninstall) {
|
||||
return Promise.reject(new Error(localize('notInstalled', "Extension '{0}' is not installed. Make sure you use the full extension ID, including the publisher, e.g.: ms-vscode.csharp.", id)));
|
||||
}
|
||||
await extensionManagementService.uninstall(extensionToUninstall, true);
|
||||
} catch (e) {
|
||||
onUnexpectedError(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// File menu registration
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.MenubarPreferencesMenu, {
|
||||
group: '2_keybindings',
|
||||
command: {
|
||||
id: ShowRecommendedKeymapExtensionsAction.ID,
|
||||
title: localize({ key: 'miOpenKeymapExtensions', comment: ['&& denotes a mnemonic'] }, "&&Keymaps")
|
||||
},
|
||||
order: 2
|
||||
});
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.GlobalActivity, {
|
||||
group: '2_keybindings',
|
||||
command: {
|
||||
id: ShowRecommendedKeymapExtensionsAction.ID,
|
||||
title: localize('miOpenKeymapExtensions2', "Keymaps")
|
||||
},
|
||||
order: 2
|
||||
});
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.MenubarPreferencesMenu, {
|
||||
group: '1_settings',
|
||||
command: {
|
||||
id: VIEWLET_ID,
|
||||
title: localize({ key: 'miPreferencesExtensions', comment: ['&& denotes a mnemonic'] }, "&&Extensions")
|
||||
},
|
||||
order: 3
|
||||
});
|
||||
|
||||
// View menu
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.MenubarViewMenu, {
|
||||
group: '3_views',
|
||||
command: {
|
||||
id: VIEWLET_ID,
|
||||
title: localize({ key: 'miViewExtensions', comment: ['&& denotes a mnemonic'] }, "E&&xtensions")
|
||||
},
|
||||
order: 5
|
||||
});
|
||||
|
||||
// Global Activity Menu
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.GlobalActivity, {
|
||||
group: '2_configuration',
|
||||
command: {
|
||||
id: VIEWLET_ID,
|
||||
title: localize('showExtensions', "Extensions")
|
||||
},
|
||||
order: 3
|
||||
});
|
||||
|
||||
const workbenchRegistry = Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench);
|
||||
|
||||
class ExtensionsContributions implements IWorkbenchContribution {
|
||||
|
||||
constructor(
|
||||
@IWorkbenchEnvironmentService workbenchEnvironmentService: IWorkbenchEnvironmentService,
|
||||
@IExtensionManagementServerService extensionManagementServerService: IExtensionManagementServerService
|
||||
) {
|
||||
|
||||
const canManageExtensions = extensionManagementServerService.localExtensionManagementServer || extensionManagementServerService.remoteExtensionManagementServer;
|
||||
|
||||
if (canManageExtensions) {
|
||||
Registry.as<IQuickOpenRegistry>(Extensions.Quickopen).registerQuickOpenHandler(
|
||||
new QuickOpenHandlerDescriptor(
|
||||
GalleryExtensionsHandler,
|
||||
GalleryExtensionsHandler.ID,
|
||||
'ext install ',
|
||||
undefined,
|
||||
localize('galleryExtensionsCommands', "Install Gallery Extensions"),
|
||||
true
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (workbenchEnvironmentService.extensionsPath) {
|
||||
const openExtensionsFolderActionDescriptor = new SyncActionDescriptor(OpenExtensionsFolderAction, OpenExtensionsFolderAction.ID, OpenExtensionsFolderAction.LABEL);
|
||||
actionRegistry.registerWorkbenchAction(openExtensionsFolderActionDescriptor, 'Extensions: Open Extensions Folder', ExtensionsLabel);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
workbenchRegistry.registerWorkbenchContribution(ExtensionsContributions, LifecyclePhase.Starting);
|
||||
workbenchRegistry.registerWorkbenchContribution(StatusUpdater, LifecyclePhase.Restored);
|
||||
workbenchRegistry.registerWorkbenchContribution(MaliciousExtensionChecker, LifecyclePhase.Eventually);
|
||||
workbenchRegistry.registerWorkbenchContribution(ConfigureRecommendedExtensionsCommandsContributor, LifecyclePhase.Eventually);
|
||||
workbenchRegistry.registerWorkbenchContribution(KeymapExtensions, LifecyclePhase.Restored);
|
||||
workbenchRegistry.registerWorkbenchContribution(ExtensionsViewletViewsContribution, LifecyclePhase.Starting);
|
||||
workbenchRegistry.registerWorkbenchContribution(ExtensionActivationProgress, LifecyclePhase.Eventually);
|
||||
workbenchRegistry.registerWorkbenchContribution(ExtensionDependencyChecker, LifecyclePhase.Eventually);
|
||||
@@ -16,7 +16,8 @@ import { dispose, Disposable } from 'vs/base/common/lifecycle';
|
||||
// {{SQL CARBON EDIT}}
|
||||
import { IExtension, ExtensionState, IExtensionsWorkbenchService, VIEWLET_ID, IExtensionsViewlet, AutoUpdateConfigurationKey, IExtensionContainer, EXTENSIONS_CONFIG, ExtensionsPolicy, ExtensionsPolicyKey } from 'vs/workbench/contrib/extensions/common/extensions';
|
||||
import { ExtensionsConfigurationInitialContent } from 'vs/workbench/contrib/extensions/common/extensionsFileTemplate';
|
||||
import { IExtensionEnablementService, IExtensionTipsService, EnablementState, ExtensionsLabel, IExtensionRecommendation, IGalleryExtension, IExtensionsConfigContent, IExtensionGalleryService, INSTALL_ERROR_MALICIOUS, INSTALL_ERROR_INCOMPATIBLE, IGalleryExtensionVersion, ILocalExtension, IExtensionManagementServerService, IExtensionManagementServer } from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { ExtensionsLabel, IGalleryExtension, IExtensionGalleryService, INSTALL_ERROR_MALICIOUS, INSTALL_ERROR_INCOMPATIBLE, IGalleryExtensionVersion, ILocalExtension } from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { IExtensionEnablementService, EnablementState, IExtensionManagementServerService, IExtensionTipsService, IExtensionRecommendation, IExtensionsConfigContent } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
|
||||
import { areSameExtensions } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
|
||||
import { ExtensionType, ExtensionIdentifier, IExtensionDescription, IExtensionManifest, isLanguagePackExtension } from 'vs/platform/extensions/common/extensions';
|
||||
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
|
||||
@@ -55,9 +56,7 @@ import { alert } from 'vs/base/browser/ui/aria/aria';
|
||||
import { coalesce } from 'vs/base/common/arrays';
|
||||
import { IWorkbenchThemeService, COLOR_THEME_SETTING, ICON_THEME_SETTING, IFileIconTheme, IColorTheme } from 'vs/workbench/services/themes/common/workbenchThemeService';
|
||||
import { ILabelService } from 'vs/platform/label/common/label';
|
||||
import { REMOTE_HOST_SCHEME } from 'vs/platform/remote/common/remoteHosts';
|
||||
import { isUIExtension } from 'vs/workbench/services/extensions/common/extensionsUtil';
|
||||
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
|
||||
import { IPreferencesService } from 'vs/workbench/services/preferences/common/preferences';
|
||||
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { IProductService } from 'vs/platform/product/common/product';
|
||||
@@ -166,10 +165,10 @@ export class InstallAction extends ExtensionAction {
|
||||
@IOpenerService private readonly openerService: IOpenerService,
|
||||
@IExtensionService private readonly runtimeExtensionService: IExtensionService,
|
||||
@IWorkbenchThemeService private readonly workbenchThemeService: IWorkbenchThemeService,
|
||||
@IWorkbenchEnvironmentService private readonly workbenchEnvironmentService: IWorkbenchEnvironmentService,
|
||||
@IConfigurationService private readonly configurationService: IConfigurationService,
|
||||
@IProductService private readonly productService: IProductService,
|
||||
@ILabelService private readonly labelService: ILabelService
|
||||
@ILabelService private readonly labelService: ILabelService,
|
||||
@IExtensionManagementServerService private readonly extensionManagementServerService: IExtensionManagementServerService
|
||||
) {
|
||||
super(`extensions.install`, InstallAction.INSTALL_LABEL, InstallAction.Class, false);
|
||||
this.update();
|
||||
@@ -197,12 +196,12 @@ export class InstallAction extends ExtensionAction {
|
||||
this.label = InstallAction.INSTALLING_LABEL;
|
||||
this.tooltip = InstallAction.INSTALLING_LABEL;
|
||||
} else {
|
||||
if (this._manifest && this.workbenchEnvironmentService.configuration.remoteAuthority) {
|
||||
if (this._manifest && this.extensionManagementServerService.localExtensionManagementServer && this.extensionManagementServerService.remoteExtensionManagementServer) {
|
||||
if (isUIExtension(this._manifest, this.productService, this.configurationService)) {
|
||||
this.label = `${InstallAction.INSTALL_LABEL} ${localize('locally', "Locally")}`;
|
||||
this.tooltip = `${InstallAction.INSTALL_LABEL} ${localize('locally', "Locally")}`;
|
||||
} else {
|
||||
const host = this.labelService.getHostLabel(REMOTE_HOST_SCHEME, this.workbenchEnvironmentService.configuration.remoteAuthority) || localize('remote', "Remote");
|
||||
const host = this.extensionManagementServerService.remoteExtensionManagementServer.label;
|
||||
this.label = `${InstallAction.INSTALL_LABEL} on ${host}`;
|
||||
this.tooltip = `${InstallAction.INSTALL_LABEL} on ${host}`;
|
||||
}
|
||||
@@ -298,7 +297,6 @@ export class RemoteInstallAction extends ExtensionAction {
|
||||
constructor(
|
||||
@IExtensionsWorkbenchService private readonly extensionsWorkbenchService: IExtensionsWorkbenchService,
|
||||
@ILabelService private readonly labelService: ILabelService,
|
||||
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService,
|
||||
@IExtensionManagementServerService private readonly extensionManagementServerService: IExtensionManagementServerService,
|
||||
@IConfigurationService private readonly configurationService: IConfigurationService,
|
||||
@IProductService private readonly productService: IProductService,
|
||||
@@ -315,10 +313,9 @@ export class RemoteInstallAction extends ExtensionAction {
|
||||
this.tooltip = this.label;
|
||||
return;
|
||||
}
|
||||
const remoteAuthority = this.environmentService.configuration.remoteAuthority;
|
||||
if (remoteAuthority) {
|
||||
const host = this.labelService.getHostLabel(REMOTE_HOST_SCHEME, this.environmentService.configuration.remoteAuthority) || localize('remote', "Remote");
|
||||
this.label = `${RemoteInstallAction.INSTALL_LABEL} on ${host}`;
|
||||
const remoteServer = this.extensionManagementServerService.remoteExtensionManagementServer;
|
||||
if (remoteServer) {
|
||||
this.label = `${RemoteInstallAction.INSTALL_LABEL} on ${remoteServer.label}`;
|
||||
this.tooltip = this.label;
|
||||
return;
|
||||
}
|
||||
@@ -333,7 +330,7 @@ export class RemoteInstallAction extends ExtensionAction {
|
||||
this.updateLabel();
|
||||
return;
|
||||
}
|
||||
if (this.environmentService.configuration.remoteAuthority
|
||||
if (this.extensionManagementServerService.localExtensionManagementServer && this.extensionManagementServerService.remoteExtensionManagementServer
|
||||
// Installed User Extension
|
||||
&& this.extension && this.extension.local && this.extension.type === ExtensionType.User && this.extension.state === ExtensionState.Installed
|
||||
// Local Workspace Extension
|
||||
@@ -377,7 +374,6 @@ export class LocalInstallAction extends ExtensionAction {
|
||||
constructor(
|
||||
@IExtensionsWorkbenchService private readonly extensionsWorkbenchService: IExtensionsWorkbenchService,
|
||||
@ILabelService private readonly labelService: ILabelService,
|
||||
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService,
|
||||
@IExtensionManagementServerService private readonly extensionManagementServerService: IExtensionManagementServerService,
|
||||
@IConfigurationService private readonly configurationService: IConfigurationService,
|
||||
@IProductService private readonly productService: IProductService,
|
||||
@@ -407,7 +403,7 @@ export class LocalInstallAction extends ExtensionAction {
|
||||
this.updateLabel();
|
||||
return;
|
||||
}
|
||||
if (this.environmentService.configuration.remoteAuthority
|
||||
if (this.extensionManagementServerService.localExtensionManagementServer && this.extensionManagementServerService.remoteExtensionManagementServer
|
||||
// Installed User Extension
|
||||
&& this.extension && this.extension.local && this.extension.type === ExtensionType.User && this.extension.state === ExtensionState.Installed
|
||||
// Remote UI or Language pack Extension
|
||||
@@ -423,7 +419,7 @@ export class LocalInstallAction extends ExtensionAction {
|
||||
}
|
||||
|
||||
async run(): Promise<void> {
|
||||
if (!this.installing) {
|
||||
if (this.extensionManagementServerService.localExtensionManagementServer && !this.installing) {
|
||||
this.installing = true;
|
||||
this.update();
|
||||
this.extensionsWorkbenchService.open(this.extension);
|
||||
@@ -918,13 +914,15 @@ export class EnableForWorkspaceAction extends ExtensionAction {
|
||||
|
||||
update(): void {
|
||||
this.enabled = false;
|
||||
if (this.extension) {
|
||||
this.enabled = this.extension.state === ExtensionState.Installed && (this.extension.enablementState === EnablementState.Disabled || this.extension.enablementState === EnablementState.WorkspaceDisabled) && !!this.extension.local && this.extensionEnablementService.canChangeEnablement(this.extension.local);
|
||||
if (this.extension && this.extension.local) {
|
||||
this.enabled = this.extension.state === ExtensionState.Installed
|
||||
&& !this.extensionEnablementService.isEnabled(this.extension.local)
|
||||
&& this.extensionEnablementService.canChangeEnablement(this.extension.local);
|
||||
}
|
||||
}
|
||||
|
||||
run(): Promise<any> {
|
||||
return this.extensionsWorkbenchService.setEnablement(this.extension, EnablementState.WorkspaceEnabled);
|
||||
return this.extensionsWorkbenchService.setEnablement(this.extension, EnablementState.EnabledWorkspace);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -944,12 +942,14 @@ export class EnableGloballyAction extends ExtensionAction {
|
||||
update(): void {
|
||||
this.enabled = false;
|
||||
if (this.extension && this.extension.local) {
|
||||
this.enabled = this.extension.state === ExtensionState.Installed && this.extension.enablementState === EnablementState.Disabled && this.extensionEnablementService.canChangeEnablement(this.extension.local);
|
||||
this.enabled = this.extension.state === ExtensionState.Installed
|
||||
&& this.extension.enablementState === EnablementState.DisabledGlobally
|
||||
&& this.extensionEnablementService.canChangeEnablement(this.extension.local);
|
||||
}
|
||||
}
|
||||
|
||||
run(): Promise<any> {
|
||||
return this.extensionsWorkbenchService.setEnablement(this.extension, EnablementState.Enabled);
|
||||
return this.extensionsWorkbenchService.setEnablement(this.extension, EnablementState.EnabledGlobally);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -969,13 +969,15 @@ export class DisableForWorkspaceAction extends ExtensionAction {
|
||||
|
||||
update(): void {
|
||||
this.enabled = false;
|
||||
if (this.extension && this.runningExtensions.some(e => areSameExtensions({ id: e.identifier.value, uuid: e.uuid }, this.extension.identifier) && this.workspaceContextService.getWorkbenchState() !== WorkbenchState.EMPTY)) {
|
||||
this.enabled = this.extension.state === ExtensionState.Installed && (this.extension.enablementState === EnablementState.Enabled || this.extension.enablementState === EnablementState.WorkspaceEnabled) && !!this.extension.local && this.extensionEnablementService.canChangeEnablement(this.extension.local);
|
||||
if (this.extension && this.extension.local && this.runningExtensions.some(e => areSameExtensions({ id: e.identifier.value, uuid: e.uuid }, this.extension.identifier) && this.workspaceContextService.getWorkbenchState() !== WorkbenchState.EMPTY)) {
|
||||
this.enabled = this.extension.state === ExtensionState.Installed
|
||||
&& (this.extension.enablementState === EnablementState.EnabledGlobally || this.extension.enablementState === EnablementState.EnabledWorkspace)
|
||||
&& this.extensionEnablementService.canChangeEnablement(this.extension.local);
|
||||
}
|
||||
}
|
||||
|
||||
run(): Promise<any> {
|
||||
return this.extensionsWorkbenchService.setEnablement(this.extension, EnablementState.WorkspaceDisabled);
|
||||
return this.extensionsWorkbenchService.setEnablement(this.extension, EnablementState.DisabledWorkspace);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -994,13 +996,15 @@ export class DisableGloballyAction extends ExtensionAction {
|
||||
|
||||
update(): void {
|
||||
this.enabled = false;
|
||||
if (this.extension && this.runningExtensions.some(e => areSameExtensions({ id: e.identifier.value, uuid: e.uuid }, this.extension.identifier))) {
|
||||
this.enabled = this.extension.state === ExtensionState.Installed && (this.extension.enablementState === EnablementState.Enabled || this.extension.enablementState === EnablementState.WorkspaceEnabled) && !!this.extension.local && this.extensionEnablementService.canChangeEnablement(this.extension.local);
|
||||
if (this.extension && this.extension.local && this.runningExtensions.some(e => areSameExtensions({ id: e.identifier.value, uuid: e.uuid }, this.extension.identifier))) {
|
||||
this.enabled = this.extension.state === ExtensionState.Installed
|
||||
&& (this.extension.enablementState === EnablementState.EnabledGlobally || this.extension.enablementState === EnablementState.EnabledWorkspace)
|
||||
&& this.extensionEnablementService.canChangeEnablement(this.extension.local);
|
||||
}
|
||||
}
|
||||
|
||||
run(): Promise<any> {
|
||||
return this.extensionsWorkbenchService.setEnablement(this.extension, EnablementState.Disabled);
|
||||
return this.extensionsWorkbenchService.setEnablement(this.extension, EnablementState.DisabledGlobally);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1082,6 +1086,7 @@ export class CheckForUpdatesAction extends Action {
|
||||
id = CheckForUpdatesAction.ID,
|
||||
label = CheckForUpdatesAction.LABEL,
|
||||
@IExtensionsWorkbenchService private readonly extensionsWorkbenchService: IExtensionsWorkbenchService,
|
||||
@IExtensionEnablementService private readonly extensionEnablementService: IExtensionEnablementService,
|
||||
@IViewletService private readonly viewletService: IViewletService,
|
||||
@INotificationService private readonly notificationService: INotificationService
|
||||
) {
|
||||
@@ -1097,7 +1102,7 @@ export class CheckForUpdatesAction extends Action {
|
||||
|
||||
let msgAvailableExtensions = outdated.length === 1 ? localize('singleUpdateAvailable', "An extension update is available.") : localize('updatesAvailable', "{0} extension updates are available.", outdated.length);
|
||||
|
||||
const disabledExtensionsCount = outdated.filter(ext => ext.enablementState === EnablementState.Disabled || ext.enablementState === EnablementState.WorkspaceDisabled).length;
|
||||
const disabledExtensionsCount = outdated.filter(ext => ext.local && !this.extensionEnablementService.isEnabled(ext.local)).length;
|
||||
if (disabledExtensionsCount) {
|
||||
if (outdated.length === 1) {
|
||||
msgAvailableExtensions = localize('singleDisabledUpdateAvailable', "An update to an extension which is disabled is available.");
|
||||
@@ -1227,7 +1232,6 @@ export class ReloadAction extends ExtensionAction {
|
||||
@IExtensionService private readonly extensionService: IExtensionService,
|
||||
@IExtensionEnablementService private readonly extensionEnablementService: IExtensionEnablementService,
|
||||
@IExtensionManagementServerService private readonly extensionManagementServerService: IExtensionManagementServerService,
|
||||
@IWorkbenchEnvironmentService private readonly workbenchEnvironmentService: IWorkbenchEnvironmentService,
|
||||
@IConfigurationService private readonly configurationService: IConfigurationService,
|
||||
@IProductService private readonly productService: IProductService,
|
||||
) {
|
||||
@@ -1312,7 +1316,7 @@ export class ReloadAction extends ExtensionAction {
|
||||
this.tooltip = localize('postEnableTooltip', "Please reload Azure Data Studio to enable this extension."); // {{SQL CARBON EDIT}} - replace Visual Studio Code with Azure Data Studio
|
||||
return;
|
||||
}
|
||||
if (this.workbenchEnvironmentService.configuration.remoteAuthority) {
|
||||
if (this.extensionManagementServerService.localExtensionManagementServer && this.extensionManagementServerService.remoteExtensionManagementServer) {
|
||||
const uiExtension = isUIExtension(this.extension.local.manifest, this.productService, this.configurationService);
|
||||
// Local Workspace Extension
|
||||
if (!uiExtension && this.extension.server === this.extensionManagementServerService.localExtensionManagementServer) {
|
||||
@@ -1741,8 +1745,10 @@ export class InstallWorkspaceRecommendedExtensionsAction extends Action {
|
||||
try {
|
||||
if (extension.local && extension.gallery) {
|
||||
if (isUIExtension(extension.local.manifest, this.productService, this.configurationService)) {
|
||||
await this.extensionManagementServerService.localExtensionManagementServer.extensionManagementService.installFromGallery(extension.gallery);
|
||||
return;
|
||||
if (this.extensionManagementServerService.localExtensionManagementServer) {
|
||||
await this.extensionManagementServerService.localExtensionManagementServer.extensionManagementService.installFromGallery(extension.gallery);
|
||||
return;
|
||||
}
|
||||
} else if (this.extensionManagementServerService.remoteExtensionManagementServer) {
|
||||
await this.extensionManagementServerService.remoteExtensionManagementServer.extensionManagementService.installFromGallery(extension.gallery);
|
||||
return;
|
||||
@@ -2547,8 +2553,8 @@ export class StatusLabelAction extends Action implements IExtensionContainer {
|
||||
}
|
||||
|
||||
if (currentEnablementState !== null) {
|
||||
const currentlyEnabled = currentEnablementState === EnablementState.Enabled || currentEnablementState === EnablementState.WorkspaceEnabled;
|
||||
const enabled = this.enablementState === EnablementState.Enabled || this.enablementState === EnablementState.WorkspaceEnabled;
|
||||
const currentlyEnabled = currentEnablementState === EnablementState.EnabledGlobally || currentEnablementState === EnablementState.EnabledWorkspace;
|
||||
const enabled = this.enablementState === EnablementState.EnabledGlobally || this.enablementState === EnablementState.EnabledWorkspace;
|
||||
if (!currentlyEnabled && enabled) {
|
||||
return canAddExtension() ? localize('enabled', "Enabled") : null;
|
||||
}
|
||||
@@ -2654,7 +2660,6 @@ export class SystemDisabledWarningAction extends ExtensionAction {
|
||||
@IConfigurationService private readonly configurationService: IConfigurationService,
|
||||
@IProductService private readonly productService: IProductService,
|
||||
@ILabelService private readonly labelService: ILabelService,
|
||||
@IWorkbenchEnvironmentService private readonly workbenchEnvironmentService: IWorkbenchEnvironmentService,
|
||||
@IExtensionsWorkbenchService private readonly extensionsWorkbenchService: IExtensionsWorkbenchService,
|
||||
@IExtensionService private readonly extensionService: IExtensionService,
|
||||
) {
|
||||
@@ -2677,8 +2682,7 @@ export class SystemDisabledWarningAction extends ExtensionAction {
|
||||
!this.extension.local ||
|
||||
!this.extension.server ||
|
||||
!this._runningExtensions ||
|
||||
!this.workbenchEnvironmentService.configuration.remoteAuthority ||
|
||||
!this.extensionManagementServerService.remoteExtensionManagementServer ||
|
||||
!(this.extensionManagementServerService.localExtensionManagementServer && this.extensionManagementServerService.remoteExtensionManagementServer) ||
|
||||
this.extension.state !== ExtensionState.Installed
|
||||
) {
|
||||
return;
|
||||
@@ -2687,7 +2691,7 @@ export class SystemDisabledWarningAction extends ExtensionAction {
|
||||
if (!this.extensionsWorkbenchService.installed.some(e => areSameExtensions(e.identifier, this.extension.identifier) && e.server !== this.extension.server)) {
|
||||
this.class = `${SystemDisabledWarningAction.INFO_CLASS}`;
|
||||
this.tooltip = this.extension.server === this.extensionManagementServerService.localExtensionManagementServer
|
||||
? localize('Install language pack also in remote server', "Install the language pack extension on '{0}' to enable it also there.", this.getServerLabel(this.extensionManagementServerService.remoteExtensionManagementServer))
|
||||
? localize('Install language pack also in remote server', "Install the language pack extension on '{0}' to enable it also there.", this.extensionManagementServerService.remoteExtensionManagementServer.label)
|
||||
: localize('Install language pack also locally', "Install the language pack extension locally to enable it also there.");
|
||||
}
|
||||
return;
|
||||
@@ -2699,19 +2703,19 @@ export class SystemDisabledWarningAction extends ExtensionAction {
|
||||
if (this.extension.server === this.extensionManagementServerService.localExtensionManagementServer && !isUIExtension(this.extension.local.manifest, this.productService, this.configurationService)) {
|
||||
if (runningExtensionServer === this.extensionManagementServerService.remoteExtensionManagementServer) {
|
||||
this.class = `${SystemDisabledWarningAction.INFO_CLASS}`;
|
||||
this.tooltip = localize('disabled locally', "Extension is enabled on '{0}' and disabled locally.", this.getServerLabel(this.extensionManagementServerService.remoteExtensionManagementServer));
|
||||
this.tooltip = localize('disabled locally', "Extension is enabled on '{0}' and disabled locally.", this.extensionManagementServerService.remoteExtensionManagementServer.label);
|
||||
return;
|
||||
}
|
||||
if (localExtensionServer !== this.extensionManagementServerService.remoteExtensionManagementServer) {
|
||||
this.class = `${SystemDisabledWarningAction.WARNING_CLASS}`;
|
||||
this.tooltip = localize('Install in remote server', "Install the extension on '{0}' to enable.", this.getServerLabel(this.extensionManagementServerService.remoteExtensionManagementServer));
|
||||
this.tooltip = localize('Install in remote server', "Install the extension on '{0}' to enable.", this.extensionManagementServerService.remoteExtensionManagementServer.label);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (this.extension.server === this.extensionManagementServerService.remoteExtensionManagementServer && isUIExtension(this.extension.local.manifest, this.productService, this.configurationService)) {
|
||||
if (runningExtensionServer === this.extensionManagementServerService.localExtensionManagementServer) {
|
||||
this.class = `${SystemDisabledWarningAction.INFO_CLASS}`;
|
||||
this.tooltip = localize('disabled remotely', "Extension is enabled locally and disabled on '{0}'.", this.getServerLabel(this.extensionManagementServerService.remoteExtensionManagementServer));
|
||||
this.tooltip = localize('disabled remotely', "Extension is enabled locally and disabled on '{0}'.", this.extensionManagementServerService.remoteExtensionManagementServer.label);
|
||||
return;
|
||||
}
|
||||
if (localExtensionServer !== this.extensionManagementServerService.localExtensionManagementServer) {
|
||||
@@ -2722,12 +2726,6 @@ export class SystemDisabledWarningAction extends ExtensionAction {
|
||||
}
|
||||
}
|
||||
|
||||
private getServerLabel(server: IExtensionManagementServer): string {
|
||||
if (server === this.extensionManagementServerService.remoteExtensionManagementServer) {
|
||||
return this.labelService.getHostLabel(REMOTE_HOST_SCHEME, this.workbenchEnvironmentService.configuration.remoteAuthority) || localize('remote', "Remote");
|
||||
}
|
||||
return server.label;
|
||||
}
|
||||
run(): Promise<any> {
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
@@ -2750,11 +2748,11 @@ export class DisableAllAction extends Action {
|
||||
}
|
||||
|
||||
private update(): void {
|
||||
this.enabled = this.extensionsWorkbenchService.local.some(e => e.type === ExtensionType.User && (e.enablementState === EnablementState.Enabled || e.enablementState === EnablementState.WorkspaceEnabled) && !!e.local && this.extensionEnablementService.canChangeEnablement(e.local));
|
||||
this.enabled = this.extensionsWorkbenchService.local.some(e => e.type === ExtensionType.User && !!e.local && this.extensionEnablementService.isEnabled(e.local) && this.extensionEnablementService.canChangeEnablement(e.local));
|
||||
}
|
||||
|
||||
run(): Promise<any> {
|
||||
return this.extensionsWorkbenchService.setEnablement(this.extensionsWorkbenchService.local.filter(e => e.type === ExtensionType.User), EnablementState.Disabled);
|
||||
return this.extensionsWorkbenchService.setEnablement(this.extensionsWorkbenchService.local.filter(e => e.type === ExtensionType.User), EnablementState.DisabledGlobally);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2767,7 +2765,8 @@ export class DisableAllWorkpsaceAction extends Action {
|
||||
constructor(
|
||||
id: string = DisableAllWorkpsaceAction.ID, label: string = DisableAllWorkpsaceAction.LABEL,
|
||||
@IWorkspaceContextService private readonly workspaceContextService: IWorkspaceContextService,
|
||||
@IExtensionsWorkbenchService private readonly extensionsWorkbenchService: IExtensionsWorkbenchService
|
||||
@IExtensionsWorkbenchService private readonly extensionsWorkbenchService: IExtensionsWorkbenchService,
|
||||
@IExtensionEnablementService private readonly extensionEnablementService: IExtensionEnablementService
|
||||
) {
|
||||
super(id, label);
|
||||
this.update();
|
||||
@@ -2776,11 +2775,11 @@ export class DisableAllWorkpsaceAction extends Action {
|
||||
}
|
||||
|
||||
private update(): void {
|
||||
this.enabled = this.workspaceContextService.getWorkbenchState() !== WorkbenchState.EMPTY && this.extensionsWorkbenchService.local.some(e => e.type === ExtensionType.User && (e.enablementState === EnablementState.Enabled || e.enablementState === EnablementState.WorkspaceEnabled));
|
||||
this.enabled = this.workspaceContextService.getWorkbenchState() !== WorkbenchState.EMPTY && this.extensionsWorkbenchService.local.some(e => e.type === ExtensionType.User && !!e.local && this.extensionEnablementService.isEnabled(e.local) && this.extensionEnablementService.canChangeEnablement(e.local));
|
||||
}
|
||||
|
||||
run(): Promise<any> {
|
||||
return this.extensionsWorkbenchService.setEnablement(this.extensionsWorkbenchService.local.filter(e => e.type === ExtensionType.User), EnablementState.WorkspaceDisabled);
|
||||
return this.extensionsWorkbenchService.setEnablement(this.extensionsWorkbenchService.local.filter(e => e.type === ExtensionType.User), EnablementState.DisabledWorkspace);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2801,11 +2800,11 @@ export class EnableAllAction extends Action {
|
||||
}
|
||||
|
||||
private update(): void {
|
||||
this.enabled = this.extensionsWorkbenchService.local.some(e => !!e.local && this.extensionEnablementService.canChangeEnablement(e.local) && (e.enablementState === EnablementState.Disabled || e.enablementState === EnablementState.WorkspaceDisabled));
|
||||
this.enabled = this.extensionsWorkbenchService.local.some(e => !!e.local && this.extensionEnablementService.canChangeEnablement(e.local) && !this.extensionEnablementService.isEnabled(e.local));
|
||||
}
|
||||
|
||||
run(): Promise<any> {
|
||||
return this.extensionsWorkbenchService.setEnablement(this.extensionsWorkbenchService.local, EnablementState.Enabled);
|
||||
return this.extensionsWorkbenchService.setEnablement(this.extensionsWorkbenchService.local, EnablementState.EnabledGlobally);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2828,11 +2827,11 @@ export class EnableAllWorkpsaceAction extends Action {
|
||||
}
|
||||
|
||||
private update(): void {
|
||||
this.enabled = this.workspaceContextService.getWorkbenchState() !== WorkbenchState.EMPTY && this.extensionsWorkbenchService.local.some(e => !!e.local && this.extensionEnablementService.canChangeEnablement(e.local) && (e.enablementState === EnablementState.Disabled || e.enablementState === EnablementState.WorkspaceDisabled));
|
||||
this.enabled = this.workspaceContextService.getWorkbenchState() !== WorkbenchState.EMPTY && this.extensionsWorkbenchService.local.some(e => !!e.local && this.extensionEnablementService.canChangeEnablement(e.local) && !this.extensionEnablementService.isEnabled(e.local));
|
||||
}
|
||||
|
||||
run(): Promise<any> {
|
||||
return this.extensionsWorkbenchService.setEnablement(this.extensionsWorkbenchService.local, EnablementState.WorkspaceEnabled);
|
||||
return this.extensionsWorkbenchService.setEnablement(this.extensionsWorkbenchService.local, EnablementState.EnabledWorkspace);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2852,18 +2851,22 @@ export class OpenExtensionsFolderAction extends Action {
|
||||
}
|
||||
|
||||
run(): Promise<void> {
|
||||
const extensionsHome = URI.file(this.environmentService.extensionsPath);
|
||||
if (this.environmentService.extensionsPath) {
|
||||
|
||||
return Promise.resolve(this.fileService.resolve(extensionsHome)).then(file => {
|
||||
let itemToShow: URI;
|
||||
if (file.children && file.children.length > 0) {
|
||||
itemToShow = file.children[0].resource;
|
||||
} else {
|
||||
itemToShow = extensionsHome;
|
||||
}
|
||||
const extensionsHome = URI.file(this.environmentService.extensionsPath);
|
||||
|
||||
return this.windowsService.showItemInFolder(itemToShow);
|
||||
});
|
||||
return Promise.resolve(this.fileService.resolve(extensionsHome)).then(file => {
|
||||
let itemToShow: URI;
|
||||
if (file.children && file.children.length > 0) {
|
||||
itemToShow = file.children[0].resource;
|
||||
} else {
|
||||
itemToShow = extensionsHome;
|
||||
}
|
||||
|
||||
return this.windowsService.showItemInFolder(itemToShow);
|
||||
});
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2909,7 +2912,7 @@ export class InstallVSIXAction extends Action {
|
||||
{
|
||||
label: localize('thirdPartExt.yes', 'Yes'),
|
||||
run: () => {
|
||||
this.extensionsWorkbenchService.install(vsix).then(extension => {
|
||||
this.extensionsWorkbenchService.install(URI.file(vsix)).then(extension => {
|
||||
const requireReload = !(extension.local && this.extensionService.canAddExtension(toExtensionDescription(extension.local)));
|
||||
const message = requireReload ? localize('InstallVSIXAction.successReload', "Please reload Azure Data Studio to complete installing the extension {0}.", extension.identifier.id)
|
||||
: localize('InstallVSIXAction.success', "Completed installing the extension {0}.", extension.identifier.id);
|
||||
@@ -2942,7 +2945,7 @@ export class InstallVSIXAction extends Action {
|
||||
{ sticky: true }
|
||||
);
|
||||
} else {
|
||||
this.extensionsWorkbenchService.install(vsix).then(extension => {
|
||||
this.extensionsWorkbenchService.install(URI.file(vsix)).then(extension => {
|
||||
const requireReload = !(extension.local && this.extensionService.canAddExtension(toExtensionDescription(extension.local)));
|
||||
const message = requireReload ? localize('InstallVSIXAction.successReload', "Please reload Azure Data Studio to complete installing the extension {0}.", extension.identifier.id)
|
||||
: localize('InstallVSIXAction.success', "Completed installing the extension {0}.", extension.identifier.id);
|
||||
@@ -3048,7 +3051,8 @@ export class InstallSpecificVersionOfExtensionAction extends Action {
|
||||
@INotificationService private readonly notificationService: INotificationService,
|
||||
@IWindowService private readonly windowService: IWindowService,
|
||||
@IInstantiationService private readonly instantiationService: IInstantiationService,
|
||||
@IExtensionService private readonly extensionService: IExtensionService
|
||||
@IExtensionService private readonly extensionService: IExtensionService,
|
||||
@IExtensionEnablementService private readonly extensionEnablementService: IExtensionEnablementService,
|
||||
) {
|
||||
super(id, label);
|
||||
}
|
||||
@@ -3070,7 +3074,7 @@ export class InstallSpecificVersionOfExtensionAction extends Action {
|
||||
}
|
||||
|
||||
private isEnabled(extension: IExtension): boolean {
|
||||
return !!extension.gallery && (extension.enablementState === EnablementState.Enabled || extension.enablementState === EnablementState.WorkspaceEnabled);
|
||||
return !!extension.gallery && !!extension.local && this.extensionEnablementService.isEnabled(extension.local);
|
||||
}
|
||||
|
||||
private async getExtensionEntries(): Promise<(IQuickPickItem & { extension: IExtension, versions: IGalleryExtensionVersion[] })[]> {
|
||||
|
||||
@@ -17,7 +17,7 @@ import { InstallAction, UpdateAction, ManageExtensionAction, ReloadAction, Malic
|
||||
import { areSameExtensions } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
|
||||
import { Label, RatingsWidget, InstallCountWidget, RecommendationWidget, RemoteBadgeWidget, TooltipWidget } from 'vs/workbench/contrib/extensions/browser/extensionsWidgets';
|
||||
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
|
||||
import { IExtensionManagementServerService } from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { IExtensionManagementServerService } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { isLanguagePackExtension } from 'vs/platform/extensions/common/extensions';
|
||||
|
||||
|
||||
@@ -24,7 +24,8 @@ import {
|
||||
ShowOutdatedExtensionsAction, ClearExtensionsInputAction, ChangeSortAction, UpdateAllAction, CheckForUpdatesAction, DisableAllAction, EnableAllAction,
|
||||
EnableAutoUpdateAction, DisableAutoUpdateAction, ShowBuiltInExtensionsAction, InstallVSIXAction
|
||||
} from 'vs/workbench/contrib/extensions/browser/extensionsActions';
|
||||
import { IExtensionManagementService, IExtensionManagementServerService, IExtensionManagementServer, IExtensionEnablementService } from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { IExtensionManagementService } from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { IExtensionEnablementService, IExtensionManagementServerService, IExtensionManagementServer } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
|
||||
import { ExtensionsInput } from 'vs/workbench/contrib/extensions/common/extensionsInput';
|
||||
import { ExtensionsListView, EnabledExtensionsView, DisabledExtensionsView, RecommendedExtensionsView, WorkspaceRecommendedExtensionsView, BuiltInExtensionsView, BuiltInThemesExtensionsView, BuiltInBasicsExtensionsView, ServerExtensionsView, DefaultRecommendedExtensionsView } from 'vs/workbench/contrib/extensions/browser/extensionsViews';
|
||||
import { OpenGlobalSettingsAction } from 'vs/workbench/contrib/preferences/browser/preferencesActions';
|
||||
@@ -55,8 +56,6 @@ import { ExtensionType } from 'vs/platform/extensions/common/extensions';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { ViewContainerViewlet } from 'vs/workbench/browser/parts/views/viewsViewlet';
|
||||
import { RemoteAuthorityContext } from 'vs/workbench/browser/contextkeys';
|
||||
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
|
||||
import { REMOTE_HOST_SCHEME } from 'vs/platform/remote/common/remoteHosts';
|
||||
import { ILabelService } from 'vs/platform/label/common/label';
|
||||
import { MementoObject } from 'vs/workbench/common/memento';
|
||||
|
||||
@@ -97,7 +96,6 @@ export class ExtensionsViewletViewsContribution implements IWorkbenchContributio
|
||||
constructor(
|
||||
@IExtensionManagementServerService private readonly extensionManagementServerService: IExtensionManagementServerService,
|
||||
@ILabelService private readonly labelService: ILabelService,
|
||||
@IWorkbenchEnvironmentService private readonly workbenchEnvironmentService: IWorkbenchEnvironmentService
|
||||
) {
|
||||
this.registerViews();
|
||||
}
|
||||
@@ -118,7 +116,9 @@ export class ExtensionsViewletViewsContribution implements IWorkbenchContributio
|
||||
viewDescriptors.push(this.createOtherRecommendedExtensionsListViewDescriptor());
|
||||
viewDescriptors.push(this.createWorkspaceRecommendedExtensionsListViewDescriptor());
|
||||
|
||||
viewDescriptors.push(...this.createExtensionsViewDescriptorsForServer(this.extensionManagementServerService.localExtensionManagementServer));
|
||||
if (this.extensionManagementServerService.localExtensionManagementServer) {
|
||||
viewDescriptors.push(...this.createExtensionsViewDescriptorsForServer(this.extensionManagementServerService.localExtensionManagementServer));
|
||||
}
|
||||
if (this.extensionManagementServerService.remoteExtensionManagementServer) {
|
||||
viewDescriptors.push(...this.createExtensionsViewDescriptorsForServer(this.extensionManagementServerService.remoteExtensionManagementServer));
|
||||
}
|
||||
@@ -187,15 +187,15 @@ export class ExtensionsViewletViewsContribution implements IWorkbenchContributio
|
||||
|
||||
private createExtensionsViewDescriptorsForServer(server: IExtensionManagementServer): IViewDescriptor[] {
|
||||
const getViewName = (viewTitle: string, server: IExtensionManagementServer): string => {
|
||||
const serverLabel = this.workbenchEnvironmentService.configuration.remoteAuthority === server.authority ? this.labelService.getHostLabel(REMOTE_HOST_SCHEME, server.authority) || server.label : server.label;
|
||||
if (viewTitle && this.workbenchEnvironmentService.configuration.remoteAuthority) {
|
||||
const serverLabel = server.label;
|
||||
if (viewTitle && this.extensionManagementServerService.localExtensionManagementServer && this.extensionManagementServerService.remoteExtensionManagementServer) {
|
||||
return `${serverLabel} - ${viewTitle}`;
|
||||
}
|
||||
return viewTitle ? viewTitle : serverLabel;
|
||||
};
|
||||
const getInstalledViewName = (): string => getViewName(localize('installed', "Installed"), server);
|
||||
const getOutdatedViewName = (): string => getViewName(localize('outdated', "Outdated"), server);
|
||||
const onDidChangeServerLabel: EventOf<void> = this.workbenchEnvironmentService.configuration.remoteAuthority ? EventOf.map(this.labelService.onDidChangeFormatters, () => undefined) : EventOf.None;
|
||||
const onDidChangeServerLabel: EventOf<void> = EventOf.map(this.labelService.onDidChangeFormatters, () => undefined);
|
||||
return [{
|
||||
id: `extensions.${server.authority}.installed`,
|
||||
get name() { return getInstalledViewName(); },
|
||||
|
||||
@@ -9,7 +9,8 @@ import { assign } from 'vs/base/common/objects';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { isPromiseCanceledError, getErrorMessage } from 'vs/base/common/errors';
|
||||
import { PagedModel, IPagedModel, IPager, DelayedPagedModel } from 'vs/base/common/paging';
|
||||
import { SortBy, SortOrder, IQueryOptions, IExtensionTipsService, IExtensionRecommendation, IExtensionManagementServer, IExtensionManagementServerService } from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { SortBy, SortOrder, IQueryOptions } from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { IExtensionManagementServer, IExtensionManagementServerService, IExtensionTipsService, IExtensionRecommendation } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
|
||||
import { areSameExtensions } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
|
||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
|
||||
|
||||
@@ -9,13 +9,11 @@ import { IExtension, IExtensionsWorkbenchService, IExtensionContainer, Extension
|
||||
import { append, $, addClass } from 'vs/base/browser/dom';
|
||||
import * as platform from 'vs/base/common/platform';
|
||||
import { localize } from 'vs/nls';
|
||||
import { IExtensionManagementServerService, IExtensionTipsService } from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { IExtensionTipsService, IExtensionManagementServerService } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
|
||||
import { ILabelService } from 'vs/platform/label/common/label';
|
||||
import { extensionButtonProminentBackground, extensionButtonProminentForeground, DisabledLabelAction, ReloadAction } from 'vs/workbench/contrib/extensions/browser/extensionsActions';
|
||||
import { IThemeService, ITheme } from 'vs/platform/theme/common/themeService';
|
||||
import { EXTENSION_BADGE_REMOTE_BACKGROUND, EXTENSION_BADGE_REMOTE_FOREGROUND } from 'vs/workbench/common/theme';
|
||||
import { REMOTE_HOST_SCHEME } from 'vs/platform/remote/common/remoteHosts';
|
||||
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
@@ -151,8 +149,7 @@ export class TooltipWidget extends ExtensionWidget {
|
||||
private readonly recommendationWidget: RecommendationWidget,
|
||||
private readonly reloadAction: ReloadAction,
|
||||
@IExtensionManagementServerService private readonly extensionManagementServerService: IExtensionManagementServerService,
|
||||
@ILabelService private readonly labelService: ILabelService,
|
||||
@IWorkbenchEnvironmentService private readonly workbenchEnvironmentService: IWorkbenchEnvironmentService
|
||||
@ILabelService private readonly labelService: ILabelService
|
||||
) {
|
||||
super();
|
||||
this._register(Event.any<any>(
|
||||
@@ -184,7 +181,7 @@ export class TooltipWidget extends ExtensionWidget {
|
||||
}
|
||||
if (this.extension.local && this.extension.state === ExtensionState.Installed) {
|
||||
if (this.extension.server === this.extensionManagementServerService.remoteExtensionManagementServer) {
|
||||
return localize('extension enabled on remote', "Extension is enabled on '{0}'", this.labelService.getHostLabel(REMOTE_HOST_SCHEME, this.workbenchEnvironmentService.configuration.remoteAuthority));
|
||||
return localize('extension enabled on remote', "Extension is enabled on '{0}'", this.extension.server.label);
|
||||
}
|
||||
return localize('extension enabled locally', "Extension is enabled locally.");
|
||||
}
|
||||
@@ -281,13 +278,11 @@ export class RemoteBadgeWidget extends ExtensionWidget {
|
||||
|
||||
render(): void {
|
||||
this.clear();
|
||||
if (!this.extension || !this.extension.local || !this.extension.server) {
|
||||
if (!this.extension || !this.extension.local || !this.extension.server || !(this.extensionManagementServerService.localExtensionManagementServer && this.extensionManagementServerService.remoteExtensionManagementServer) || this.extension.server !== this.extensionManagementServerService.remoteExtensionManagementServer) {
|
||||
return;
|
||||
}
|
||||
if (this.extension.server === this.extensionManagementServerService.remoteExtensionManagementServer) {
|
||||
this.remoteBadge.value = this.instantiationService.createInstance(RemoteBadge, this.tooltip);
|
||||
append(this.element, this.remoteBadge.value.element);
|
||||
}
|
||||
this.remoteBadge.value = this.instantiationService.createInstance(RemoteBadge, this.tooltip);
|
||||
append(this.element, this.remoteBadge.value.element);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -299,7 +294,7 @@ class RemoteBadge extends Disposable {
|
||||
private readonly tooltip: boolean,
|
||||
@ILabelService private readonly labelService: ILabelService,
|
||||
@IThemeService private readonly themeService: IThemeService,
|
||||
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService
|
||||
@IExtensionManagementServerService private readonly extensionManagementServerService: IExtensionManagementServerService
|
||||
) {
|
||||
super();
|
||||
this.element = $('div.extension-remote-badge');
|
||||
@@ -323,8 +318,8 @@ class RemoteBadge extends Disposable {
|
||||
|
||||
if (this.tooltip) {
|
||||
const updateTitle = () => {
|
||||
if (this.element) {
|
||||
this.element.title = localize('remote extension title', "Extension in {0}", this.labelService.getHostLabel(REMOTE_HOST_SCHEME, this.environmentService.configuration.remoteAuthority));
|
||||
if (this.element && this.extensionManagementServerService.remoteExtensionManagementServer) {
|
||||
this.element.title = localize('remote extension title', "Extension in {0}", this.extensionManagementServerService.remoteExtensionManagementServer.label);
|
||||
}
|
||||
};
|
||||
this._register(this.labelService.onDidChangeFormatters(() => updateTitle()));
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as nls from 'vs/nls';
|
||||
import * as semver from 'semver';
|
||||
import * as semver from 'semver-umd';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { index, distinct } from 'vs/base/common/arrays';
|
||||
import { ThrottledDelayer } from 'vs/base/common/async';
|
||||
@@ -15,8 +15,9 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
// {{SQL CARBON EDIT}}
|
||||
import {
|
||||
IExtensionManagementService, IExtensionGalleryService, ILocalExtension, IGalleryExtension, IQueryOptions,
|
||||
InstallExtensionEvent, DidInstallExtensionEvent, DidUninstallExtensionEvent, IExtensionEnablementService, IExtensionIdentifier, EnablementState, IExtensionManagementServerService, IExtensionManagementServer, INSTALL_ERROR_INCOMPATIBLE
|
||||
InstallExtensionEvent, DidInstallExtensionEvent, DidUninstallExtensionEvent, IExtensionIdentifier, INSTALL_ERROR_INCOMPATIBLE
|
||||
} from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { IExtensionEnablementService, EnablementState, IExtensionManagementServerService, IExtensionManagementServer } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
|
||||
import { getGalleryExtensionTelemetryData, getLocalExtensionTelemetryData, areSameExtensions, getMaliciousExtensionsSet, groupByExtension, ExtensionIdentifierWithVersion } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
@@ -36,6 +37,7 @@ import { IFileService } from 'vs/platform/files/common/files';
|
||||
import { IExtensionManifest, ExtensionType, IExtension as IPlatformExtension, isLanguagePackExtension } from 'vs/platform/extensions/common/extensions';
|
||||
import { IModeService } from 'vs/editor/common/services/modeService';
|
||||
import { IProductService } from 'vs/platform/product/common/product';
|
||||
import { asDomUri } from 'vs/base/browser/dom';
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
import { ExtensionManagementError } from 'vs/platform/extensionManagement/node/extensionManagementService';
|
||||
@@ -48,7 +50,7 @@ interface IExtensionStateProvider<T> {
|
||||
|
||||
class Extension implements IExtension {
|
||||
|
||||
public enablementState: EnablementState = EnablementState.Enabled;
|
||||
public enablementState: EnablementState = EnablementState.EnabledGlobally;
|
||||
|
||||
constructor(
|
||||
private stateProvider: IExtensionStateProvider<ExtensionState>,
|
||||
@@ -145,7 +147,7 @@ class Extension implements IExtension {
|
||||
|
||||
private get localIconUrl(): string | null {
|
||||
if (this.local && this.local.manifest.icon) {
|
||||
return resources.joinPath(this.local.location, this.local.manifest.icon).toString();
|
||||
return asDomUri(resources.joinPath(this.local.location, this.local.manifest.icon)).toString();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -162,14 +164,14 @@ class Extension implements IExtension {
|
||||
if (this.type === ExtensionType.System && this.local) {
|
||||
if (this.local.manifest && this.local.manifest.contributes) {
|
||||
if (Array.isArray(this.local.manifest.contributes.themes) && this.local.manifest.contributes.themes.length) {
|
||||
return require.toUrl('../browser/media/theme-icon.png');
|
||||
return require.toUrl('./media/theme-icon.png');
|
||||
}
|
||||
if (Array.isArray(this.local.manifest.contributes.grammars) && this.local.manifest.contributes.grammars.length) {
|
||||
return require.toUrl('../browser/media/language-icon.svg');
|
||||
return require.toUrl('./media/language-icon.svg');
|
||||
}
|
||||
}
|
||||
}
|
||||
return require.toUrl('../browser/media/defaultIcon.png');
|
||||
return require.toUrl('./media/defaultIcon.png');
|
||||
}
|
||||
|
||||
get repository(): string | undefined {
|
||||
@@ -490,8 +492,8 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension
|
||||
private static readonly SyncPeriod = 1000 * 60 * 60 * 12; // 12 hours
|
||||
_serviceBrand: any;
|
||||
|
||||
private readonly localExtensions: Extensions;
|
||||
private readonly remoteExtensions: Extensions | null;
|
||||
private readonly localExtensions: Extensions | null = null;
|
||||
private readonly remoteExtensions: Extensions | null = null;
|
||||
private syncDelayer: ThrottledDelayer<void>;
|
||||
private autoUpdateDelayer: ThrottledDelayer<void>;
|
||||
|
||||
@@ -519,13 +521,13 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension
|
||||
@IProductService private readonly productService: IProductService
|
||||
) {
|
||||
super();
|
||||
this.localExtensions = this._register(instantiationService.createInstance(Extensions, extensionManagementServerService.localExtensionManagementServer, ext => this.getExtensionState(ext)));
|
||||
this._register(this.localExtensions.onChange(e => this._onChange.fire(e)));
|
||||
if (this.extensionManagementServerService.localExtensionManagementServer) {
|
||||
this.localExtensions = this._register(instantiationService.createInstance(Extensions, extensionManagementServerService.localExtensionManagementServer, ext => this.getExtensionState(ext)));
|
||||
this._register(this.localExtensions.onChange(e => this._onChange.fire(e)));
|
||||
}
|
||||
if (this.extensionManagementServerService.remoteExtensionManagementServer) {
|
||||
this.remoteExtensions = this._register(instantiationService.createInstance(Extensions, extensionManagementServerService.remoteExtensionManagementServer, ext => this.getExtensionState(ext)));
|
||||
this._register(this.remoteExtensions.onChange(e => this._onChange.fire(e)));
|
||||
} else {
|
||||
this.remoteExtensions = null;
|
||||
}
|
||||
|
||||
this.syncDelayer = new ThrottledDelayer<void>(ExtensionsWorkbenchService.SyncPeriod);
|
||||
@@ -560,7 +562,10 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension
|
||||
}
|
||||
|
||||
get installed(): IExtension[] {
|
||||
const result = [...this.localExtensions.local];
|
||||
const result = [];
|
||||
if (this.localExtensions) {
|
||||
result.push(...this.localExtensions.local);
|
||||
}
|
||||
if (this.remoteExtensions) {
|
||||
result.push(...this.remoteExtensions.local);
|
||||
}
|
||||
@@ -568,7 +573,10 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension
|
||||
}
|
||||
|
||||
get outdated(): IExtension[] {
|
||||
const allLocal = [...this.localExtensions.local];
|
||||
const allLocal = [];
|
||||
if (this.localExtensions) {
|
||||
allLocal.push(...this.localExtensions.local);
|
||||
}
|
||||
if (this.remoteExtensions) {
|
||||
allLocal.push(...this.remoteExtensions.local);
|
||||
}
|
||||
@@ -577,7 +585,7 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension
|
||||
|
||||
async queryLocal(server?: IExtensionManagementServer): Promise<IExtension[]> {
|
||||
if (server) {
|
||||
if (this.extensionManagementServerService.localExtensionManagementServer === server) {
|
||||
if (this.localExtensions && this.extensionManagementServerService.localExtensionManagementServer === server) {
|
||||
return this.localExtensions.queryInstalled();
|
||||
}
|
||||
if (this.remoteExtensions && this.extensionManagementServerService.remoteExtensionManagementServer === server) {
|
||||
@@ -585,12 +593,12 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension
|
||||
}
|
||||
}
|
||||
|
||||
await this.localExtensions.queryInstalled();
|
||||
if (this.remoteExtensions) {
|
||||
await Promise.all([this.localExtensions.queryInstalled(), this.remoteExtensions.queryInstalled()]);
|
||||
} else {
|
||||
if (this.localExtensions) {
|
||||
await this.localExtensions.queryInstalled();
|
||||
}
|
||||
if (this.remoteExtensions) {
|
||||
await this.remoteExtensions.queryInstalled();
|
||||
}
|
||||
return this.local;
|
||||
}
|
||||
|
||||
@@ -654,7 +662,10 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension
|
||||
}
|
||||
|
||||
private fromGallery(gallery: IGalleryExtension, maliciousExtensionSet: Set<string>): IExtension {
|
||||
Promise.all([this.localExtensions.syncLocalWithGalleryExtension(gallery, maliciousExtensionSet), this.remoteExtensions ? this.remoteExtensions.syncLocalWithGalleryExtension(gallery, maliciousExtensionSet) : Promise.resolve(false)])
|
||||
Promise.all([
|
||||
this.localExtensions ? this.localExtensions.syncLocalWithGalleryExtension(gallery, maliciousExtensionSet) : Promise.resolve(false),
|
||||
this.remoteExtensions ? this.remoteExtensions.syncLocalWithGalleryExtension(gallery, maliciousExtensionSet) : Promise.resolve(false)
|
||||
])
|
||||
.then(result => {
|
||||
if (result[0] || result[1]) {
|
||||
this.eventuallyAutoUpdateExtensions();
|
||||
@@ -690,7 +701,7 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension
|
||||
private getExtensionState(extension: Extension): ExtensionState {
|
||||
const isInstalling = this.installing.some(i => areSameExtensions(i.identifier, extension.identifier));
|
||||
if (extension.server) {
|
||||
const state = (extension.server === this.extensionManagementServerService.localExtensionManagementServer ? this.localExtensions : this.remoteExtensions!).getExtensionState(extension);
|
||||
const state = (extension.server === this.extensionManagementServerService.localExtensionManagementServer ? this.localExtensions! : this.remoteExtensions!).getExtensionState(extension);
|
||||
return state === ExtensionState.Uninstalled && isInstalling ? ExtensionState.Installing : state;
|
||||
} else if (isInstalling) {
|
||||
return ExtensionState.Installing;
|
||||
@@ -701,7 +712,10 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension
|
||||
return state;
|
||||
}
|
||||
}
|
||||
return this.localExtensions.getExtensionState(extension);
|
||||
if (this.localExtensions) {
|
||||
return this.localExtensions.getExtensionState(extension);
|
||||
}
|
||||
return ExtensionState.Uninstalled;
|
||||
}
|
||||
|
||||
checkForUpdates(): Promise<void> {
|
||||
@@ -772,20 +786,26 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension
|
||||
return false;
|
||||
}
|
||||
|
||||
return !!(extension as Extension).gallery;
|
||||
if (!extension.gallery) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.extensionManagementServerService.localExtensionManagementServer || this.extensionManagementServerService.remoteExtensionManagementServer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
install(extension: string | IExtension): Promise<IExtension> {
|
||||
// {{SQL CARBON EDIT}}
|
||||
let extensionPolicy = this.configurationService.getValue<string>(ExtensionsPolicyKey);
|
||||
|
||||
if (typeof extension === 'string') {
|
||||
install(extension: URI | IExtension): Promise<IExtension> {
|
||||
let extensionPolicy = this.configurationService.getValue<string>(ExtensionsPolicyKey); // {{SQL CARBON EDIT}} add line
|
||||
if (extension instanceof URI) {
|
||||
return this.installWithProgress(async () => {
|
||||
// {{SQL CARBON EDIT}} - Wrap async call in try/catch.
|
||||
// This is the error handler when installing local VSIX file.
|
||||
// Prompt the user about the error detail.
|
||||
try {
|
||||
const { identifier } = await this.extensionService.install(URI.file(extension));
|
||||
const { identifier } = await this.extensionService.install(extension);
|
||||
this.checkAndEnableDisabledDependencies(identifier);
|
||||
return this.local.filter(local => areSameExtensions(local.identifier, identifier))[0];
|
||||
} catch (error) {
|
||||
@@ -924,16 +944,16 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension
|
||||
private checkAndEnableDisabledDependencies(extensionIdentifier: IExtensionIdentifier): Promise<void> {
|
||||
const extension = this.local.filter(e => (e.local || e.gallery) && areSameExtensions(extensionIdentifier, e.identifier))[0];
|
||||
if (extension) {
|
||||
const disabledDepencies = this.getExtensionsRecursively([extension], this.local, EnablementState.Enabled, { dependencies: true, pack: false });
|
||||
const disabledDepencies = this.getExtensionsRecursively([extension], this.local, EnablementState.EnabledGlobally, { dependencies: true, pack: false });
|
||||
if (disabledDepencies.length) {
|
||||
return this.setEnablement(disabledDepencies, EnablementState.Enabled);
|
||||
return this.setEnablement(disabledDepencies, EnablementState.EnabledGlobally);
|
||||
}
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
private promptAndSetEnablement(extensions: IExtension[], enablementState: EnablementState): Promise<any> {
|
||||
const enable = enablementState === EnablementState.Enabled || enablementState === EnablementState.WorkspaceEnabled;
|
||||
const enable = enablementState === EnablementState.EnabledGlobally || enablementState === EnablementState.EnabledWorkspace;
|
||||
if (enable) {
|
||||
const allDependenciesAndPackedExtensions = this.getExtensionsRecursively(extensions, this.local, enablementState, { dependencies: true, pack: true });
|
||||
return this.checkAndSetEnablement(extensions, allDependenciesAndPackedExtensions, enablementState);
|
||||
@@ -948,7 +968,7 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension
|
||||
|
||||
private checkAndSetEnablement(extensions: IExtension[], otherExtensions: IExtension[], enablementState: EnablementState): Promise<any> {
|
||||
const allExtensions = [...extensions, ...otherExtensions];
|
||||
const enable = enablementState === EnablementState.Enabled || enablementState === EnablementState.WorkspaceEnabled;
|
||||
const enable = enablementState === EnablementState.EnabledGlobally || enablementState === EnablementState.EnabledWorkspace;
|
||||
if (!enable) {
|
||||
for (const extension of extensions) {
|
||||
let dependents = this.getDependentsAfterDisablement(extension, allExtensions, this.local);
|
||||
@@ -973,7 +993,7 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension
|
||||
if (i.enablementState === enablementState) {
|
||||
return false;
|
||||
}
|
||||
const enable = enablementState === EnablementState.Enabled || enablementState === EnablementState.WorkspaceEnabled;
|
||||
const enable = enablementState === EnablementState.EnabledGlobally || enablementState === EnablementState.EnabledWorkspace;
|
||||
return (enable || i.type === ExtensionType.User) // Include all Extensions for enablement and only user extensions for disablement
|
||||
&& (options.dependencies || options.pack)
|
||||
&& extensions.some(extension =>
|
||||
@@ -997,7 +1017,7 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension
|
||||
if (i === extension) {
|
||||
return false;
|
||||
}
|
||||
if (i.enablementState === EnablementState.WorkspaceDisabled || i.enablementState === EnablementState.Disabled) {
|
||||
if (!(i.enablementState === EnablementState.EnabledWorkspace || i.enablementState === EnablementState.EnabledGlobally)) {
|
||||
return false;
|
||||
}
|
||||
if (extensionsToDisable.indexOf(i) !== -1) {
|
||||
@@ -1047,7 +1067,7 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension
|
||||
]
|
||||
}
|
||||
*/
|
||||
this.telemetryService.publicLog(enablementState === EnablementState.Enabled || enablementState === EnablementState.WorkspaceEnabled ? 'extension:enable' : 'extension:disable', extensions[i].telemetryData);
|
||||
this.telemetryService.publicLog(enablementState === EnablementState.EnabledGlobally || enablementState === EnablementState.EnabledWorkspace ? 'extension:enable' : 'extension:disable', extensions[i].telemetryData);
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
@@ -7,13 +7,15 @@ import { IViewlet } from 'vs/workbench/common/viewlet';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { IPager } from 'vs/base/common/paging';
|
||||
import { IQueryOptions, EnablementState, ILocalExtension, IGalleryExtension, IExtensionIdentifier, IExtensionManagementServer } from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { IQueryOptions, ILocalExtension, IGalleryExtension, IExtensionIdentifier } from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { EnablementState, IExtensionManagementServer } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
|
||||
import { IViewContainersRegistry, ViewContainer, Extensions as ViewContainerExtensions } from 'vs/workbench/common/views';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { areSameExtensions } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
|
||||
import { IExtensionManifest, ExtensionType } from 'vs/platform/extensions/common/extensions';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
|
||||
export const VIEWLET_ID = 'workbench.view.extensions';
|
||||
export const VIEW_CONTAINER: ViewContainer = Registry.as<IViewContainersRegistry>(ViewContainerExtensions.ViewContainersRegistry).registerViewContainer(VIEWLET_ID);
|
||||
@@ -83,7 +85,7 @@ export interface IExtensionsWorkbenchService {
|
||||
queryGallery(token: CancellationToken): Promise<IPager<IExtension>>;
|
||||
queryGallery(options: IQueryOptions, token: CancellationToken): Promise<IPager<IExtension>>;
|
||||
canInstall(extension: IExtension): boolean;
|
||||
install(vsix: string): Promise<IExtension>;
|
||||
install(vsix: URI): Promise<IExtension>;
|
||||
install(extension: IExtension, promptToInstallDependencies?: boolean): Promise<IExtension>;
|
||||
uninstall(extension: IExtension): Promise<void>;
|
||||
installVersion(extension: IExtension, version: string): Promise<IExtension>;
|
||||
|
||||
@@ -9,7 +9,8 @@ import { Event } from 'vs/base/common/event';
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IExtensionManagementService, ILocalExtension, IExtensionEnablementService, IExtensionTipsService, IExtensionIdentifier, EnablementState, InstallOperation } from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { IExtensionManagementService, ILocalExtension, IExtensionIdentifier, InstallOperation } from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { IExtensionEnablementService, EnablementState, IExtensionTipsService } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
|
||||
import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
|
||||
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
|
||||
import { ServicesAccessor, IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
@@ -70,7 +71,7 @@ export class KeymapExtensions extends Disposable implements IWorkbenchContributi
|
||||
*/
|
||||
this.telemetryService.publicLog('disableOtherKeymaps', telemetryData);
|
||||
if (confirmed) {
|
||||
this.extensionEnablementService.setEnablement(oldKeymaps.map(keymap => keymap.local), EnablementState.Disabled);
|
||||
this.extensionEnablementService.setEnablement(oldKeymaps.map(keymap => keymap.local), EnablementState.DisabledGlobally);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -9,10 +9,8 @@ import { forEach } from 'vs/base/common/collections';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { match } from 'vs/base/common/glob';
|
||||
import * as json from 'vs/base/common/json';
|
||||
import {
|
||||
IExtensionManagementService, IExtensionGalleryService, IExtensionTipsService, ExtensionRecommendationReason, EXTENSION_IDENTIFIER_PATTERN,
|
||||
IExtensionsConfigContent, RecommendationChangeNotification, IExtensionRecommendation, ExtensionRecommendationSource, InstallOperation, ILocalExtension
|
||||
} from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { IExtensionManagementService, IExtensionGalleryService, EXTENSION_IDENTIFIER_PATTERN, InstallOperation, ILocalExtension } from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { IExtensionTipsService, ExtensionRecommendationReason, IExtensionsConfigContent, RecommendationChangeNotification, IExtensionRecommendation, ExtensionRecommendationSource } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
import { ITextModel } from 'vs/editor/common/model';
|
||||
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
|
||||
|
||||
@@ -3,105 +3,33 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import 'vs/css!../browser/media/extensions';
|
||||
import { localize } from 'vs/nls';
|
||||
import { KeyMod, KeyChord, KeyCode } from 'vs/base/common/keyCodes';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { SyncActionDescriptor, MenuRegistry, MenuId } from 'vs/platform/actions/common/actions';
|
||||
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
import { IExtensionTipsService, ExtensionsLabel, ExtensionsChannelId, PreferencesLabel, IExtensionManagementService, IExtensionGalleryService } from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
|
||||
import { IExtensionTipsService } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
|
||||
import { IWorkbenchActionRegistry, Extensions as WorkbenchActionExtensions } from 'vs/workbench/common/actions';
|
||||
import { ExtensionTipsService } from 'vs/workbench/contrib/extensions/electron-browser/extensionTipsService';
|
||||
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
|
||||
import { IOutputChannelRegistry, Extensions as OutputExtensions } from 'vs/workbench/contrib/output/common/output';
|
||||
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
// {{SQL CARBON EDIT}}
|
||||
import { VIEWLET_ID, IExtensionsWorkbenchService, ExtensionsPolicy } from '../common/extensions';
|
||||
import { ExtensionsWorkbenchService } from 'vs/workbench/contrib/extensions/node/extensionsWorkbenchService';
|
||||
import {
|
||||
OpenExtensionsViewletAction, InstallExtensionsAction, ShowOutdatedExtensionsAction, ShowRecommendedExtensionsAction, ShowRecommendedKeymapExtensionsAction, ShowPopularExtensionsAction,
|
||||
ShowEnabledExtensionsAction, ShowInstalledExtensionsAction, ShowDisabledExtensionsAction, ShowBuiltInExtensionsAction, UpdateAllAction,
|
||||
EnableAllAction, EnableAllWorkpsaceAction, DisableAllAction, DisableAllWorkpsaceAction, CheckForUpdatesAction, ShowLanguageExtensionsAction, ShowAzureExtensionsAction, EnableAutoUpdateAction, DisableAutoUpdateAction, ConfigureRecommendedExtensionsCommandsContributor, OpenExtensionsFolderAction, InstallVSIXAction, ReinstallAction, InstallSpecificVersionOfExtensionAction
|
||||
} from 'vs/workbench/contrib/extensions/browser/extensionsActions';
|
||||
import { ExtensionsInput } from 'vs/workbench/contrib/extensions/common/extensionsInput';
|
||||
import { ViewletRegistry, Extensions as ViewletExtensions, ViewletDescriptor } from 'vs/workbench/browser/viewlet';
|
||||
import { ExtensionEditor } from 'vs/workbench/contrib/extensions/browser/extensionEditor';
|
||||
import { StatusUpdater, ExtensionsViewlet, MaliciousExtensionChecker, ExtensionsViewletViewsContribution } from 'vs/workbench/contrib/extensions/browser/extensionsViewlet';
|
||||
import { IQuickOpenRegistry, Extensions, QuickOpenHandlerDescriptor } from 'vs/workbench/browser/quickopen';
|
||||
import { IConfigurationRegistry, Extensions as ConfigurationExtensions, ConfigurationScope } from 'vs/platform/configuration/common/configurationRegistry';
|
||||
import * as jsonContributionRegistry from 'vs/platform/jsonschemas/common/jsonContributionRegistry';
|
||||
import { ExtensionsConfigurationSchema, ExtensionsConfigurationSchemaId } from 'vs/workbench/contrib/extensions/common/extensionsFileTemplate';
|
||||
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||
import { ServicesAccessor, IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { KeymapExtensions } from 'vs/workbench/contrib/extensions/common/extensionsUtils';
|
||||
import { areSameExtensions } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
|
||||
import { GalleryExtensionsHandler, ExtensionsHandler } from 'vs/workbench/contrib/extensions/browser/extensionsQuickOpen';
|
||||
import { EditorDescriptor, IEditorRegistry, Extensions as EditorExtensions } from 'vs/workbench/browser/editor';
|
||||
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
|
||||
import { RuntimeExtensionsEditor, ShowRuntimeExtensionsAction, IExtensionHostProfileService, DebugExtensionHostAction, StartExtensionHostProfileAction, StopExtensionHostProfileAction, CONTEXT_PROFILE_SESSION_STATE, SaveExtensionHostProfileAction, CONTEXT_EXTENSION_HOST_PROFILE_RECORDED } from 'vs/workbench/contrib/extensions/electron-browser/runtimeExtensionsEditor';
|
||||
import { EditorInput, IEditorInputFactory, IEditorInputFactoryRegistry, Extensions as EditorInputExtensions, ActiveEditorContext } from 'vs/workbench/common/editor';
|
||||
import { ExtensionHostProfileService } from 'vs/workbench/contrib/extensions/electron-browser/extensionProfileService';
|
||||
import { RuntimeExtensionsInput } from 'vs/workbench/contrib/extensions/electron-browser/runtimeExtensionsInput';
|
||||
import { URI, UriComponents } from 'vs/base/common/uri';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { ExtensionActivationProgress } from 'vs/workbench/contrib/extensions/browser/extensionsActivationProgress';
|
||||
import { ExtensionsAutoProfiler } from 'vs/workbench/contrib/extensions/electron-browser/extensionsAutoProfiler';
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
import { ExtensionDependencyChecker } from 'vs/workbench/contrib/extensions/browser/extensionsDependencyChecker';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { ExtensionType } from 'vs/platform/extensions/common/extensions';
|
||||
|
||||
// Singletons
|
||||
registerSingleton(IExtensionsWorkbenchService, ExtensionsWorkbenchService);
|
||||
registerSingleton(IExtensionTipsService, ExtensionTipsService);
|
||||
registerSingleton(IExtensionHostProfileService, ExtensionHostProfileService, true);
|
||||
|
||||
const workbenchRegistry = Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench);
|
||||
workbenchRegistry.registerWorkbenchContribution(StatusUpdater, LifecyclePhase.Restored);
|
||||
workbenchRegistry.registerWorkbenchContribution(MaliciousExtensionChecker, LifecyclePhase.Eventually);
|
||||
workbenchRegistry.registerWorkbenchContribution(ConfigureRecommendedExtensionsCommandsContributor, LifecyclePhase.Eventually);
|
||||
workbenchRegistry.registerWorkbenchContribution(KeymapExtensions, LifecyclePhase.Restored);
|
||||
workbenchRegistry.registerWorkbenchContribution(ExtensionsViewletViewsContribution, LifecyclePhase.Starting);
|
||||
workbenchRegistry.registerWorkbenchContribution(ExtensionActivationProgress, LifecyclePhase.Eventually);
|
||||
workbenchRegistry.registerWorkbenchContribution(ExtensionsAutoProfiler, LifecyclePhase.Eventually);
|
||||
workbenchRegistry.registerWorkbenchContribution(ExtensionDependencyChecker, LifecyclePhase.Eventually);
|
||||
|
||||
Registry.as<IOutputChannelRegistry>(OutputExtensions.OutputChannels)
|
||||
.registerChannel({ id: ExtensionsChannelId, label: ExtensionsLabel, log: false });
|
||||
|
||||
// Quickopen
|
||||
Registry.as<IQuickOpenRegistry>(Extensions.Quickopen).registerQuickOpenHandler(
|
||||
new QuickOpenHandlerDescriptor(
|
||||
ExtensionsHandler,
|
||||
ExtensionsHandler.ID,
|
||||
'ext ',
|
||||
undefined,
|
||||
localize('extensionsCommands', "Manage Extensions"),
|
||||
true
|
||||
)
|
||||
);
|
||||
|
||||
Registry.as<IQuickOpenRegistry>(Extensions.Quickopen).registerQuickOpenHandler(
|
||||
new QuickOpenHandlerDescriptor(
|
||||
GalleryExtensionsHandler,
|
||||
GalleryExtensionsHandler.ID,
|
||||
'ext install ',
|
||||
undefined,
|
||||
localize('galleryExtensionsCommands', "Install Gallery Extensions"),
|
||||
true
|
||||
)
|
||||
);
|
||||
|
||||
// Editor
|
||||
const editorDescriptor = new EditorDescriptor(
|
||||
ExtensionEditor,
|
||||
ExtensionEditor.ID,
|
||||
localize('extension', "Extension")
|
||||
);
|
||||
|
||||
Registry.as<IEditorRegistry>(EditorExtensions.Editors)
|
||||
.registerEditor(editorDescriptor, [new SyncDescriptor(ExtensionsInput)]);
|
||||
|
||||
// Running Extensions Editor
|
||||
|
||||
@@ -126,159 +54,12 @@ class RuntimeExtensionsInputFactory implements IEditorInputFactory {
|
||||
Registry.as<IEditorInputFactoryRegistry>(EditorInputExtensions.EditorInputFactories).registerEditorInputFactory(RuntimeExtensionsInput.ID, RuntimeExtensionsInputFactory);
|
||||
|
||||
|
||||
// Viewlet
|
||||
const viewletDescriptor = new ViewletDescriptor(
|
||||
ExtensionsViewlet,
|
||||
VIEWLET_ID,
|
||||
localize('extensions', "Extensions"),
|
||||
'extensions',
|
||||
// {{SQL CARBON EDIT}}
|
||||
14
|
||||
);
|
||||
|
||||
Registry.as<ViewletRegistry>(ViewletExtensions.Viewlets)
|
||||
.registerViewlet(viewletDescriptor);
|
||||
|
||||
// Global actions
|
||||
const actionRegistry = Registry.as<IWorkbenchActionRegistry>(WorkbenchActionExtensions.WorkbenchActions);
|
||||
|
||||
const openViewletActionDescriptor = new SyncActionDescriptor(OpenExtensionsViewletAction, OpenExtensionsViewletAction.ID, OpenExtensionsViewletAction.LABEL, { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_X });
|
||||
actionRegistry.registerWorkbenchAction(openViewletActionDescriptor, 'View: Show Extensions', localize('view', "View"));
|
||||
|
||||
const installActionDescriptor = new SyncActionDescriptor(InstallExtensionsAction, InstallExtensionsAction.ID, InstallExtensionsAction.LABEL);
|
||||
actionRegistry.registerWorkbenchAction(installActionDescriptor, 'Extensions: Install Extensions', ExtensionsLabel);
|
||||
|
||||
const listOutdatedActionDescriptor = new SyncActionDescriptor(ShowOutdatedExtensionsAction, ShowOutdatedExtensionsAction.ID, ShowOutdatedExtensionsAction.LABEL);
|
||||
actionRegistry.registerWorkbenchAction(listOutdatedActionDescriptor, 'Extensions: Show Outdated Extensions', ExtensionsLabel);
|
||||
|
||||
const recommendationsActionDescriptor = new SyncActionDescriptor(ShowRecommendedExtensionsAction, ShowRecommendedExtensionsAction.ID, ShowRecommendedExtensionsAction.LABEL);
|
||||
actionRegistry.registerWorkbenchAction(recommendationsActionDescriptor, 'Extensions: Show Recommended Extensions', ExtensionsLabel);
|
||||
|
||||
const keymapRecommendationsActionDescriptor = new SyncActionDescriptor(ShowRecommendedKeymapExtensionsAction, ShowRecommendedKeymapExtensionsAction.ID, ShowRecommendedKeymapExtensionsAction.SHORT_LABEL, { primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_M) });
|
||||
actionRegistry.registerWorkbenchAction(keymapRecommendationsActionDescriptor, 'Preferences: Keymaps', PreferencesLabel);
|
||||
|
||||
const languageExtensionsActionDescriptor = new SyncActionDescriptor(ShowLanguageExtensionsAction, ShowLanguageExtensionsAction.ID, ShowLanguageExtensionsAction.SHORT_LABEL);
|
||||
actionRegistry.registerWorkbenchAction(languageExtensionsActionDescriptor, 'Preferences: Language Extensions', PreferencesLabel);
|
||||
|
||||
const azureExtensionsActionDescriptor = new SyncActionDescriptor(ShowAzureExtensionsAction, ShowAzureExtensionsAction.ID, ShowAzureExtensionsAction.SHORT_LABEL);
|
||||
actionRegistry.registerWorkbenchAction(azureExtensionsActionDescriptor, 'Preferences: Azure Extensions', PreferencesLabel);
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
// const popularActionDescriptor = new SyncActionDescriptor(ShowPopularExtensionsAction, ShowPopularExtensionsAction.ID, ShowPopularExtensionsAction.LABEL);
|
||||
// actionRegistry.registerWorkbenchAction(popularActionDescriptor, 'Extensions: Show Popular Extensions', ExtensionsLabel);
|
||||
|
||||
const enabledActionDescriptor = new SyncActionDescriptor(ShowEnabledExtensionsAction, ShowEnabledExtensionsAction.ID, ShowEnabledExtensionsAction.LABEL);
|
||||
actionRegistry.registerWorkbenchAction(enabledActionDescriptor, 'Extensions: Show Enabled Extensions', ExtensionsLabel);
|
||||
|
||||
const installedActionDescriptor = new SyncActionDescriptor(ShowInstalledExtensionsAction, ShowInstalledExtensionsAction.ID, ShowInstalledExtensionsAction.LABEL);
|
||||
actionRegistry.registerWorkbenchAction(installedActionDescriptor, 'Extensions: Show Installed Extensions', ExtensionsLabel);
|
||||
|
||||
const disabledActionDescriptor = new SyncActionDescriptor(ShowDisabledExtensionsAction, ShowDisabledExtensionsAction.ID, ShowDisabledExtensionsAction.LABEL);
|
||||
actionRegistry.registerWorkbenchAction(disabledActionDescriptor, 'Extensions: Show Disabled Extensions', ExtensionsLabel);
|
||||
|
||||
const builtinActionDescriptor = new SyncActionDescriptor(ShowBuiltInExtensionsAction, ShowBuiltInExtensionsAction.ID, ShowBuiltInExtensionsAction.LABEL);
|
||||
actionRegistry.registerWorkbenchAction(builtinActionDescriptor, 'Extensions: Show Built-in Extensions', ExtensionsLabel);
|
||||
|
||||
const updateAllActionDescriptor = new SyncActionDescriptor(UpdateAllAction, UpdateAllAction.ID, UpdateAllAction.LABEL);
|
||||
actionRegistry.registerWorkbenchAction(updateAllActionDescriptor, 'Extensions: Update All Extensions', ExtensionsLabel);
|
||||
|
||||
const openExtensionsFolderActionDescriptor = new SyncActionDescriptor(OpenExtensionsFolderAction, OpenExtensionsFolderAction.ID, OpenExtensionsFolderAction.LABEL);
|
||||
actionRegistry.registerWorkbenchAction(openExtensionsFolderActionDescriptor, 'Extensions: Open Extensions Folder', ExtensionsLabel);
|
||||
|
||||
const installVSIXActionDescriptor = new SyncActionDescriptor(InstallVSIXAction, InstallVSIXAction.ID, InstallVSIXAction.LABEL);
|
||||
actionRegistry.registerWorkbenchAction(installVSIXActionDescriptor, 'Extensions: Install from VSIX...', ExtensionsLabel);
|
||||
|
||||
const disableAllAction = new SyncActionDescriptor(DisableAllAction, DisableAllAction.ID, DisableAllAction.LABEL);
|
||||
actionRegistry.registerWorkbenchAction(disableAllAction, 'Extensions: Disable All Installed Extensions', ExtensionsLabel);
|
||||
|
||||
const disableAllWorkspaceAction = new SyncActionDescriptor(DisableAllWorkpsaceAction, DisableAllWorkpsaceAction.ID, DisableAllWorkpsaceAction.LABEL);
|
||||
actionRegistry.registerWorkbenchAction(disableAllWorkspaceAction, 'Extensions: Disable All Installed Extensions for this Workspace', ExtensionsLabel);
|
||||
|
||||
const enableAllAction = new SyncActionDescriptor(EnableAllAction, EnableAllAction.ID, EnableAllAction.LABEL);
|
||||
actionRegistry.registerWorkbenchAction(enableAllAction, 'Extensions: Enable All Extensions', ExtensionsLabel);
|
||||
|
||||
const enableAllWorkspaceAction = new SyncActionDescriptor(EnableAllWorkpsaceAction, EnableAllWorkpsaceAction.ID, EnableAllWorkpsaceAction.LABEL);
|
||||
actionRegistry.registerWorkbenchAction(enableAllWorkspaceAction, 'Extensions: Enable All Extensions for this Workspace', ExtensionsLabel);
|
||||
|
||||
const checkForUpdatesAction = new SyncActionDescriptor(CheckForUpdatesAction, CheckForUpdatesAction.ID, CheckForUpdatesAction.LABEL);
|
||||
actionRegistry.registerWorkbenchAction(checkForUpdatesAction, `Extensions: Check for Extension Updates`, ExtensionsLabel);
|
||||
|
||||
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(EnableAutoUpdateAction, EnableAutoUpdateAction.ID, EnableAutoUpdateAction.LABEL), `Extensions: Enable Auto Updating Extensions`, ExtensionsLabel);
|
||||
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(DisableAutoUpdateAction, DisableAutoUpdateAction.ID, DisableAutoUpdateAction.LABEL), `Extensions: Disable Auto Updating Extensions`, ExtensionsLabel);
|
||||
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(InstallSpecificVersionOfExtensionAction, InstallSpecificVersionOfExtensionAction.ID, InstallSpecificVersionOfExtensionAction.LABEL), 'Install Specific Version of Extension...', ExtensionsLabel);
|
||||
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(ShowRuntimeExtensionsAction, ShowRuntimeExtensionsAction.ID, ShowRuntimeExtensionsAction.LABEL), 'Show Running Extensions', localize('developer', "Developer"));
|
||||
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(ReinstallAction, ReinstallAction.ID, ReinstallAction.LABEL), 'Reinstall Extension...', localize('developer', "Developer"));
|
||||
|
||||
Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration)
|
||||
.registerConfiguration({
|
||||
id: 'extensions',
|
||||
order: 30,
|
||||
title: localize('extensionsConfigurationTitle', "Extensions"),
|
||||
type: 'object',
|
||||
properties: {
|
||||
'extensions.autoUpdate': {
|
||||
type: 'boolean',
|
||||
description: localize('extensionsAutoUpdate', "When enabled, automatically installs updates for extensions. The updates are fetched from a Microsoft online service."),
|
||||
default: true,
|
||||
scope: ConfigurationScope.APPLICATION,
|
||||
tags: ['usesOnlineServices']
|
||||
},
|
||||
'extensions.autoCheckUpdates': {
|
||||
type: 'boolean',
|
||||
description: localize('extensionsCheckUpdates', "When enabled, automatically checks extensions for updates. If an extension has an update, it is marked as outdated in the Extensions view. The updates are fetched from a Microsoft online service."),
|
||||
default: true,
|
||||
scope: ConfigurationScope.APPLICATION,
|
||||
tags: ['usesOnlineServices']
|
||||
},
|
||||
'extensions.ignoreRecommendations': {
|
||||
type: 'boolean',
|
||||
description: localize('extensionsIgnoreRecommendations', "When enabled, the notifications for extension recommendations will not be shown."),
|
||||
default: false
|
||||
},
|
||||
'extensions.showRecommendationsOnlyOnDemand': {
|
||||
type: 'boolean',
|
||||
description: localize('extensionsShowRecommendationsOnlyOnDemand', "When enabled, recommendations will not be fetched or shown unless specifically requested by the user. Some recommendations are fetched from a Microsoft online service."),
|
||||
default: false,
|
||||
tags: ['usesOnlineServices']
|
||||
},
|
||||
'extensions.closeExtensionDetailsOnViewChange': {
|
||||
type: 'boolean',
|
||||
description: localize('extensionsCloseExtensionDetailsOnViewChange', "When enabled, editors with extension details will be automatically closed upon navigating away from the Extensions View."),
|
||||
default: false
|
||||
},
|
||||
// {{SQL CARBON EDIT}}
|
||||
'extensions.extensionsPolicy': {
|
||||
type: 'string',
|
||||
description: localize('extensionsPolicy', "Sets the security policy for downloading extensions."),
|
||||
scope: ConfigurationScope.APPLICATION,
|
||||
default: ExtensionsPolicy.allowAll
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
const jsonRegistry = <jsonContributionRegistry.IJSONContributionRegistry>Registry.as(jsonContributionRegistry.Extensions.JSONContribution);
|
||||
jsonRegistry.registerSchema(ExtensionsConfigurationSchemaId, ExtensionsConfigurationSchema);
|
||||
|
||||
// Register Commands
|
||||
CommandsRegistry.registerCommand('_extensions.manage', (accessor: ServicesAccessor, extensionId: string) => {
|
||||
const extensionService = accessor.get(IExtensionsWorkbenchService);
|
||||
const extension = extensionService.local.filter(e => areSameExtensions(e.identifier, { id: extensionId }));
|
||||
if (extension.length === 1) {
|
||||
extensionService.open(extension[0]);
|
||||
}
|
||||
});
|
||||
|
||||
CommandsRegistry.registerCommand('extension.open', (accessor: ServicesAccessor, extensionId: string) => {
|
||||
const extensionService = accessor.get(IExtensionsWorkbenchService);
|
||||
|
||||
return extensionService.queryGallery({ names: [extensionId], pageSize: 1 }, CancellationToken.None).then(pager => {
|
||||
if (pager.total !== 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
extensionService.open(pager.firstPage[0]);
|
||||
});
|
||||
});
|
||||
|
||||
CommandsRegistry.registerCommand(DebugExtensionHostAction.ID, (accessor: ServicesAccessor) => {
|
||||
const instantiationService = accessor.get(IInstantiationService);
|
||||
@@ -300,49 +81,6 @@ CommandsRegistry.registerCommand(SaveExtensionHostProfileAction.ID, (accessor: S
|
||||
instantiationService.createInstance(SaveExtensionHostProfileAction, SaveExtensionHostProfileAction.ID, SaveExtensionHostProfileAction.LABEL).run();
|
||||
});
|
||||
|
||||
// File menu registration
|
||||
|
||||
// {{SQL CARBON EDIT}} - Disable unused menu item
|
||||
// MenuRegistry.appendMenuItem(MenuId.MenubarPreferencesMenu, {
|
||||
// group: '2_keybindings',
|
||||
// command: {
|
||||
// id: ShowRecommendedKeymapExtensionsAction.ID,
|
||||
// title: localize({ key: 'miOpenKeymapExtensions', comment: ['&& denotes a mnemonic'] }, "&&Keymaps")
|
||||
// },
|
||||
// order: 2
|
||||
// });
|
||||
// {{SQL CARBON EDIT}} - End
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.GlobalActivity, {
|
||||
group: '2_keybindings',
|
||||
command: {
|
||||
id: ShowRecommendedKeymapExtensionsAction.ID,
|
||||
title: localize('miOpenKeymapExtensions2', "Keymaps")
|
||||
},
|
||||
order: 2
|
||||
});
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.MenubarPreferencesMenu, {
|
||||
group: '1_settings',
|
||||
command: {
|
||||
id: VIEWLET_ID,
|
||||
title: localize({ key: 'miPreferencesExtensions', comment: ['&& denotes a mnemonic'] }, "&&Extensions")
|
||||
},
|
||||
order: 3
|
||||
});
|
||||
|
||||
// View menu
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.MenubarViewMenu, {
|
||||
group: '3_views',
|
||||
command: {
|
||||
id: VIEWLET_ID,
|
||||
title: localize({ key: 'miViewExtensions', comment: ['&& denotes a mnemonic'] }, "E&&xtensions")
|
||||
},
|
||||
// {{SQL CARBON EDIT}} - Change the order
|
||||
order: 7
|
||||
});
|
||||
|
||||
// Running extensions
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.EditorTitle, {
|
||||
@@ -396,78 +134,4 @@ MenuRegistry.appendMenuItem(MenuId.EditorTitle, {
|
||||
},
|
||||
group: 'navigation',
|
||||
when: ContextKeyExpr.and(ActiveEditorContext.isEqualTo(RuntimeExtensionsEditor.ID))
|
||||
});
|
||||
|
||||
CommandsRegistry.registerCommand({
|
||||
id: 'workbench.extensions.installExtension',
|
||||
description: {
|
||||
description: localize('workbench.extensions.installExtension.description', "Install the given extension"),
|
||||
args: [
|
||||
{
|
||||
name: localize('workbench.extensions.installExtension.arg.name', "Extension id or VSIX resource uri"),
|
||||
schema: {
|
||||
'type': ['object', 'string']
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
handler: async (accessor, arg: string | UriComponents) => {
|
||||
const extensionManagementService = accessor.get(IExtensionManagementService);
|
||||
const extensionGalleryService = accessor.get(IExtensionGalleryService);
|
||||
try {
|
||||
if (typeof arg === 'string') {
|
||||
const extension = await extensionGalleryService.getCompatibleExtension({ id: arg });
|
||||
if (extension) {
|
||||
await extensionManagementService.installFromGallery(extension);
|
||||
} else {
|
||||
throw new Error(localize('notFound', "Extension '{0}' not found.", arg));
|
||||
}
|
||||
} else {
|
||||
const vsix = URI.revive(arg);
|
||||
await extensionManagementService.install(vsix);
|
||||
}
|
||||
} catch (e) {
|
||||
onUnexpectedError(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
CommandsRegistry.registerCommand({
|
||||
id: 'workbench.extensions.uninstallExtension',
|
||||
description: {
|
||||
description: localize('workbench.extensions.uninstallExtension.description', "Uninstall the given extension"),
|
||||
args: [
|
||||
{
|
||||
name: localize('workbench.extensions.uninstallExtension.arg.name', "Id of the extension to uninstall"),
|
||||
schema: {
|
||||
'type': 'string'
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
handler: async (accessor, id: string) => {
|
||||
if (!id) {
|
||||
throw new Error(localize('id required', "Extension id required."));
|
||||
}
|
||||
const extensionManagementService = accessor.get(IExtensionManagementService);
|
||||
try {
|
||||
const installed = await extensionManagementService.getInstalled(ExtensionType.User);
|
||||
const [extensionToUninstall] = installed.filter(e => areSameExtensions(e.identifier, { id }));
|
||||
if (!extensionToUninstall) {
|
||||
return Promise.reject(new Error(localize('notInstalled', "Extension '{0}' is not installed. Make sure you use the full extension ID, including the publisher, e.g.: ms-vscode.csharp.", id)));
|
||||
}
|
||||
await extensionManagementService.uninstall(extensionToUninstall, true);
|
||||
} catch (e) {
|
||||
onUnexpectedError(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.GlobalActivity, {
|
||||
group: '2_configuration',
|
||||
command: {
|
||||
id: VIEWLET_ID,
|
||||
title: localize('showExtensions', "Extensions")
|
||||
},
|
||||
order: 3
|
||||
});
|
||||
@@ -23,7 +23,7 @@ import { ActionBar, Separator } from 'vs/base/browser/ui/actionbar/actionbar';
|
||||
import { dispose, IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { RunOnceScheduler } from 'vs/base/common/async';
|
||||
import { clipboard } from 'electron';
|
||||
import { EnablementState } from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { EnablementState } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
|
||||
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { IWindowService, IWindowsService } from 'vs/platform/windows/common/windows';
|
||||
import { writeFile } from 'vs/base/node/pfs';
|
||||
@@ -420,8 +420,8 @@ export class RuntimeExtensionsEditor extends BaseEditor {
|
||||
actions.push(new Separator());
|
||||
|
||||
if (e.element.marketplaceInfo) {
|
||||
actions.push(new Action('runtimeExtensionsEditor.action.disableWorkspace', nls.localize('disable workspace', "Disable (Workspace)"), undefined, true, () => this._extensionsWorkbenchService.setEnablement(e.element!.marketplaceInfo, EnablementState.WorkspaceDisabled)));
|
||||
actions.push(new Action('runtimeExtensionsEditor.action.disable', nls.localize('disable', "Disable"), undefined, true, () => this._extensionsWorkbenchService.setEnablement(e.element!.marketplaceInfo, EnablementState.Disabled)));
|
||||
actions.push(new Action('runtimeExtensionsEditor.action.disableWorkspace', nls.localize('disable workspace', "Disable (Workspace)"), undefined, true, () => this._extensionsWorkbenchService.setEnablement(e.element!.marketplaceInfo, EnablementState.DisabledWorkspace)));
|
||||
actions.push(new Action('runtimeExtensionsEditor.action.disable', nls.localize('disable', "Disable"), undefined, true, () => this._extensionsWorkbenchService.setEnablement(e.element!.marketplaceInfo, EnablementState.DisabledGlobally)));
|
||||
actions.push(new Separator());
|
||||
}
|
||||
const state = this._extensionHostProfileService.state;
|
||||
|
||||
@@ -8,11 +8,12 @@ import { assign } from 'vs/base/common/objects';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
import { IExtensionsWorkbenchService, ExtensionContainers } from 'vs/workbench/contrib/extensions/common/extensions';
|
||||
import * as ExtensionsActions from 'vs/workbench/contrib/extensions/browser/extensionsActions';
|
||||
import { ExtensionsWorkbenchService } from 'vs/workbench/contrib/extensions/node/extensionsWorkbenchService';
|
||||
import { ExtensionsWorkbenchService } from 'vs/workbench/contrib/extensions/browser/extensionsWorkbenchService';
|
||||
import {
|
||||
IExtensionManagementService, IExtensionGalleryService, IExtensionEnablementService, IExtensionTipsService, ILocalExtension, IGalleryExtension,
|
||||
DidInstallExtensionEvent, DidUninstallExtensionEvent, InstallExtensionEvent, IExtensionIdentifier, EnablementState, InstallOperation, IExtensionManagementServerService, IExtensionManagementServer
|
||||
IExtensionManagementService, IExtensionGalleryService, ILocalExtension, IGalleryExtension,
|
||||
DidInstallExtensionEvent, DidUninstallExtensionEvent, InstallExtensionEvent, IExtensionIdentifier, InstallOperation
|
||||
} from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { IExtensionEnablementService, EnablementState, IExtensionManagementServerService, IExtensionManagementServer, IExtensionTipsService } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
|
||||
import { getGalleryExtensionId } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
|
||||
import { ExtensionManagementService } from 'vs/platform/extensionManagement/node/extensionManagementService';
|
||||
import { ExtensionTipsService } from 'vs/workbench/contrib/extensions/electron-browser/extensionTipsService';
|
||||
@@ -39,7 +40,7 @@ import { ExtensionIdentifier, IExtensionContributions, ExtensionType, IExtension
|
||||
import { ISharedProcessService } from 'vs/platform/ipc/electron-browser/sharedProcessService';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { ILabelService } from 'vs/platform/label/common/label';
|
||||
import { ExtensionManagementServerService } from 'vs/workbench/services/extensions/electron-browser/extensionManagementServerService';
|
||||
import { ExtensionManagementServerService } from 'vs/workbench/services/extensionManagement/electron-browser/extensionManagementServerService';
|
||||
import { IProductService } from 'vs/platform/product/common/product';
|
||||
|
||||
suite('ExtensionsActions Test', () => {
|
||||
@@ -79,7 +80,7 @@ suite('ExtensionsActions Test', () => {
|
||||
instantiationService.stub(IExtensionManagementServerService, new class extends ExtensionManagementServerService {
|
||||
private _localExtensionManagementServer: IExtensionManagementServer = { extensionManagementService: instantiationService.get(IExtensionManagementService), label: 'local', authority: 'vscode-local' };
|
||||
constructor() {
|
||||
super(instantiationService.get(ISharedProcessService), instantiationService.get(IRemoteAgentService), instantiationService.get(IExtensionGalleryService), instantiationService.get(IConfigurationService), instantiationService.get(IProductService), instantiationService.get(ILogService));
|
||||
super(instantiationService.get(ISharedProcessService), instantiationService.get(IRemoteAgentService), instantiationService.get(IExtensionGalleryService), instantiationService.get(IConfigurationService), instantiationService.get(IProductService), instantiationService.get(ILogService), instantiationService.get(ILabelService));
|
||||
}
|
||||
get localExtensionManagementServer(): IExtensionManagementServer { return this._localExtensionManagementServer; }
|
||||
set localExtensionManagementServer(server: IExtensionManagementServer) { }
|
||||
@@ -601,7 +602,7 @@ suite('ExtensionsActions Test', () => {
|
||||
|
||||
test('Test EnableForWorkspaceAction when the extension is disabled globally', () => {
|
||||
const local = aLocalExtension('a');
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([local], EnablementState.Disabled)
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([local], EnablementState.DisabledGlobally)
|
||||
.then(() => {
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [local]);
|
||||
|
||||
@@ -616,7 +617,7 @@ suite('ExtensionsActions Test', () => {
|
||||
|
||||
test('Test EnableForWorkspaceAction when extension is disabled for workspace', () => {
|
||||
const local = aLocalExtension('a');
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([local], EnablementState.WorkspaceDisabled)
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([local], EnablementState.DisabledWorkspace)
|
||||
.then(() => {
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [local]);
|
||||
|
||||
@@ -631,8 +632,8 @@ suite('ExtensionsActions Test', () => {
|
||||
|
||||
test('Test EnableForWorkspaceAction when the extension is disabled globally and workspace', () => {
|
||||
const local = aLocalExtension('a');
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([local], EnablementState.Disabled)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([local], EnablementState.WorkspaceDisabled))
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([local], EnablementState.DisabledGlobally)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([local], EnablementState.DisabledWorkspace))
|
||||
.then(() => {
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [local]);
|
||||
|
||||
@@ -665,7 +666,7 @@ suite('ExtensionsActions Test', () => {
|
||||
|
||||
test('Test EnableGloballyAction when the extension is disabled for workspace', () => {
|
||||
const local = aLocalExtension('a');
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([local], EnablementState.WorkspaceDisabled)
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([local], EnablementState.DisabledWorkspace)
|
||||
.then(() => {
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [local]);
|
||||
|
||||
@@ -680,7 +681,7 @@ suite('ExtensionsActions Test', () => {
|
||||
|
||||
test('Test EnableGloballyAction when the extension is disabled globally', () => {
|
||||
const local = aLocalExtension('a');
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([local], EnablementState.Disabled)
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([local], EnablementState.DisabledGlobally)
|
||||
.then(() => {
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [local]);
|
||||
|
||||
@@ -695,8 +696,8 @@ suite('ExtensionsActions Test', () => {
|
||||
|
||||
test('Test EnableGloballyAction when the extension is disabled in both', () => {
|
||||
const local = aLocalExtension('a');
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([local], EnablementState.Disabled)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([local], EnablementState.WorkspaceDisabled))
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([local], EnablementState.DisabledGlobally)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([local], EnablementState.DisabledWorkspace))
|
||||
.then(() => {
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [local]);
|
||||
|
||||
@@ -729,7 +730,7 @@ suite('ExtensionsActions Test', () => {
|
||||
|
||||
test('Test EnableDropDownAction when extension is installed and disabled globally', () => {
|
||||
const local = aLocalExtension('a');
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([local], EnablementState.Disabled)
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([local], EnablementState.DisabledGlobally)
|
||||
.then(() => {
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [local]);
|
||||
|
||||
@@ -744,7 +745,7 @@ suite('ExtensionsActions Test', () => {
|
||||
|
||||
test('Test EnableDropDownAction when extension is installed and disabled for workspace', () => {
|
||||
const local = aLocalExtension('a');
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([local], EnablementState.WorkspaceDisabled)
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([local], EnablementState.DisabledWorkspace)
|
||||
.then(() => {
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [local]);
|
||||
|
||||
@@ -805,7 +806,7 @@ suite('ExtensionsActions Test', () => {
|
||||
|
||||
test('Test DisableForWorkspaceAction when the extension is disabled globally', () => {
|
||||
const local = aLocalExtension('a');
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([local], EnablementState.Disabled)
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([local], EnablementState.DisabledGlobally)
|
||||
.then(() => {
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [local]);
|
||||
|
||||
@@ -820,7 +821,7 @@ suite('ExtensionsActions Test', () => {
|
||||
|
||||
test('Test DisableForWorkspaceAction when the extension is disabled workspace', () => {
|
||||
const local = aLocalExtension('a');
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([local], EnablementState.Disabled)
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([local], EnablementState.DisabledGlobally)
|
||||
.then(() => {
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [local]);
|
||||
|
||||
@@ -853,7 +854,7 @@ suite('ExtensionsActions Test', () => {
|
||||
|
||||
test('Test DisableGloballyAction when the extension is disabled globally', () => {
|
||||
const local = aLocalExtension('a');
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([local], EnablementState.Disabled)
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([local], EnablementState.DisabledGlobally)
|
||||
.then(() => {
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [local]);
|
||||
|
||||
@@ -868,7 +869,7 @@ suite('ExtensionsActions Test', () => {
|
||||
|
||||
test('Test DisableGloballyAction when the extension is disabled for workspace', () => {
|
||||
const local = aLocalExtension('a');
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([local], EnablementState.WorkspaceDisabled)
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([local], EnablementState.DisabledWorkspace)
|
||||
.then(() => {
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [local]);
|
||||
|
||||
@@ -913,7 +914,7 @@ suite('ExtensionsActions Test', () => {
|
||||
|
||||
test('Test DisableDropDownAction when extension is installed and disabled globally', () => {
|
||||
const local = aLocalExtension('a');
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([local], EnablementState.Disabled)
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([local], EnablementState.DisabledGlobally)
|
||||
.then(() => {
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [local]);
|
||||
|
||||
@@ -928,7 +929,7 @@ suite('ExtensionsActions Test', () => {
|
||||
|
||||
test('Test DisableDropDownAction when extension is installed and disabled for workspace', () => {
|
||||
const local = aLocalExtension('a');
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([local], EnablementState.WorkspaceDisabled)
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([local], EnablementState.DisabledWorkspace)
|
||||
.then(() => {
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [local]);
|
||||
|
||||
@@ -1200,7 +1201,7 @@ suite('ExtensionsActions Test', () => {
|
||||
test('Test ReloadAction when extension is updated when not running', () => {
|
||||
instantiationService.stubPromise(IExtensionService, 'getExtensions', [{ identifier: new ExtensionIdentifier('pub.b'), extensionLocation: URI.file('pub.b') }]);
|
||||
const local = aLocalExtension('a', { version: '1.0.1' });
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([local], EnablementState.Disabled)
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([local], EnablementState.DisabledGlobally)
|
||||
.then(() => {
|
||||
const testObject: ExtensionsActions.ReloadAction = instantiationService.createInstance(ExtensionsActions.ReloadAction);
|
||||
instantiationService.createInstance(ExtensionContainers, [testObject]);
|
||||
@@ -1228,7 +1229,7 @@ suite('ExtensionsActions Test', () => {
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [local]);
|
||||
return workbenchService.queryLocal().then(extensions => {
|
||||
testObject.extension = extensions[0];
|
||||
return workbenchService.setEnablement(extensions[0], EnablementState.Disabled)
|
||||
return workbenchService.setEnablement(extensions[0], EnablementState.DisabledGlobally)
|
||||
.then(() => testObject.update())
|
||||
.then(() => {
|
||||
assert.ok(testObject.enabled);
|
||||
@@ -1248,8 +1249,8 @@ suite('ExtensionsActions Test', () => {
|
||||
return workbenchService.queryLocal().
|
||||
then(extensions => {
|
||||
testObject.extension = extensions[0];
|
||||
return workbenchService.setEnablement(extensions[0], EnablementState.Disabled)
|
||||
.then(() => workbenchService.setEnablement(extensions[0], EnablementState.Enabled))
|
||||
return workbenchService.setEnablement(extensions[0], EnablementState.DisabledGlobally)
|
||||
.then(() => workbenchService.setEnablement(extensions[0], EnablementState.EnabledGlobally))
|
||||
.then(() => assert.ok(!testObject.enabled));
|
||||
});
|
||||
});
|
||||
@@ -1257,7 +1258,7 @@ suite('ExtensionsActions Test', () => {
|
||||
test('Test ReloadAction when extension is enabled when not running', () => {
|
||||
instantiationService.stubPromise(IExtensionService, 'getExtensions', [{ identifier: new ExtensionIdentifier('pub.b'), extensionLocation: URI.file('pub.b') }]);
|
||||
const local = aLocalExtension('a');
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([local], EnablementState.Disabled)
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([local], EnablementState.DisabledGlobally)
|
||||
.then(() => {
|
||||
const testObject: ExtensionsActions.ReloadAction = instantiationService.createInstance(ExtensionsActions.ReloadAction);
|
||||
instantiationService.createInstance(ExtensionContainers, [testObject]);
|
||||
@@ -1266,7 +1267,7 @@ suite('ExtensionsActions Test', () => {
|
||||
return workbenchService.queryLocal()
|
||||
.then(extensions => {
|
||||
testObject.extension = extensions[0];
|
||||
return workbenchService.setEnablement(extensions[0], EnablementState.Enabled)
|
||||
return workbenchService.setEnablement(extensions[0], EnablementState.EnabledGlobally)
|
||||
.then(() => testObject.update())
|
||||
.then(() => {
|
||||
assert.ok(testObject.enabled);
|
||||
@@ -1280,7 +1281,7 @@ suite('ExtensionsActions Test', () => {
|
||||
test('Test ReloadAction when extension enablement is toggled when not running', () => {
|
||||
instantiationService.stubPromise(IExtensionService, 'getExtensions', [{ identifier: new ExtensionIdentifier('pub.b'), extensionLocation: URI.file('pub.b') }]);
|
||||
const local = aLocalExtension('a');
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([local], EnablementState.Disabled)
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([local], EnablementState.DisabledGlobally)
|
||||
.then(() => {
|
||||
const testObject: ExtensionsActions.ReloadAction = instantiationService.createInstance(ExtensionsActions.ReloadAction);
|
||||
instantiationService.createInstance(ExtensionContainers, [testObject]);
|
||||
@@ -1289,8 +1290,8 @@ suite('ExtensionsActions Test', () => {
|
||||
return workbenchService.queryLocal()
|
||||
.then(extensions => {
|
||||
testObject.extension = extensions[0];
|
||||
return workbenchService.setEnablement(extensions[0], EnablementState.Enabled)
|
||||
.then(() => workbenchService.setEnablement(extensions[0], EnablementState.Disabled))
|
||||
return workbenchService.setEnablement(extensions[0], EnablementState.EnabledGlobally)
|
||||
.then(() => workbenchService.setEnablement(extensions[0], EnablementState.DisabledGlobally))
|
||||
.then(() => assert.ok(!testObject.enabled));
|
||||
});
|
||||
});
|
||||
@@ -1299,7 +1300,7 @@ suite('ExtensionsActions Test', () => {
|
||||
test('Test ReloadAction when extension is updated when not running and enabled', () => {
|
||||
instantiationService.stubPromise(IExtensionService, 'getExtensions', [{ identifier: new ExtensionIdentifier('pub.b'), extensionLocation: URI.file('pub.b') }]);
|
||||
const local = aLocalExtension('a', { version: '1.0.1' });
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([local], EnablementState.Disabled)
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([local], EnablementState.DisabledGlobally)
|
||||
.then(() => {
|
||||
const testObject: ExtensionsActions.ReloadAction = instantiationService.createInstance(ExtensionsActions.ReloadAction);
|
||||
instantiationService.createInstance(ExtensionContainers, [testObject]);
|
||||
@@ -1312,7 +1313,7 @@ suite('ExtensionsActions Test', () => {
|
||||
const gallery = aGalleryExtension('a', { identifier: local.identifier, version: '1.0.2' });
|
||||
installEvent.fire({ identifier: gallery.identifier, gallery });
|
||||
didInstallEvent.fire({ identifier: gallery.identifier, gallery, operation: InstallOperation.Install, local: aLocalExtension('a', gallery, gallery) });
|
||||
return workbenchService.setEnablement(extensions[0], EnablementState.Enabled)
|
||||
return workbenchService.setEnablement(extensions[0], EnablementState.EnabledGlobally)
|
||||
.then(() => testObject.update())
|
||||
.then(() => {
|
||||
assert.ok(testObject.enabled);
|
||||
|
||||
@@ -12,8 +12,9 @@ import * as uuid from 'vs/base/common/uuid';
|
||||
import { mkdirp, rimraf, RimRafMode } from 'vs/base/node/pfs';
|
||||
import {
|
||||
IExtensionGalleryService, IGalleryExtensionAssets, IGalleryExtension, IExtensionManagementService,
|
||||
IExtensionEnablementService, DidInstallExtensionEvent, DidUninstallExtensionEvent, InstallExtensionEvent, IExtensionIdentifier
|
||||
DidInstallExtensionEvent, DidUninstallExtensionEvent, InstallExtensionEvent, IExtensionIdentifier
|
||||
} from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { IExtensionEnablementService } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
|
||||
import { ExtensionTipsService } from 'vs/workbench/contrib/extensions/electron-browser/extensionTipsService';
|
||||
import { ExtensionGalleryService } from 'vs/platform/extensionManagement/common/extensionGalleryService';
|
||||
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
|
||||
|
||||
@@ -9,11 +9,12 @@ import { generateUuid } from 'vs/base/common/uuid';
|
||||
import { ExtensionsListView } from 'vs/workbench/contrib/extensions/browser/extensionsViews';
|
||||
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
|
||||
import { IExtensionsWorkbenchService } from 'vs/workbench/contrib/extensions/common/extensions';
|
||||
import { ExtensionsWorkbenchService } from 'vs/workbench/contrib/extensions/node/extensionsWorkbenchService';
|
||||
import { ExtensionsWorkbenchService } from 'vs/workbench/contrib/extensions/browser/extensionsWorkbenchService';
|
||||
import {
|
||||
IExtensionManagementService, IExtensionGalleryService, IExtensionEnablementService, IExtensionTipsService, ILocalExtension, IGalleryExtension, IQueryOptions,
|
||||
DidInstallExtensionEvent, DidUninstallExtensionEvent, InstallExtensionEvent, IExtensionIdentifier, IExtensionManagementServerService, EnablementState, ExtensionRecommendationReason, SortBy, IExtensionManagementServer
|
||||
IExtensionManagementService, IExtensionGalleryService, ILocalExtension, IGalleryExtension, IQueryOptions,
|
||||
DidInstallExtensionEvent, DidUninstallExtensionEvent, InstallExtensionEvent, IExtensionIdentifier, SortBy
|
||||
} from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { IExtensionEnablementService, EnablementState, IExtensionManagementServerService, IExtensionManagementServer, IExtensionTipsService, ExtensionRecommendationReason } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
|
||||
import { getGalleryExtensionId } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
|
||||
import { ExtensionManagementService } from 'vs/platform/extensionManagement/node/extensionManagementService';
|
||||
import { ExtensionTipsService } from 'vs/workbench/contrib/extensions/electron-browser/extensionTipsService';
|
||||
@@ -40,8 +41,9 @@ import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteA
|
||||
import { RemoteAgentService } from 'vs/workbench/services/remote/electron-browser/remoteAgentServiceImpl';
|
||||
import { ExtensionIdentifier, ExtensionType, IExtensionDescription } from 'vs/platform/extensions/common/extensions';
|
||||
import { ISharedProcessService } from 'vs/platform/ipc/electron-browser/sharedProcessService';
|
||||
import { ExtensionManagementServerService } from 'vs/workbench/services/extensions/electron-browser/extensionManagementServerService';
|
||||
import { ExtensionManagementServerService } from 'vs/workbench/services/extensionManagement/electron-browser/extensionManagementServerService';
|
||||
import { IProductService } from 'vs/platform/product/common/product';
|
||||
import { ILabelService } from 'vs/platform/label/common/label';
|
||||
|
||||
|
||||
suite('ExtensionsListView Tests', () => {
|
||||
@@ -95,7 +97,7 @@ suite('ExtensionsListView Tests', () => {
|
||||
instantiationService.stub(IExtensionManagementServerService, new class extends ExtensionManagementServerService {
|
||||
private _localExtensionManagementServer: IExtensionManagementServer = { extensionManagementService: instantiationService.get(IExtensionManagementService), label: 'local', authority: 'vscode-local' };
|
||||
constructor() {
|
||||
super(instantiationService.get(ISharedProcessService), instantiationService.get(IRemoteAgentService), instantiationService.get(IExtensionGalleryService), instantiationService.get(IConfigurationService), instantiationService.get(IProductService), instantiationService.get(ILogService));
|
||||
super(instantiationService.get(ISharedProcessService), instantiationService.get(IRemoteAgentService), instantiationService.get(IExtensionGalleryService), instantiationService.get(IConfigurationService), instantiationService.get(IProductService), instantiationService.get(ILogService), instantiationService.get(ILabelService));
|
||||
}
|
||||
get localExtensionManagementServer(): IExtensionManagementServer { return this._localExtensionManagementServer; }
|
||||
set localExtensionManagementServer(server: IExtensionManagementServer) { }
|
||||
@@ -143,8 +145,8 @@ suite('ExtensionsListView Tests', () => {
|
||||
]);
|
||||
}
|
||||
});
|
||||
await (<TestExtensionEnablementService>instantiationService.get(IExtensionEnablementService)).setEnablement([localDisabledTheme], EnablementState.Disabled);
|
||||
await (<TestExtensionEnablementService>instantiationService.get(IExtensionEnablementService)).setEnablement([localDisabledLanguage], EnablementState.Disabled);
|
||||
await (<TestExtensionEnablementService>instantiationService.get(IExtensionEnablementService)).setEnablement([localDisabledTheme], EnablementState.DisabledGlobally);
|
||||
await (<TestExtensionEnablementService>instantiationService.get(IExtensionEnablementService)).setEnablement([localDisabledLanguage], EnablementState.DisabledGlobally);
|
||||
|
||||
instantiationService.set(IExtensionsWorkbenchService, instantiationService.createInstance(ExtensionsWorkbenchService));
|
||||
testableView = instantiationService.createInstance(ExtensionsListView, {});
|
||||
|
||||
@@ -9,11 +9,12 @@ import * as fs from 'fs';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
import { IExtensionsWorkbenchService, ExtensionState, AutoCheckUpdatesConfigurationKey, AutoUpdateConfigurationKey } from 'vs/workbench/contrib/extensions/common/extensions';
|
||||
import { ExtensionsWorkbenchService } from 'vs/workbench/contrib/extensions/node/extensionsWorkbenchService';
|
||||
import { ExtensionsWorkbenchService } from 'vs/workbench/contrib/extensions/browser/extensionsWorkbenchService';
|
||||
import {
|
||||
IExtensionManagementService, IExtensionGalleryService, IExtensionEnablementService, IExtensionTipsService, ILocalExtension, IGalleryExtension,
|
||||
DidInstallExtensionEvent, DidUninstallExtensionEvent, InstallExtensionEvent, IGalleryExtensionAssets, IExtensionIdentifier, EnablementState, InstallOperation, IExtensionManagementServerService
|
||||
IExtensionManagementService, IExtensionGalleryService, ILocalExtension, IGalleryExtension,
|
||||
DidInstallExtensionEvent, DidUninstallExtensionEvent, InstallExtensionEvent, IGalleryExtensionAssets, IExtensionIdentifier, InstallOperation
|
||||
} from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { IExtensionEnablementService, EnablementState, IExtensionManagementServerService, IExtensionTipsService } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
|
||||
import { getGalleryExtensionId } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
|
||||
import { ExtensionManagementService } from 'vs/platform/extensionManagement/node/extensionManagementService';
|
||||
import { ExtensionTipsService } from 'vs/workbench/contrib/extensions/electron-browser/extensionTipsService';
|
||||
@@ -481,86 +482,86 @@ suite('ExtensionsWorkbenchServiceTest', () => {
|
||||
});
|
||||
|
||||
test('test uninstalled extensions are always enabled', async () => {
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([aLocalExtension('b')], EnablementState.Disabled)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([aLocalExtension('c')], EnablementState.WorkspaceDisabled))
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([aLocalExtension('b')], EnablementState.DisabledGlobally)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([aLocalExtension('c')], EnablementState.DisabledWorkspace))
|
||||
.then(async () => {
|
||||
testObject = await aWorkbenchService();
|
||||
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(aGalleryExtension('a')));
|
||||
return testObject.queryGallery(CancellationToken.None).then(pagedResponse => {
|
||||
const actual = pagedResponse.firstPage[0];
|
||||
assert.equal(actual.enablementState, EnablementState.Enabled);
|
||||
assert.equal(actual.enablementState, EnablementState.EnabledGlobally);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('test enablement state installed enabled extension', async () => {
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([aLocalExtension('b')], EnablementState.Disabled)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([aLocalExtension('c')], EnablementState.WorkspaceDisabled))
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([aLocalExtension('b')], EnablementState.DisabledGlobally)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([aLocalExtension('c')], EnablementState.DisabledWorkspace))
|
||||
.then(async () => {
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [aLocalExtension('a')]);
|
||||
testObject = await aWorkbenchService();
|
||||
|
||||
const actual = testObject.local[0];
|
||||
|
||||
assert.equal(actual.enablementState, EnablementState.Enabled);
|
||||
assert.equal(actual.enablementState, EnablementState.EnabledGlobally);
|
||||
});
|
||||
});
|
||||
|
||||
test('test workspace disabled extension', async () => {
|
||||
const extensionA = aLocalExtension('a');
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([aLocalExtension('b')], EnablementState.Disabled)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([aLocalExtension('d')], EnablementState.Disabled))
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionA], EnablementState.WorkspaceDisabled))
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([aLocalExtension('e')], EnablementState.WorkspaceDisabled))
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([aLocalExtension('b')], EnablementState.DisabledGlobally)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([aLocalExtension('d')], EnablementState.DisabledGlobally))
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionA], EnablementState.DisabledWorkspace))
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([aLocalExtension('e')], EnablementState.DisabledWorkspace))
|
||||
.then(async () => {
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [extensionA]);
|
||||
testObject = await aWorkbenchService();
|
||||
|
||||
const actual = testObject.local[0];
|
||||
|
||||
assert.equal(actual.enablementState, EnablementState.WorkspaceDisabled);
|
||||
assert.equal(actual.enablementState, EnablementState.DisabledWorkspace);
|
||||
});
|
||||
});
|
||||
|
||||
test('test globally disabled extension', async () => {
|
||||
const localExtension = aLocalExtension('a');
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([localExtension], EnablementState.Disabled)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([aLocalExtension('d')], EnablementState.Disabled))
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([aLocalExtension('c')], EnablementState.WorkspaceDisabled))
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([localExtension], EnablementState.DisabledGlobally)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([aLocalExtension('d')], EnablementState.DisabledGlobally))
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([aLocalExtension('c')], EnablementState.DisabledWorkspace))
|
||||
.then(async () => {
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [localExtension]);
|
||||
testObject = await aWorkbenchService();
|
||||
|
||||
const actual = testObject.local[0];
|
||||
|
||||
assert.equal(actual.enablementState, EnablementState.Disabled);
|
||||
assert.equal(actual.enablementState, EnablementState.DisabledGlobally);
|
||||
});
|
||||
});
|
||||
|
||||
test('test enablement state is updated for user extensions', async () => {
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([aLocalExtension('c')], EnablementState.Disabled)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([aLocalExtension('b')], EnablementState.WorkspaceDisabled))
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([aLocalExtension('c')], EnablementState.DisabledGlobally)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([aLocalExtension('b')], EnablementState.DisabledWorkspace))
|
||||
.then(async () => {
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [aLocalExtension('a')]);
|
||||
testObject = await aWorkbenchService();
|
||||
return testObject.setEnablement(testObject.local[0], EnablementState.WorkspaceDisabled)
|
||||
return testObject.setEnablement(testObject.local[0], EnablementState.DisabledWorkspace)
|
||||
.then(() => {
|
||||
const actual = testObject.local[0];
|
||||
assert.equal(actual.enablementState, EnablementState.WorkspaceDisabled);
|
||||
assert.equal(actual.enablementState, EnablementState.DisabledWorkspace);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('test enable extension globally when extension is disabled for workspace', async () => {
|
||||
const localExtension = aLocalExtension('a');
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([localExtension], EnablementState.WorkspaceDisabled)
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([localExtension], EnablementState.DisabledWorkspace)
|
||||
.then(async () => {
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [localExtension]);
|
||||
testObject = await aWorkbenchService();
|
||||
return testObject.setEnablement(testObject.local[0], EnablementState.Enabled)
|
||||
return testObject.setEnablement(testObject.local[0], EnablementState.EnabledGlobally)
|
||||
.then(() => {
|
||||
const actual = testObject.local[0];
|
||||
assert.equal(actual.enablementState, EnablementState.Enabled);
|
||||
assert.equal(actual.enablementState, EnablementState.EnabledGlobally);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -569,10 +570,10 @@ suite('ExtensionsWorkbenchServiceTest', () => {
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [aLocalExtension('a')]);
|
||||
testObject = await aWorkbenchService();
|
||||
|
||||
return testObject.setEnablement(testObject.local[0], EnablementState.Disabled)
|
||||
return testObject.setEnablement(testObject.local[0], EnablementState.DisabledGlobally)
|
||||
.then(() => {
|
||||
const actual = testObject.local[0];
|
||||
assert.equal(actual.enablementState, EnablementState.Disabled);
|
||||
assert.equal(actual.enablementState, EnablementState.DisabledGlobally);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -580,25 +581,25 @@ suite('ExtensionsWorkbenchServiceTest', () => {
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [aLocalExtension('a', {}, { type: ExtensionType.System })]);
|
||||
testObject = await aWorkbenchService();
|
||||
|
||||
return testObject.setEnablement(testObject.local[0], EnablementState.Disabled)
|
||||
return testObject.setEnablement(testObject.local[0], EnablementState.DisabledGlobally)
|
||||
.then(() => {
|
||||
const actual = testObject.local[0];
|
||||
assert.equal(actual.enablementState, EnablementState.Disabled);
|
||||
assert.equal(actual.enablementState, EnablementState.DisabledGlobally);
|
||||
});
|
||||
});
|
||||
|
||||
test('test enablement state is updated on change from outside', async () => {
|
||||
const localExtension = aLocalExtension('a');
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([aLocalExtension('c')], EnablementState.Disabled)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([aLocalExtension('b')], EnablementState.WorkspaceDisabled))
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([aLocalExtension('c')], EnablementState.DisabledGlobally)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([aLocalExtension('b')], EnablementState.DisabledWorkspace))
|
||||
.then(async () => {
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [localExtension]);
|
||||
testObject = await aWorkbenchService();
|
||||
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([localExtension], EnablementState.Disabled)
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([localExtension], EnablementState.DisabledGlobally)
|
||||
.then(() => {
|
||||
const actual = testObject.local[0];
|
||||
assert.equal(actual.enablementState, EnablementState.Disabled);
|
||||
assert.equal(actual.enablementState, EnablementState.DisabledGlobally);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -608,17 +609,17 @@ suite('ExtensionsWorkbenchServiceTest', () => {
|
||||
const extensionB = aLocalExtension('b');
|
||||
const extensionC = aLocalExtension('c');
|
||||
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([extensionA], EnablementState.Enabled)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionB], EnablementState.Enabled))
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionC], EnablementState.Enabled))
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([extensionA], EnablementState.EnabledGlobally)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionB], EnablementState.EnabledGlobally))
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionC], EnablementState.EnabledGlobally))
|
||||
.then(async () => {
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [extensionA, extensionB, extensionC]);
|
||||
testObject = await aWorkbenchService();
|
||||
|
||||
return testObject.setEnablement(testObject.local[0], EnablementState.Disabled)
|
||||
return testObject.setEnablement(testObject.local[0], EnablementState.DisabledGlobally)
|
||||
.then(() => {
|
||||
assert.equal(testObject.local[0].enablementState, EnablementState.Disabled);
|
||||
assert.equal(testObject.local[1].enablementState, EnablementState.Enabled);
|
||||
assert.equal(testObject.local[0].enablementState, EnablementState.DisabledGlobally);
|
||||
assert.equal(testObject.local[1].enablementState, EnablementState.EnabledGlobally);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -628,17 +629,17 @@ suite('ExtensionsWorkbenchServiceTest', () => {
|
||||
const extensionB = aLocalExtension('b');
|
||||
const extensionC = aLocalExtension('c');
|
||||
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([extensionA], EnablementState.Enabled)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionB], EnablementState.Enabled))
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionC], EnablementState.Enabled))
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([extensionA], EnablementState.EnabledGlobally)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionB], EnablementState.EnabledGlobally))
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionC], EnablementState.EnabledGlobally))
|
||||
.then(async () => {
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [extensionA, extensionB, extensionC]);
|
||||
testObject = await aWorkbenchService();
|
||||
|
||||
return testObject.setEnablement(testObject.local[0], EnablementState.Disabled)
|
||||
return testObject.setEnablement(testObject.local[0], EnablementState.DisabledGlobally)
|
||||
.then(() => {
|
||||
assert.equal(testObject.local[0].enablementState, EnablementState.Disabled);
|
||||
assert.equal(testObject.local[1].enablementState, EnablementState.Disabled);
|
||||
assert.equal(testObject.local[0].enablementState, EnablementState.DisabledGlobally);
|
||||
assert.equal(testObject.local[1].enablementState, EnablementState.DisabledGlobally);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -648,17 +649,17 @@ suite('ExtensionsWorkbenchServiceTest', () => {
|
||||
const extensionB = aLocalExtension('b');
|
||||
const extensionC = aLocalExtension('c');
|
||||
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([extensionA], EnablementState.Enabled)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionB], EnablementState.Enabled))
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionC], EnablementState.Enabled))
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([extensionA], EnablementState.EnabledGlobally)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionB], EnablementState.EnabledGlobally))
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionC], EnablementState.EnabledGlobally))
|
||||
.then(async () => {
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [extensionA, extensionB, extensionC]);
|
||||
testObject = await aWorkbenchService();
|
||||
|
||||
return testObject.setEnablement(testObject.local[0], EnablementState.Disabled)
|
||||
return testObject.setEnablement(testObject.local[0], EnablementState.DisabledGlobally)
|
||||
.then(() => {
|
||||
assert.equal(testObject.local[0].enablementState, EnablementState.Disabled);
|
||||
assert.equal(testObject.local[1].enablementState, EnablementState.Disabled);
|
||||
assert.equal(testObject.local[0].enablementState, EnablementState.DisabledGlobally);
|
||||
assert.equal(testObject.local[1].enablementState, EnablementState.DisabledGlobally);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -668,13 +669,13 @@ suite('ExtensionsWorkbenchServiceTest', () => {
|
||||
const extensionB = aLocalExtension('b');
|
||||
const extensionC = aLocalExtension('c');
|
||||
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([extensionA], EnablementState.Enabled)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionB], EnablementState.Enabled))
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionC], EnablementState.Enabled))
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([extensionA], EnablementState.EnabledGlobally)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionB], EnablementState.EnabledGlobally))
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionC], EnablementState.EnabledGlobally))
|
||||
.then(async () => {
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [extensionA, extensionB, extensionC]);
|
||||
testObject = await aWorkbenchService();
|
||||
return testObject.setEnablement(testObject.local[1], EnablementState.Disabled).then(() => assert.fail('Should fail'), error => assert.ok(true));
|
||||
return testObject.setEnablement(testObject.local[1], EnablementState.DisabledGlobally).then(() => assert.fail('Should fail'), error => assert.ok(true));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -683,15 +684,15 @@ suite('ExtensionsWorkbenchServiceTest', () => {
|
||||
const extensionB = aLocalExtension('b');
|
||||
const extensionC = aLocalExtension('c');
|
||||
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([extensionA], EnablementState.Enabled)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionB], EnablementState.Enabled))
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionC], EnablementState.Enabled))
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([extensionA], EnablementState.EnabledGlobally)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionB], EnablementState.EnabledGlobally))
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionC], EnablementState.EnabledGlobally))
|
||||
.then(async () => {
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [extensionA, extensionB, extensionC]);
|
||||
testObject = await aWorkbenchService();
|
||||
return testObject.setEnablement(testObject.local[1], EnablementState.Disabled)
|
||||
return testObject.setEnablement(testObject.local[1], EnablementState.DisabledGlobally)
|
||||
.then(() => {
|
||||
assert.equal(testObject.local[1].enablementState, EnablementState.Disabled);
|
||||
assert.equal(testObject.local[1].enablementState, EnablementState.DisabledGlobally);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -701,19 +702,19 @@ suite('ExtensionsWorkbenchServiceTest', () => {
|
||||
const extensionB = aLocalExtension('b');
|
||||
const extensionC = aLocalExtension('c');
|
||||
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([extensionA], EnablementState.Enabled)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionB], EnablementState.Enabled))
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionC], EnablementState.Enabled))
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([extensionA], EnablementState.EnabledGlobally)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionB], EnablementState.EnabledGlobally))
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionC], EnablementState.EnabledGlobally))
|
||||
.then(async () => {
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [extensionA, extensionB, extensionC]);
|
||||
const target = sinon.spy();
|
||||
testObject = await aWorkbenchService();
|
||||
|
||||
return testObject.setEnablement([testObject.local[1], testObject.local[0]], EnablementState.Disabled)
|
||||
return testObject.setEnablement([testObject.local[1], testObject.local[0]], EnablementState.DisabledGlobally)
|
||||
.then(() => {
|
||||
assert.ok(!target.called);
|
||||
assert.equal(testObject.local[0].enablementState, EnablementState.Disabled);
|
||||
assert.equal(testObject.local[1].enablementState, EnablementState.Disabled);
|
||||
assert.equal(testObject.local[0].enablementState, EnablementState.DisabledGlobally);
|
||||
assert.equal(testObject.local[1].enablementState, EnablementState.DisabledGlobally);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -723,19 +724,19 @@ suite('ExtensionsWorkbenchServiceTest', () => {
|
||||
const extensionB = aLocalExtension('b');
|
||||
const extensionC = aLocalExtension('c');
|
||||
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([extensionA], EnablementState.Disabled)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionB], EnablementState.Disabled))
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionC], EnablementState.Disabled))
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([extensionA], EnablementState.DisabledGlobally)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionB], EnablementState.DisabledGlobally))
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionC], EnablementState.DisabledGlobally))
|
||||
.then(async () => {
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [extensionA, extensionB, extensionC]);
|
||||
const target = sinon.spy();
|
||||
testObject = await aWorkbenchService();
|
||||
|
||||
return testObject.setEnablement([testObject.local[1], testObject.local[0]], EnablementState.Enabled)
|
||||
return testObject.setEnablement([testObject.local[1], testObject.local[0]], EnablementState.EnabledGlobally)
|
||||
.then(() => {
|
||||
assert.ok(!target.called);
|
||||
assert.equal(testObject.local[0].enablementState, EnablementState.Enabled);
|
||||
assert.equal(testObject.local[1].enablementState, EnablementState.Enabled);
|
||||
assert.equal(testObject.local[0].enablementState, EnablementState.EnabledGlobally);
|
||||
assert.equal(testObject.local[1].enablementState, EnablementState.EnabledGlobally);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -745,16 +746,16 @@ suite('ExtensionsWorkbenchServiceTest', () => {
|
||||
const extensionB = aLocalExtension('b');
|
||||
const extensionC = aLocalExtension('c', { extensionDependencies: ['pub.b'] });
|
||||
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([extensionA], EnablementState.Enabled)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionB], EnablementState.Enabled))
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionC], EnablementState.Enabled))
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([extensionA], EnablementState.EnabledGlobally)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionB], EnablementState.EnabledGlobally))
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionC], EnablementState.EnabledGlobally))
|
||||
.then(async () => {
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [extensionA, extensionB, extensionC]);
|
||||
testObject = await aWorkbenchService();
|
||||
|
||||
return testObject.setEnablement(testObject.local[0], EnablementState.Disabled)
|
||||
return testObject.setEnablement(testObject.local[0], EnablementState.DisabledGlobally)
|
||||
.then(() => {
|
||||
assert.equal(testObject.local[0].enablementState, EnablementState.Disabled);
|
||||
assert.equal(testObject.local[0].enablementState, EnablementState.DisabledGlobally);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -764,16 +765,16 @@ suite('ExtensionsWorkbenchServiceTest', () => {
|
||||
const extensionB = aLocalExtension('b');
|
||||
const extensionC = aLocalExtension('c', { extensionDependencies: ['pub.b'] });
|
||||
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([extensionA], EnablementState.Enabled)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionB], EnablementState.Enabled))
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionC], EnablementState.Disabled))
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([extensionA], EnablementState.EnabledGlobally)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionB], EnablementState.EnabledGlobally))
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionC], EnablementState.DisabledGlobally))
|
||||
.then(async () => {
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [extensionA, extensionB, extensionC]);
|
||||
testObject = await aWorkbenchService();
|
||||
|
||||
return testObject.setEnablement(testObject.local[0], EnablementState.Disabled)
|
||||
return testObject.setEnablement(testObject.local[0], EnablementState.DisabledGlobally)
|
||||
.then(() => {
|
||||
assert.equal(testObject.local[0].enablementState, EnablementState.Disabled);
|
||||
assert.equal(testObject.local[0].enablementState, EnablementState.DisabledGlobally);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -783,14 +784,14 @@ suite('ExtensionsWorkbenchServiceTest', () => {
|
||||
const extensionB = aLocalExtension('b', { extensionDependencies: ['pub.a'] });
|
||||
const extensionC = aLocalExtension('c');
|
||||
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([extensionA], EnablementState.Enabled)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionB], EnablementState.Enabled))
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionC], EnablementState.Enabled))
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([extensionA], EnablementState.EnabledGlobally)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionB], EnablementState.EnabledGlobally))
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionC], EnablementState.EnabledGlobally))
|
||||
.then(async () => {
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [extensionA, extensionB, extensionC]);
|
||||
testObject = await aWorkbenchService();
|
||||
|
||||
return testObject.setEnablement(testObject.local[0], EnablementState.Disabled)
|
||||
return testObject.setEnablement(testObject.local[0], EnablementState.DisabledGlobally)
|
||||
.then(() => assert.fail('An extension with dependent should not be disabled'), () => null);
|
||||
});
|
||||
});
|
||||
@@ -800,16 +801,16 @@ suite('ExtensionsWorkbenchServiceTest', () => {
|
||||
const extensionB = aLocalExtension('b');
|
||||
const extensionC = aLocalExtension('c', { extensionDependencies: ['pub.b'] });
|
||||
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([extensionA], EnablementState.Enabled)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionB], EnablementState.Disabled))
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionC], EnablementState.Enabled))
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([extensionA], EnablementState.EnabledGlobally)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionB], EnablementState.DisabledGlobally))
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionC], EnablementState.EnabledGlobally))
|
||||
.then(async () => {
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [extensionA, extensionB, extensionC]);
|
||||
|
||||
testObject = await aWorkbenchService();
|
||||
|
||||
return testObject.setEnablement(testObject.local[0], EnablementState.Disabled)
|
||||
.then(() => assert.equal(testObject.local[0].enablementState, EnablementState.Disabled));
|
||||
return testObject.setEnablement(testObject.local[0], EnablementState.DisabledGlobally)
|
||||
.then(() => assert.equal(testObject.local[0].enablementState, EnablementState.DisabledGlobally));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -818,13 +819,13 @@ suite('ExtensionsWorkbenchServiceTest', () => {
|
||||
const extensionB = aLocalExtension('b', { extensionDependencies: ['pub.c'] });
|
||||
const extensionC = aLocalExtension('c', { extensionDependencies: ['pub.a'] });
|
||||
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([extensionA], EnablementState.Enabled)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionB], EnablementState.Enabled))
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionC], EnablementState.Enabled))
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([extensionA], EnablementState.EnabledGlobally)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionB], EnablementState.EnabledGlobally))
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionC], EnablementState.EnabledGlobally))
|
||||
.then(async () => {
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [extensionA, extensionB, extensionC]);
|
||||
testObject = await aWorkbenchService();
|
||||
return testObject.setEnablement(testObject.local[0], EnablementState.Disabled)
|
||||
return testObject.setEnablement(testObject.local[0], EnablementState.DisabledGlobally)
|
||||
.then(() => assert.fail('An extension with dependent should not be disabled'), () => null);
|
||||
});
|
||||
});
|
||||
@@ -834,17 +835,17 @@ suite('ExtensionsWorkbenchServiceTest', () => {
|
||||
const extensionB = aLocalExtension('b');
|
||||
const extensionC = aLocalExtension('c');
|
||||
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([extensionA], EnablementState.Disabled)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionB], EnablementState.Disabled))
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionC], EnablementState.Disabled))
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([extensionA], EnablementState.DisabledGlobally)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionB], EnablementState.DisabledGlobally))
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionC], EnablementState.DisabledGlobally))
|
||||
.then(async () => {
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [extensionA, extensionB, extensionC]);
|
||||
testObject = await aWorkbenchService();
|
||||
|
||||
return testObject.setEnablement(testObject.local[0], EnablementState.Enabled)
|
||||
return testObject.setEnablement(testObject.local[0], EnablementState.EnabledGlobally)
|
||||
.then(() => {
|
||||
assert.equal(testObject.local[0].enablementState, EnablementState.Enabled);
|
||||
assert.equal(testObject.local[1].enablementState, EnablementState.Enabled);
|
||||
assert.equal(testObject.local[0].enablementState, EnablementState.EnabledGlobally);
|
||||
assert.equal(testObject.local[1].enablementState, EnablementState.EnabledGlobally);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -854,18 +855,18 @@ suite('ExtensionsWorkbenchServiceTest', () => {
|
||||
const extensionB = aLocalExtension('b');
|
||||
const extensionC = aLocalExtension('c');
|
||||
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([extensionA], EnablementState.Disabled)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionB], EnablementState.Enabled))
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionC], EnablementState.Disabled))
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([extensionA], EnablementState.DisabledGlobally)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionB], EnablementState.EnabledGlobally))
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionC], EnablementState.DisabledGlobally))
|
||||
.then(async () => {
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [extensionA, extensionB, extensionC]);
|
||||
const target = sinon.spy();
|
||||
testObject = await aWorkbenchService();
|
||||
|
||||
return testObject.setEnablement(testObject.local[0], EnablementState.Enabled)
|
||||
return testObject.setEnablement(testObject.local[0], EnablementState.EnabledGlobally)
|
||||
.then(() => {
|
||||
assert.ok(!target.called);
|
||||
assert.equal(testObject.local[0].enablementState, EnablementState.Enabled);
|
||||
assert.equal(testObject.local[0].enablementState, EnablementState.EnabledGlobally);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -875,19 +876,19 @@ suite('ExtensionsWorkbenchServiceTest', () => {
|
||||
const extensionB = aLocalExtension('b');
|
||||
const extensionC = aLocalExtension('c');
|
||||
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([extensionA], EnablementState.Disabled)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionB], EnablementState.Disabled))
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionC], EnablementState.Disabled))
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([extensionA], EnablementState.DisabledGlobally)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionB], EnablementState.DisabledGlobally))
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionC], EnablementState.DisabledGlobally))
|
||||
.then(async () => {
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [extensionA, extensionB, extensionC]);
|
||||
const target = sinon.spy();
|
||||
testObject = await aWorkbenchService();
|
||||
|
||||
return testObject.setEnablement([testObject.local[1], testObject.local[0]], EnablementState.Enabled)
|
||||
return testObject.setEnablement([testObject.local[1], testObject.local[0]], EnablementState.EnabledGlobally)
|
||||
.then(() => {
|
||||
assert.ok(!target.called);
|
||||
assert.equal(testObject.local[0].enablementState, EnablementState.Enabled);
|
||||
assert.equal(testObject.local[1].enablementState, EnablementState.Enabled);
|
||||
assert.equal(testObject.local[0].enablementState, EnablementState.EnabledGlobally);
|
||||
assert.equal(testObject.local[1].enablementState, EnablementState.EnabledGlobally);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -897,48 +898,48 @@ suite('ExtensionsWorkbenchServiceTest', () => {
|
||||
const extensionB = aLocalExtension('b', { extensionDependencies: ['pub.c'] });
|
||||
const extensionC = aLocalExtension('c', { extensionDependencies: ['pub.a'] });
|
||||
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([extensionA], EnablementState.Disabled)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionB], EnablementState.Disabled))
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionC], EnablementState.Disabled))
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([extensionA], EnablementState.DisabledGlobally)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionB], EnablementState.DisabledGlobally))
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([extensionC], EnablementState.DisabledGlobally))
|
||||
.then(async () => {
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [extensionA, extensionB, extensionC]);
|
||||
|
||||
testObject = await aWorkbenchService();
|
||||
|
||||
return testObject.setEnablement(testObject.local[0], EnablementState.Enabled)
|
||||
return testObject.setEnablement(testObject.local[0], EnablementState.EnabledGlobally)
|
||||
.then(() => {
|
||||
assert.equal(testObject.local[0].enablementState, EnablementState.Enabled);
|
||||
assert.equal(testObject.local[1].enablementState, EnablementState.Enabled);
|
||||
assert.equal(testObject.local[2].enablementState, EnablementState.Enabled);
|
||||
assert.equal(testObject.local[0].enablementState, EnablementState.EnabledGlobally);
|
||||
assert.equal(testObject.local[1].enablementState, EnablementState.EnabledGlobally);
|
||||
assert.equal(testObject.local[2].enablementState, EnablementState.EnabledGlobally);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('test change event is fired when disablement flags are changed', async () => {
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([aLocalExtension('c')], EnablementState.Disabled)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([aLocalExtension('b')], EnablementState.WorkspaceDisabled))
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([aLocalExtension('c')], EnablementState.DisabledGlobally)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([aLocalExtension('b')], EnablementState.DisabledWorkspace))
|
||||
.then(async () => {
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [aLocalExtension('a')]);
|
||||
testObject = await aWorkbenchService();
|
||||
const target = sinon.spy();
|
||||
testObject.onChange(target);
|
||||
|
||||
return testObject.setEnablement(testObject.local[0], EnablementState.Disabled)
|
||||
return testObject.setEnablement(testObject.local[0], EnablementState.DisabledGlobally)
|
||||
.then(() => assert.ok(target.calledOnce));
|
||||
});
|
||||
});
|
||||
|
||||
test('test change event is fired when disablement flags are changed from outside', async () => {
|
||||
const localExtension = aLocalExtension('a');
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([aLocalExtension('c')], EnablementState.Disabled)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([aLocalExtension('b')], EnablementState.WorkspaceDisabled))
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([aLocalExtension('c')], EnablementState.DisabledGlobally)
|
||||
.then(() => instantiationService.get(IExtensionEnablementService).setEnablement([aLocalExtension('b')], EnablementState.DisabledWorkspace))
|
||||
.then(async () => {
|
||||
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [localExtension]);
|
||||
testObject = await aWorkbenchService();
|
||||
const target = sinon.spy();
|
||||
testObject.onChange(target);
|
||||
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([localExtension], EnablementState.Disabled)
|
||||
return instantiationService.get(IExtensionEnablementService).setEnablement([localExtension], EnablementState.DisabledGlobally)
|
||||
.then(() => assert.ok(target.calledOnce));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -27,7 +27,7 @@ import { ITextModel } from 'vs/editor/common/model';
|
||||
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
|
||||
import { IModeService } from 'vs/editor/common/services/modeService';
|
||||
import { ILabelService } from 'vs/platform/label/common/label';
|
||||
import { IExtensionEnablementService } from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { IExtensionEnablementService } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
|
||||
|
||||
type FormattingEditProvider = DocumentFormattingEditProvider | DocumentRangeFormattingEditProvider;
|
||||
|
||||
|
||||
@@ -7,7 +7,8 @@ import { IssueReporterStyles, IIssueService, IssueReporterData, ProcessExplorerD
|
||||
import { ITheme, IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { textLinkForeground, inputBackground, inputBorder, inputForeground, buttonBackground, buttonHoverBackground, buttonForeground, inputValidationErrorBorder, foreground, inputActiveOptionBorder, scrollbarSliderActiveBackground, scrollbarSliderBackground, scrollbarSliderHoverBackground, editorBackground, editorForeground, listHoverBackground, listHoverForeground, listHighlightForeground, textLinkActiveForeground } from 'vs/platform/theme/common/colorRegistry';
|
||||
import { SIDE_BAR_BACKGROUND } from 'vs/workbench/common/theme';
|
||||
import { IExtensionManagementService, IExtensionEnablementService } from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { IExtensionManagementService } from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { IExtensionEnablementService } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
|
||||
import { webFrame } from 'electron';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
import { IWorkbenchIssueService } from 'vs/workbench/contrib/issue/electron-browser/issue';
|
||||
|
||||
@@ -15,7 +15,8 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { IPreferencesSearchService, ISearchProvider, IWorkbenchSettingsConfiguration } from 'vs/workbench/contrib/preferences/common/preferences';
|
||||
import { IRequestService, asJson } from 'vs/platform/request/common/request';
|
||||
import { IExtensionManagementService, ILocalExtension, IExtensionEnablementService } from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { IExtensionManagementService, ILocalExtension } from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { IExtensionEnablementService } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { canceled } from 'vs/base/common/errors';
|
||||
|
||||
@@ -70,6 +70,10 @@ function getExcludeDisplayValue(element: SettingsTreeSettingElement): IListDataI
|
||||
}
|
||||
|
||||
function getListDisplayValue(element: SettingsTreeSettingElement): IListDataItem[] {
|
||||
if (!element.value || !isArray(element.value)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return element.value.map((key: string) => {
|
||||
return {
|
||||
value: key
|
||||
|
||||
@@ -168,8 +168,6 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
|
||||
private static readonly IgnoreTask010DonotShowAgain_key = 'workbench.tasks.ignoreTask010Shown';
|
||||
|
||||
private static CustomizationTelemetryEventName: string = 'taskService.customize';
|
||||
public static TemplateTelemetryEventName: string = 'taskService.template';
|
||||
|
||||
public _serviceBrand: any;
|
||||
public static OutputChannelId: string = 'tasks';
|
||||
public static OutputChannelLabel: string = nls.localize('tasks', "Tasks");
|
||||
@@ -2057,14 +2055,16 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
|
||||
content = content.replace(/(\n)(\t+)/g, (_, s1, s2) => s1 + strings.repeat(' ', s2.length * editorConfig.editor.tabSize));
|
||||
}
|
||||
configFileCreated = true;
|
||||
/* __GDPR__
|
||||
"taskService.template" : {
|
||||
"templateId" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
|
||||
"autoDetect" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }
|
||||
}
|
||||
*/
|
||||
type TaskServiceTemplateClassification = {
|
||||
templateId?: { classification: 'SystemMetaData', purpose: 'FeatureInsight' };
|
||||
autoDetect: { classification: 'SystemMetaData', purpose: 'FeatureInsight', isMeasurement: true };
|
||||
};
|
||||
type TaskServiceEvent = {
|
||||
templateId?: string;
|
||||
autoDetect: boolean;
|
||||
};
|
||||
return this.textFileService.create(resource, content).then((result): URI => {
|
||||
this.telemetryService.publicLog(AbstractTaskService.TemplateTelemetryEventName, {
|
||||
this.telemetryService.publicLog2<TaskServiceEvent, TaskServiceTemplateClassification>('taskService.template', {
|
||||
templateId: selection.id,
|
||||
autoDetect: selection.autoDetect
|
||||
});
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as Objects from 'vs/base/common/objects';
|
||||
import * as semver from 'semver';
|
||||
import * as semver from 'semver-umd';
|
||||
import { IStringDictionary } from 'vs/base/common/collections';
|
||||
import { WorkbenchState, IWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
|
||||
import { ITaskSystem } from 'vs/workbench/contrib/tasks/common/taskSystem';
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { Extensions as WorkbenchExtensions, IWorkbenchContributionsRegistry, IWorkbenchContribution } from 'vs/workbench/common/contributions';
|
||||
import { LifecyclePhase, ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
|
||||
import { LifecyclePhase, ILifecycleService, StartupKind } from 'vs/platform/lifecycle/common/lifecycle';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
|
||||
import { IActivityBarService } from 'vs/workbench/services/activityBar/browser/activityBarService';
|
||||
@@ -39,27 +39,41 @@ export class TelemetryContribution extends Disposable implements IWorkbenchContr
|
||||
const { filesToOpenOrCreate, filesToDiff } = environmentService.configuration;
|
||||
const activeViewlet = viewletService.getActiveViewlet();
|
||||
|
||||
/* __GDPR__
|
||||
"workspaceLoad" : {
|
||||
"userAgent" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
|
||||
"windowSize.innerHeight": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
|
||||
"windowSize.innerWidth": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
|
||||
"windowSize.outerHeight": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
|
||||
"windowSize.outerWidth": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
|
||||
"emptyWorkbench": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
|
||||
"workbench.filesToOpenOrCreate": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
|
||||
"workbench.filesToDiff": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
|
||||
"customKeybindingsCount": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
|
||||
"theme": { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
|
||||
"language": { "classification": "SystemMetaData", "purpose": "BusinessInsight" },
|
||||
"pinnedViewlets": { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
|
||||
"restoredViewlet": { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
|
||||
"restoredEditors": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
|
||||
"pinnedViewlets": { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
|
||||
"startupKind": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }
|
||||
}
|
||||
*/
|
||||
telemetryService.publicLog('workspaceLoad', {
|
||||
type WindowSizeFragment = {
|
||||
innerHeight: { classification: 'SystemMetaData', purpose: 'FeatureInsight', isMeasurement: true };
|
||||
innerWidth: { classification: 'SystemMetaData', purpose: 'FeatureInsight', isMeasurement: true };
|
||||
outerHeight: { classification: 'SystemMetaData', purpose: 'FeatureInsight', isMeasurement: true };
|
||||
outerWidth: { classification: 'SystemMetaData', purpose: 'FeatureInsight', isMeasurement: true };
|
||||
};
|
||||
type WorkspaceLoadClassification = {
|
||||
userAgent: { classification: 'SystemMetaData', purpose: 'FeatureInsight' };
|
||||
emptyWorkbench: { classification: 'SystemMetaData', purpose: 'FeatureInsight', isMeasurement: true };
|
||||
windowSize: WindowSizeFragment;
|
||||
'workbench.filesToOpenOrCreate': { classification: 'SystemMetaData', purpose: 'FeatureInsight', isMeasurement: true };
|
||||
'workbench.filesToDiff': { classification: 'SystemMetaData', purpose: 'FeatureInsight', isMeasurement: true };
|
||||
customKeybindingsCount: { classification: 'SystemMetaData', purpose: 'FeatureInsight', isMeasurement: true };
|
||||
theme: { classification: 'SystemMetaData', purpose: 'FeatureInsight' };
|
||||
language: { classification: 'SystemMetaData', purpose: 'BusinessInsight' };
|
||||
pinnedViewlets: { classification: 'SystemMetaData', purpose: 'FeatureInsight' };
|
||||
restoredViewlet?: { classification: 'SystemMetaData', purpose: 'FeatureInsight' };
|
||||
restoredEditors: { classification: 'SystemMetaData', purpose: 'FeatureInsight', isMeasurement: true };
|
||||
startupKind: { classification: 'SystemMetaData', purpose: 'FeatureInsight', isMeasurement: true };
|
||||
};
|
||||
type WorkspaceLoadEvent = {
|
||||
userAgent: string;
|
||||
windowSize: { innerHeight: number, innerWidth: number, outerHeight: number, outerWidth: number };
|
||||
emptyWorkbench: boolean;
|
||||
'workbench.filesToOpenOrCreate': number;
|
||||
'workbench.filesToDiff': number;
|
||||
customKeybindingsCount: number;
|
||||
theme: string;
|
||||
language: string;
|
||||
pinnedViewlets: string[];
|
||||
restoredViewlet?: string;
|
||||
restoredEditors: number;
|
||||
startupKind: StartupKind;
|
||||
};
|
||||
telemetryService.publicLog2<WorkspaceLoadEvent, WorkspaceLoadClassification>('workspaceLoad', {
|
||||
userAgent: navigator.userAgent,
|
||||
windowSize: { innerHeight: window.innerHeight, innerWidth: window.innerWidth, outerHeight: window.outerHeight, outerWidth: window.outerWidth },
|
||||
emptyWorkbench: contextService.getWorkbenchState() === WorkbenchState.EMPTY,
|
||||
|
||||
@@ -48,7 +48,7 @@ function renderBody(
|
||||
|
||||
export class ReleaseNotesManager {
|
||||
|
||||
private _releaseNotesCache: { [version: string]: Promise<string>; } = Object.create(null);
|
||||
private readonly _releaseNotesCache = new Map<string, Promise<string>>();
|
||||
|
||||
private _currentReleaseNotes: WebviewEditorInput | undefined = undefined;
|
||||
private _lastText: string | undefined;
|
||||
@@ -71,7 +71,7 @@ export class ReleaseNotesManager {
|
||||
}
|
||||
const html = await this.renderBody(this._lastText);
|
||||
if (this._currentReleaseNotes) {
|
||||
this._currentReleaseNotes.html = html;
|
||||
this._currentReleaseNotes.webview.html = html;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -88,7 +88,7 @@ export class ReleaseNotesManager {
|
||||
const activeControl = this._editorService.activeControl;
|
||||
if (this._currentReleaseNotes) {
|
||||
this._currentReleaseNotes.setName(title);
|
||||
this._currentReleaseNotes.html = html;
|
||||
this._currentReleaseNotes.webview.html = html;
|
||||
this._webviewEditorService.revealWebview(this._currentReleaseNotes, activeControl ? activeControl.group : this._editorGroupService.activeGroup, false);
|
||||
} else {
|
||||
this._currentReleaseNotes = this._webviewEditorService.createWebview(
|
||||
@@ -103,17 +103,17 @@ export class ReleaseNotesManager {
|
||||
URI.parse(require.toUrl('./media'))
|
||||
]
|
||||
},
|
||||
undefined, {
|
||||
onDidClickLink: uri => this.onDidClickLink(uri),
|
||||
onDispose: () => { this._currentReleaseNotes = undefined; }
|
||||
});
|
||||
undefined);
|
||||
|
||||
this._currentReleaseNotes.webview.onDidClickLink(uri => this.onDidClickLink(uri));
|
||||
this._currentReleaseNotes.onDispose(() => { this._currentReleaseNotes = undefined; });
|
||||
|
||||
const iconPath = URI.parse(require.toUrl('./media/code-icon.svg'));
|
||||
this._currentReleaseNotes.iconPath = {
|
||||
light: iconPath,
|
||||
dark: iconPath
|
||||
};
|
||||
this._currentReleaseNotes.html = html;
|
||||
this._currentReleaseNotes.webview.html = html;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -162,8 +162,8 @@ export class ReleaseNotesManager {
|
||||
.replace(/kbstyle\(([^\)]+)\)/gi, kbstyle);
|
||||
};
|
||||
|
||||
if (!this._releaseNotesCache[version]) {
|
||||
this._releaseNotesCache[version] = this._requestService.request({ url }, CancellationToken.None)
|
||||
if (!this._releaseNotesCache.has(version)) {
|
||||
this._releaseNotesCache.set(version, this._requestService.request({ url }, CancellationToken.None)
|
||||
.then(asText)
|
||||
.then(text => {
|
||||
if (!text || !/^#\s/.test(text)) { // release notes always starts with `#` followed by whitespace
|
||||
@@ -172,10 +172,10 @@ export class ReleaseNotesManager {
|
||||
|
||||
return Promise.resolve(text);
|
||||
})
|
||||
.then(text => patchKeybindings(text));
|
||||
.then(text => patchKeybindings(text)));
|
||||
}
|
||||
|
||||
return this._releaseNotesCache[version];
|
||||
return this._releaseNotesCache.get(version)!;
|
||||
}
|
||||
|
||||
private onDidClickLink(uri: URI) {
|
||||
|
||||
@@ -17,7 +17,7 @@ import { IOpenerService } from 'vs/platform/opener/common/opener';
|
||||
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
|
||||
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
|
||||
import { IUpdateService, State as UpdateState, StateType, IUpdate } from 'vs/platform/update/common/update';
|
||||
import * as semver from 'semver';
|
||||
import * as semver from 'semver-umd';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { INotificationService, INotificationHandle, Severity } from 'vs/platform/notification/common/notification';
|
||||
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
|
||||
|
||||
@@ -7,31 +7,27 @@ import * as DOM from 'vs/base/browser/dom';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { DisposableStore, MutableDisposable } from 'vs/base/common/lifecycle';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { IWindowService } from 'vs/platform/windows/common/windows';
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor';
|
||||
import { EditorOptions } from 'vs/workbench/common/editor';
|
||||
import { WebviewEditorInput } from 'vs/workbench/contrib/webview/browser/webviewEditorInput';
|
||||
import { IWebviewService, KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_VISIBLE, Webview } from 'vs/workbench/contrib/webview/common/webview';
|
||||
import { KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_VISIBLE, Webview, WebviewEditorOverlay } from 'vs/workbench/contrib/webview/common/webview';
|
||||
import { IEditorGroup } from 'vs/workbench/services/editor/common/editorGroupsService';
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
|
||||
|
||||
export class WebviewEditor extends BaseEditor {
|
||||
|
||||
public static readonly ID = 'WebviewEditor';
|
||||
|
||||
private _webview: Webview | undefined;
|
||||
private readonly _scopedContextKeyService = this._register(new MutableDisposable<IContextKeyService>());
|
||||
private _findWidgetVisible: IContextKey<boolean>;
|
||||
|
||||
private _editorFrame: HTMLElement;
|
||||
private _editorFrame?: HTMLElement;
|
||||
private _content?: HTMLElement;
|
||||
private _webviewContent: HTMLElement | undefined;
|
||||
|
||||
private readonly _webviewFocusTrackerDisposables = this._register(new DisposableStore());
|
||||
private readonly _onFocusWindowHandler = this._register(new MutableDisposable());
|
||||
@@ -39,22 +35,21 @@ export class WebviewEditor extends BaseEditor {
|
||||
private readonly _onDidFocusWebview = this._register(new Emitter<void>());
|
||||
public get onDidFocus(): Event<any> { return this._onDidFocusWebview.event; }
|
||||
|
||||
private _pendingMessages: any[] = [];
|
||||
|
||||
constructor(
|
||||
@ITelemetryService telemetryService: ITelemetryService,
|
||||
@IThemeService themeService: IThemeService,
|
||||
@IContextKeyService private _contextKeyService: IContextKeyService,
|
||||
@IWebviewService private readonly _webviewService: IWebviewService,
|
||||
@IWorkspaceContextService private readonly _contextService: IWorkspaceContextService,
|
||||
@IContextKeyService private readonly _contextKeyService: IContextKeyService,
|
||||
@IEditorService private readonly _editorService: IEditorService,
|
||||
@IWindowService private readonly _windowService: IWindowService,
|
||||
@IStorageService storageService: IStorageService
|
||||
) {
|
||||
super(WebviewEditor.ID, telemetryService, themeService, storageService);
|
||||
if (_contextKeyService) {
|
||||
this._findWidgetVisible = KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_VISIBLE.bindTo(_contextKeyService);
|
||||
}
|
||||
|
||||
this._findWidgetVisible = KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_VISIBLE.bindTo(_contextKeyService);
|
||||
}
|
||||
|
||||
public get isWebviewEditor() {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected createEditor(parent: HTMLElement): void {
|
||||
@@ -63,58 +58,25 @@ export class WebviewEditor extends BaseEditor {
|
||||
parent.appendChild(this._content);
|
||||
}
|
||||
|
||||
private doUpdateContainer() {
|
||||
const webviewContainer = this.input && (this.input as WebviewEditorInput).container;
|
||||
if (webviewContainer && webviewContainer.parentElement) {
|
||||
const frameRect = this._editorFrame.getBoundingClientRect();
|
||||
const containerRect = webviewContainer.parentElement.getBoundingClientRect();
|
||||
|
||||
webviewContainer.style.position = 'absolute';
|
||||
webviewContainer.style.top = `${frameRect.top - containerRect.top}px`;
|
||||
webviewContainer.style.left = `${frameRect.left - containerRect.left}px`;
|
||||
webviewContainer.style.width = `${frameRect.width}px`;
|
||||
webviewContainer.style.height = `${frameRect.height}px`;
|
||||
}
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
this._pendingMessages = [];
|
||||
|
||||
// Let the editor input dispose of the webview.
|
||||
this._webview = undefined;
|
||||
this._webviewContent = undefined;
|
||||
|
||||
if (this._content && this._content.parentElement) {
|
||||
this._content.parentElement.removeChild(this._content);
|
||||
if (this._content) {
|
||||
this._content.remove();
|
||||
this._content = undefined;
|
||||
}
|
||||
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
public sendMessage(data: any): void {
|
||||
if (this._webview) {
|
||||
this._webview.sendMessage(data);
|
||||
} else {
|
||||
this._pendingMessages.push(data);
|
||||
}
|
||||
}
|
||||
public showFind() {
|
||||
if (this._webview) {
|
||||
this._webview.showFind();
|
||||
this.withWebview(webview => {
|
||||
webview.showFind();
|
||||
this._findWidgetVisible.set(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public hideFind() {
|
||||
this._findWidgetVisible.reset();
|
||||
if (this._webview) {
|
||||
this._webview.hideFind();
|
||||
}
|
||||
}
|
||||
|
||||
public get isWebviewEditor() {
|
||||
return true;
|
||||
this.withWebview(webview => webview.hideFind());
|
||||
}
|
||||
|
||||
public reload() {
|
||||
@@ -122,16 +84,15 @@ export class WebviewEditor extends BaseEditor {
|
||||
}
|
||||
|
||||
public layout(_dimension: DOM.Dimension): void {
|
||||
this.withWebview(webview => {
|
||||
this.doUpdateContainer();
|
||||
webview.layout();
|
||||
});
|
||||
if (this.input && this.input instanceof WebviewEditorInput) {
|
||||
this.synchronizeWebviewContainerDimensions(this.input.webview);
|
||||
this.input.webview.layout();
|
||||
}
|
||||
}
|
||||
|
||||
public focus(): void {
|
||||
super.focus();
|
||||
if (!this._onFocusWindowHandler.value) {
|
||||
|
||||
// Make sure we restore focus when switching back to a VS Code window
|
||||
this._onFocusWindowHandler.value = this._windowService.onDidChangeFocus(focused => {
|
||||
if (focused && this._editorService.activeControl === this) {
|
||||
@@ -143,29 +104,20 @@ export class WebviewEditor extends BaseEditor {
|
||||
}
|
||||
|
||||
public withWebview(f: (element: Webview) => void): void {
|
||||
if (this._webview) {
|
||||
f(this._webview);
|
||||
if (this.input && this.input instanceof WebviewEditorInput) {
|
||||
f(this.input.webview);
|
||||
}
|
||||
}
|
||||
|
||||
protected setEditorVisible(visible: boolean, group: IEditorGroup): void {
|
||||
if (this.input && this.input instanceof WebviewEditorInput) {
|
||||
const webview = this.input && (this.input as WebviewEditorInput).webview;
|
||||
if (webview) {
|
||||
if (visible) {
|
||||
this.input.claimWebview(this);
|
||||
webview.claim(this);
|
||||
} else {
|
||||
this.input.releaseWebview(this);
|
||||
}
|
||||
|
||||
this.updateWebview(this.input as WebviewEditorInput);
|
||||
}
|
||||
|
||||
if (this._webviewContent) {
|
||||
if (visible) {
|
||||
this._webviewContent.style.visibility = 'visible';
|
||||
this.doUpdateContainer();
|
||||
} else {
|
||||
this._webviewContent.style.visibility = 'hidden';
|
||||
webview.release(this);
|
||||
}
|
||||
this.claimWebview(this.input as WebviewEditorInput);
|
||||
}
|
||||
|
||||
super.setEditorVisible(visible, group);
|
||||
@@ -173,115 +125,69 @@ export class WebviewEditor extends BaseEditor {
|
||||
|
||||
public clearInput() {
|
||||
if (this.input && this.input instanceof WebviewEditorInput) {
|
||||
this.input.releaseWebview(this);
|
||||
this.input.webview.release(this);
|
||||
}
|
||||
|
||||
this._webview = undefined;
|
||||
this._webviewContent = undefined;
|
||||
this._pendingMessages = [];
|
||||
|
||||
super.clearInput();
|
||||
}
|
||||
|
||||
setInput(input: WebviewEditorInput, options: EditorOptions, token: CancellationToken): Promise<void> {
|
||||
if (this.input) {
|
||||
(this.input as WebviewEditorInput).releaseWebview(this);
|
||||
this._webview = undefined;
|
||||
this._webviewContent = undefined;
|
||||
public async setInput(input: WebviewEditorInput, options: EditorOptions, token: CancellationToken): Promise<void> {
|
||||
if (this.input && this.input instanceof WebviewEditorInput) {
|
||||
this.input.webview.release(this);
|
||||
}
|
||||
this._pendingMessages = [];
|
||||
return super.setInput(input, options, token)
|
||||
.then(() => input.resolve())
|
||||
.then(() => {
|
||||
if (token.isCancellationRequested) {
|
||||
return;
|
||||
}
|
||||
if (this.group) {
|
||||
input.updateGroup(this.group.id);
|
||||
}
|
||||
this.updateWebview(input);
|
||||
});
|
||||
|
||||
await super.setInput(input, options, token);
|
||||
await input.resolve();
|
||||
if (token.isCancellationRequested) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.group) {
|
||||
input.updateGroup(this.group.id);
|
||||
}
|
||||
|
||||
this.claimWebview(input);
|
||||
}
|
||||
|
||||
private updateWebview(input: WebviewEditorInput) {
|
||||
const webview = this.getWebview(input);
|
||||
input.claimWebview(this);
|
||||
webview.update(input.html, {
|
||||
allowScripts: input.options.enableScripts,
|
||||
localResourceRoots: input.options.localResourceRoots || this.getDefaultLocalResourceRoots(),
|
||||
portMappings: input.options.portMapping,
|
||||
}, !!input.options.retainContextWhenHidden);
|
||||
private claimWebview(input: WebviewEditorInput): void {
|
||||
input.webview.claim(this);
|
||||
|
||||
if (this._webviewContent) {
|
||||
this._webviewContent.style.visibility = 'visible';
|
||||
if (input.webview.options.enableFindWidget) {
|
||||
this._scopedContextKeyService.value = this._contextKeyService.createScoped(input.webview.container);
|
||||
this._findWidgetVisible = KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_VISIBLE.bindTo(this._scopedContextKeyService.value);
|
||||
}
|
||||
|
||||
this.doUpdateContainer();
|
||||
if (this._content) {
|
||||
this._content.setAttribute('aria-flowto', input.webview.container.id);
|
||||
}
|
||||
|
||||
this.synchronizeWebviewContainerDimensions(input.webview);
|
||||
this.trackFocus(input.webview);
|
||||
}
|
||||
|
||||
private getDefaultLocalResourceRoots(): URI[] {
|
||||
const rootPaths = this._contextService.getWorkspace().folders.map(x => x.uri);
|
||||
const extension = (this.input as WebviewEditorInput).extension;
|
||||
if (extension) {
|
||||
rootPaths.push(extension.location);
|
||||
private synchronizeWebviewContainerDimensions(webview: WebviewEditorOverlay) {
|
||||
const webviewContainer = webview.container;
|
||||
if (webviewContainer && webviewContainer.parentElement && this._editorFrame) {
|
||||
const frameRect = this._editorFrame.getBoundingClientRect();
|
||||
const containerRect = webviewContainer.parentElement.getBoundingClientRect();
|
||||
|
||||
webviewContainer.style.position = 'absolute';
|
||||
webviewContainer.style.top = `${frameRect.top - containerRect.top}px`;
|
||||
webviewContainer.style.left = `${frameRect.left - containerRect.left}px`;
|
||||
webviewContainer.style.width = `${frameRect.width}px`;
|
||||
webviewContainer.style.height = `${frameRect.height}px`;
|
||||
}
|
||||
return rootPaths;
|
||||
}
|
||||
|
||||
private getWebview(input: WebviewEditorInput): Webview {
|
||||
if (this._webview) {
|
||||
return this._webview;
|
||||
}
|
||||
|
||||
this._webviewContent = input.container;
|
||||
|
||||
if (input.webview) {
|
||||
this._webview = input.webview;
|
||||
} else {
|
||||
if (input.options.enableFindWidget) {
|
||||
this._contextKeyService = this._register(this._contextKeyService.createScoped(this._webviewContent));
|
||||
this._findWidgetVisible = KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_VISIBLE.bindTo(this._contextKeyService);
|
||||
}
|
||||
|
||||
this._webview = this._webviewService.createWebview(input.id,
|
||||
{
|
||||
allowSvgs: true,
|
||||
extension: input.extension,
|
||||
enableFindWidget: input.options.enableFindWidget
|
||||
}, {});
|
||||
this._webview.mountTo(this._webviewContent);
|
||||
input.webview = this._webview;
|
||||
|
||||
if (input.options.tryRestoreScrollPosition) {
|
||||
this._webview.initialScrollProgress = input.scrollYPercentage;
|
||||
}
|
||||
|
||||
this._webview.state = input.state ? input.state.state : undefined;
|
||||
|
||||
this._content!.setAttribute('aria-flowto', this._webviewContent.id);
|
||||
|
||||
this.doUpdateContainer();
|
||||
}
|
||||
|
||||
for (const message of this._pendingMessages) {
|
||||
this._webview.sendMessage(message);
|
||||
}
|
||||
this._pendingMessages = [];
|
||||
|
||||
this.trackFocus();
|
||||
|
||||
return this._webview;
|
||||
}
|
||||
|
||||
private trackFocus() {
|
||||
private trackFocus(webview: WebviewEditorOverlay): void {
|
||||
this._webviewFocusTrackerDisposables.clear();
|
||||
|
||||
// Track focus in webview content
|
||||
const webviewContentFocusTracker = DOM.trackFocus(this._webviewContent!);
|
||||
const webviewContentFocusTracker = DOM.trackFocus(webview.container);
|
||||
this._webviewFocusTrackerDisposables.add(webviewContentFocusTracker);
|
||||
this._webviewFocusTrackerDisposables.add(webviewContentFocusTracker.onDidFocus(() => this._onDidFocusWebview.fire()));
|
||||
|
||||
// Track focus in webview element
|
||||
this._webviewFocusTrackerDisposables.add(this._webview!.onDidFocus(() => this._onDidFocusWebview.fire()));
|
||||
this._webviewFocusTrackerDisposables.add(webview.onDidFocus(() => this._onDidFocusWebview.fire()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,15 +4,11 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as dom from 'vs/base/browser/dom';
|
||||
import { memoize } from 'vs/base/common/decorators';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
import { DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { IEditorModel } from 'vs/platform/editor/common/editor';
|
||||
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
|
||||
import { EditorInput, EditorModel, GroupIdentifier, IEditorInput } from 'vs/workbench/common/editor';
|
||||
import { Webview, WebviewOptions } from 'vs/workbench/contrib/webview/common/webview';
|
||||
import { IWorkbenchLayoutService, Parts } from 'vs/workbench/services/layout/browser/layoutService';
|
||||
import { WebviewEvents, WebviewInputOptions } from './webviewEditorService';
|
||||
import { WebviewEditorOverlay } from 'vs/workbench/contrib/webview/common/webview';
|
||||
|
||||
class WebviewIconsManager {
|
||||
private readonly _icons = new Map<string, { light: URI, dark: URI }>();
|
||||
@@ -53,77 +49,38 @@ class WebviewIconsManager {
|
||||
}
|
||||
}
|
||||
|
||||
export class WebviewEditorInput<State = any> extends EditorInput {
|
||||
|
||||
private readonly iconsManager = new WebviewIconsManager();
|
||||
export class WebviewEditorInput extends EditorInput {
|
||||
|
||||
public static readonly typeId = 'workbench.editors.webviewInput';
|
||||
|
||||
private static readonly iconsManager = new WebviewIconsManager();
|
||||
|
||||
private _name: string;
|
||||
private _iconPath?: { light: URI, dark: URI };
|
||||
private _options: WebviewInputOptions;
|
||||
private _html: string = '';
|
||||
private _currentWebviewHtml: string = '';
|
||||
public _events: WebviewEvents | undefined;
|
||||
private _container?: HTMLElement;
|
||||
private _webview?: Webview;
|
||||
private _webviewOwner: any;
|
||||
private readonly _webviewDisposables = this._register(new DisposableStore());
|
||||
private _group?: GroupIdentifier;
|
||||
private _scrollYPercentage: number = 0;
|
||||
private _state: State;
|
||||
|
||||
public readonly extension?: {
|
||||
readonly location: URI;
|
||||
readonly id: ExtensionIdentifier;
|
||||
};
|
||||
|
||||
constructor(
|
||||
public readonly id: string,
|
||||
public readonly viewType: string,
|
||||
name: string,
|
||||
options: WebviewInputOptions,
|
||||
state: State,
|
||||
events: WebviewEvents,
|
||||
extension: undefined | {
|
||||
public readonly extension: undefined | {
|
||||
readonly location: URI;
|
||||
readonly id: ExtensionIdentifier;
|
||||
},
|
||||
@IWorkbenchLayoutService private readonly _layoutService: IWorkbenchLayoutService,
|
||||
public readonly webview: WebviewEditorOverlay,
|
||||
) {
|
||||
super();
|
||||
|
||||
this._name = name;
|
||||
this._options = options;
|
||||
this._events = events;
|
||||
this._state = state;
|
||||
this.extension = extension;
|
||||
|
||||
this._register(webview); // The input owns this webview
|
||||
}
|
||||
|
||||
public getTypeId(): string {
|
||||
return WebviewEditorInput.typeId;
|
||||
}
|
||||
|
||||
private readonly _onDidChangeIcon = this._register(new Emitter<void>());
|
||||
public readonly onDidChangeIcon = this._onDidChangeIcon.event;
|
||||
|
||||
public dispose() {
|
||||
this.disposeWebview();
|
||||
|
||||
if (this._container) {
|
||||
this._container.remove();
|
||||
this._container = undefined;
|
||||
}
|
||||
|
||||
if (this._events && this._events.onDispose) {
|
||||
this._events.onDispose();
|
||||
}
|
||||
this._events = undefined;
|
||||
|
||||
this._webview = undefined;
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
public getResource(): URI {
|
||||
return URI.from({
|
||||
scheme: 'webview-panel',
|
||||
@@ -154,7 +111,7 @@ export class WebviewEditorInput<State = any> extends EditorInput {
|
||||
|
||||
public set iconPath(value: { light: URI, dark: URI } | undefined) {
|
||||
this._iconPath = value;
|
||||
this.iconsManager.setIcons(this.id, value);
|
||||
WebviewEditorInput.iconsManager.setIcons(this.id, value);
|
||||
}
|
||||
|
||||
public matches(other: IEditorInput): boolean {
|
||||
@@ -165,145 +122,19 @@ export class WebviewEditorInput<State = any> extends EditorInput {
|
||||
return this._group;
|
||||
}
|
||||
|
||||
public get html(): string {
|
||||
return this._html;
|
||||
}
|
||||
|
||||
public set html(value: string) {
|
||||
if (value === this._currentWebviewHtml) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._html = value;
|
||||
|
||||
if (this._webview) {
|
||||
this._webview.html = value;
|
||||
this._currentWebviewHtml = value;
|
||||
}
|
||||
}
|
||||
|
||||
public get state(): State {
|
||||
return this._state;
|
||||
}
|
||||
|
||||
public set state(value: State) {
|
||||
this._state = value;
|
||||
}
|
||||
|
||||
public get options(): WebviewInputOptions {
|
||||
return this._options;
|
||||
}
|
||||
|
||||
public setOptions(value: WebviewOptions) {
|
||||
this._options = {
|
||||
...this._options,
|
||||
...value
|
||||
};
|
||||
|
||||
if (this._webview) {
|
||||
this._webview.options = {
|
||||
allowScripts: this._options.enableScripts,
|
||||
localResourceRoots: this._options.localResourceRoots,
|
||||
portMappings: this._options.portMapping,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public resolve(): Promise<IEditorModel> {
|
||||
return Promise.resolve(new EditorModel());
|
||||
public async resolve(): Promise<IEditorModel> {
|
||||
return new EditorModel();
|
||||
}
|
||||
|
||||
public supportsSplitEditor() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public get container(): HTMLElement {
|
||||
if (!this._container) {
|
||||
this._container = document.createElement('div');
|
||||
this._container.id = `webview-${this.id}`;
|
||||
const part = this._layoutService.getContainer(Parts.EDITOR_PART);
|
||||
part.appendChild(this._container);
|
||||
}
|
||||
return this._container;
|
||||
}
|
||||
|
||||
public get webview(): Webview | undefined {
|
||||
return this._webview;
|
||||
}
|
||||
|
||||
public set webview(value: Webview | undefined) {
|
||||
this._webviewDisposables.clear();
|
||||
|
||||
this._webview = value;
|
||||
if (!this._webview) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._webview.onDidClickLink(link => {
|
||||
if (this._events && this._events.onDidClickLink) {
|
||||
this._events.onDidClickLink(link, this._options);
|
||||
}
|
||||
}, null, this._webviewDisposables);
|
||||
|
||||
this._webview.onMessage(message => {
|
||||
if (this._events && this._events.onMessage) {
|
||||
this._events.onMessage(message);
|
||||
}
|
||||
}, null, this._webviewDisposables);
|
||||
|
||||
this._webview.onDidScroll(message => {
|
||||
this._scrollYPercentage = message.scrollYPercentage;
|
||||
}, null, this._webviewDisposables);
|
||||
|
||||
this._webview.onDidUpdateState(newState => {
|
||||
if (this._events && this._events.onDidUpdateWebviewState) {
|
||||
this._events.onDidUpdateWebviewState(newState);
|
||||
}
|
||||
}, null, this._webviewDisposables);
|
||||
}
|
||||
|
||||
public get scrollYPercentage() {
|
||||
return this._scrollYPercentage;
|
||||
}
|
||||
|
||||
public claimWebview(owner: any) {
|
||||
this._webviewOwner = owner;
|
||||
}
|
||||
|
||||
public releaseWebview(owner: any) {
|
||||
if (this._webviewOwner === owner) {
|
||||
this._webviewOwner = undefined;
|
||||
if (this._options.retainContextWhenHidden && this._container) {
|
||||
this._container.style.visibility = 'hidden';
|
||||
} else {
|
||||
this.disposeWebview();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public disposeWebview() {
|
||||
// The input owns the webview and its parent
|
||||
if (this._webview) {
|
||||
this._webview.dispose();
|
||||
this._webview = undefined;
|
||||
}
|
||||
|
||||
this._webviewDisposables.clear();
|
||||
this._webviewOwner = undefined;
|
||||
|
||||
if (this._container) {
|
||||
this._container.style.visibility = 'hidden';
|
||||
}
|
||||
|
||||
this._currentWebviewHtml = '';
|
||||
}
|
||||
|
||||
public updateGroup(group: GroupIdentifier): void {
|
||||
this._group = group;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export class RevivedWebviewEditorInput extends WebviewEditorInput {
|
||||
private _revived: boolean = false;
|
||||
|
||||
@@ -311,17 +142,14 @@ export class RevivedWebviewEditorInput extends WebviewEditorInput {
|
||||
id: string,
|
||||
viewType: string,
|
||||
name: string,
|
||||
options: WebviewInputOptions,
|
||||
state: any,
|
||||
events: WebviewEvents,
|
||||
extension: undefined | {
|
||||
readonly location: URI;
|
||||
readonly id: ExtensionIdentifier
|
||||
},
|
||||
private readonly reviver: (input: WebviewEditorInput) => Promise<void>,
|
||||
@IWorkbenchLayoutService partService: IWorkbenchLayoutService,
|
||||
webview: WebviewEditorOverlay,
|
||||
) {
|
||||
super(id, viewType, name, options, state, events, extension, partService);
|
||||
super(id, viewType, name, extension, webview);
|
||||
}
|
||||
|
||||
public async resolve(): Promise<IEditorModel> {
|
||||
|
||||
@@ -45,10 +45,10 @@ export class WebviewEditorInputFactory implements IEditorInputFactory {
|
||||
const data: SerializedWebview = {
|
||||
viewType: input.viewType,
|
||||
title: input.getName(),
|
||||
options: input.options,
|
||||
options: input.webview.options,
|
||||
extensionLocation: input.extension ? input.extension.location : undefined,
|
||||
extensionId: input.extension && input.extension.id ? input.extension.id.value : undefined,
|
||||
state: input.state,
|
||||
state: input.webview.state,
|
||||
iconPath: input.iconPath ? { light: input.iconPath.light, dark: input.iconPath.dark, } : undefined,
|
||||
group: input.group
|
||||
};
|
||||
@@ -68,12 +68,15 @@ export class WebviewEditorInputFactory implements IEditorInputFactory {
|
||||
const extensionLocation = reviveUri(data.extensionLocation);
|
||||
const extensionId = data.extensionId ? new ExtensionIdentifier(data.extensionId) : undefined;
|
||||
const iconPath = reviveIconPath(data.iconPath);
|
||||
return this._webviewService.reviveWebview(generateUuid(), data.viewType, data.title, iconPath, data.state, data.options, extensionLocation ? {
|
||||
const state = reviveState(data.state);
|
||||
|
||||
return this._webviewService.reviveWebview(generateUuid(), data.viewType, data.title, iconPath, state, data.options, extensionLocation ? {
|
||||
location: extensionLocation,
|
||||
id: extensionId
|
||||
} : undefined, data.group);
|
||||
}
|
||||
}
|
||||
|
||||
function reviveIconPath(data: SerializedIconPath | undefined) {
|
||||
if (!data) {
|
||||
return undefined;
|
||||
@@ -98,3 +101,21 @@ function reviveUri(data: string | UriComponents | undefined): URI | undefined {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function reviveState(state: unknown | undefined): undefined | string {
|
||||
if (!state) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (typeof state === 'string') {
|
||||
return state;
|
||||
}
|
||||
|
||||
// Likely an old style state. Unwrap to a simple state object
|
||||
// Remove after 1.37
|
||||
if ('state' in (state as any) && typeof (state as any).state === 'string') {
|
||||
return (state as any).state;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
@@ -7,13 +7,14 @@ import { equals } from 'vs/base/common/arrays';
|
||||
import { IDisposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { values } from 'vs/base/common/map';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { IWebviewOptions, IWebviewPanelOptions } from 'vs/editor/common/modes';
|
||||
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
|
||||
import { createDecorator, IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { GroupIdentifier } from 'vs/workbench/common/editor';
|
||||
import { IWebviewService, WebviewOptions, WebviewContentOptions } from 'vs/workbench/contrib/webview/common/webview';
|
||||
import { IEditorGroup, IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
|
||||
import { ACTIVE_GROUP_TYPE, IEditorService, SIDE_GROUP_TYPE } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { RevivedWebviewEditorInput, WebviewEditorInput } from './webviewEditorInput';
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
|
||||
export const IWebviewEditorService = createDecorator<IWebviewEditorService>('webviewEditorService');
|
||||
|
||||
@@ -35,7 +36,6 @@ export interface IWebviewEditorService {
|
||||
location: URI,
|
||||
id: ExtensionIdentifier
|
||||
},
|
||||
events: WebviewEvents
|
||||
): WebviewEditorInput;
|
||||
|
||||
reviveWebview(
|
||||
@@ -77,25 +77,20 @@ export interface WebviewReviver {
|
||||
): Promise<void>;
|
||||
}
|
||||
|
||||
export interface WebviewEvents {
|
||||
onMessage?(message: any): void;
|
||||
onDispose?(): void;
|
||||
onDidClickLink?(link: URI, options: IWebviewOptions): void;
|
||||
onDidUpdateWebviewState?(newState: any): void;
|
||||
}
|
||||
|
||||
export interface WebviewInputOptions extends IWebviewOptions, IWebviewPanelOptions {
|
||||
tryRestoreScrollPosition?: boolean;
|
||||
export interface WebviewInputOptions extends WebviewOptions, WebviewContentOptions {
|
||||
readonly tryRestoreScrollPosition?: boolean;
|
||||
readonly retainContextWhenHidden?: boolean;
|
||||
readonly enableCommandUris?: boolean;
|
||||
}
|
||||
|
||||
export function areWebviewInputOptionsEqual(a: WebviewInputOptions, b: WebviewInputOptions): boolean {
|
||||
return a.enableCommandUris === b.enableCommandUris
|
||||
&& a.enableFindWidget === b.enableFindWidget
|
||||
&& a.enableScripts === b.enableScripts
|
||||
&& a.allowScripts === b.allowScripts
|
||||
&& a.retainContextWhenHidden === b.retainContextWhenHidden
|
||||
&& a.tryRestoreScrollPosition === b.tryRestoreScrollPosition
|
||||
&& (a.localResourceRoots === b.localResourceRoots || (Array.isArray(a.localResourceRoots) && Array.isArray(b.localResourceRoots) && equals(a.localResourceRoots, b.localResourceRoots, (a, b) => a.toString() === b.toString())))
|
||||
&& (a.portMapping === b.portMapping || (Array.isArray(a.portMapping) && Array.isArray(b.portMapping) && equals(a.portMapping, b.portMapping, (a, b) => a.extensionHostPort === b.extensionHostPort && a.webviewPort === b.webviewPort)));
|
||||
&& (a.portMappings === b.portMappings || (Array.isArray(a.portMappings) && Array.isArray(b.portMappings) && equals(a.portMappings, b.portMappings, (a, b) => a.extensionHostPort === b.extensionHostPort && a.webviewPort === b.webviewPort)));
|
||||
}
|
||||
|
||||
function canRevive(reviver: WebviewReviver, webview: WebviewEditorInput): boolean {
|
||||
@@ -132,6 +127,8 @@ export class WebviewEditorService implements IWebviewEditorService {
|
||||
@IEditorService private readonly _editorService: IEditorService,
|
||||
@IInstantiationService private readonly _instantiationService: IInstantiationService,
|
||||
@IEditorGroupsService private readonly _editorGroupService: IEditorGroupsService,
|
||||
@IWebviewService private readonly _webviewService: IWebviewService,
|
||||
@IWorkspaceContextService private readonly _contextService: IWorkspaceContextService,
|
||||
) { }
|
||||
|
||||
public createWebview(
|
||||
@@ -139,14 +136,15 @@ export class WebviewEditorService implements IWebviewEditorService {
|
||||
viewType: string,
|
||||
title: string,
|
||||
showOptions: ICreateWebViewShowOptions,
|
||||
options: IWebviewOptions,
|
||||
options: WebviewInputOptions,
|
||||
extension: undefined | {
|
||||
location: URI,
|
||||
id: ExtensionIdentifier
|
||||
},
|
||||
events: WebviewEvents
|
||||
): WebviewEditorInput {
|
||||
const webviewInput = this._instantiationService.createInstance(WebviewEditorInput, id, viewType, title, options, {}, events, extension);
|
||||
const webview = this.createWebiew(id, extension, options);
|
||||
|
||||
const webviewInput = this._instantiationService.createInstance(WebviewEditorInput, id, viewType, title, extension, webview);
|
||||
this._editorService.openEditor(webviewInput, { pinned: true, preserveFocus: showOptions.preserveFocus }, showOptions.group);
|
||||
return webviewInput;
|
||||
}
|
||||
@@ -175,11 +173,14 @@ export class WebviewEditorService implements IWebviewEditorService {
|
||||
options: WebviewInputOptions,
|
||||
extension: undefined | {
|
||||
readonly location: URI,
|
||||
readonly id?: ExtensionIdentifier
|
||||
readonly id: ExtensionIdentifier
|
||||
},
|
||||
group: number | undefined,
|
||||
): WebviewEditorInput {
|
||||
const webviewInput = this._instantiationService.createInstance(RevivedWebviewEditorInput, id, viewType, title, options, state, {}, extension, async (webview: WebviewEditorInput): Promise<void> => {
|
||||
const webview = this.createWebiew(id, extension, options);
|
||||
webview.state = state;
|
||||
|
||||
const webviewInput = new RevivedWebviewEditorInput(id, viewType, title, extension, async (webview: WebviewEditorInput): Promise<void> => {
|
||||
const didRevive = await this.tryRevive(webview);
|
||||
if (didRevive) {
|
||||
return Promise.resolve(undefined);
|
||||
@@ -190,8 +191,10 @@ export class WebviewEditorService implements IWebviewEditorService {
|
||||
const promise = new Promise<void>(r => { resolve = r; });
|
||||
this._revivalPool.add(webview, resolve!);
|
||||
return promise;
|
||||
});
|
||||
}, webview);
|
||||
|
||||
webviewInput.iconPath = iconPath;
|
||||
|
||||
if (typeof group === 'number') {
|
||||
webviewInput.updateGroup(group);
|
||||
}
|
||||
@@ -213,7 +216,7 @@ export class WebviewEditorService implements IWebviewEditorService {
|
||||
webview: WebviewEditorInput
|
||||
): boolean {
|
||||
// Has no state, don't persist
|
||||
if (!webview.state) {
|
||||
if (!webview.webview.state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -237,4 +240,27 @@ export class WebviewEditorService implements IWebviewEditorService {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private createWebiew(id: string, extension: { location: URI; id: ExtensionIdentifier; } | undefined, options: WebviewInputOptions) {
|
||||
return this._webviewService.createWebviewEditorOverlay(id, {
|
||||
allowSvgs: true,
|
||||
extension: extension,
|
||||
enableFindWidget: options.enableFindWidget,
|
||||
retainContextWhenHidden: options.retainContextWhenHidden
|
||||
}, {
|
||||
...options,
|
||||
localResourceRoots: options.localResourceRoots || this.getDefaultLocalResourceRoots(extension),
|
||||
});
|
||||
}
|
||||
|
||||
private getDefaultLocalResourceRoots(extension: undefined | {
|
||||
location: URI,
|
||||
id: ExtensionIdentifier
|
||||
}): URI[] {
|
||||
const rootPaths = this._contextService.getWorkspace().folders.map(x => x.uri);
|
||||
if (extension) {
|
||||
rootPaths.push(extension.location);
|
||||
}
|
||||
return rootPaths;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ export class IFrameWebview extends Disposable implements Webview {
|
||||
}
|
||||
}
|
||||
|
||||
public set options(options: WebviewContentOptions) {
|
||||
public set contentOptions(options: WebviewContentOptions) {
|
||||
if (areWebviewInputOptionsEqual(options, this.content.options)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -3,9 +3,14 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { Disposable, DisposableStore, MutableDisposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IFrameWebview as WebviewElement } from 'vs/workbench/contrib/webview/browser/webviewElement';
|
||||
import { IWebviewService, WebviewOptions, WebviewContentOptions, Webview } from 'vs/workbench/contrib/webview/common/webview';
|
||||
import { IFrameWebview } from 'vs/workbench/contrib/webview/browser/webviewElement';
|
||||
import { IWebviewService, Webview, WebviewContentOptions, WebviewEditorOverlay, WebviewElement, WebviewOptions } from 'vs/workbench/contrib/webview/common/webview';
|
||||
import { IWorkbenchLayoutService, Parts } from 'vs/workbench/services/layout/browser/layoutService';
|
||||
import { memoize } from 'vs/base/common/decorators';
|
||||
|
||||
export class WebviewService implements IWebviewService {
|
||||
_serviceBrand: any;
|
||||
@@ -18,10 +23,178 @@ export class WebviewService implements IWebviewService {
|
||||
id: string,
|
||||
options: WebviewOptions,
|
||||
contentOptions: WebviewContentOptions
|
||||
): Webview {
|
||||
return this._instantiationService.createInstance(WebviewElement,
|
||||
id,
|
||||
options,
|
||||
contentOptions);
|
||||
): WebviewElement {
|
||||
return this._instantiationService.createInstance(IFrameWebview, id, options, contentOptions);
|
||||
}
|
||||
|
||||
createWebviewEditorOverlay(
|
||||
id: string,
|
||||
options: WebviewOptions,
|
||||
contentOptions: WebviewContentOptions,
|
||||
): WebviewEditorOverlay {
|
||||
return this._instantiationService.createInstance(DynamicWebviewEditorOverlay, id, options, contentOptions);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Webview editor overlay that creates and destroys the underlying webview as needed.
|
||||
*/
|
||||
class DynamicWebviewEditorOverlay extends Disposable implements WebviewEditorOverlay {
|
||||
|
||||
private readonly _pendingMessages = new Set<any>();
|
||||
private readonly _webview = this._register(new MutableDisposable<WebviewElement>());
|
||||
private readonly _webviewEvents = this._register(new DisposableStore());
|
||||
|
||||
private _html: string = '';
|
||||
private _initialScrollProgress: number = 0;
|
||||
private _state: string | undefined = undefined;
|
||||
private _owner: any = undefined;
|
||||
|
||||
public constructor(
|
||||
private readonly id: string,
|
||||
public readonly options: WebviewOptions,
|
||||
private _contentOptions: WebviewContentOptions,
|
||||
@IWorkbenchLayoutService private readonly _layoutService: IWorkbenchLayoutService,
|
||||
@IWebviewService private readonly _webviewService: IWebviewService,
|
||||
) {
|
||||
super();
|
||||
|
||||
this._register(toDisposable(() => this.container.remove()));
|
||||
}
|
||||
|
||||
@memoize
|
||||
public get container() {
|
||||
const container = document.createElement('div');
|
||||
container.id = `webview-${this.id}`;
|
||||
this._layoutService.getContainer(Parts.EDITOR_PART).appendChild(container);
|
||||
return container;
|
||||
}
|
||||
|
||||
public claim(owner: any) {
|
||||
this._owner = owner;
|
||||
this.show();
|
||||
}
|
||||
|
||||
public release(owner: any) {
|
||||
if (this._owner !== owner) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._owner = undefined;
|
||||
this.container.style.visibility = 'hidden';
|
||||
if (!this.options.retainContextWhenHidden) {
|
||||
this._webview.clear();
|
||||
this._webviewEvents.clear();
|
||||
}
|
||||
}
|
||||
|
||||
private show() {
|
||||
if (!this._webview.value) {
|
||||
const webview = this._webviewService.createWebview(this.id, this.options, this._contentOptions);
|
||||
this._webview.value = webview;
|
||||
webview.state = this._state;
|
||||
webview.html = this._html;
|
||||
|
||||
if (this.options.tryRestoreScrollPosition) {
|
||||
webview.initialScrollProgress = this._initialScrollProgress;
|
||||
}
|
||||
|
||||
this._webview.value.mountTo(this.container);
|
||||
|
||||
this._webviewEvents.clear();
|
||||
|
||||
webview.onDidFocus(() => {
|
||||
this._onDidFocus.fire();
|
||||
}, undefined, this._webviewEvents);
|
||||
|
||||
webview.onDidClickLink(x => {
|
||||
this._onDidClickLink.fire(x);
|
||||
}, undefined, this._webviewEvents);
|
||||
|
||||
webview.onDidScroll(x => {
|
||||
this._initialScrollProgress = x.scrollYPercentage;
|
||||
this._onDidScroll.fire(x);
|
||||
}, undefined, this._webviewEvents);
|
||||
|
||||
webview.onDidUpdateState(state => {
|
||||
this._state = state;
|
||||
this._onDidUpdateState.fire(state);
|
||||
}, undefined, this._webviewEvents);
|
||||
|
||||
webview.onMessage(x => {
|
||||
this._onMessage.fire(x);
|
||||
}, undefined, this._webviewEvents);
|
||||
|
||||
this._pendingMessages.forEach(msg => webview.sendMessage(msg));
|
||||
this._pendingMessages.clear();
|
||||
}
|
||||
this.container.style.visibility = 'visible';
|
||||
}
|
||||
|
||||
public get html(): string { return this._html; }
|
||||
public set html(value: string) {
|
||||
this._html = value;
|
||||
this.withWebview(webview => webview.html = value);
|
||||
}
|
||||
|
||||
public get initialScrollProgress(): number { return this._initialScrollProgress; }
|
||||
public set initialScrollProgress(value: number) {
|
||||
this._initialScrollProgress = value;
|
||||
this.withWebview(webview => webview.initialScrollProgress = value);
|
||||
}
|
||||
|
||||
public get state(): string | undefined { return this._state; }
|
||||
public set state(value: string | undefined) {
|
||||
this._state = value;
|
||||
this.withWebview(webview => webview.state = value);
|
||||
}
|
||||
|
||||
public get contentOptions(): WebviewContentOptions { return this._contentOptions; }
|
||||
public set contentOptions(value: WebviewContentOptions) {
|
||||
this._contentOptions = value;
|
||||
this.withWebview(webview => webview.contentOptions = value);
|
||||
}
|
||||
|
||||
private readonly _onDidFocus = this._register(new Emitter<void>());
|
||||
public readonly onDidFocus: Event<void> = this._onDidFocus.event;
|
||||
|
||||
private readonly _onDidClickLink = this._register(new Emitter<URI>());
|
||||
public readonly onDidClickLink: Event<URI> = this._onDidClickLink.event;
|
||||
|
||||
private readonly _onDidScroll = this._register(new Emitter<{ scrollYPercentage: number; }>());
|
||||
public readonly onDidScroll: Event<{ scrollYPercentage: number; }> = this._onDidScroll.event;
|
||||
|
||||
private readonly _onDidUpdateState = this._register(new Emitter<string | undefined>());
|
||||
public readonly onDidUpdateState: Event<string | undefined> = this._onDidUpdateState.event;
|
||||
|
||||
private readonly _onMessage = this._register(new Emitter<any>());
|
||||
public readonly onMessage: Event<any> = this._onMessage.event;
|
||||
|
||||
sendMessage(data: any): void {
|
||||
if (this._webview.value) {
|
||||
this._webview.value.sendMessage(data);
|
||||
} else {
|
||||
this._pendingMessages.add(data);
|
||||
}
|
||||
}
|
||||
|
||||
update(html: string, options: WebviewContentOptions, retainContextWhenHidden: boolean): void {
|
||||
this._contentOptions = options;
|
||||
this._html = html;
|
||||
this.withWebview(webview => {
|
||||
webview.update(html, options, retainContextWhenHidden);
|
||||
});
|
||||
}
|
||||
|
||||
layout(): void { this.withWebview(webview => webview.layout()); }
|
||||
focus(): void { this.withWebview(webview => webview.focus()); }
|
||||
reload(): void { this.withWebview(webview => webview.reload()); }
|
||||
showFind(): void { this.withWebview(webview => webview.showFind()); }
|
||||
hideFind(): void { this.withWebview(webview => webview.hideFind()); }
|
||||
|
||||
private withWebview(f: (webview: Webview) => void): void {
|
||||
if (this._webview.value) {
|
||||
f(this._webview.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,10 +7,10 @@ import { Event } from 'vs/base/common/event';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import * as modes from 'vs/editor/common/modes';
|
||||
import * as nls from 'vs/nls';
|
||||
import { RawContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import * as nls from 'vs/nls';
|
||||
|
||||
/**
|
||||
* Set when the find widget in a webview is visible.
|
||||
@@ -29,7 +29,13 @@ export interface IWebviewService {
|
||||
id: string,
|
||||
options: WebviewOptions,
|
||||
contentOptions: WebviewContentOptions,
|
||||
): Webview;
|
||||
): WebviewElement;
|
||||
|
||||
createWebviewEditorOverlay(
|
||||
id: string,
|
||||
options: WebviewOptions,
|
||||
contentOptions: WebviewContentOptions,
|
||||
): WebviewEditorOverlay;
|
||||
}
|
||||
|
||||
export const WebviewResourceScheme = 'vscode-resource';
|
||||
@@ -41,6 +47,8 @@ export interface WebviewOptions {
|
||||
readonly id?: ExtensionIdentifier;
|
||||
};
|
||||
readonly enableFindWidget?: boolean;
|
||||
readonly tryRestoreScrollPosition?: boolean;
|
||||
readonly retainContextWhenHidden?: boolean;
|
||||
}
|
||||
|
||||
export interface WebviewContentOptions {
|
||||
@@ -48,12 +56,13 @@ export interface WebviewContentOptions {
|
||||
readonly svgWhiteList?: string[];
|
||||
readonly localResourceRoots?: ReadonlyArray<URI>;
|
||||
readonly portMappings?: ReadonlyArray<modes.IWebviewPortMapping>;
|
||||
readonly enableCommandUris?: boolean;
|
||||
}
|
||||
|
||||
export interface Webview extends IDisposable {
|
||||
|
||||
html: string;
|
||||
options: WebviewContentOptions;
|
||||
contentOptions: WebviewContentOptions;
|
||||
initialScrollProgress: number;
|
||||
state: string | undefined;
|
||||
|
||||
@@ -65,13 +74,12 @@ export interface Webview extends IDisposable {
|
||||
|
||||
sendMessage(data: any): void;
|
||||
update(
|
||||
value: string,
|
||||
html: string,
|
||||
options: WebviewContentOptions,
|
||||
retainContextWhenHidden: boolean
|
||||
): void;
|
||||
|
||||
layout(): void;
|
||||
mountTo(parent: HTMLElement): void;
|
||||
focus(): void;
|
||||
reload(): void;
|
||||
|
||||
@@ -79,4 +87,16 @@ export interface Webview extends IDisposable {
|
||||
hideFind(): void;
|
||||
}
|
||||
|
||||
export interface WebviewElement extends Webview {
|
||||
mountTo(parent: HTMLElement): void;
|
||||
}
|
||||
|
||||
export interface WebviewEditorOverlay extends Webview {
|
||||
readonly container: HTMLElement;
|
||||
readonly options: WebviewOptions;
|
||||
|
||||
claim(owner: any): void;
|
||||
release(owner: any): void;
|
||||
}
|
||||
|
||||
export const webviewDeveloperCategory = nls.localize('developer', "Developer");
|
||||
|
||||
@@ -8,7 +8,7 @@ import * as nls from 'vs/nls';
|
||||
import { Command, ServicesAccessor } from 'vs/editor/browser/editorExtensions';
|
||||
import { WebviewEditor } from 'vs/workbench/contrib/webview/browser/webviewEditor';
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { WebviewElement } from 'vs/workbench/contrib/webview/electron-browser/webviewElement';
|
||||
import { ElectronWebviewBasedWebview } from 'vs/workbench/contrib/webview/electron-browser/webviewElement';
|
||||
|
||||
export class OpenWebviewDeveloperToolsAction extends Action {
|
||||
static readonly ID = 'workbench.action.webview.openDeveloperTools';
|
||||
@@ -86,11 +86,11 @@ function getActiveWebviewEditor(accessor: ServicesAccessor): WebviewEditor | und
|
||||
return activeControl.isWebviewEditor ? activeControl : undefined;
|
||||
}
|
||||
|
||||
function withActiveWebviewBasedWebview(accessor: ServicesAccessor, f: (webview: WebviewElement) => void): void {
|
||||
function withActiveWebviewBasedWebview(accessor: ServicesAccessor, f: (webview: ElectronWebviewBasedWebview) => void): void {
|
||||
const webViewEditor = getActiveWebviewEditor(accessor);
|
||||
if (webViewEditor) {
|
||||
webViewEditor.withWebview(webview => {
|
||||
if (webview instanceof WebviewElement) {
|
||||
if (webview instanceof ElectronWebviewBasedWebview) {
|
||||
f(webview);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -13,7 +13,6 @@ import { endsWith } from 'vs/base/common/strings';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import * as modes from 'vs/editor/common/modes';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
|
||||
import { IFileService } from 'vs/platform/files/common/files';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { ITunnelService } from 'vs/platform/remote/common/tunnel';
|
||||
@@ -25,27 +24,6 @@ import { registerFileProtocol } from 'vs/workbench/contrib/webview/electron-brow
|
||||
import { areWebviewInputOptionsEqual } from '../browser/webviewEditorService';
|
||||
import { WebviewFindWidget } from '../browser/webviewFindWidget';
|
||||
|
||||
export interface WebviewPortMapping {
|
||||
readonly port: number;
|
||||
readonly resolvedPort: number;
|
||||
}
|
||||
|
||||
export interface WebviewOptions {
|
||||
readonly allowSvgs?: boolean;
|
||||
readonly extension?: {
|
||||
readonly location: URI;
|
||||
readonly id?: ExtensionIdentifier;
|
||||
};
|
||||
readonly enableFindWidget?: boolean;
|
||||
}
|
||||
|
||||
export interface WebviewContentOptions {
|
||||
readonly allowScripts?: boolean;
|
||||
readonly svgWhiteList?: string[];
|
||||
readonly localResourceRoots?: ReadonlyArray<URI>;
|
||||
readonly portMappings?: ReadonlyArray<WebviewPortMapping>;
|
||||
}
|
||||
|
||||
interface IKeydownEvent {
|
||||
key: string;
|
||||
keyCode: number;
|
||||
@@ -285,7 +263,7 @@ interface WebviewContent {
|
||||
readonly state: string | undefined;
|
||||
}
|
||||
|
||||
export class WebviewElement extends Disposable implements Webview {
|
||||
export class ElectronWebviewBasedWebview extends Disposable implements Webview {
|
||||
private _webview: Electron.WebviewTag | undefined;
|
||||
private _ready: Promise<void>;
|
||||
|
||||
@@ -508,7 +486,7 @@ export class WebviewElement extends Disposable implements Webview {
|
||||
};
|
||||
}
|
||||
|
||||
public set options(options: WebviewContentOptions) {
|
||||
public set contentOptions(options: WebviewContentOptions) {
|
||||
if (areWebviewInputOptionsEqual(options, this.content.options)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -4,23 +4,24 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IWebviewService, Webview, WebviewContentOptions, WebviewOptions } from 'vs/workbench/contrib/webview/common/webview';
|
||||
import { WebviewElement } from 'vs/workbench/contrib/webview/electron-browser/webviewElement';
|
||||
import { WebviewService as BrowserWebviewService } from 'vs/workbench/contrib/webview/browser/webviewService';
|
||||
import { IWebviewService, WebviewContentOptions, WebviewElement, WebviewOptions } from 'vs/workbench/contrib/webview/common/webview';
|
||||
import { ElectronWebviewBasedWebview } from 'vs/workbench/contrib/webview/electron-browser/webviewElement';
|
||||
|
||||
export class WebviewService implements IWebviewService {
|
||||
export class WebviewService extends BrowserWebviewService implements IWebviewService {
|
||||
_serviceBrand: any;
|
||||
|
||||
constructor(
|
||||
@IInstantiationService private readonly _instantiationService: IInstantiationService,
|
||||
) { }
|
||||
@IInstantiationService private readonly instantiationService: IInstantiationService,
|
||||
) {
|
||||
super(instantiationService);
|
||||
}
|
||||
|
||||
createWebview(
|
||||
_id: string,
|
||||
options: WebviewOptions,
|
||||
contentOptions: WebviewContentOptions
|
||||
): Webview {
|
||||
return this._instantiationService.createInstance(WebviewElement,
|
||||
options,
|
||||
contentOptions);
|
||||
): WebviewElement {
|
||||
return this.instantiationService.createInstance(ElectronWebviewBasedWebview, options, contentOptions);
|
||||
}
|
||||
}
|
||||
@@ -110,12 +110,14 @@ export class TelemetryOptOut implements IWorkbenchContribution {
|
||||
}
|
||||
|
||||
const logTelemetry = (optout?: boolean) => {
|
||||
/* __GDPR__
|
||||
"experiments:optout" : {
|
||||
"optOut": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }
|
||||
}
|
||||
*/
|
||||
this.telemetryService.publicLog('experiments:optout', typeof optout === 'boolean' ? { optout } : {});
|
||||
type ExperimentsOptOutClassification = {
|
||||
optout?: { classification: 'SystemMetaData', purpose: 'FeatureInsight', isMeasurement: true };
|
||||
};
|
||||
|
||||
type ExperimentsOptOutEvent = {
|
||||
optout?: boolean;
|
||||
};
|
||||
this.telemetryService.publicLog2<ExperimentsOptOutEvent, ExperimentsOptOutClassification>('experiments:optout', typeof optout === 'boolean' ? { optout } : {});
|
||||
};
|
||||
|
||||
queryPromise.then(() => {
|
||||
|
||||
@@ -22,9 +22,9 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { IBackupFileService } from 'vs/workbench/services/backup/common/backup';
|
||||
import { getInstalledExtensions, IExtensionStatus, onExtensionChanged, isKeymapExtension } from 'vs/workbench/contrib/extensions/common/extensionsUtils';
|
||||
import { IExtensionEnablementService, IExtensionManagementService, IExtensionGalleryService, IExtensionTipsService, EnablementState, ILocalExtension } from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
// {{SQL CARBON EDIT}} - Redirect to ADS welcome page
|
||||
import { used } from 'sql/workbench/contrib/welcome/page/browser/az_data_welcome_page';
|
||||
import { IExtensionManagementService, IExtensionGalleryService, ILocalExtension } from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { IExtensionEnablementService, EnablementState, IExtensionTipsService } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
|
||||
import { used } from 'sql/workbench/contrib/welcome/page/browser/az_data_welcome_page'; // {{SQL CARBON EDIT}} - Redirect to ADS welcome page
|
||||
import { ILifecycleService, StartupKind } from 'vs/platform/lifecycle/common/lifecycle';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { splitName } from 'vs/base/common/labels';
|
||||
@@ -459,7 +459,7 @@ class WelcomePage extends Disposable {
|
||||
.then(installed => {
|
||||
const local = installed.filter(i => areSameExtensions(extension.identifier, i.identifier))[0];
|
||||
// TODO: Do this as part of the install to avoid multiple events.
|
||||
return this.extensionEnablementService.setEnablement([local], EnablementState.Disabled).then(() => local);
|
||||
return this.extensionEnablementService.setEnablement([local], EnablementState.DisabledGlobally).then(() => local);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -474,12 +474,12 @@ class WelcomePage extends Disposable {
|
||||
this.notificationService.info(strings.installing.replace('{0}', extensionSuggestion.name));
|
||||
}, 300);
|
||||
const extensionsToDisable = extensions.filter(extension => isKeymapExtension(this.tipsService, extension) && extension.globallyEnabled).map(extension => extension.local);
|
||||
extensionsToDisable.length ? this.extensionEnablementService.setEnablement(extensionsToDisable, EnablementState.Disabled) : Promise.resolve()
|
||||
extensionsToDisable.length ? this.extensionEnablementService.setEnablement(extensionsToDisable, EnablementState.DisabledGlobally) : Promise.resolve()
|
||||
.then(() => {
|
||||
return foundAndInstalled.then(foundExtension => {
|
||||
messageDelay.cancel();
|
||||
if (foundExtension) {
|
||||
return this.extensionEnablementService.setEnablement([foundExtension], EnablementState.Enabled)
|
||||
return this.extensionEnablementService.setEnablement([foundExtension], EnablementState.EnabledGlobally)
|
||||
.then(() => {
|
||||
/* __GDPR__FRAGMENT__
|
||||
"WelcomePageInstalled-2" : {
|
||||
|
||||
@@ -356,43 +356,33 @@ export class WalkThroughPart extends BaseEditor {
|
||||
}
|
||||
}));
|
||||
|
||||
type WalkThroughSnippetInteractionClassification = {
|
||||
from?: { classification: 'SystemMetaData', purpose: 'FeatureInsight' };
|
||||
type: { classification: 'SystemMetaData', purpose: 'FeatureInsight' };
|
||||
snippet: { classification: 'SystemMetaData', purpose: 'FeatureInsight', isMeasurement: true };
|
||||
};
|
||||
type WalkThroughSnippetInteractionEvent = {
|
||||
from?: string,
|
||||
type: string,
|
||||
snippet: number
|
||||
};
|
||||
|
||||
this.contentDisposables.push(Event.once(editor.onMouseDown)(() => {
|
||||
/* __GDPR__
|
||||
"walkThroughSnippetInteraction" : {
|
||||
"from" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
|
||||
"type": { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
|
||||
"snippet": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }
|
||||
}
|
||||
*/
|
||||
this.telemetryService.publicLog('walkThroughSnippetInteraction', {
|
||||
this.telemetryService.publicLog2<WalkThroughSnippetInteractionEvent, WalkThroughSnippetInteractionClassification>('walkThroughSnippetInteraction', {
|
||||
from: this.input instanceof WalkThroughInput ? this.input.getTelemetryFrom() : undefined,
|
||||
type: 'mouseDown',
|
||||
snippet: i
|
||||
});
|
||||
}));
|
||||
this.contentDisposables.push(Event.once(editor.onKeyDown)(() => {
|
||||
/* __GDPR__
|
||||
"walkThroughSnippetInteraction" : {
|
||||
"from" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
|
||||
"type": { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
|
||||
"snippet": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }
|
||||
}
|
||||
*/
|
||||
this.telemetryService.publicLog('walkThroughSnippetInteraction', {
|
||||
this.telemetryService.publicLog2<WalkThroughSnippetInteractionEvent, WalkThroughSnippetInteractionClassification>('walkThroughSnippetInteraction', {
|
||||
from: this.input instanceof WalkThroughInput ? this.input.getTelemetryFrom() : undefined,
|
||||
type: 'keyDown',
|
||||
snippet: i
|
||||
});
|
||||
}));
|
||||
this.contentDisposables.push(Event.once(editor.onDidChangeModelContent)(() => {
|
||||
/* __GDPR__
|
||||
"walkThroughSnippetInteraction" : {
|
||||
"from" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
|
||||
"type": { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
|
||||
"snippet": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }
|
||||
}
|
||||
*/
|
||||
this.telemetryService.publicLog('walkThroughSnippetInteraction', {
|
||||
this.telemetryService.publicLog2<WalkThroughSnippetInteractionEvent, WalkThroughSnippetInteractionClassification>('walkThroughSnippetInteraction', {
|
||||
from: this.input instanceof WalkThroughInput ? this.input.getTelemetryFrom() : undefined,
|
||||
type: 'changeModelContent',
|
||||
snippet: i
|
||||
|
||||
Reference in New Issue
Block a user