From 9cb0c414afc284947fc2b8494504387e4e7edd87 Mon Sep 17 00:00:00 2001 From: Jack Wills <32690432+mrjackwills@users.noreply.github.com> Date: Sun, 16 Oct 2022 01:22:04 +0000 Subject: [PATCH] feat: log title show container name, closes #16 --- src/app_data/mod.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/app_data/mod.rs b/src/app_data/mod.rs index 3821f99..cf7887a 100644 --- a/src/app_data/mod.rs +++ b/src/app_data/mod.rs @@ -253,11 +253,20 @@ impl AppData { } /// Get the title for log panel for selected container - /// will be "logs x/x" + /// will be either + /// 1) "logs x/x - container_name" where container_name is 32 chars max + /// 2) "logs - container_name" when no logs found, again 32 chars max pub fn get_log_title(&self) -> String { self.get_selected_log_index() .map_or("".to_owned(), |index| { - self.containers.items[index].logs.get_state_title() + let logs_len = self.containers.items[index].logs.get_state_title(); + let mut name = self.containers.items[index].name.clone(); + name.truncate(32); + if logs_len.is_empty() { + format!("- {} ", name) + } else { + format!("{} - {}", logs_len, name) + } }) }