Skip to content

Commit

Permalink
feat(console): Add way to inspect details of task from resource view
Browse files Browse the repository at this point in the history
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 tokio-rs#448
  • Loading branch information
guerinoni committed Jul 11, 2023
1 parent 7c8e80a commit 549a083
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
25 changes: 25 additions & 0 deletions tokio-console/src/view/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tokio-console/src/view/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use std::{cell::RefCell, rc::Rc};

pub(crate) struct ResourceView {
resource: Rc<RefCell<Resource>>,
async_ops_table: TableListState<AsyncOpsTable, 9>,
pub async_ops_table: TableListState<AsyncOpsTable, 9>,
initial_render: bool,
}

Expand Down

0 comments on commit 549a083

Please sign in to comment.