Updated library colors to match the web UI
This commit is contained in:
+11
-3
@@ -213,7 +213,7 @@ fn decorate_with_row_style<'a>(
|
||||
.find(|&download| download.movie_id == movie.id)
|
||||
{
|
||||
if download.status == "downloading" {
|
||||
return row.warning();
|
||||
return row.downloading();
|
||||
}
|
||||
|
||||
if download.status == "completed" {
|
||||
@@ -221,13 +221,21 @@ fn decorate_with_row_style<'a>(
|
||||
}
|
||||
}
|
||||
|
||||
return row.failure();
|
||||
if !movie.monitored {
|
||||
return row.unmonitored_missing();
|
||||
}
|
||||
|
||||
if movie.status != "released" {
|
||||
return row.unreleased();
|
||||
}
|
||||
|
||||
return row.missing();
|
||||
}
|
||||
|
||||
if !movie.monitored {
|
||||
row.unmonitored()
|
||||
} else {
|
||||
row.success()
|
||||
row.downloaded()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use ratatui::widgets::{Cell, Row};
|
||||
use rstest::rstest;
|
||||
use strum::IntoEnumIterator;
|
||||
use crate::models::radarr_models::{DownloadRecord, Movie};
|
||||
|
||||
use crate::models::servarr_data::radarr::radarr_data::ActiveRadarrBlock;
|
||||
use crate::ui::radarr_ui::RadarrUi;
|
||||
use crate::ui::radarr_ui::{decorate_with_row_style, RadarrUi};
|
||||
use crate::ui::DrawUi;
|
||||
use crate::ui::styles::ManagarrStyle;
|
||||
|
||||
#[test]
|
||||
fn test_radarr_ui_accepts() {
|
||||
@@ -12,4 +16,60 @@ mod tests {
|
||||
assert!(RadarrUi::accepts(active_radarr_block.into()));
|
||||
});
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
#[case(false, Some("downloading"), false, "", RowStyle::Downloading)]
|
||||
#[case(false, Some("completed"), false, "", RowStyle::AwaitingImport)]
|
||||
#[case(false, None, false, "", RowStyle::UnmonitoredMissing)]
|
||||
#[case(false, None, true, "", RowStyle::Unreleased)]
|
||||
#[case(false, None, true, "released", RowStyle::Missing)]
|
||||
#[case(true, None, false, "", RowStyle::Unmonitored)]
|
||||
#[case(true, None, true, "", RowStyle::Downloaded)]
|
||||
fn test_decorate_with_row_style(
|
||||
#[case] has_file: bool,
|
||||
#[case] download_status: Option<&str>,
|
||||
#[case] is_monitored: bool,
|
||||
#[case] movie_status: String,
|
||||
#[case] expected_style: RowStyle,
|
||||
) {
|
||||
let downloads_vec = if let Some(download_status) = download_status {
|
||||
vec![DownloadRecord {
|
||||
movie_id: 1,
|
||||
status: download_status.to_owned(),
|
||||
..DownloadRecord::default()
|
||||
}]
|
||||
} else {
|
||||
vec![]
|
||||
};
|
||||
let movie = Movie {
|
||||
id: 1,
|
||||
has_file,
|
||||
monitored: is_monitored,
|
||||
status: movie_status,
|
||||
..Movie::default()
|
||||
};
|
||||
let row = Row::new(vec![Cell::from("test".to_owned())]);
|
||||
|
||||
let style = decorate_with_row_style(&downloads_vec, &movie, row.clone());
|
||||
|
||||
match expected_style {
|
||||
RowStyle::AwaitingImport => assert_eq!(style, row.awaiting_import()),
|
||||
RowStyle::Downloaded => assert_eq!(style, row.downloaded()),
|
||||
RowStyle::Downloading => assert_eq!(style, row.downloading()),
|
||||
RowStyle::Missing => assert_eq!(style, row.missing()),
|
||||
RowStyle::Unmonitored => assert_eq!(style, row.unmonitored()),
|
||||
RowStyle::UnmonitoredMissing => assert_eq!(style, row.unmonitored_missing()),
|
||||
RowStyle::Unreleased => assert_eq!(style, row.unreleased()),
|
||||
}
|
||||
}
|
||||
|
||||
enum RowStyle {
|
||||
AwaitingImport,
|
||||
Downloaded,
|
||||
Downloading,
|
||||
Missing,
|
||||
Unmonitored,
|
||||
UnmonitoredMissing,
|
||||
Unreleased,
|
||||
}
|
||||
}
|
||||
|
||||
+26
-1
@@ -15,14 +15,19 @@ where
|
||||
fn new() -> T;
|
||||
fn awaiting_import(self) -> T;
|
||||
fn default(self) -> T;
|
||||
fn downloaded(self) -> T;
|
||||
fn downloading(self) -> T;
|
||||
fn failure(self) -> T;
|
||||
fn help(self) -> T;
|
||||
fn highlight(self) -> T;
|
||||
fn missing(self) -> T;
|
||||
fn primary(self) -> T;
|
||||
fn secondary(self) -> T;
|
||||
fn success(self) -> T;
|
||||
fn system_function(self) -> T;
|
||||
fn unmonitored(self) -> T;
|
||||
fn unmonitored_missing(self) -> T;
|
||||
fn unreleased(self) -> T;
|
||||
fn warning(self) -> T;
|
||||
}
|
||||
|
||||
@@ -43,6 +48,14 @@ where
|
||||
self.white()
|
||||
}
|
||||
|
||||
fn downloaded(self) -> T {
|
||||
self.green()
|
||||
}
|
||||
|
||||
fn downloading(self) -> T {
|
||||
self.magenta()
|
||||
}
|
||||
|
||||
fn failure(self) -> T {
|
||||
self.red()
|
||||
}
|
||||
@@ -55,6 +68,10 @@ where
|
||||
self.reversed()
|
||||
}
|
||||
|
||||
fn missing(self) -> T {
|
||||
self.red()
|
||||
}
|
||||
|
||||
fn primary(self) -> T {
|
||||
self.cyan()
|
||||
}
|
||||
@@ -72,7 +89,15 @@ where
|
||||
}
|
||||
|
||||
fn unmonitored(self) -> T {
|
||||
self.white()
|
||||
self.gray()
|
||||
}
|
||||
|
||||
fn unmonitored_missing(self) -> T {
|
||||
self.yellow()
|
||||
}
|
||||
|
||||
fn unreleased(self) -> T {
|
||||
self.light_cyan()
|
||||
}
|
||||
|
||||
fn warning(self) -> T {
|
||||
|
||||
+26
-1
@@ -23,6 +23,16 @@ mod test {
|
||||
assert_eq!(Style::new().default(), Style::new().white());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_style_downloaded() {
|
||||
assert_eq!(Style::new().downloaded(), Style::new().green());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_style_downloading() {
|
||||
assert_eq!(Style::new().downloading(), Style::new().magenta());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_style_failure() {
|
||||
assert_eq!(Style::new().failure(), Style::new().red());
|
||||
@@ -41,6 +51,11 @@ mod test {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_style_missing() {
|
||||
assert_eq!(Style::new().missing(), Style::new().red());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_style_primary() {
|
||||
assert_eq!(Style::new().primary(), Style::new().cyan());
|
||||
@@ -63,7 +78,17 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn test_style_unmonitored() {
|
||||
assert_eq!(Style::new().unmonitored(), Style::new().white());
|
||||
assert_eq!(Style::new().unmonitored(), Style::new().gray());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_style_unmonitored_missing() {
|
||||
assert_eq!(Style::new().unmonitored_missing(), Style::new().yellow());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_style_unreleased() {
|
||||
assert_eq!(Style::new().unreleased(), Style::new().light_cyan());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user