Created the managarr-demo repository and created a Dockerfile for CI/CD builds. Added Docker sections to the README as well
This commit is contained in:
@@ -165,6 +165,8 @@ fn draw_file_info(f: &mut Frame<'_>, app: &App<'_>, area: Rect) {
|
||||
|
||||
fn draw_movie_details(f: &mut Frame<'_>, app: &App<'_>, area: Rect) {
|
||||
let block = layout_block_top_border();
|
||||
let is_monitored = app.data.radarr_data.movies.current_selection().monitored;
|
||||
let status = app.data.radarr_data.movies.current_selection().status.clone();
|
||||
|
||||
match app.data.radarr_data.movie_details_modal.as_ref() {
|
||||
Some(movie_details_modal) if !app.is_loading => {
|
||||
@@ -183,7 +185,7 @@ fn draw_movie_details(f: &mut Frame<'_>, app: &App<'_>, area: Rect) {
|
||||
.map(|line| {
|
||||
let split = line.split(':').collect::<Vec<&str>>();
|
||||
let title = format!("{}:", split[0]);
|
||||
let style = style_from_download_status(download_status);
|
||||
let style = style_from_download_status(download_status, is_monitored, status.clone());
|
||||
|
||||
Line::from(vec![
|
||||
title.bold().style(style),
|
||||
@@ -518,13 +520,15 @@ fn draw_manual_search_confirm_prompt(f: &mut Frame<'_>, app: &mut App<'_>) {
|
||||
}
|
||||
}
|
||||
|
||||
fn style_from_download_status(download_status: &str) -> Style {
|
||||
fn style_from_download_status(download_status: &str, is_monitored: bool, status: String) -> Style {
|
||||
match download_status {
|
||||
"Downloaded" => Style::new().success(),
|
||||
"Downloaded" => Style::new().downloaded(),
|
||||
"Awaiting Import" => Style::new().awaiting_import(),
|
||||
"Downloading" => Style::new().warning(),
|
||||
"Missing" => Style::new().failure(),
|
||||
_ => Style::new().success(),
|
||||
"Downloading" => Style::new().downloading(),
|
||||
_ if !is_monitored && download_status == "Missing" => Style::new().unmonitored_missing(),
|
||||
_ if status != "released" && download_status == "Missing" => Style::new().unreleased(),
|
||||
"Missing" => Style::new().missing(),
|
||||
_ => Style::new().downloaded(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use pretty_assertions::assert_eq;
|
||||
use ratatui::style::Style;
|
||||
use ratatui::text::Text;
|
||||
use rstest::rstest;
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, MOVIE_DETAILS_BLOCKS};
|
||||
use crate::ui::radarr_ui::library::movie_details_ui::MovieDetailsUi;
|
||||
use crate::ui::radarr_ui::library::movie_details_ui::{decorate_peer_style, MovieDetailsUi, style_from_download_status};
|
||||
use crate::ui::DrawUi;
|
||||
use crate::ui::styles::ManagarrStyle;
|
||||
|
||||
#[test]
|
||||
fn test_movie_details_ui_accepts() {
|
||||
@@ -16,4 +21,44 @@ mod tests {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
#[case("Downloading", true, "", Style::new().downloading())]
|
||||
#[case("Downloaded", true, "", Style::new().downloaded())]
|
||||
#[case("Awaiting Import", true, "", Style::new().awaiting_import())]
|
||||
#[case("Missing", false, "", Style::new().unmonitored_missing())]
|
||||
#[case("Missing", false, "", Style::new().unmonitored_missing())]
|
||||
#[case("Missing", true, "released", Style::new().missing())]
|
||||
#[case("", true, "", Style::new().downloaded())]
|
||||
fn test_style_from_download_status(
|
||||
#[case] download_status: &str,
|
||||
#[case] is_monitored: bool,
|
||||
#[case] movie_status: &str,
|
||||
#[case] expected_style: Style,
|
||||
) {
|
||||
assert_eq!(style_from_download_status(download_status, is_monitored, movie_status.to_owned()), expected_style);
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
#[case(0, 0, PeerStyle::Failure)]
|
||||
#[case(1, 2, PeerStyle::Warning)]
|
||||
#[case(4, 2, PeerStyle::Success)]
|
||||
fn test_decorate_peer_style(
|
||||
#[case] seeders: u64,
|
||||
#[case] leechers: u64,
|
||||
#[case] expected_style: PeerStyle,
|
||||
) {
|
||||
let text = Text::from("test");
|
||||
match expected_style {
|
||||
PeerStyle::Failure => assert_eq!(decorate_peer_style(seeders, leechers, text.clone()), text.failure()),
|
||||
PeerStyle::Warning => assert_eq!(decorate_peer_style(seeders, leechers, text.clone()), text.warning()),
|
||||
PeerStyle::Success => assert_eq!(decorate_peer_style(seeders, leechers, text.clone()), text.success()),
|
||||
}
|
||||
}
|
||||
|
||||
enum PeerStyle {
|
||||
Failure,
|
||||
Warning,
|
||||
Success,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use pretty_assertions::assert_eq;
|
||||
use ratatui::widgets::{Cell, Row};
|
||||
use rstest::rstest;
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
Reference in New Issue
Block a user