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)
|
.find(|&download| download.movie_id == movie.id)
|
||||||
{
|
{
|
||||||
if download.status == "downloading" {
|
if download.status == "downloading" {
|
||||||
return row.warning();
|
return row.downloading();
|
||||||
}
|
}
|
||||||
|
|
||||||
if download.status == "completed" {
|
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 {
|
if !movie.monitored {
|
||||||
row.unmonitored()
|
row.unmonitored()
|
||||||
} else {
|
} else {
|
||||||
row.success()
|
row.downloaded()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use ratatui::widgets::{Cell, Row};
|
||||||
|
use rstest::rstest;
|
||||||
use strum::IntoEnumIterator;
|
use strum::IntoEnumIterator;
|
||||||
|
use crate::models::radarr_models::{DownloadRecord, Movie};
|
||||||
|
|
||||||
use crate::models::servarr_data::radarr::radarr_data::ActiveRadarrBlock;
|
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::DrawUi;
|
||||||
|
use crate::ui::styles::ManagarrStyle;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_radarr_ui_accepts() {
|
fn test_radarr_ui_accepts() {
|
||||||
@@ -12,4 +16,60 @@ mod tests {
|
|||||||
assert!(RadarrUi::accepts(active_radarr_block.into()));
|
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 new() -> T;
|
||||||
fn awaiting_import(self) -> T;
|
fn awaiting_import(self) -> T;
|
||||||
fn default(self) -> T;
|
fn default(self) -> T;
|
||||||
|
fn downloaded(self) -> T;
|
||||||
|
fn downloading(self) -> T;
|
||||||
fn failure(self) -> T;
|
fn failure(self) -> T;
|
||||||
fn help(self) -> T;
|
fn help(self) -> T;
|
||||||
fn highlight(self) -> T;
|
fn highlight(self) -> T;
|
||||||
|
fn missing(self) -> T;
|
||||||
fn primary(self) -> T;
|
fn primary(self) -> T;
|
||||||
fn secondary(self) -> T;
|
fn secondary(self) -> T;
|
||||||
fn success(self) -> T;
|
fn success(self) -> T;
|
||||||
fn system_function(self) -> T;
|
fn system_function(self) -> T;
|
||||||
fn unmonitored(self) -> T;
|
fn unmonitored(self) -> T;
|
||||||
|
fn unmonitored_missing(self) -> T;
|
||||||
|
fn unreleased(self) -> T;
|
||||||
fn warning(self) -> T;
|
fn warning(self) -> T;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,6 +48,14 @@ where
|
|||||||
self.white()
|
self.white()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn downloaded(self) -> T {
|
||||||
|
self.green()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn downloading(self) -> T {
|
||||||
|
self.magenta()
|
||||||
|
}
|
||||||
|
|
||||||
fn failure(self) -> T {
|
fn failure(self) -> T {
|
||||||
self.red()
|
self.red()
|
||||||
}
|
}
|
||||||
@@ -55,6 +68,10 @@ where
|
|||||||
self.reversed()
|
self.reversed()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn missing(self) -> T {
|
||||||
|
self.red()
|
||||||
|
}
|
||||||
|
|
||||||
fn primary(self) -> T {
|
fn primary(self) -> T {
|
||||||
self.cyan()
|
self.cyan()
|
||||||
}
|
}
|
||||||
@@ -72,9 +89,17 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn unmonitored(self) -> T {
|
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 {
|
fn warning(self) -> T {
|
||||||
self.magenta()
|
self.magenta()
|
||||||
}
|
}
|
||||||
|
|||||||
+26
-1
@@ -23,6 +23,16 @@ mod test {
|
|||||||
assert_eq!(Style::new().default(), Style::new().white());
|
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]
|
#[test]
|
||||||
fn test_style_failure() {
|
fn test_style_failure() {
|
||||||
assert_eq!(Style::new().failure(), Style::new().red());
|
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]
|
#[test]
|
||||||
fn test_style_primary() {
|
fn test_style_primary() {
|
||||||
assert_eq!(Style::new().primary(), Style::new().cyan());
|
assert_eq!(Style::new().primary(), Style::new().cyan());
|
||||||
@@ -63,7 +78,17 @@ mod test {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_style_unmonitored() {
|
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]
|
#[test]
|
||||||
|
|||||||
Reference in New Issue
Block a user