From 549a08359c11368c61aec1df9bc08a8a01765bbb Mon Sep 17 00:00:00 2001 From: Federico Guerinoni Date: Tue, 11 Jul 2023 12:32:37 +0200 Subject: [PATCH] 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 --- tokio-console/src/view/mod.rs | 25 +++++++++++++++++++++++++ tokio-console/src/view/resource.rs | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/tokio-console/src/view/mod.rs b/tokio-console/src/view/mod.rs index 72221ac73..9656345d9 100644 --- a/tokio-console/src/view/mod.rs +++ b/tokio-console/src/view/mod.rs @@ -167,6 +167,31 @@ impl View { self.state = ResourcesList; update_kind = UpdateKind::Other; } + key!(Enter) => { + if let Some(op) = view.async_ops_table.selected_item().upgrade() { + if let Some(task_id) = op.borrow().task_id() { + let task: u64 = task_id.to_string().parse().unwrap(); + let item = self + .tasks_list + .sorted_items + .iter() + .filter_map(|i| i.upgrade()) + .find(|t| { + let task_id: u64 = + t.borrow().id().to_string().parse().unwrap(); + task_id == task + }); + + if let Some(t) = item { + update_kind = UpdateKind::SelectTask(task); + self.state = TaskInstance(self::task::TaskView::new( + t, + state.task_details_ref(), + )); + } + } + } + } _ => { // otherwise pass on to view view.update_input(event); diff --git a/tokio-console/src/view/resource.rs b/tokio-console/src/view/resource.rs index 25f3c45e0..a55989657 100644 --- a/tokio-console/src/view/resource.rs +++ b/tokio-console/src/view/resource.rs @@ -21,7 +21,7 @@ use std::{cell::RefCell, rc::Rc}; pub(crate) struct ResourceView { resource: Rc>, - async_ops_table: TableListState, + pub async_ops_table: TableListState, initial_render: bool, }