From b10c6ee8af01b9c5f32f5960c4c03b1ebdde8f98 Mon Sep 17 00:00:00 2001 From: Kelvin Schoofs Date: Mon, 12 Apr 2021 22:27:29 +0200 Subject: [PATCH] Add port forwarding things to Connections view --- package.json | 12 +++++++++++- src/treeViewManager.ts | 8 +++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 1a85dbf..7c6598d 100644 --- a/package.json +++ b/package.json @@ -286,14 +286,24 @@ "group": "inline@1" }, { - "command": "sshfs.disconnect", + "command": "sshfs.forwardPort", "when": "view == 'sshfs-connections' && viewItem == connection", "group": "inline@2" }, + { + "command": "sshfs.disconnect", + "when": "view == 'sshfs-connections' && viewItem == connection", + "group": "inline@3" + }, { "command": "sshfs.closeTerminal", "when": "view == 'sshfs-connections' && viewItem == terminal", "group": "inline@1" + }, + { + "command": "sshfs.unforwardPort", + "when": "view == 'sshfs-connections' && viewItem == forwarding", + "group": "inline@1" } ], "explorer/context": [ diff --git a/src/treeViewManager.ts b/src/treeViewManager.ts index d0fbf52..fabc72f 100644 --- a/src/treeViewManager.ts +++ b/src/treeViewManager.ts @@ -3,12 +3,13 @@ import * as vscode from 'vscode'; import { getConfigs, UPDATE_LISTENERS } from './config'; import type { Connection, ConnectionManager } from './connection'; import { FileSystemConfig, getGroups } from './fileSystemConfig'; +import { ActivePortForwarding, isActivePortForwarding } from './portForwarding'; import type { SSHPseudoTerminal } from './pseudoTerminal'; import type { SSHFileSystem } from './sshFileSystem'; import { formatItem } from './ui-utils'; type PendingConnection = [string, FileSystemConfig | undefined]; -type TreeData = Connection | PendingConnection | SSHFileSystem | SSHPseudoTerminal; +type TreeData = Connection | PendingConnection | SSHFileSystem | SSHPseudoTerminal | ActivePortForwarding; export class ConnectionTreeProvider implements vscode.TreeDataProvider { protected onDidChangeTreeDataEmitter = new vscode.EventEmitter(); public onDidChangeTreeData: vscode.Event = this.onDidChangeTreeDataEmitter.event; @@ -21,7 +22,8 @@ export class ConnectionTreeProvider implements vscode.TreeDataProvider this.onDidChangeTreeDataEmitter.fire(); } public getTreeItem(element: TreeData): vscode.TreeItem | Thenable { - if ('onDidChangeFile' in element || 'handleInput' in element) { // SSHFileSystem | SSHPseudoTerminal + if ('onDidChangeFile' in element || 'handleInput' in element || isActivePortForwarding(element)) { + // SSHFileSystem | SSHPseudoTerminal | ActivePortForwarding return { ...formatItem(element), collapsibleState: vscode.TreeItemCollapsibleState.None } } else if (Array.isArray(element)) { // PendingConnection const [name, config] = element; @@ -45,7 +47,7 @@ export class ConnectionTreeProvider implements vscode.TreeDataProvider if ('onDidChangeFile' in element) return []; // SSHFileSystem if ('handleInput' in element) return []; // SSHPseudoTerminal if (Array.isArray(element)) return []; // PendingConnection - return [...element.terminals, ...element.filesystems]; // Connection + return [...element.terminals, ...element.filesystems, ...element.forwardings]; // Connection } }