allow icon and contextualtitle on views from exts

This commit is contained in:
SteVen Batten 2020-05-11 16:43:55 -07:00
parent fedd448714
commit 6b4258e724

View file

@ -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 = <ICustomViewDescriptor>{
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;