diff --git a/src/app_data/container_state.rs b/src/app_data/container_state.rs index d48e279..69b5c5e 100644 --- a/src/app_data/container_state.rs +++ b/src/app_data/container_state.rs @@ -125,7 +125,7 @@ impl ContainerPorts { pub fn len_ip(&self) -> usize { self.ip .as_ref() - .map_or(0, |i|i.to_string().chars().count()) + .map_or(0, |i| i.to_string().chars().count()) } pub fn len_private(&self) -> usize { format!("{}", self.private).chars().count() diff --git a/src/app_data/mod.rs b/src/app_data/mod.rs index ae7dabb..9cbd0c8 100644 --- a/src/app_data/mod.rs +++ b/src/app_data/mod.rs @@ -407,7 +407,7 @@ impl AppData { } /// Get title for containers section, add a suffix indicating if the containers are currently under filter - pub fn container_title(&self) -> String { + pub fn get_container_title(&self) -> String { let suffix = if !self.hidden_containers.is_empty() && !self.containers.items.is_empty() { " - filtered" } else { diff --git a/src/ui/draw_blocks.rs b/src/ui/draw_blocks.rs index b78a06c..6731b5e 100644 --- a/src/ui/draw_blocks.rs +++ b/src/ui/draw_blocks.rs @@ -72,7 +72,6 @@ fn max_line_width(text: &str) -> usize { /// Generate block, add a border if is the selected panel, /// add custom title based on state of each panel fn generate_block<'a>( - app_data: &Arc>, area: Rect, fd: &FrameData, gui_state: &Arc>, @@ -83,10 +82,10 @@ fn generate_block<'a>( .update_region_map(Region::Panel(panel), area); let mut title = match panel { SelectablePanel::Containers => { - format!("{}{}", panel.title(), app_data.lock().container_title()) + format!("{}{}", panel.title(), fd.container_title) } SelectablePanel::Logs => { - format!("{}{}", panel.title(), app_data.lock().get_log_title()) + format!("{}{}", panel.title(), fd.log_title) } SelectablePanel::Commands => String::new(), }; @@ -111,7 +110,7 @@ pub fn commands( fd: &FrameData, gui_state: &Arc>, ) { - let block = generate_block(app_data, area, fd, gui_state, SelectablePanel::Commands); + let block = generate_block(area, fd, gui_state, SelectablePanel::Commands); let items = app_data.lock().get_control_items().map_or(vec![], |i| { i.iter() .map(|c| { @@ -220,7 +219,7 @@ pub fn containers( fd: &FrameData, gui_state: &Arc>, ) { - let block = generate_block(app_data, area, fd, gui_state, SelectablePanel::Containers); + let block = generate_block(area, fd, gui_state, SelectablePanel::Containers); let items = app_data .lock() @@ -259,7 +258,7 @@ pub fn logs( fd: &FrameData, gui_state: &Arc>, ) { - let block = generate_block(app_data, area, fd, gui_state, SelectablePanel::Logs); + let block = generate_block(area, fd, gui_state, SelectablePanel::Logs); if fd.init { let paragraph = Paragraph::new(format!("parsing logs {}", fd.loading_icon)) .style(Style::default()) diff --git a/src/ui/mod.rs b/src/ui/mod.rs index 0dfd492..3a41c1d 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -224,6 +224,8 @@ impl Ui { #[derive(Debug)] pub struct FrameData { columns: Columns, + container_title: String, + log_title: String, delete_confirm: Option, has_containers: bool, has_error: Option, @@ -248,6 +250,8 @@ impl From<(MutexGuard<'_, AppData>, MutexGuard<'_, GuiState>)> for FrameData { Self { columns: data.0.get_width(), + container_title: data.0.get_container_title(), + log_title: data.0.get_log_title(), delete_confirm: data.1.get_delete_container(), has_containers: data.0.get_container_len() > 0, has_error: data.0.get_error(),