Skip to content

Commit f417d7a

Browse files
arifdhawkw
authored andcommitted
fix(console): enable view-switching keystrokes on details views (#387)
Currently, the help text for the `r` and `t` keystrokes to switch to the Resources and Tasks views is shown on the Task Details and Resource Details views, as well as on the Task List and Resource List views. See this screenshot for an example: ![image](https://user-images.githubusercontent.com/2345750/202058962-4a8f062c-78fd-47eb-a3b1-5de470976aa8.png) However, the keystrokes are not actually handled while the console is showing a details view. This branch changes the console to handle the `r` and `t` keystrokes on all views. This also simplifies the keyboard input code somewhat.
1 parent 8e3c6c5 commit f417d7a

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tokio-console/src/view/mod.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,17 @@ impl View {
9696
pub(crate) fn update_input(&mut self, event: input::Event, state: &State) -> UpdateKind {
9797
use ViewState::*;
9898
let mut update_kind = UpdateKind::Other;
99+
100+
if matches!(event, key!(Char('t'))) {
101+
self.state = TasksList;
102+
return update_kind;
103+
}
104+
105+
if matches!(event, key!(Char('r'))) {
106+
self.state = ResourcesList;
107+
return update_kind;
108+
}
109+
99110
match self.state {
100111
TasksList => {
101112
// The enter key changes views, so handle here since we can
@@ -110,9 +121,6 @@ impl View {
110121
));
111122
}
112123
}
113-
key!(Char('r')) => {
114-
self.state = ResourcesList;
115-
}
116124
_ => {
117125
// otherwise pass on to view
118126
self.tasks_list.update_input(event);
@@ -127,9 +135,6 @@ impl View {
127135
self.state = ResourceInstance(self::resource::ResourceView::new(res));
128136
}
129137
}
130-
key!(Char('t')) => {
131-
self.state = TasksList;
132-
}
133138
_ => {
134139
// otherwise pass on to view
135140
self.resources_list.update_input(event);

0 commit comments

Comments
 (0)