Skip to content

Commit

Permalink
Show full url of ports when in panel
Browse files Browse the repository at this point in the history
Fixes #111378
  • Loading branch information
alexr00 committed Feb 11, 2021
1 parent ea048b8 commit c514299
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
29 changes: 20 additions & 9 deletions src/vs/workbench/contrib/remote/browser/tunnelView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export class TunnelViewModel extends Disposable implements ITunnelViewModel {
this._register(this.model.onCandidatesChanged(() => this._onForwardedPortsChanged.fire()));
this._input = {
label: nls.localize('remote.tunnelsView.add', "Forward a Port..."),
wideLabel: nls.localize('remote.tunnelsView.add', "Forward a Port..."),
tunnelType: TunnelType.Add,
remoteHost: 'localhost',
remotePort: 0,
Expand Down Expand Up @@ -265,8 +266,9 @@ class TunnelTreeRenderer extends Disposable implements ITreeRenderer<ITunnelGrou
private renderTunnel(node: ITunnelItem, templateData: ITunnelTemplateData) {
const isWide = templateData.container.parentElement?.parentElement?.parentElement?.parentElement?.parentElement?.parentElement?.parentElement?.parentElement?.classList.contains('wide');
const description = isWide ? node.wideDescription : node.description;
const label = node.label + (description ? (' - ' + description) : '');
templateData.iconLabel.setLabel(node.label, description, { title: node instanceof TunnelItem ? node.tooltip : label, extraClasses: ['tunnel-view-label'] });
const label = isWide ? node.wideLabel : node.label;
const tooltip = label + (description ? (' - ' + description) : '');
templateData.iconLabel.setLabel(label, description, { title: node instanceof TunnelItem ? node.tooltip : tooltip, extraClasses: ['tunnel-view-label'] });

templateData.actionBar.context = node;
const contextKeyService = this._register(this.contextKeyService.createScoped());
Expand Down Expand Up @@ -434,16 +436,25 @@ class TunnelItem implements ITunnelItem {
public privacy?: TunnelPrivacy,
private remoteExplorerService?: IRemoteExplorerService
) { }
get label(): string {
if (this.name) {
return nls.localize('remote.tunnelsView.forwardedPortLabel0', "{0}", this.name);
} else if (this.localAddress) {
return nls.localize('remote.tunnelsView.forwardedPortLabel1', "{0} \u2192 {1}", this.remotePort, TunnelItem.compactLongAddress(this.localAddress));

private static getLabel(name: string | undefined, localAddress: string | undefined, remotePort: number, isWide: boolean = false): string {
if (name) {
return nls.localize('remote.tunnelsView.forwardedPortLabel0', "{0}", name);
} else if (localAddress) {
return nls.localize('remote.tunnelsView.forwardedPortLabel1', "{0} \u2192 {1}", remotePort, isWide ? localAddress : TunnelItem.compactLongAddress(localAddress));
} else {
return nls.localize('remote.tunnelsView.forwardedPortLabel2', "{0}", this.remotePort);
return nls.localize('remote.tunnelsView.forwardedPortLabel2', "{0}", remotePort);
}
}

get label(): string {
return TunnelItem.getLabel(this.name, this.localAddress, this.remotePort);
}

get wideLabel(): string {
return TunnelItem.getLabel(this.name, this.localAddress, this.remotePort, true);
}

private static compactLongAddress(address: string): string {
if (address.length < 16) {
return address;
Expand Down Expand Up @@ -475,7 +486,7 @@ class TunnelItem implements ITunnelItem {
const description: string[] = [];

if (item.name && item.localAddress) {
description.push(nls.localize('remote.tunnelsView.forwardedPortDescription0', "{0} \u2192 {1}", item.remotePort, TunnelItem.compactLongAddress(item.localAddress)));
description.push(nls.localize('remote.tunnelsView.forwardedPortDescription0', "{0} \u2192 {1}", item.remotePort, isWide ? item.localAddress : TunnelItem.compactLongAddress(item.localAddress)));
}

if (item.runningProcess) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export interface ITunnelItem {
wideDescription?: string;
readonly icon?: ThemeIcon;
readonly label: string;
readonly wideLabel: string;
}

export interface Tunnel {
Expand Down

0 comments on commit c514299

Please sign in to comment.