diff --git a/src/vs/workbench/api/browser/viewsExtensionPoint.ts b/src/vs/workbench/api/browser/viewsExtensionPoint.ts index e6621fc362c..06e521040c9 100644 --- a/src/vs/workbench/api/browser/viewsExtensionPoint.ts +++ b/src/vs/workbench/api/browser/viewsExtensionPoint.ts @@ -80,7 +80,10 @@ interface IUserFriendlyViewDescriptor { id: string; name: string; when?: string; + + // From 'remoteViewDescriptor' type group?: string; + remoteAuthority?: string; } const viewDescriptor: IJSONSchema = { @@ -101,7 +104,7 @@ const viewDescriptor: IJSONSchema = { } }; -const nestableViewDescriptor: IJSONSchema = { +const remoteViewDescriptor: IJSONSchema = { type: 'object', properties: { id: { @@ -119,6 +122,10 @@ const nestableViewDescriptor: IJSONSchema = { group: { description: localize('vscode.extension.contributes.view.group', 'Nested group in the viewlet'), type: 'string' + }, + remoteAuthority: { + description: localize('vscode.extension.contributes.view.remoteAuthority', 'The remote authority associated with this view'), + type: 'string' } } }; @@ -153,7 +160,7 @@ const viewsContribution: IJSONSchema = { 'remote': { description: localize('views.remote', "Contributes views to Remote container in the Activity bar. To contribute to this container, enableProposedApi needs to be turned on"), type: 'array', - items: nestableViewDescriptor, + items: remoteViewDescriptor, default: [] } }, @@ -427,7 +434,8 @@ class ViewsExtensionHandler implements IWorkbenchContribution { order: order, extensionId: extension.description.identifier, originalContainerId: entry.key, - group: item.group + group: item.group, + remoteAuthority: item.remoteAuthority }; viewIds.push(viewDescriptor.id); diff --git a/src/vs/workbench/browser/parts/views/viewsViewlet.ts b/src/vs/workbench/browser/parts/views/viewsViewlet.ts index 6413ac3173f..76d8302ca88 100644 --- a/src/vs/workbench/browser/parts/views/viewsViewlet.ts +++ b/src/vs/workbench/browser/parts/views/viewsViewlet.ts @@ -132,7 +132,7 @@ export abstract class ViewContainerViewlet extends PanelViewlet implements IView if (!view) { this.toggleViewVisibility(id); } - view = this.getView(id); + view = this.getView(id)!; view.setExpanded(true); if (focus) { view.focus(); @@ -185,7 +185,7 @@ export abstract class ViewContainerViewlet extends PanelViewlet implements IView return (this.instantiationService as any).createInstance(viewDescriptor.ctorDescriptor.ctor, ...(viewDescriptor.ctorDescriptor.arguments || []), options) as ViewletPanel; } - protected getView(id: string): ViewletPanel { + protected getView(id: string): ViewletPanel | undefined { return this.panels.filter(view => view.id === id)[0]; } diff --git a/src/vs/workbench/common/views.ts b/src/vs/workbench/common/views.ts index c0fc9afa809..a93bb3aca6c 100644 --- a/src/vs/workbench/common/views.ts +++ b/src/vs/workbench/common/views.ts @@ -130,8 +130,6 @@ export interface IViewDescriptor { readonly when?: ContextKeyExpr; - readonly group?: string; - readonly order?: number; readonly weight?: number; @@ -146,6 +144,11 @@ export interface IViewDescriptor { readonly workspace?: boolean; readonly focusCommand?: { id: string, keybindings?: IKeybindings }; + + // For contributed remote explorer views + readonly group?: string; + + readonly remoteAuthority?: string; } export interface IViewDescriptorCollection extends IDisposable { diff --git a/src/vs/workbench/contrib/remote/browser/remote.ts b/src/vs/workbench/contrib/remote/browser/remote.ts index 1abc5d22b22..0002bb19824 100644 --- a/src/vs/workbench/contrib/remote/browser/remote.ts +++ b/src/vs/workbench/contrib/remote/browser/remote.ts @@ -47,6 +47,7 @@ import Severity from 'vs/base/common/severity'; import { ReloadWindowAction } from 'vs/workbench/browser/actions/windowActions'; import { IDisposable } from 'vs/base/common/lifecycle'; import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle'; +import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; interface HelpInformation { extensionDescription: IExtensionDescription; @@ -378,7 +379,8 @@ export class RemoteViewlet extends ViewContainerViewlet implements IViewModel { @IInstantiationService instantiationService: IInstantiationService, @IThemeService themeService: IThemeService, @IContextMenuService contextMenuService: IContextMenuService, - @IExtensionService extensionService: IExtensionService + @IExtensionService extensionService: IExtensionService, + @IWorkbenchEnvironmentService private environmentService: IWorkbenchEnvironmentService, ) { super(VIEWLET_ID, `${VIEWLET_ID}.state`, true, configurationService, layoutService, telemetryService, storageService, instantiationService, themeService, contextMenuService, extensionService, contextService); @@ -419,7 +421,29 @@ export class RemoteViewlet extends ViewContainerViewlet implements IViewModel { onDidAddViews(added: IAddedViewDescriptorRef[]): ViewletPanel[] { // too late, already added to the view model - return super.onDidAddViews(added); + const result = super.onDidAddViews(added); + + const remoteAuthority = this.environmentService.configuration.remoteAuthority; + if (remoteAuthority) { + const actualRemoteAuthority = remoteAuthority.split('+')[0]; + added.forEach((descriptor) => { + const panel = this.getView(descriptor.viewDescriptor.id); + if (!panel) { + return; + } + + if (typeof descriptor.viewDescriptor.remoteAuthority === 'undefined' || + descriptor.viewDescriptor.remoteAuthority === actualRemoteAuthority || + descriptor.viewDescriptor.id === HelpPanel.ID + ) { + panel.setExpanded(true); + } else { + panel.setExpanded(false); + } + }); + } + + return result; } getTitle(): string {