|
15 | 15 | from textual.app import App, ComposeResult
|
16 | 16 | from textual.containers import Container, VerticalScroll
|
17 | 17 | from textual.reactive import var
|
18 |
| -from textual.widgets import DirectoryTree, Footer, Header, Static, Placeholder |
| 18 | +from textual.widgets import DirectoryTree, Footer, Header, Static, Placeholder, Tree |
19 | 19 |
|
20 | 20 | from configs import CONFIG_PATH as ROOT_CONFIG_PATH
|
21 | 21 | from tui.ssh_connections.ssh_connect import connect_shell, connect_sftp
|
@@ -110,20 +110,26 @@ def action_connect_ssh(self) -> None:
|
110 | 110 | Called in response to c key binding.
|
111 | 111 | :return:
|
112 | 112 | """
|
113 |
| - if not self.selected_file_path: |
| 113 | + path = self.query_one(Tree).cursor_node.data.path |
| 114 | + # Prevent selection of a group of nodes. |
| 115 | + if '.json' not in str(path).lower(): |
114 | 116 | pass
|
115 | 117 | else:
|
116 |
| - self.return_command(connect_shell, config_path=self.selected_file_path) |
| 118 | + self.return_command(connect_shell, config_path=path) |
117 | 119 |
|
118 | 120 | def action_connect_sftp(self) -> None:
|
119 | 121 | """
|
120 | 122 | Called in response to s key binding.
|
121 | 123 | :return:
|
122 | 124 | """
|
123 |
| - if not self.selected_file_path: |
| 125 | + path = self.query_one(Tree).cursor_node.data.path |
| 126 | + # Prevent selection of a group of nodes. |
| 127 | + if '.json' not in path.lower(): |
124 | 128 | pass
|
125 | 129 | else:
|
126 |
| - self.return_command(connect_sftp, config_path=self.selected_file_path) |
| 130 | + self.return_command(connect_sftp, config_path=path) |
| 131 | + |
| 132 | + |
127 | 133 |
|
128 | 134 |
|
129 | 135 | def main():
|
|
0 commit comments