Skip to content

Commit 28a2efd

Browse files
Fixed the crash when clicking/selecting a dataset
Prompt: When clicking on a dataset I am receiving this error ``` ╭────────────────────────────────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ──────────────────────────────────────────────────────────────────────────────────────────────────╮ │ /home/sergio/Projects/sergiovibes/zfs-dashboard-python/src/zfs_dashboard/ui/screens.py:141 in on_dataset_tree_widget_selected │ │ │ │ 138 │ │ ╭────────── locals ───────────╮ │ │ 139 │ │ # The message bubbles up from the tree. │ message = Selected() │ │ │ 140 │ │ # We can look at message.control.id to find the pool name │ self = DashboardScreen() │ │ │ ❱ 141 │ │ tree_id = message.control.id # e.g. tree-tank ╰─────────────────────────────╯ │ │ 142 │ │ if tree_id and tree_id.startswith("tree-"): │ │ 143 │ │ │ pool_name = tree_id.split("-", 1)[1] │ │ 144 │ │ │ details = self.query_one(f"#details-{pool_name}", DatasetDetails) │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ AttributeError: 'NoneType' object has no attribute 'id' ```
1 parent 42e19c9 commit 28a2efd

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/zfs_dashboard/ui/screens.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def on_dataset_tree_widget_selected(self, message: DatasetTreeWidget.Selected):
138138

139139
# The message bubbles up from the tree.
140140
# We can look at message.control.id to find the pool name
141-
tree_id = message.control.id # e.g. tree-tank
141+
tree_id = message.tree_id # e.g. tree-tank
142142
if tree_id and tree_id.startswith("tree-"):
143143
pool_name = tree_id.split("-", 1)[1]
144144
details = self.query_one(f"#details-{pool_name}", DatasetDetails)

src/zfs_dashboard/ui/widgets.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,9 @@ class DatasetTreeWidget(Static):
9494
dataset_filter = reactive("")
9595

9696
class Selected(Message):
97-
def __init__(self, dataset: Dataset):
97+
def __init__(self, dataset: Dataset, tree_id: str):
9898
self.dataset = dataset
99+
self.tree_id = tree_id
99100
super().__init__()
100101

101102
def compose(self) -> ComposeResult:
@@ -170,7 +171,7 @@ def has_matching_child(self, dataset: Dataset) -> bool:
170171

171172
def on_tree_node_selected(self, event: Tree.NodeSelected):
172173
if event.node.data:
173-
self.post_message(self.Selected(event.node.data))
174+
self.post_message(self.Selected(event.node.data, self.id))
174175

175176
class DatasetDetails(Static):
176177
dataset = reactive(None)

0 commit comments

Comments
 (0)