treewide: fix various UI bugs; optimize crypto dependencies & format
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: If8fe8b38c1d9c4fecd40ff71f88d2ae06a6a6964
This commit is contained in:
parent
764aafa88d
commit
3ccddce7fd
178 changed files with 58342 additions and 54241 deletions
|
|
@ -1,64 +1,66 @@
|
|||
use ratatui::Frame;
|
||||
use ratatui::layout::Rect;
|
||||
use ratatui::style::{Color, Modifier, Style};
|
||||
use ratatui::widgets::{Block, Borders, Row, Table};
|
||||
use ratatui::{
|
||||
Frame,
|
||||
layout::Rect,
|
||||
style::{Color, Modifier, Style},
|
||||
widgets::{Block, Borders, Row, Table},
|
||||
};
|
||||
|
||||
use super::format_date;
|
||||
use crate::app::AppState;
|
||||
|
||||
pub fn render(f: &mut Frame, state: &AppState, area: Rect) {
|
||||
let header = Row::new(vec!["Name", "Kind", "Description", "Members", "Created"]).style(
|
||||
Style::default()
|
||||
.fg(Color::Yellow)
|
||||
.add_modifier(Modifier::BOLD),
|
||||
let header =
|
||||
Row::new(vec!["Name", "Kind", "Description", "Members", "Created"]).style(
|
||||
Style::default()
|
||||
.fg(Color::Yellow)
|
||||
.add_modifier(Modifier::BOLD),
|
||||
);
|
||||
|
||||
let rows: Vec<Row> = state
|
||||
.collections
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, col)| {
|
||||
let style = if Some(i) == state.collection_selected {
|
||||
Style::default().fg(Color::Black).bg(Color::Cyan)
|
||||
} else {
|
||||
Style::default()
|
||||
};
|
||||
let rows: Vec<Row> = state
|
||||
.collections
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, col)| {
|
||||
let style = if Some(i) == state.collection_selected {
|
||||
Style::default().fg(Color::Black).bg(Color::Cyan)
|
||||
} else {
|
||||
Style::default()
|
||||
};
|
||||
|
||||
// We show the filter_query as a proxy for member info when kind is "smart"
|
||||
let members_display = if col.kind == "smart" {
|
||||
col.filter_query
|
||||
.as_deref()
|
||||
.map(|q| format!("filter: {q}"))
|
||||
.unwrap_or_else(|| "-".to_string())
|
||||
} else {
|
||||
"-".to_string()
|
||||
};
|
||||
// We show the filter_query as a proxy for member info when kind is
|
||||
// "smart"
|
||||
let members_display = if col.kind == "smart" {
|
||||
col
|
||||
.filter_query
|
||||
.as_deref()
|
||||
.map(|q| format!("filter: {q}"))
|
||||
.unwrap_or_else(|| "-".to_string())
|
||||
} else {
|
||||
"-".to_string()
|
||||
};
|
||||
|
||||
Row::new(vec![
|
||||
col.name.clone(),
|
||||
col.kind.clone(),
|
||||
col.description.clone().unwrap_or_else(|| "-".into()),
|
||||
members_display,
|
||||
format_date(&col.created_at).to_string(),
|
||||
])
|
||||
.style(style)
|
||||
})
|
||||
.collect();
|
||||
Row::new(vec![
|
||||
col.name.clone(),
|
||||
col.kind.clone(),
|
||||
col.description.clone().unwrap_or_else(|| "-".into()),
|
||||
members_display,
|
||||
format_date(&col.created_at).to_string(),
|
||||
])
|
||||
.style(style)
|
||||
})
|
||||
.collect();
|
||||
|
||||
let title = format!(" Collections ({}) ", state.collections.len());
|
||||
let title = format!(" Collections ({}) ", state.collections.len());
|
||||
|
||||
let table = Table::new(
|
||||
rows,
|
||||
[
|
||||
ratatui::layout::Constraint::Percentage(25),
|
||||
ratatui::layout::Constraint::Percentage(12),
|
||||
ratatui::layout::Constraint::Percentage(28),
|
||||
ratatui::layout::Constraint::Percentage(15),
|
||||
ratatui::layout::Constraint::Percentage(20),
|
||||
],
|
||||
)
|
||||
.header(header)
|
||||
.block(Block::default().borders(Borders::ALL).title(title));
|
||||
let table = Table::new(rows, [
|
||||
ratatui::layout::Constraint::Percentage(25),
|
||||
ratatui::layout::Constraint::Percentage(12),
|
||||
ratatui::layout::Constraint::Percentage(28),
|
||||
ratatui::layout::Constraint::Percentage(15),
|
||||
ratatui::layout::Constraint::Percentage(20),
|
||||
])
|
||||
.header(header)
|
||||
.block(Block::default().borders(Borders::ALL).title(title));
|
||||
|
||||
f.render_widget(table, area);
|
||||
f.render_widget(table, area);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue