sidebar if there is no profile selected
This commit is contained in:
@@ -37,9 +37,10 @@ pub fn render_sidebar(
|
||||
let mut items = Vec::new();
|
||||
|
||||
if let Some(profile_name) = selected_profile {
|
||||
if let Some(profile) = profile_tree.profiles.iter()
|
||||
.find(|p| &p.name == profile_name)
|
||||
{
|
||||
// Existing code for when a profile is selected...
|
||||
} else {
|
||||
// Show full profile tree when no profile is selected
|
||||
for (profile_idx, profile) in profile_tree.profiles.iter().enumerate() {
|
||||
// Profile header
|
||||
items.push(ListItem::new(Line::from(vec![
|
||||
Span::styled("📁 ", Style::default().fg(theme.accent)),
|
||||
@@ -48,11 +49,18 @@ pub fn render_sidebar(
|
||||
|
||||
// Tables
|
||||
for (table_idx, table) in profile.tables.iter().enumerate() {
|
||||
let is_last = table_idx == profile.tables.len() - 1;
|
||||
let prefix = if is_last { "└─ " } else { "├─ " };
|
||||
let is_last_table = table_idx == profile.tables.len() - 1;
|
||||
let is_last_profile = profile_idx == profile_tree.profiles.len() - 1;
|
||||
|
||||
let prefix = match (is_last_profile, is_last_table) {
|
||||
(true, true) => " └─ ",
|
||||
(true, false) => " ├─ ",
|
||||
(false, true) => "│ └─ ",
|
||||
(false, false) => "│ ├─ ",
|
||||
};
|
||||
|
||||
let mut line = vec![
|
||||
Span::styled(format!(" {}", prefix), Style::default().fg(theme.fg)),
|
||||
Span::styled(prefix, Style::default().fg(theme.fg)),
|
||||
Span::styled(&table.name, Style::default().fg(theme.fg)),
|
||||
];
|
||||
|
||||
@@ -65,12 +73,21 @@ pub fn render_sidebar(
|
||||
|
||||
items.push(ListItem::new(Line::from(line)));
|
||||
}
|
||||
|
||||
// Add spacing between profiles
|
||||
if profile_idx < profile_tree.profiles.len() - 1 {
|
||||
items.push(ListItem::new(Line::from(
|
||||
Span::styled("│", Style::default().fg(theme.secondary))
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
if profile_tree.profiles.is_empty() {
|
||||
items.push(ListItem::new(Span::styled(
|
||||
"No profiles available",
|
||||
Style::default().fg(theme.secondary)
|
||||
)));
|
||||
}
|
||||
} else {
|
||||
items.push(ListItem::new(Span::styled(
|
||||
"No profile selected",
|
||||
Style::default().fg(theme.secondary)
|
||||
)));
|
||||
}
|
||||
|
||||
let list = List::new(items)
|
||||
|
||||
Reference in New Issue
Block a user