Skip to content

Commit

Permalink
feat(tui): only show flows if tui-max-flows > 1
Browse files Browse the repository at this point in the history
  • Loading branch information
fujiapple852 committed Feb 12, 2024
1 parent 34f7d01 commit e5014b2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
26 changes: 17 additions & 9 deletions src/frontend/render/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,23 @@ pub fn render(f: &mut Frame<'_>, app: &TuiApp, rect: Rect) {
let source = render_source(app);
let dest = render_destination(app);
let target = format!("{source} -> {dest}");
let plural_flows = if app.tracer_data().flows().len() > 1 {
"flows"
let discovered = if app.tui_config.max_flows > 1 {
let plural_flows = if app.tracer_data().flows().len() > 1 {
"flows"
} else {
"flow"
};
format!(
", discovered {} hops and {} unique {}",
app.tracer_data().hops(app.selected_flow).len(),
app.tracer_data().flows().len(),
plural_flows
)
} else {
"flow"
format!(
", discovered {} hops",
app.tracer_data().hops(app.selected_flow).len()
)
};
let left_line = vec![
Line::from(vec![
Expand All @@ -104,12 +117,7 @@ pub fn render(f: &mut Frame<'_>, app: &TuiApp, rect: Rect) {
Line::from(vec![
Span::styled("Status: ", Style::default().add_modifier(Modifier::BOLD)),
Span::raw(render_status(app)),
Span::raw(format!(
", discovered {} hops and {} unique {}",
app.tracer_data().hops(app.selected_flow).len(),
app.tracer_data().flows().len(),
plural_flows
)),
Span::raw(discovered),
]),
];

Expand Down
2 changes: 1 addition & 1 deletion src/frontend/tui_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ impl TuiApp {
}

pub fn toggle_flows(&mut self) {
if self.trace_info.len() == 1 {
if self.trace_info.len() == 1 && self.tui_config.max_flows > 1 {
if self.show_flows {
self.selected_flow = FlowId(0);
self.show_flows = false;
Expand Down

0 comments on commit e5014b2

Please sign in to comment.