feat(ui): Sonarr support for the series details popup
This commit is contained in:
@@ -10,6 +10,7 @@ use crate::{
|
||||
},
|
||||
sonarr::sonarr_context_clues::{
|
||||
HISTORY_CONTEXT_CLUES, SERIES_CONTEXT_CLUES, SERIES_DETAILS_CONTEXT_CLUES,
|
||||
SERIES_HISTORY_CONTEXT_CLUES,
|
||||
},
|
||||
},
|
||||
models::{
|
||||
@@ -80,6 +81,12 @@ impl<'a> SonarrData<'a> {
|
||||
self.delete_series_files = false;
|
||||
self.add_list_exclusion = false;
|
||||
}
|
||||
|
||||
pub fn reset_series_info_tabs(&mut self) {
|
||||
self.series_history = None;
|
||||
self.seasons = StatefulTable::default();
|
||||
self.series_info_tabs.index = 0;
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Default for SonarrData<'a> {
|
||||
@@ -174,7 +181,7 @@ impl<'a> Default for SonarrData<'a> {
|
||||
title: "History",
|
||||
route: ActiveSonarrBlock::SeriesHistory.into(),
|
||||
help: String::new(),
|
||||
contextual_help: Some(build_context_clue_string(&HISTORY_CONTEXT_CLUES)),
|
||||
contextual_help: Some(build_context_clue_string(&SERIES_HISTORY_CONTEXT_CLUES)),
|
||||
},
|
||||
]),
|
||||
}
|
||||
@@ -304,12 +311,13 @@ pub static LIBRARY_BLOCKS: [ActiveSonarrBlock; 7] = [
|
||||
ActiveSonarrBlock::UpdateAllSeriesPrompt,
|
||||
];
|
||||
|
||||
pub static SERIES_DETAILS_BLOCKS: [ActiveSonarrBlock; 11] = [
|
||||
pub static SERIES_DETAILS_BLOCKS: [ActiveSonarrBlock; 12] = [
|
||||
ActiveSonarrBlock::SeriesDetails,
|
||||
ActiveSonarrBlock::SeriesHistory,
|
||||
ActiveSonarrBlock::SearchSeason,
|
||||
ActiveSonarrBlock::SearchSeasonError,
|
||||
ActiveSonarrBlock::UpdateAndScanSeriesPrompt,
|
||||
ActiveSonarrBlock::AutomaticallySearchSeriesPrompt,
|
||||
ActiveSonarrBlock::SearchSeriesHistory,
|
||||
ActiveSonarrBlock::SearchSeriesHistoryError,
|
||||
ActiveSonarrBlock::FilterSeriesHistory,
|
||||
|
||||
@@ -4,6 +4,9 @@ mod tests {
|
||||
use chrono::{DateTime, Utc};
|
||||
use pretty_assertions::{assert_eq, assert_str_eq};
|
||||
|
||||
use crate::app::sonarr::sonarr_context_clues::SERIES_HISTORY_CONTEXT_CLUES;
|
||||
use crate::models::sonarr_models::{Season, SonarrHistoryItem};
|
||||
use crate::models::stateful_table::StatefulTable;
|
||||
use crate::{
|
||||
app::{
|
||||
context_clues::{
|
||||
@@ -56,6 +59,24 @@ mod tests {
|
||||
assert!(!sonarr_data.add_list_exclusion);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_reset_series_info_tabs() {
|
||||
let mut series_history = StatefulTable::default();
|
||||
series_history.set_items(vec![SonarrHistoryItem::default()]);
|
||||
let mut sonarr_data = SonarrData {
|
||||
series_history: Some(series_history),
|
||||
..SonarrData::default()
|
||||
};
|
||||
sonarr_data.seasons.set_items(vec![Season::default()]);
|
||||
sonarr_data.series_info_tabs.index = 1;
|
||||
|
||||
sonarr_data.reset_series_info_tabs();
|
||||
|
||||
assert!(sonarr_data.series_history.is_none());
|
||||
assert!(sonarr_data.seasons.is_empty());
|
||||
assert_eq!(sonarr_data.series_info_tabs.index, 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_sonarr_data_defaults() {
|
||||
let sonarr_data = SonarrData::default();
|
||||
@@ -195,7 +216,7 @@ mod tests {
|
||||
assert!(sonarr_data.series_info_tabs.tabs[1].help.is_empty());
|
||||
assert_eq!(
|
||||
sonarr_data.series_info_tabs.tabs[1].contextual_help,
|
||||
Some(build_context_clue_string(&HISTORY_CONTEXT_CLUES))
|
||||
Some(build_context_clue_string(&SERIES_HISTORY_CONTEXT_CLUES))
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -570,12 +591,13 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_series_details_blocks_contents() {
|
||||
assert_eq!(SERIES_DETAILS_BLOCKS.len(), 11);
|
||||
assert_eq!(SERIES_DETAILS_BLOCKS.len(), 12);
|
||||
assert!(SERIES_DETAILS_BLOCKS.contains(&ActiveSonarrBlock::SeriesDetails));
|
||||
assert!(SERIES_DETAILS_BLOCKS.contains(&ActiveSonarrBlock::SeriesHistory));
|
||||
assert!(SERIES_DETAILS_BLOCKS.contains(&ActiveSonarrBlock::SearchSeason));
|
||||
assert!(SERIES_DETAILS_BLOCKS.contains(&ActiveSonarrBlock::SearchSeasonError));
|
||||
assert!(SERIES_DETAILS_BLOCKS.contains(&ActiveSonarrBlock::UpdateAndScanSeriesPrompt));
|
||||
assert!(SERIES_DETAILS_BLOCKS.contains(&ActiveSonarrBlock::AutomaticallySearchSeriesPrompt));
|
||||
assert!(SERIES_DETAILS_BLOCKS.contains(&ActiveSonarrBlock::SearchSeriesHistory));
|
||||
assert!(SERIES_DETAILS_BLOCKS.contains(&ActiveSonarrBlock::SearchSeriesHistoryError));
|
||||
assert!(SERIES_DETAILS_BLOCKS.contains(&ActiveSonarrBlock::FilterSeriesHistory));
|
||||
|
||||
@@ -32,6 +32,8 @@ pub mod utils {
|
||||
|
||||
let mut seasons = StatefulTable::default();
|
||||
seasons.set_items(vec![Season::default()]);
|
||||
let mut series_history = StatefulTable::default();
|
||||
series_history.set_items(vec![SonarrHistoryItem::default()]);
|
||||
|
||||
let mut sonarr_data = SonarrData {
|
||||
delete_series_files: true,
|
||||
@@ -39,6 +41,7 @@ pub mod utils {
|
||||
add_series_search: Some("test search".into()),
|
||||
edit_root_folder: Some("test path".into()),
|
||||
seasons,
|
||||
series_history: Some(series_history),
|
||||
season_details_modal: Some(season_details_modal),
|
||||
add_searched_series: Some(StatefulTable::default()),
|
||||
..SonarrData::default()
|
||||
|
||||
@@ -239,6 +239,7 @@ impl Eq for Rating {}
|
||||
#[derive(Derivative, Serialize, Deserialize, Debug, Default, Clone, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Season {
|
||||
pub title: Option<String>,
|
||||
#[serde(deserialize_with = "super::from_i64")]
|
||||
pub season_number: i64,
|
||||
pub monitored: bool,
|
||||
|
||||
Reference in New Issue
Block a user