Skip to content

Commit 69b70b2

Browse files
authored
1 parent bfa8a0c commit 69b70b2

File tree

1 file changed

+51
-17
lines changed

1 file changed

+51
-17
lines changed

src/vs/workbench/contrib/remote/browser/tunnelView.ts

Lines changed: 51 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ export class TunnelViewModel implements ITunnelViewModel {
101101
id: TunnelPrivacyId.Private,
102102
themeIcon: privatePortIcon.id,
103103
label: nls.localize('tunnelPrivacy.private', "Private")
104-
}
104+
},
105+
strip: () => undefined
105106
};
106107

107108
constructor(
@@ -415,6 +416,31 @@ class ActionBarRenderer extends Disposable implements ITableRenderer<ActionBarCe
415416
}));
416417
}
417418

419+
private tunnelContext(tunnel: ITunnelItem): ITunnelItem {
420+
let context: ITunnelItem | undefined;
421+
if (tunnel instanceof TunnelItem) {
422+
context = tunnel.strip();
423+
}
424+
if (!context) {
425+
context = {
426+
tunnelType: tunnel.tunnelType,
427+
remoteHost: tunnel.remoteHost,
428+
remotePort: tunnel.remotePort,
429+
localAddress: tunnel.localAddress,
430+
protocol: tunnel.protocol,
431+
localUri: tunnel.localUri,
432+
localPort: tunnel.localPort,
433+
name: tunnel.name,
434+
closeable: tunnel.closeable,
435+
source: tunnel.source,
436+
privacy: tunnel.privacy,
437+
processDescription: tunnel.processDescription,
438+
label: tunnel.label
439+
};
440+
}
441+
return context;
442+
}
443+
418444
renderActionBarItem(element: ActionBarCell, templateData: IActionBarTemplateData): void {
419445
templateData.label.element.style.display = 'flex';
420446
templateData.label.setLabel(element.label, undefined,
@@ -424,22 +450,7 @@ class ActionBarRenderer extends Disposable implements ITableRenderer<ActionBarCe
424450
: element.tooltip,
425451
extraClasses: element.menuId === MenuId.TunnelLocalAddressInline ? ['ports-view-actionbar-cell-localaddress'] : undefined
426452
});
427-
const tunnelContext: ITunnelItem = {
428-
tunnelType: element.tunnel.tunnelType,
429-
remoteHost: element.tunnel.remoteHost,
430-
remotePort: element.tunnel.remotePort,
431-
localAddress: element.tunnel.localAddress,
432-
protocol: element.tunnel.protocol,
433-
localUri: element.tunnel.localUri,
434-
localPort: element.tunnel.localPort,
435-
name: element.tunnel.name,
436-
closeable: element.tunnel.closeable,
437-
source: element.tunnel.source,
438-
privacy: element.tunnel.privacy,
439-
processDescription: element.tunnel.processDescription,
440-
label: element.tunnel.label
441-
};
442-
templateData.actionBar.context = tunnelContext;
453+
templateData.actionBar.context = this.tunnelContext(element.tunnel);
443454
templateData.container.style.paddingLeft = '10px';
444455
const context: [string, any][] =
445456
[
@@ -581,6 +592,29 @@ class TunnelItem implements ITunnelItem {
581592
tunnelService);
582593
}
583594

595+
/**
596+
* Removes all non-serializable properties from the tunnel
597+
* @returns A new TunnelItem without any services
598+
*/
599+
public strip(): TunnelItem | undefined {
600+
return new TunnelItem(
601+
this.tunnelType,
602+
this.remoteHost,
603+
this.remotePort,
604+
this.source,
605+
this.hasRunningProcess,
606+
this.protocol,
607+
this.localUri,
608+
this.localAddress,
609+
this.localPort,
610+
this.closeable,
611+
this.name,
612+
this.runningProcess,
613+
this.pid,
614+
this._privacy
615+
);
616+
}
617+
584618
constructor(
585619
public tunnelType: TunnelType,
586620
public remoteHost: string,

0 commit comments

Comments
 (0)