Enable the full clippy all + pedantic + nursery groups as workspace warnings, with a small documented allow-list for the pedantic/nursery lints this project intentionally does not follow (rustdoc-style requirements, deliberate numeric casts in the protocol/UI layers, and a few noisy nursery lints). Also enable the rust unused_lifetimes and unsafe_op_in_unsafe_fn lints. Fixed every resulting warning (527 -> 0) mechanically per clippy's suggestions: inline format args, const fns, item ordering, let-else, redundant clones, map_or, cast_lossless, Eq derives, associated-fn conversions for methods that never used self, and removing unnecessary Result wrappers whose call sites could never propagate an error. No runtime behavior changed; cargo fmt applied. cargo clippy --workspace --all-targets: 0 warnings. All tests pass.
76 lines
2.2 KiB
Rust
76 lines
2.2 KiB
Rust
use crate::models::{SearchEntry, SearchStatus};
|
|
use crate::ui::{
|
|
HIGHLIGHT_SYMBOL, border_style, border_type, header_style, highlight_style,
|
|
success_style, warning_style,
|
|
};
|
|
use ratatui::{
|
|
Frame,
|
|
layout::Rect,
|
|
widgets::{Block, Borders, Cell, HighlightSpacing, Row, Table, TableState},
|
|
};
|
|
|
|
pub fn render_searches_pane(
|
|
frame: &mut Frame,
|
|
area: Rect,
|
|
searches: &[SearchEntry],
|
|
table_state: &mut TableState,
|
|
focused: bool,
|
|
) {
|
|
let header = Row::new(vec![
|
|
Cell::from("Status").style(header_style()),
|
|
Cell::from("Query").style(header_style()),
|
|
Cell::from("Results").style(header_style()),
|
|
])
|
|
.height(1);
|
|
|
|
let rows: Vec<Row> = searches
|
|
.iter()
|
|
.map(|search| {
|
|
let status_cell = match &search.status {
|
|
SearchStatus::Active => {
|
|
Cell::from("Active").style(warning_style())
|
|
}
|
|
SearchStatus::Completed => {
|
|
Cell::from("Done").style(success_style())
|
|
}
|
|
};
|
|
|
|
let results_count = search.results.len();
|
|
let results_text = if results_count == 0
|
|
&& search.status == SearchStatus::Active
|
|
{
|
|
"Searching...".to_string()
|
|
} else {
|
|
format!("{results_count}")
|
|
};
|
|
|
|
Row::new(vec![
|
|
status_cell,
|
|
Cell::from(search.query.clone()),
|
|
Cell::from(results_text),
|
|
])
|
|
})
|
|
.collect();
|
|
|
|
let widths = [
|
|
ratatui::layout::Constraint::Length(15),
|
|
ratatui::layout::Constraint::Fill(1),
|
|
ratatui::layout::Constraint::Length(10),
|
|
];
|
|
|
|
let table = Table::new(rows, widths)
|
|
.header(header)
|
|
.row_highlight_style(highlight_style())
|
|
.highlight_symbol(HIGHLIGHT_SYMBOL)
|
|
.highlight_spacing(HighlightSpacing::Always)
|
|
.block(
|
|
Block::default()
|
|
.borders(Borders::ALL)
|
|
.border_style(border_style(focused))
|
|
.border_type(border_type(focused))
|
|
.title("[1] Searches"),
|
|
);
|
|
|
|
frame.render_stateful_widget(table, area, table_state);
|
|
}
|