canvas common needs redesign, sidebar displaying even when no profile selected

This commit is contained in:
filipriec
2025-03-24 16:46:02 +01:00
parent 36dc4302a0
commit 65ff1256aa
2 changed files with 35 additions and 76 deletions

View File

@@ -9,7 +9,8 @@ use crate::config::colors::themes::Theme;
use common::proto::multieko2::table_definition::{ProfileTreeResponse};
use ratatui::text::{Span, Line};
const SIDEBAR_WIDTH: u16 = 16;
// Reduced sidebar width
const SIDEBAR_WIDTH: u16 = 12;
pub fn calculate_sidebar_layout(show_sidebar: bool, main_content_area: Rect) -> (Option<Rect>, Rect) {
if show_sidebar {
@@ -39,34 +40,43 @@ pub fn render_sidebar(
if let Some(profile_name) = selected_profile {
// Existing code for when a profile is selected...
} else {
// Show full profile tree when no profile is selected
// Show full profile tree when no profile is selected (compact version)
for (profile_idx, profile) in profile_tree.profiles.iter().enumerate() {
// Profile header
// Profile header - more compact
items.push(ListItem::new(Line::from(vec![
Span::styled("📁 ", Style::default().fg(theme.accent)),
Span::styled("", Style::default().fg(theme.accent)),
Span::styled(&profile.name, Style::default().fg(theme.highlight)),
])));
// Tables
// Tables with compact prefixes
for (table_idx, table) in profile.tables.iter().enumerate() {
let is_last_table = table_idx == profile.tables.len() - 1;
let is_last_profile = profile_idx == profile_tree.profiles.len() - 1;
// Shorter prefix characters
let prefix = match (is_last_profile, is_last_table) {
(true, true) => " └─ ",
(true, false) => " ├─ ",
(false, true) => " └─ ",
(false, false) => " ├─ ",
(true, true) => " ",
(true, false) => " ",
(false, true) => "",
(false, false) => "",
};
// Get table name without year prefix to save space
let display_name = if table.name.starts_with("2025_") {
&table.name[5..] // Skip "2025_" prefix
} else {
&table.name
};
let mut line = vec![
Span::styled(prefix, Style::default().fg(theme.fg)),
Span::styled(&table.name, Style::default().fg(theme.fg)),
Span::styled(display_name, Style::default().fg(theme.fg)),
];
// Show a simple indicator for dependencies instead of listing them
if !table.depends_on.is_empty() {
line.push(Span::styled(
format!("{}", table.depends_on.join(", ")),
"",
Style::default().fg(theme.secondary)
));
}
@@ -74,7 +84,7 @@ pub fn render_sidebar(
items.push(ListItem::new(Line::from(line)));
}
// Add spacing between profiles
// Compact separator between profiles
if profile_idx < profile_tree.profiles.len() - 1 {
items.push(ListItem::new(Line::from(
Span::styled("", Style::default().fg(theme.secondary))
@@ -84,7 +94,7 @@ pub fn render_sidebar(
if profile_tree.profiles.is_empty() {
items.push(ListItem::new(Span::styled(
"No profiles available",
"No profiles",
Style::default().fg(theme.secondary)
)));
}
@@ -93,7 +103,7 @@ pub fn render_sidebar(
let list = List::new(items)
.block(sidebar_block)
.highlight_style(Style::default().fg(theme.highlight))
.highlight_symbol(">>");
.highlight_symbol(">");
f.render_widget(list, area);
}