Files
managarr/src/ui/readarr_ui/readarr_ui_utils.rs
T
Dark-Alex-17 a8d13ae5c8 feat(readarr): render the author details view
Add AuthorDetailsUi: the author description pane plus the three author info
tabs (Books, History, and Author Search), along with the history item details,
automatic search, update and scan, and manual search confirmation popups.
LibraryUi now accepts and draws it over the authors table.

The description pane omits the Disambiguation and Type lines that the Lidarr
equivalent renders. GET /author returns neither key, so both lines would be
blank on every record. The books table drops the Type and Duration columns for
the same reason, since books have no type and no duration, and renders Files as
the book file count over the total book count.

Land create_history_event_details together with this first caller so it is not
committed as an unused function.

Extract decorate_book_row_with_style rather than inlining the row styling in
the table closure, matching decorate_author_row_with_style in the sibling
library view. Rendering to a string discards colour, so the styling branches
are only reachable by tests through a named function.
2026-09-03 01:41:01 -06:00

165 lines
4.6 KiB
Rust

use crate::models::readarr_models::{
ReadarrHistoryData, ReadarrHistoryEventType, ReadarrHistoryItem,
};
use ratatui::text::Line;
#[cfg(test)]
#[path = "readarr_ui_utils_tests.rs"]
mod readarr_ui_utils_tests;
pub(super) fn create_history_event_details(history_item: ReadarrHistoryItem) -> Vec<Line<'static>> {
let ReadarrHistoryItem {
source_title,
event_type,
quality,
date,
data,
..
} = history_item;
let ReadarrHistoryData {
indexer,
nzb_info_url,
release_group,
age,
published_date,
download_client_name,
download_client,
message,
reason,
dropped_path,
imported_path,
source_path,
path,
status_messages,
} = data;
let mut lines = vec![
Line::from(format!("Source Title: {}", source_title.text.trim_start())),
Line::from(format!("Event Type: {event_type}")),
Line::from(format!("Quality: {}", quality.quality.name.trim_start())),
Line::from(format!("Date: {date}")),
];
match event_type {
ReadarrHistoryEventType::Grabbed => {
lines.push(Line::from(format!(
"Indexer: {}",
indexer.unwrap_or_default().trim_start()
)));
lines.push(Line::from(format!(
"NZB Info URL: {}",
nzb_info_url.unwrap_or_default().trim_start()
)));
lines.push(Line::from(format!(
"Release Group: {}",
release_group.unwrap_or_default().trim_start()
)));
lines.push(Line::from(format!(
"Age: {} days",
age.unwrap_or("0".to_owned()).trim_start()
)));
lines.push(Line::from(format!(
"Published Date: {}",
published_date.unwrap_or_default()
)));
lines.push(Line::from(format!(
"Download Client: {}",
download_client_name
.unwrap_or(download_client.unwrap_or_default())
.trim_start()
)));
}
ReadarrHistoryEventType::DownloadImported => {
lines.push(Line::from(format!(
"Release Group: {}",
release_group.unwrap_or_default().trim_start()
)));
}
ReadarrHistoryEventType::DownloadFailed => {
lines.push(Line::from(format!(
"Download Client: {}",
download_client_name
.unwrap_or(download_client.unwrap_or_default())
.trim_start()
)));
lines.push(Line::from(format!(
"Message: {}",
message.unwrap_or_default().trim_start()
)));
lines.push(Line::from(format!(
"Release Group: {}",
release_group.unwrap_or_default().trim_start()
)));
lines.push(Line::from(format!(
"Indexer: {}",
indexer.unwrap_or_default().trim_start()
)));
}
ReadarrHistoryEventType::BookFileDeleted => {
lines.push(Line::from(format!(
"Reason: {}",
reason.unwrap_or_default().trim_start()
)));
lines.push(Line::from(format!(
"Release Group: {}",
release_group.unwrap_or_default().trim_start()
)));
}
ReadarrHistoryEventType::BookFileImported => {
lines.push(Line::from(format!(
"Dropped Path: {}",
dropped_path.unwrap_or_default().trim_start()
)));
lines.push(Line::from(format!(
"Imported Path: {}",
imported_path.unwrap_or_default().trim_start()
)));
lines.push(Line::from(format!(
"Download Client: {}",
download_client_name
.unwrap_or(download_client.unwrap_or_default())
.trim_start()
)));
lines.push(Line::from(format!(
"Release Group: {}",
release_group.unwrap_or_default().trim_start()
)));
}
ReadarrHistoryEventType::BookFileRenamed => {
lines.push(Line::from(format!(
"Source Path: {}",
source_path.unwrap_or_default().trim_start()
)));
lines.push(Line::from(format!(
"Path: {}",
path.unwrap_or_default().trim_start()
)));
lines.push(Line::from(format!(
"Release Group: {}",
release_group.unwrap_or_default().trim_start()
)));
}
ReadarrHistoryEventType::BookFileRetagged => {
lines.push(Line::from(format!(
"Release Group: {}",
release_group.unwrap_or_default().trim_start()
)));
}
ReadarrHistoryEventType::BookImportIncomplete => {
lines.push(Line::from(format!(
"Status Messages: {}",
status_messages.unwrap_or_default().trim_start()
)));
lines.push(Line::from(format!(
"Release Group: {}",
release_group.unwrap_or_default().trim_start()
)));
}
_ => {
lines.push(Line::from("No additional details available.".to_owned()));
}
}
lines
}