feat(handler): History tab support
This commit is contained in:
@@ -94,7 +94,7 @@ Key:
|
|||||||
| 🕒 | ✅ | Search your library |
|
| 🕒 | ✅ | Search your library |
|
||||||
| 🕒 | ✅ | Add series to your library |
|
| 🕒 | ✅ | Add series to your library |
|
||||||
| 🕒 | ✅ | Delete series, downloads, indexers, root folders, and episode files |
|
| 🕒 | ✅ | Delete series, downloads, indexers, root folders, and episode files |
|
||||||
| 🕒 | ✅ | Mark history events as failed |
|
| 🚫 | ✅ | Mark history events as failed |
|
||||||
| 🕒 | ✅ | Trigger automatic searches for series, seasons, or episodes |
|
| 🕒 | ✅ | Trigger automatic searches for series, seasons, or episodes |
|
||||||
| 🕒 | ✅ | Trigger refresh and disk scan for series and downloads |
|
| 🕒 | ✅ | Trigger refresh and disk scan for series and downloads |
|
||||||
| 🕒 | ✅ | Manually search for series, seasons, or episodes |
|
| 🕒 | ✅ | Manually search for series, seasons, or episodes |
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ impl<'a> App<'a> {
|
|||||||
}
|
}
|
||||||
ActiveSonarrBlock::History => {
|
ActiveSonarrBlock::History => {
|
||||||
self
|
self
|
||||||
.dispatch_network_event(SonarrEvent::GetHistory(None).into())
|
.dispatch_network_event(SonarrEvent::GetHistory(Some(10000)).into())
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
ActiveSonarrBlock::RootFolders => {
|
ActiveSonarrBlock::RootFolders => {
|
||||||
|
|||||||
@@ -25,9 +25,8 @@ pub static SERIES_CONTEXT_CLUES: [ContextClue; 10] = [
|
|||||||
(DEFAULT_KEYBINDINGS.esc, "cancel filter"),
|
(DEFAULT_KEYBINDINGS.esc, "cancel filter"),
|
||||||
];
|
];
|
||||||
|
|
||||||
pub static HISTORY_CONTEXT_CLUES: [ContextClue; 6] = [
|
pub static HISTORY_CONTEXT_CLUES: [ContextClue; 5] = [
|
||||||
(DEFAULT_KEYBINDINGS.sort, DEFAULT_KEYBINDINGS.sort.desc),
|
(DEFAULT_KEYBINDINGS.sort, DEFAULT_KEYBINDINGS.sort.desc),
|
||||||
(DEFAULT_KEYBINDINGS.delete, "mark as failed"),
|
|
||||||
(DEFAULT_KEYBINDINGS.search, DEFAULT_KEYBINDINGS.search.desc),
|
(DEFAULT_KEYBINDINGS.search, DEFAULT_KEYBINDINGS.search.desc),
|
||||||
(DEFAULT_KEYBINDINGS.filter, DEFAULT_KEYBINDINGS.filter.desc),
|
(DEFAULT_KEYBINDINGS.filter, DEFAULT_KEYBINDINGS.filter.desc),
|
||||||
(
|
(
|
||||||
|
|||||||
@@ -96,11 +96,6 @@ mod tests {
|
|||||||
|
|
||||||
let (key_binding, description) = history_context_clues_iter.next().unwrap();
|
let (key_binding, description) = history_context_clues_iter.next().unwrap();
|
||||||
|
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.delete);
|
|
||||||
assert_str_eq!(*description, "mark as failed");
|
|
||||||
|
|
||||||
let (key_binding, description) = history_context_clues_iter.next().unwrap();
|
|
||||||
|
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.search);
|
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.search);
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.search.desc);
|
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.search.desc);
|
||||||
|
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ mod tests {
|
|||||||
assert!(app.is_loading);
|
assert!(app.is_loading);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
sync_network_rx.recv().await.unwrap(),
|
sync_network_rx.recv().await.unwrap(),
|
||||||
SonarrEvent::GetHistory(None).into()
|
SonarrEvent::GetHistory(Some(10000)).into()
|
||||||
);
|
);
|
||||||
assert!(!app.data.sonarr_data.prompt_confirm);
|
assert!(!app.data.sonarr_data.prompt_confirm);
|
||||||
assert_eq!(app.tick_count, 0);
|
assert_eq!(app.tick_count, 0);
|
||||||
|
|||||||
@@ -475,8 +475,6 @@ mod tests {
|
|||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
|
|
||||||
use crate::handlers::sonarr_handlers::downloads::DownloadsHandler;
|
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
const ESC_KEY: Key = DEFAULT_KEYBINDINGS.esc.key;
|
const ESC_KEY: Key = DEFAULT_KEYBINDINGS.esc.key;
|
||||||
@@ -547,7 +545,7 @@ mod tests {
|
|||||||
app.push_navigation_stack(ActiveSonarrBlock::Blocklist.into());
|
app.push_navigation_stack(ActiveSonarrBlock::Blocklist.into());
|
||||||
app.push_navigation_stack(ActiveSonarrBlock::Blocklist.into());
|
app.push_navigation_stack(ActiveSonarrBlock::Blocklist.into());
|
||||||
|
|
||||||
DownloadsHandler::with(ESC_KEY, &mut app, ActiveSonarrBlock::Blocklist, None).handle();
|
BlocklistHandler::with(ESC_KEY, &mut app, ActiveSonarrBlock::Blocklist, None).handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), ActiveSonarrBlock::Blocklist.into());
|
assert_eq!(app.get_current_route(), ActiveSonarrBlock::Blocklist.into());
|
||||||
assert!(app.error.text.is_empty());
|
assert!(app.error.text.is_empty());
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,354 @@
|
|||||||
|
use crate::app::key_binding::DEFAULT_KEYBINDINGS;
|
||||||
|
use crate::app::App;
|
||||||
|
use crate::event::Key;
|
||||||
|
use crate::handlers::sonarr_handlers::handle_change_tab_left_right_keys;
|
||||||
|
use crate::handlers::{handle_clear_errors, KeyEventHandler};
|
||||||
|
use crate::models::servarr_data::sonarr::sonarr_data::{ActiveSonarrBlock, HISTORY_BLOCKS};
|
||||||
|
use crate::models::sonarr_models::SonarrHistoryItem;
|
||||||
|
use crate::models::stateful_table::SortOption;
|
||||||
|
use crate::models::{HorizontallyScrollableText, Scrollable};
|
||||||
|
use crate::{handle_text_box_keys, handle_text_box_left_right_keys};
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
#[path = "history_handler_tests.rs"]
|
||||||
|
mod history_handler_tests;
|
||||||
|
|
||||||
|
pub(super) struct HistoryHandler<'a, 'b> {
|
||||||
|
key: Key,
|
||||||
|
app: &'a mut App<'b>,
|
||||||
|
active_sonarr_block: ActiveSonarrBlock,
|
||||||
|
_context: Option<ActiveSonarrBlock>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for HistoryHandler<'a, 'b> {
|
||||||
|
fn accepts(active_block: ActiveSonarrBlock) -> bool {
|
||||||
|
HISTORY_BLOCKS.contains(&active_block)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn with(
|
||||||
|
key: Key,
|
||||||
|
app: &'a mut App<'b>,
|
||||||
|
active_block: ActiveSonarrBlock,
|
||||||
|
context: Option<ActiveSonarrBlock>,
|
||||||
|
) -> Self {
|
||||||
|
HistoryHandler {
|
||||||
|
key,
|
||||||
|
app,
|
||||||
|
active_sonarr_block: active_block,
|
||||||
|
_context: context,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_key(&self) -> Key {
|
||||||
|
self.key
|
||||||
|
}
|
||||||
|
|
||||||
|
fn is_ready(&self) -> bool {
|
||||||
|
!self.app.is_loading && !self.app.data.sonarr_data.history.is_empty()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn handle_scroll_up(&mut self) {
|
||||||
|
match self.active_sonarr_block {
|
||||||
|
ActiveSonarrBlock::History => self.app.data.sonarr_data.history.scroll_up(),
|
||||||
|
ActiveSonarrBlock::HistorySortPrompt => self
|
||||||
|
.app
|
||||||
|
.data
|
||||||
|
.sonarr_data
|
||||||
|
.history
|
||||||
|
.sort
|
||||||
|
.as_mut()
|
||||||
|
.unwrap()
|
||||||
|
.scroll_up(),
|
||||||
|
_ => (),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn handle_scroll_down(&mut self) {
|
||||||
|
match self.active_sonarr_block {
|
||||||
|
ActiveSonarrBlock::History => self.app.data.sonarr_data.history.scroll_down(),
|
||||||
|
ActiveSonarrBlock::HistorySortPrompt => self
|
||||||
|
.app
|
||||||
|
.data
|
||||||
|
.sonarr_data
|
||||||
|
.history
|
||||||
|
.sort
|
||||||
|
.as_mut()
|
||||||
|
.unwrap()
|
||||||
|
.scroll_down(),
|
||||||
|
_ => (),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn handle_home(&mut self) {
|
||||||
|
match self.active_sonarr_block {
|
||||||
|
ActiveSonarrBlock::History => self.app.data.sonarr_data.history.scroll_to_top(),
|
||||||
|
ActiveSonarrBlock::SearchHistory => {
|
||||||
|
self
|
||||||
|
.app
|
||||||
|
.data
|
||||||
|
.sonarr_data
|
||||||
|
.history
|
||||||
|
.search
|
||||||
|
.as_mut()
|
||||||
|
.unwrap()
|
||||||
|
.scroll_home();
|
||||||
|
}
|
||||||
|
ActiveSonarrBlock::FilterHistory => {
|
||||||
|
self
|
||||||
|
.app
|
||||||
|
.data
|
||||||
|
.sonarr_data
|
||||||
|
.history
|
||||||
|
.filter
|
||||||
|
.as_mut()
|
||||||
|
.unwrap()
|
||||||
|
.scroll_home();
|
||||||
|
}
|
||||||
|
ActiveSonarrBlock::HistorySortPrompt => self
|
||||||
|
.app
|
||||||
|
.data
|
||||||
|
.sonarr_data
|
||||||
|
.history
|
||||||
|
.sort
|
||||||
|
.as_mut()
|
||||||
|
.unwrap()
|
||||||
|
.scroll_to_top(),
|
||||||
|
_ => (),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn handle_end(&mut self) {
|
||||||
|
match self.active_sonarr_block {
|
||||||
|
ActiveSonarrBlock::History => self.app.data.sonarr_data.history.scroll_to_bottom(),
|
||||||
|
ActiveSonarrBlock::SearchHistory => self
|
||||||
|
.app
|
||||||
|
.data
|
||||||
|
.sonarr_data
|
||||||
|
.history
|
||||||
|
.search
|
||||||
|
.as_mut()
|
||||||
|
.unwrap()
|
||||||
|
.reset_offset(),
|
||||||
|
ActiveSonarrBlock::FilterHistory => self
|
||||||
|
.app
|
||||||
|
.data
|
||||||
|
.sonarr_data
|
||||||
|
.history
|
||||||
|
.filter
|
||||||
|
.as_mut()
|
||||||
|
.unwrap()
|
||||||
|
.reset_offset(),
|
||||||
|
ActiveSonarrBlock::HistorySortPrompt => self
|
||||||
|
.app
|
||||||
|
.data
|
||||||
|
.sonarr_data
|
||||||
|
.history
|
||||||
|
.sort
|
||||||
|
.as_mut()
|
||||||
|
.unwrap()
|
||||||
|
.scroll_to_bottom(),
|
||||||
|
_ => (),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn handle_delete(&mut self) {}
|
||||||
|
|
||||||
|
fn handle_left_right_action(&mut self) {
|
||||||
|
match self.active_sonarr_block {
|
||||||
|
ActiveSonarrBlock::History => handle_change_tab_left_right_keys(self.app, self.key),
|
||||||
|
ActiveSonarrBlock::SearchHistory => {
|
||||||
|
handle_text_box_left_right_keys!(
|
||||||
|
self,
|
||||||
|
self.key,
|
||||||
|
self.app.data.sonarr_data.history.search.as_mut().unwrap()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
ActiveSonarrBlock::FilterHistory => {
|
||||||
|
handle_text_box_left_right_keys!(
|
||||||
|
self,
|
||||||
|
self.key,
|
||||||
|
self.app.data.sonarr_data.history.filter.as_mut().unwrap()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn handle_submit(&mut self) {
|
||||||
|
match self.active_sonarr_block {
|
||||||
|
ActiveSonarrBlock::SearchHistory => {
|
||||||
|
self.app.pop_navigation_stack();
|
||||||
|
self.app.should_ignore_quit_key = false;
|
||||||
|
|
||||||
|
if self.app.data.sonarr_data.history.search.is_some() {
|
||||||
|
let has_match = self
|
||||||
|
.app
|
||||||
|
.data
|
||||||
|
.sonarr_data
|
||||||
|
.history
|
||||||
|
.apply_search(|history| &history.source_title.text);
|
||||||
|
|
||||||
|
if !has_match {
|
||||||
|
self
|
||||||
|
.app
|
||||||
|
.push_navigation_stack(ActiveSonarrBlock::SearchHistoryError.into());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ActiveSonarrBlock::FilterHistory => {
|
||||||
|
self.app.pop_navigation_stack();
|
||||||
|
self.app.should_ignore_quit_key = false;
|
||||||
|
|
||||||
|
if self.app.data.sonarr_data.history.filter.is_some() {
|
||||||
|
let has_matches = self
|
||||||
|
.app
|
||||||
|
.data
|
||||||
|
.sonarr_data
|
||||||
|
.history
|
||||||
|
.apply_filter(|history| &history.source_title.text);
|
||||||
|
|
||||||
|
if !has_matches {
|
||||||
|
self
|
||||||
|
.app
|
||||||
|
.push_navigation_stack(ActiveSonarrBlock::FilterHistoryError.into());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ActiveSonarrBlock::HistorySortPrompt => {
|
||||||
|
self
|
||||||
|
.app
|
||||||
|
.data
|
||||||
|
.sonarr_data
|
||||||
|
.history
|
||||||
|
.items
|
||||||
|
.sort_by(|a, b| a.id.cmp(&b.id));
|
||||||
|
self.app.data.sonarr_data.history.apply_sorting();
|
||||||
|
|
||||||
|
self.app.pop_navigation_stack();
|
||||||
|
}
|
||||||
|
ActiveSonarrBlock::History => {
|
||||||
|
self
|
||||||
|
.app
|
||||||
|
.push_navigation_stack(ActiveSonarrBlock::HistoryItemDetails.into());
|
||||||
|
}
|
||||||
|
_ => (),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn handle_esc(&mut self) {
|
||||||
|
match self.active_sonarr_block {
|
||||||
|
ActiveSonarrBlock::FilterHistory | ActiveSonarrBlock::FilterHistoryError => {
|
||||||
|
self.app.pop_navigation_stack();
|
||||||
|
self.app.data.sonarr_data.history.reset_filter();
|
||||||
|
self.app.should_ignore_quit_key = false;
|
||||||
|
}
|
||||||
|
ActiveSonarrBlock::SearchHistory | ActiveSonarrBlock::SearchHistoryError => {
|
||||||
|
self.app.pop_navigation_stack();
|
||||||
|
self.app.data.sonarr_data.history.reset_search();
|
||||||
|
self.app.should_ignore_quit_key = false;
|
||||||
|
}
|
||||||
|
ActiveSonarrBlock::HistoryItemDetails | ActiveSonarrBlock::HistorySortPrompt => {
|
||||||
|
self.app.pop_navigation_stack();
|
||||||
|
}
|
||||||
|
_ => handle_clear_errors(self.app),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn handle_char_key_event(&mut self) {
|
||||||
|
let key = self.key;
|
||||||
|
match self.active_sonarr_block {
|
||||||
|
ActiveSonarrBlock::History => match self.key {
|
||||||
|
_ if key == DEFAULT_KEYBINDINGS.search.key => {
|
||||||
|
self
|
||||||
|
.app
|
||||||
|
.push_navigation_stack(ActiveSonarrBlock::SearchHistory.into());
|
||||||
|
self.app.data.sonarr_data.history.search = Some(HorizontallyScrollableText::default());
|
||||||
|
self.app.should_ignore_quit_key = true;
|
||||||
|
}
|
||||||
|
_ if key == DEFAULT_KEYBINDINGS.filter.key => {
|
||||||
|
self
|
||||||
|
.app
|
||||||
|
.push_navigation_stack(ActiveSonarrBlock::FilterHistory.into());
|
||||||
|
self.app.data.sonarr_data.history.reset_filter();
|
||||||
|
self.app.data.sonarr_data.history.filter = Some(HorizontallyScrollableText::default());
|
||||||
|
self.app.should_ignore_quit_key = true;
|
||||||
|
}
|
||||||
|
_ if key == DEFAULT_KEYBINDINGS.refresh.key => {
|
||||||
|
self.app.should_refresh = true;
|
||||||
|
}
|
||||||
|
_ if key == DEFAULT_KEYBINDINGS.sort.key => {
|
||||||
|
self
|
||||||
|
.app
|
||||||
|
.data
|
||||||
|
.sonarr_data
|
||||||
|
.history
|
||||||
|
.sorting(history_sorting_options());
|
||||||
|
self
|
||||||
|
.app
|
||||||
|
.push_navigation_stack(ActiveSonarrBlock::HistorySortPrompt.into());
|
||||||
|
}
|
||||||
|
_ => (),
|
||||||
|
},
|
||||||
|
ActiveSonarrBlock::SearchHistory => {
|
||||||
|
handle_text_box_keys!(
|
||||||
|
self,
|
||||||
|
key,
|
||||||
|
self.app.data.sonarr_data.history.search.as_mut().unwrap()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
ActiveSonarrBlock::FilterHistory => {
|
||||||
|
handle_text_box_keys!(
|
||||||
|
self,
|
||||||
|
key,
|
||||||
|
self.app.data.sonarr_data.history.filter.as_mut().unwrap()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
_ => (),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn history_sorting_options() -> Vec<SortOption<SonarrHistoryItem>> {
|
||||||
|
vec![
|
||||||
|
SortOption {
|
||||||
|
name: "Source Title",
|
||||||
|
cmp_fn: Some(|a, b| {
|
||||||
|
a.source_title
|
||||||
|
.text
|
||||||
|
.to_lowercase()
|
||||||
|
.cmp(&b.source_title.text.to_lowercase())
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
SortOption {
|
||||||
|
name: "Event Type",
|
||||||
|
cmp_fn: Some(|a, b| {
|
||||||
|
a.event_type
|
||||||
|
.to_lowercase()
|
||||||
|
.cmp(&b.event_type.to_lowercase())
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
SortOption {
|
||||||
|
name: "Language",
|
||||||
|
cmp_fn: Some(|a, b| {
|
||||||
|
a.language
|
||||||
|
.name
|
||||||
|
.to_lowercase()
|
||||||
|
.cmp(&b.language.name.to_lowercase())
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
SortOption {
|
||||||
|
name: "Quality",
|
||||||
|
cmp_fn: Some(|a, b| {
|
||||||
|
a.quality
|
||||||
|
.quality
|
||||||
|
.name
|
||||||
|
.to_lowercase()
|
||||||
|
.cmp(&b.quality.quality.name.to_lowercase())
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
SortOption {
|
||||||
|
name: "Date",
|
||||||
|
cmp_fn: Some(|a, b| a.date.cmp(&b.date)),
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
use blocklist::BlocklistHandler;
|
use blocklist::BlocklistHandler;
|
||||||
use downloads::DownloadsHandler;
|
use downloads::DownloadsHandler;
|
||||||
|
use history::HistoryHandler;
|
||||||
use library::LibraryHandler;
|
use library::LibraryHandler;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@@ -12,6 +13,7 @@ use super::KeyEventHandler;
|
|||||||
|
|
||||||
mod blocklist;
|
mod blocklist;
|
||||||
mod downloads;
|
mod downloads;
|
||||||
|
mod history;
|
||||||
mod library;
|
mod library;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
@@ -41,6 +43,9 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for SonarrHandler<'a, 'b
|
|||||||
_ if BlocklistHandler::accepts(self.active_sonarr_block) => {
|
_ if BlocklistHandler::accepts(self.active_sonarr_block) => {
|
||||||
BlocklistHandler::with(self.key, self.app, self.active_sonarr_block, self.context).handle()
|
BlocklistHandler::with(self.key, self.app, self.active_sonarr_block, self.context).handle()
|
||||||
}
|
}
|
||||||
|
_ if HistoryHandler::accepts(self.active_sonarr_block) => {
|
||||||
|
HistoryHandler::with(self.key, self.app, self.active_sonarr_block, self.context).handle()
|
||||||
|
}
|
||||||
_ => self.handle_key_event(),
|
_ => self.handle_key_event(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -145,4 +145,24 @@ mod tests {
|
|||||||
active_sonarr_block
|
active_sonarr_block
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[rstest]
|
||||||
|
fn test_delegates_history_blocks_to_history_handler(
|
||||||
|
#[values(
|
||||||
|
ActiveSonarrBlock::History,
|
||||||
|
ActiveSonarrBlock::HistoryItemDetails,
|
||||||
|
ActiveSonarrBlock::HistorySortPrompt,
|
||||||
|
ActiveSonarrBlock::FilterHistory,
|
||||||
|
ActiveSonarrBlock::FilterHistoryError,
|
||||||
|
ActiveSonarrBlock::SearchHistory,
|
||||||
|
ActiveSonarrBlock::SearchHistoryError
|
||||||
|
)]
|
||||||
|
active_sonarr_block: ActiveSonarrBlock,
|
||||||
|
) {
|
||||||
|
test_handler_delegation!(
|
||||||
|
SonarrHandler,
|
||||||
|
ActiveSonarrBlock::History,
|
||||||
|
active_sonarr_block
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ pub enum ActiveSonarrBlock {
|
|||||||
FilterSeriesHistory,
|
FilterSeriesHistory,
|
||||||
FilterSeriesHistoryError,
|
FilterSeriesHistoryError,
|
||||||
History,
|
History,
|
||||||
HistoryDetails,
|
HistoryItemDetails,
|
||||||
HistorySortPrompt,
|
HistorySortPrompt,
|
||||||
Indexers,
|
Indexers,
|
||||||
IndexerSettingsConfirmPrompt,
|
IndexerSettingsConfirmPrompt,
|
||||||
@@ -252,8 +252,6 @@ pub enum ActiveSonarrBlock {
|
|||||||
ManualSeasonSearch,
|
ManualSeasonSearch,
|
||||||
ManualSeasonSearchConfirmPrompt,
|
ManualSeasonSearchConfirmPrompt,
|
||||||
ManualSeasonSearchSortPrompt,
|
ManualSeasonSearchSortPrompt,
|
||||||
MarkHistoryItemAsFailedConfirmPrompt,
|
|
||||||
MarkHistoryItemAsFailedPrompt,
|
|
||||||
RootFolders,
|
RootFolders,
|
||||||
SearchEpisodes,
|
SearchEpisodes,
|
||||||
SearchEpisodesError,
|
SearchEpisodesError,
|
||||||
@@ -372,6 +370,16 @@ pub const DELETE_SERIES_SELECTION_BLOCKS: &[&[ActiveSonarrBlock]] = &[
|
|||||||
&[ActiveSonarrBlock::DeleteSeriesConfirmPrompt],
|
&[ActiveSonarrBlock::DeleteSeriesConfirmPrompt],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
pub static HISTORY_BLOCKS: [ActiveSonarrBlock; 7] = [
|
||||||
|
ActiveSonarrBlock::History,
|
||||||
|
ActiveSonarrBlock::HistoryItemDetails,
|
||||||
|
ActiveSonarrBlock::HistorySortPrompt,
|
||||||
|
ActiveSonarrBlock::FilterHistory,
|
||||||
|
ActiveSonarrBlock::FilterHistoryError,
|
||||||
|
ActiveSonarrBlock::SearchHistory,
|
||||||
|
ActiveSonarrBlock::SearchHistoryError,
|
||||||
|
];
|
||||||
|
|
||||||
impl From<ActiveSonarrBlock> for Route {
|
impl From<ActiveSonarrBlock> for Route {
|
||||||
fn from(active_sonarr_block: ActiveSonarrBlock) -> Route {
|
fn from(active_sonarr_block: ActiveSonarrBlock) -> Route {
|
||||||
Route::Sonarr(active_sonarr_block, None)
|
Route::Sonarr(active_sonarr_block, None)
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ mod tests {
|
|||||||
use crate::models::servarr_data::sonarr::sonarr_data::{
|
use crate::models::servarr_data::sonarr::sonarr_data::{
|
||||||
ActiveSonarrBlock, ADD_SERIES_BLOCKS, ADD_SERIES_SELECTION_BLOCKS, BLOCKLIST_BLOCKS,
|
ActiveSonarrBlock, ADD_SERIES_BLOCKS, ADD_SERIES_SELECTION_BLOCKS, BLOCKLIST_BLOCKS,
|
||||||
DELETE_SERIES_BLOCKS, DELETE_SERIES_SELECTION_BLOCKS, DOWNLOADS_BLOCKS, EDIT_SERIES_BLOCKS,
|
DELETE_SERIES_BLOCKS, DELETE_SERIES_SELECTION_BLOCKS, DOWNLOADS_BLOCKS, EDIT_SERIES_BLOCKS,
|
||||||
EDIT_SERIES_SELECTION_BLOCKS, LIBRARY_BLOCKS,
|
EDIT_SERIES_SELECTION_BLOCKS, HISTORY_BLOCKS, LIBRARY_BLOCKS,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -374,5 +374,17 @@ mod tests {
|
|||||||
);
|
);
|
||||||
assert_eq!(delete_series_block_iter.next(), None);
|
assert_eq!(delete_series_block_iter.next(), None);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_history_blocks_contents() {
|
||||||
|
assert_eq!(HISTORY_BLOCKS.len(), 7);
|
||||||
|
assert!(HISTORY_BLOCKS.contains(&ActiveSonarrBlock::History));
|
||||||
|
assert!(HISTORY_BLOCKS.contains(&ActiveSonarrBlock::HistoryItemDetails));
|
||||||
|
assert!(HISTORY_BLOCKS.contains(&ActiveSonarrBlock::HistorySortPrompt));
|
||||||
|
assert!(HISTORY_BLOCKS.contains(&ActiveSonarrBlock::FilterHistory));
|
||||||
|
assert!(HISTORY_BLOCKS.contains(&ActiveSonarrBlock::FilterHistoryError));
|
||||||
|
assert!(HISTORY_BLOCKS.contains(&ActiveSonarrBlock::SearchHistory));
|
||||||
|
assert!(HISTORY_BLOCKS.contains(&ActiveSonarrBlock::SearchHistoryError));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use crate::models::servarr_data::sonarr::sonarr_data::{ActiveSonarrBlock, BLOCKL
|
|||||||
use crate::models::sonarr_models::BlocklistItem;
|
use crate::models::sonarr_models::BlocklistItem;
|
||||||
use crate::models::Route;
|
use crate::models::Route;
|
||||||
use crate::ui::styles::ManagarrStyle;
|
use crate::ui::styles::ManagarrStyle;
|
||||||
use crate::ui::utils::{get_width_from_percentage, layout_block_top_border};
|
use crate::ui::utils::layout_block_top_border;
|
||||||
use crate::ui::widgets::confirmation_prompt::ConfirmationPrompt;
|
use crate::ui::widgets::confirmation_prompt::ConfirmationPrompt;
|
||||||
use crate::ui::widgets::managarr_table::ManagarrTable;
|
use crate::ui::widgets::managarr_table::ManagarrTable;
|
||||||
use crate::ui::widgets::message::Message;
|
use crate::ui::widgets::message::Message;
|
||||||
@@ -78,11 +78,6 @@ impl DrawUi for BlocklistUi {
|
|||||||
|
|
||||||
fn draw_blocklist_table(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
fn draw_blocklist_table(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||||
if let Route::Sonarr(active_sonarr_block, _) = app.get_current_route() {
|
if let Route::Sonarr(active_sonarr_block, _) = app.get_current_route() {
|
||||||
let current_selection = if app.data.sonarr_data.blocklist.items.is_empty() {
|
|
||||||
BlocklistItem::default()
|
|
||||||
} else {
|
|
||||||
app.data.sonarr_data.blocklist.current_selection().clone()
|
|
||||||
};
|
|
||||||
let blocklist_table_footer = app
|
let blocklist_table_footer = app
|
||||||
.data
|
.data
|
||||||
.sonarr_data
|
.sonarr_data
|
||||||
|
|||||||
Reference in New Issue
Block a user