Skip to content

Commit 549a083

Browse files
committed
feat(console): Add way to inspect details of task from resource view
Now it is possible while navigate in `async_ops_table` to go directly to details of the task that you are pointing on the list. This closes #448
1 parent 7c8e80a commit 549a083

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

Diff for: tokio-console/src/view/mod.rs

+25
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,31 @@ impl View {
167167
self.state = ResourcesList;
168168
update_kind = UpdateKind::Other;
169169
}
170+
key!(Enter) => {
171+
if let Some(op) = view.async_ops_table.selected_item().upgrade() {
172+
if let Some(task_id) = op.borrow().task_id() {
173+
let task: u64 = task_id.to_string().parse().unwrap();
174+
let item = self
175+
.tasks_list
176+
.sorted_items
177+
.iter()
178+
.filter_map(|i| i.upgrade())
179+
.find(|t| {
180+
let task_id: u64 =
181+
t.borrow().id().to_string().parse().unwrap();
182+
task_id == task
183+
});
184+
185+
if let Some(t) = item {
186+
update_kind = UpdateKind::SelectTask(task);
187+
self.state = TaskInstance(self::task::TaskView::new(
188+
t,
189+
state.task_details_ref(),
190+
));
191+
}
192+
}
193+
}
194+
}
170195
_ => {
171196
// otherwise pass on to view
172197
view.update_input(event);

Diff for: tokio-console/src/view/resource.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use std::{cell::RefCell, rc::Rc};
2121

2222
pub(crate) struct ResourceView {
2323
resource: Rc<RefCell<Resource>>,
24-
async_ops_table: TableListState<AsyncOpsTable, 9>,
24+
pub async_ops_table: TableListState<AsyncOpsTable, 9>,
2525
initial_render: bool,
2626
}
2727

0 commit comments

Comments
 (0)