From 6b4258e72491d474ced673085ff8693307fd8a79 Mon Sep 17 00:00:00 2001 From: SteVen Batten Date: Mon, 11 May 2020 16:43:55 -0700 Subject: [PATCH] allow icon and contextualtitle on views from exts --- .../api/browser/viewsExtensionPoint.ts | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/vs/workbench/api/browser/viewsExtensionPoint.ts b/src/vs/workbench/api/browser/viewsExtensionPoint.ts index ce84fd5028b..df17b498274 100644 --- a/src/vs/workbench/api/browser/viewsExtensionPoint.ts +++ b/src/vs/workbench/api/browser/viewsExtensionPoint.ts @@ -80,6 +80,9 @@ interface IUserFriendlyViewDescriptor { name: string; when?: string; + icon?: string; + contextualTitle?: string; + // From 'remoteViewDescriptor' type group?: string; remoteName?: string | string[]; @@ -100,6 +103,14 @@ const viewDescriptor: IJSONSchema = { description: localize('vscode.extension.contributes.view.when', 'Condition which must be true to show this view'), type: 'string' }, + icon: { + description: localize('vscode.extension.contributes.view.icon', "Path to the view icon. View icons are displayed when the name of the view cannot be shown. It is recommended that icons be in SVG, though any image file type is accepted."), + type: 'string' + }, + contextualTitle: { + description: localize('vscode.extension.contributes.view.contextualTitle', "Human-readable context for when the view is moved out of its original location. By default, the view's container name will be used. Will be shown"), + type: 'string' + }, } }; @@ -406,13 +417,14 @@ class ViewsExtensionHandler implements IWorkbenchContribution { ? container.viewOrderDelegate.getOrder(item.group) : undefined; + const icon = item.icon ? resources.joinPath(extension.description.extensionLocation, item.icon) : undefined; const viewDescriptor = { id: item.id, name: item.name, ctorDescriptor: new SyncDescriptor(TreeViewPane), when: ContextKeyExpr.deserialize(item.when), - containerIcon: viewContainer?.icon, - containerTitle: viewContainer?.name, + containerIcon: icon || viewContainer?.icon, + containerTitle: item.contextualTitle || viewContainer?.name, canToggleVisibility: true, canMoveView: true, treeView: this.instantiationService.createInstance(CustomTreeView, item.id, item.name), @@ -469,6 +481,14 @@ class ViewsExtensionHandler implements IWorkbenchContribution { collector.error(localize('optstring', "property `{0}` can be omitted or must be of type `string`", 'when')); return false; } + if (descriptor.icon && typeof descriptor.icon !== 'string') { + collector.error(localize('optstring', "property `{0}` can be omitted or must be of type `string`", 'icon')); + return false; + } + if (descriptor.contextualTitle && typeof descriptor.contextualTitle !== 'string') { + collector.error(localize('optstring', "property `{0}` can be omitted or must be of type `string`", 'contextualTitle')); + return false; + } } return true;