Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port UI #85603

Merged
merged 7 commits into from
Nov 28, 2019
Merged

Port UI #85603

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/vs/platform/actions/common/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ export const enum MenuId {
StatusBarWindowIndicatorMenu,
TouchBarContext,
TitleBarContext,
TunnelContext,
TunnelInline,
TunnelTitle,
ViewItemContext,
ViewTitle,
CommentThreadTitle,
Expand Down
8 changes: 6 additions & 2 deletions src/vs/platform/remote/common/tunnel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,26 @@

import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { URI } from 'vs/base/common/uri';
import { Event } from 'vs/base/common/event';

export const ITunnelService = createDecorator<ITunnelService>('tunnelService');

export interface RemoteTunnel {
readonly tunnelRemotePort: number;
readonly tunnelLocalPort: number;

readonly localAddress?: URI;
dispose(): void;
}

export interface ITunnelService {
_serviceBrand: undefined;

readonly tunnels: Promise<readonly RemoteTunnel[]>;
readonly onTunnelOpened: Event<RemoteTunnel>;
readonly onTunnelClosed: Event<number>;

openTunnel(remotePort: number): Promise<RemoteTunnel> | undefined;
openTunnel(remotePort: number, localPort?: number): Promise<RemoteTunnel> | undefined;
closeTunnel(remotePort: number): Promise<void>;
}

export function extractLocalHostUriMetaDataForPortMapping(uri: URI): { address: string, port: number } | undefined {
Expand Down
8 changes: 7 additions & 1 deletion src/vs/platform/remote/common/tunnelService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@
*--------------------------------------------------------------------------------------------*/

import { ITunnelService, RemoteTunnel } from 'vs/platform/remote/common/tunnel';
import { Event, Emitter } from 'vs/base/common/event';

export class NoOpTunnelService implements ITunnelService {
_serviceBrand: undefined;

public readonly tunnels: Promise<readonly RemoteTunnel[]> = Promise.resolve([]);

private _onTunnelOpened: Emitter<RemoteTunnel> = new Emitter();
public onTunnelOpened: Event<RemoteTunnel> = this._onTunnelOpened.event;
private _onTunnelClosed: Emitter<number> = new Emitter();
public onTunnelClosed: Event<number> = this._onTunnelClosed.event;
openTunnel(_remotePort: number): Promise<RemoteTunnel> | undefined {
return undefined;
}
async closeTunnel(_remotePort: number): Promise<void> {
}
}
12 changes: 12 additions & 0 deletions src/vs/workbench/contrib/remote/browser/media/tunnelView.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

.customview-tree .tunnel-view-label {
flex: 1;
}

.customview-tree .tunnel-view-label .action-label.codicon {
margin-top: 4px;
}
18 changes: 17 additions & 1 deletion src/vs/workbench/contrib/remote/browser/remote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ import { isStringArray } from 'vs/base/common/types';
import { IRemoteExplorerService, HelpInformation } from 'vs/workbench/services/remote/common/remoteExplorerService';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { startsWith } from 'vs/base/common/strings';
import { TunnelPanelDescriptor, TunnelViewModel } from 'vs/workbench/contrib/remote/browser/tunnelView';
import { IAddedViewDescriptorRef } from 'vs/workbench/browser/parts/views/views';
import { ViewletPane } from 'vs/workbench/browser/parts/views/paneViewlet';

class HelpModel {
items: IHelpItem[] | undefined;
Expand Down Expand Up @@ -263,6 +266,7 @@ class HelpAction extends Action {

export class RemoteViewlet extends FilterViewContainerViewlet {
private actions: IAction[] | undefined;
private tunnelPanelDescriptor: TunnelPanelDescriptor | undefined;

constructor(
@IWorkbenchLayoutService layoutService: IWorkbenchLayoutService,
Expand All @@ -274,7 +278,8 @@ export class RemoteViewlet extends FilterViewContainerViewlet {
@IThemeService themeService: IThemeService,
@IContextMenuService contextMenuService: IContextMenuService,
@IExtensionService extensionService: IExtensionService,
@IRemoteExplorerService remoteExplorerService: IRemoteExplorerService
@IRemoteExplorerService private readonly remoteExplorerService: IRemoteExplorerService,
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService,
) {
super(VIEWLET_ID, remoteExplorerService.onDidChangeTargetType, configurationService, layoutService, telemetryService, storageService, instantiationService, themeService, contextMenuService, extensionService, contextService);
}
Expand Down Expand Up @@ -308,6 +313,17 @@ export class RemoteViewlet extends FilterViewContainerViewlet {
const title = nls.localize('remote.explorer', "Remote Explorer");
return title;
}

onDidAddViews(added: IAddedViewDescriptorRef[]): ViewletPane[] {
// Call to super MUST be first, since registering the additional view will cause this to be called again.
const panels: ViewletPane[] = super.onDidAddViews(added);
if (this.environmentService.configuration.remoteAuthority && !this.tunnelPanelDescriptor && this.configurationService.getValue<boolean>('remote.forwardedPortsView.visible')) {
this.tunnelPanelDescriptor = new TunnelPanelDescriptor(new TunnelViewModel(this.remoteExplorerService), this.environmentService);
const viewsRegistry = Registry.as<IViewsRegistry>(Extensions.ViewsRegistry);
viewsRegistry.registerViews([this.tunnelPanelDescriptor!], VIEW_CONTAINER);
}
return panels;
}
}

Registry.as<ViewletRegistry>(ViewletExtensions.Viewlets).registerViewlet(ViewletDescriptor.create(
Expand Down
Loading