refactor: Migrated the handle_table_events macro into a trait for better IDE support, created a TableEventAdapter wrapper for the KeyEventHandlers to make it so that the trait can be used properly and a simple function to replace the previous call to the handle_table_events macro
This commit is contained in:
Generated
-1
@@ -1386,7 +1386,6 @@ dependencies = [
|
|||||||
"mockall",
|
"mockall",
|
||||||
"mockito",
|
"mockito",
|
||||||
"openssl",
|
"openssl",
|
||||||
"paste",
|
|
||||||
"pretty_assertions",
|
"pretty_assertions",
|
||||||
"ratatui",
|
"ratatui",
|
||||||
"regex",
|
"regex",
|
||||||
|
|||||||
@@ -63,7 +63,6 @@ managarr-tree-widget = "0.24.0"
|
|||||||
indicatif = "0.17.9"
|
indicatif = "0.17.9"
|
||||||
derive_setters = "0.1.6"
|
derive_setters = "0.1.6"
|
||||||
deunicode = "1.6.0"
|
deunicode = "1.6.0"
|
||||||
paste = "1.0.15"
|
|
||||||
openssl = { version = "0.10.70", features = ["vendored"] }
|
openssl = { version = "0.10.70", features = ["vendored"] }
|
||||||
veil = "0.2.0"
|
veil = "0.2.0"
|
||||||
validate_theme_derive = "0.1.0"
|
validate_theme_derive = "0.1.0"
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
use crate::event::Key;
|
use crate::event::Key;
|
||||||
use crate::handle_table_events;
|
|
||||||
use crate::handlers::KeyEventHandler;
|
use crate::handlers::KeyEventHandler;
|
||||||
use crate::handlers::table_handler::TableHandlingConfig;
|
use crate::handlers::table_handler::{TableHandlingConfig, handle_table};
|
||||||
use crate::models::servarr_data::ActiveKeybindingBlock;
|
use crate::models::servarr_data::ActiveKeybindingBlock;
|
||||||
use crate::models::servarr_models::KeybindingItem;
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[path = "keybinding_handler_tests.rs"]
|
#[path = "keybinding_handler_tests.rs"]
|
||||||
@@ -15,20 +13,15 @@ pub(super) struct KeybindingHandler<'a, 'b> {
|
|||||||
app: &'a mut App<'b>,
|
app: &'a mut App<'b>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl KeybindingHandler<'_, '_> {
|
|
||||||
handle_table_events!(
|
|
||||||
self,
|
|
||||||
keybindings,
|
|
||||||
self.app.keymapping_table.as_mut().unwrap(),
|
|
||||||
KeybindingItem
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveKeybindingBlock> for KeybindingHandler<'a, 'b> {
|
impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveKeybindingBlock> for KeybindingHandler<'a, 'b> {
|
||||||
fn handle(&mut self) {
|
fn handle(&mut self) {
|
||||||
let keybinding_table_handling_config = TableHandlingConfig::new(self.app.get_current_route());
|
let keybinding_table_handling_config = TableHandlingConfig::new(self.app.get_current_route());
|
||||||
|
|
||||||
if !self.handle_keybindings_table_events(keybinding_table_handling_config) {
|
if !handle_table(
|
||||||
|
self,
|
||||||
|
|app| app.keymapping_table.as_mut().unwrap(),
|
||||||
|
keybinding_table_handling_config,
|
||||||
|
) {
|
||||||
self.handle_key_event();
|
self.handle_key_event();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -77,4 +70,12 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveKeybindingBlock> for KeybindingHandle
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn handle_char_key_event(&mut self) {}
|
fn handle_char_key_event(&mut self) {}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,6 +93,18 @@ pub trait KeyEventHandler<'a, 'b, T: Into<Route> + Copy> {
|
|||||||
fn handle_submit(&mut self);
|
fn handle_submit(&mut self);
|
||||||
fn handle_esc(&mut self);
|
fn handle_esc(&mut self);
|
||||||
fn handle_char_key_event(&mut self);
|
fn handle_char_key_event(&mut self);
|
||||||
|
|
||||||
|
/// Returns a mutable reference to the application state.
|
||||||
|
///
|
||||||
|
/// This method is used by the trait-based table handler to modify app state during
|
||||||
|
/// table operations (e.g., navigation stack, loading flags).
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b>;
|
||||||
|
|
||||||
|
/// Returns the current navigation route.
|
||||||
|
///
|
||||||
|
/// This method is used by the trait-based table handler to determine which screen
|
||||||
|
/// or mode is currently active, enabling context-aware event handling.
|
||||||
|
fn current_route(&self) -> Route;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_events(key: Key, app: &mut App<'_>) {
|
pub fn handle_events(key: Key, app: &mut App<'_>) {
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
use crate::event::Key;
|
use crate::event::Key;
|
||||||
use crate::handlers::radarr_handlers::handle_change_tab_left_right_keys;
|
use crate::handlers::radarr_handlers::handle_change_tab_left_right_keys;
|
||||||
use crate::handlers::table_handler::TableHandlingConfig;
|
use crate::handlers::table_handler::{TableHandlingConfig, handle_table};
|
||||||
use crate::handlers::{KeyEventHandler, handle_clear_errors, handle_prompt_toggle};
|
use crate::handlers::{KeyEventHandler, handle_clear_errors, handle_prompt_toggle};
|
||||||
|
use crate::matches_key;
|
||||||
use crate::models::radarr_models::BlocklistItem;
|
use crate::models::radarr_models::BlocklistItem;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, BLOCKLIST_BLOCKS};
|
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, BLOCKLIST_BLOCKS};
|
||||||
use crate::models::stateful_table::SortOption;
|
use crate::models::stateful_table::SortOption;
|
||||||
use crate::network::radarr_network::RadarrEvent;
|
use crate::network::radarr_network::RadarrEvent;
|
||||||
use crate::{handle_table_events, matches_key};
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[path = "blocklist_handler_tests.rs"]
|
#[path = "blocklist_handler_tests.rs"]
|
||||||
@@ -21,13 +21,6 @@ pub(super) struct BlocklistHandler<'a, 'b> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl BlocklistHandler<'_, '_> {
|
impl BlocklistHandler<'_, '_> {
|
||||||
handle_table_events!(
|
|
||||||
self,
|
|
||||||
blocklist,
|
|
||||||
self.app.data.radarr_data.blocklist,
|
|
||||||
BlocklistItem
|
|
||||||
);
|
|
||||||
|
|
||||||
fn extract_blocklist_item_id(&self) -> i64 {
|
fn extract_blocklist_item_id(&self) -> i64 {
|
||||||
self.app.data.radarr_data.blocklist.current_selection().id
|
self.app.data.radarr_data.blocklist.current_selection().id
|
||||||
}
|
}
|
||||||
@@ -40,7 +33,11 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for BlocklistHandler<'a,
|
|||||||
.sorting_block(ActiveRadarrBlock::BlocklistSortPrompt.into())
|
.sorting_block(ActiveRadarrBlock::BlocklistSortPrompt.into())
|
||||||
.sort_options(blocklist_sorting_options());
|
.sort_options(blocklist_sorting_options());
|
||||||
|
|
||||||
if !self.handle_blocklist_table_events(blocklist_table_handling_config) {
|
if !handle_table(
|
||||||
|
self,
|
||||||
|
|app| &mut app.data.radarr_data.blocklist,
|
||||||
|
blocklist_table_handling_config,
|
||||||
|
) {
|
||||||
self.handle_key_event();
|
self.handle_key_event();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -176,6 +173,14 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for BlocklistHandler<'a,
|
|||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn blocklist_sorting_options() -> Vec<SortOption<BlocklistItem>> {
|
fn blocklist_sorting_options() -> Vec<SortOption<BlocklistItem>> {
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
use crate::event::Key;
|
use crate::event::Key;
|
||||||
use crate::handlers::KeyEventHandler;
|
use crate::handlers::KeyEventHandler;
|
||||||
use crate::handlers::table_handler::TableHandlingConfig;
|
use crate::handlers::table_handler::{TableHandlingConfig, handle_table};
|
||||||
|
use crate::matches_key;
|
||||||
use crate::models::BlockSelectionState;
|
use crate::models::BlockSelectionState;
|
||||||
use crate::models::radarr_models::CollectionMovie;
|
|
||||||
use crate::models::servarr_data::radarr::radarr_data::{
|
use crate::models::servarr_data::radarr::radarr_data::{
|
||||||
ADD_MOVIE_SELECTION_BLOCKS, ActiveRadarrBlock, COLLECTION_DETAILS_BLOCKS,
|
ADD_MOVIE_SELECTION_BLOCKS, ActiveRadarrBlock, COLLECTION_DETAILS_BLOCKS,
|
||||||
EDIT_COLLECTION_SELECTION_BLOCKS,
|
EDIT_COLLECTION_SELECTION_BLOCKS,
|
||||||
};
|
};
|
||||||
use crate::models::stateful_table::StatefulTable;
|
use crate::models::stateful_table::StatefulTable;
|
||||||
use crate::{handle_table_events, matches_key};
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[path = "collection_details_handler_tests.rs"]
|
#[path = "collection_details_handler_tests.rs"]
|
||||||
@@ -22,21 +21,18 @@ pub(super) struct CollectionDetailsHandler<'a, 'b> {
|
|||||||
_context: Option<ActiveRadarrBlock>,
|
_context: Option<ActiveRadarrBlock>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CollectionDetailsHandler<'_, '_> {
|
impl CollectionDetailsHandler<'_, '_> {}
|
||||||
handle_table_events!(
|
|
||||||
self,
|
|
||||||
collection_movies,
|
|
||||||
self.app.data.radarr_data.collection_movies,
|
|
||||||
CollectionMovie
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for CollectionDetailsHandler<'a, 'b> {
|
impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for CollectionDetailsHandler<'a, 'b> {
|
||||||
fn handle(&mut self) {
|
fn handle(&mut self) {
|
||||||
let collection_movies_table_handling_config =
|
let collection_movies_table_handling_config =
|
||||||
TableHandlingConfig::new(ActiveRadarrBlock::CollectionDetails.into());
|
TableHandlingConfig::new(ActiveRadarrBlock::CollectionDetails.into());
|
||||||
|
|
||||||
if !self.handle_collection_movies_table_events(collection_movies_table_handling_config) {
|
if !handle_table(
|
||||||
|
self,
|
||||||
|
|app| &mut app.data.radarr_data.collection_movies,
|
||||||
|
collection_movies_table_handling_config,
|
||||||
|
) {
|
||||||
self.handle_key_event();
|
self.handle_key_event();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -147,4 +143,12 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for CollectionDetailsHan
|
|||||||
BlockSelectionState::new(EDIT_COLLECTION_SELECTION_BLOCKS);
|
BlockSelectionState::new(EDIT_COLLECTION_SELECTION_BLOCKS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -371,4 +371,12 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for EditCollectionHandle
|
|||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ use crate::event::Key;
|
|||||||
use crate::handlers::radarr_handlers::collections::collection_details_handler::CollectionDetailsHandler;
|
use crate::handlers::radarr_handlers::collections::collection_details_handler::CollectionDetailsHandler;
|
||||||
use crate::handlers::radarr_handlers::collections::edit_collection_handler::EditCollectionHandler;
|
use crate::handlers::radarr_handlers::collections::edit_collection_handler::EditCollectionHandler;
|
||||||
use crate::handlers::radarr_handlers::handle_change_tab_left_right_keys;
|
use crate::handlers::radarr_handlers::handle_change_tab_left_right_keys;
|
||||||
use crate::handlers::table_handler::TableHandlingConfig;
|
use crate::handlers::table_handler::{TableHandlingConfig, handle_table};
|
||||||
use crate::handlers::{KeyEventHandler, handle_clear_errors, handle_prompt_toggle};
|
use crate::handlers::{KeyEventHandler, handle_clear_errors, handle_prompt_toggle};
|
||||||
|
use crate::matches_key;
|
||||||
use crate::models::BlockSelectionState;
|
use crate::models::BlockSelectionState;
|
||||||
use crate::models::radarr_models::Collection;
|
use crate::models::radarr_models::Collection;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::{
|
use crate::models::servarr_data::radarr::radarr_data::{
|
||||||
@@ -12,7 +13,6 @@ use crate::models::servarr_data::radarr::radarr_data::{
|
|||||||
};
|
};
|
||||||
use crate::models::stateful_table::SortOption;
|
use crate::models::stateful_table::SortOption;
|
||||||
use crate::network::radarr_network::RadarrEvent;
|
use crate::network::radarr_network::RadarrEvent;
|
||||||
use crate::{handle_table_events, matches_key};
|
|
||||||
|
|
||||||
mod collection_details_handler;
|
mod collection_details_handler;
|
||||||
mod edit_collection_handler;
|
mod edit_collection_handler;
|
||||||
@@ -28,14 +28,7 @@ pub(super) struct CollectionsHandler<'a, 'b> {
|
|||||||
context: Option<ActiveRadarrBlock>,
|
context: Option<ActiveRadarrBlock>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CollectionsHandler<'_, '_> {
|
impl CollectionsHandler<'_, '_> {}
|
||||||
handle_table_events!(
|
|
||||||
self,
|
|
||||||
collections,
|
|
||||||
self.app.data.radarr_data.collections,
|
|
||||||
Collection
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for CollectionsHandler<'a, 'b> {
|
impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for CollectionsHandler<'a, 'b> {
|
||||||
fn handle(&mut self) {
|
fn handle(&mut self) {
|
||||||
@@ -50,7 +43,11 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for CollectionsHandler<'
|
|||||||
.filter_error_block(ActiveRadarrBlock::FilterCollectionsError.into())
|
.filter_error_block(ActiveRadarrBlock::FilterCollectionsError.into())
|
||||||
.filter_field_fn(|collection| &collection.title.text);
|
.filter_field_fn(|collection| &collection.title.text);
|
||||||
|
|
||||||
if !self.handle_collections_table_events(collections_table_handling_config) {
|
if !handle_table(
|
||||||
|
self,
|
||||||
|
|app| &mut app.data.radarr_data.collections,
|
||||||
|
collections_table_handling_config,
|
||||||
|
) {
|
||||||
match self.active_radarr_block {
|
match self.active_radarr_block {
|
||||||
_ if CollectionDetailsHandler::accepts(self.active_radarr_block) => {
|
_ if CollectionDetailsHandler::accepts(self.active_radarr_block) => {
|
||||||
CollectionDetailsHandler::new(self.key, self.app, self.active_radarr_block, self.context)
|
CollectionDetailsHandler::new(self.key, self.app, self.active_radarr_block, self.context)
|
||||||
@@ -177,6 +174,14 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for CollectionsHandler<'
|
|||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn collections_sorting_options() -> Vec<SortOption<Collection>> {
|
fn collections_sorting_options() -> Vec<SortOption<Collection>> {
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
use crate::event::Key;
|
use crate::event::Key;
|
||||||
use crate::handlers::radarr_handlers::handle_change_tab_left_right_keys;
|
use crate::handlers::radarr_handlers::handle_change_tab_left_right_keys;
|
||||||
use crate::handlers::table_handler::TableHandlingConfig;
|
use crate::handlers::table_handler::{TableHandlingConfig, handle_table};
|
||||||
use crate::handlers::{KeyEventHandler, handle_clear_errors, handle_prompt_toggle};
|
use crate::handlers::{KeyEventHandler, handle_clear_errors, handle_prompt_toggle};
|
||||||
use crate::models::radarr_models::DownloadRecord;
|
use crate::matches_key;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, DOWNLOADS_BLOCKS};
|
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, DOWNLOADS_BLOCKS};
|
||||||
use crate::network::radarr_network::RadarrEvent;
|
use crate::network::radarr_network::RadarrEvent;
|
||||||
use crate::{handle_table_events, matches_key};
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[path = "downloads_handler_tests.rs"]
|
#[path = "downloads_handler_tests.rs"]
|
||||||
@@ -20,13 +19,6 @@ pub(super) struct DownloadsHandler<'a, 'b> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl DownloadsHandler<'_, '_> {
|
impl DownloadsHandler<'_, '_> {
|
||||||
handle_table_events!(
|
|
||||||
self,
|
|
||||||
downloads,
|
|
||||||
self.app.data.radarr_data.downloads,
|
|
||||||
DownloadRecord
|
|
||||||
);
|
|
||||||
|
|
||||||
fn extract_download_id(&self) -> i64 {
|
fn extract_download_id(&self) -> i64 {
|
||||||
self.app.data.radarr_data.downloads.current_selection().id
|
self.app.data.radarr_data.downloads.current_selection().id
|
||||||
}
|
}
|
||||||
@@ -37,7 +29,11 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for DownloadsHandler<'a,
|
|||||||
let downloads_table_handling_config =
|
let downloads_table_handling_config =
|
||||||
TableHandlingConfig::new(ActiveRadarrBlock::Downloads.into());
|
TableHandlingConfig::new(ActiveRadarrBlock::Downloads.into());
|
||||||
|
|
||||||
if !self.handle_downloads_table_events(downloads_table_handling_config) {
|
if !handle_table(
|
||||||
|
self,
|
||||||
|
|app| &mut app.data.radarr_data.downloads,
|
||||||
|
downloads_table_handling_config,
|
||||||
|
) {
|
||||||
self.handle_key_event();
|
self.handle_key_event();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -163,4 +159,12 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for DownloadsHandler<'a,
|
|||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -522,4 +522,12 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for EditIndexerHandler<'
|
|||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -288,4 +288,12 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for IndexerSettingsHandl
|
|||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,16 +4,15 @@ use crate::handlers::radarr_handlers::handle_change_tab_left_right_keys;
|
|||||||
use crate::handlers::radarr_handlers::indexers::edit_indexer_handler::EditIndexerHandler;
|
use crate::handlers::radarr_handlers::indexers::edit_indexer_handler::EditIndexerHandler;
|
||||||
use crate::handlers::radarr_handlers::indexers::edit_indexer_settings_handler::IndexerSettingsHandler;
|
use crate::handlers::radarr_handlers::indexers::edit_indexer_settings_handler::IndexerSettingsHandler;
|
||||||
use crate::handlers::radarr_handlers::indexers::test_all_indexers_handler::TestAllIndexersHandler;
|
use crate::handlers::radarr_handlers::indexers::test_all_indexers_handler::TestAllIndexersHandler;
|
||||||
use crate::handlers::table_handler::TableHandlingConfig;
|
use crate::handlers::table_handler::{TableHandlingConfig, handle_table};
|
||||||
use crate::handlers::{KeyEventHandler, handle_clear_errors, handle_prompt_toggle};
|
use crate::handlers::{KeyEventHandler, handle_clear_errors, handle_prompt_toggle};
|
||||||
|
use crate::matches_key;
|
||||||
use crate::models::BlockSelectionState;
|
use crate::models::BlockSelectionState;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::{
|
use crate::models::servarr_data::radarr::radarr_data::{
|
||||||
ActiveRadarrBlock, EDIT_INDEXER_NZB_SELECTION_BLOCKS, EDIT_INDEXER_TORRENT_SELECTION_BLOCKS,
|
ActiveRadarrBlock, EDIT_INDEXER_NZB_SELECTION_BLOCKS, EDIT_INDEXER_TORRENT_SELECTION_BLOCKS,
|
||||||
INDEXER_SETTINGS_SELECTION_BLOCKS, INDEXERS_BLOCKS,
|
INDEXER_SETTINGS_SELECTION_BLOCKS, INDEXERS_BLOCKS,
|
||||||
};
|
};
|
||||||
use crate::models::servarr_models::Indexer;
|
|
||||||
use crate::network::radarr_network::RadarrEvent;
|
use crate::network::radarr_network::RadarrEvent;
|
||||||
use crate::{handle_table_events, matches_key};
|
|
||||||
|
|
||||||
mod edit_indexer_handler;
|
mod edit_indexer_handler;
|
||||||
mod edit_indexer_settings_handler;
|
mod edit_indexer_settings_handler;
|
||||||
@@ -31,8 +30,6 @@ pub(super) struct IndexersHandler<'a, 'b> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl IndexersHandler<'_, '_> {
|
impl IndexersHandler<'_, '_> {
|
||||||
handle_table_events!(self, indexers, self.app.data.radarr_data.indexers, Indexer);
|
|
||||||
|
|
||||||
fn extract_indexer_id(&self) -> i64 {
|
fn extract_indexer_id(&self) -> i64 {
|
||||||
self.app.data.radarr_data.indexers.current_selection().id
|
self.app.data.radarr_data.indexers.current_selection().id
|
||||||
}
|
}
|
||||||
@@ -43,7 +40,11 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for IndexersHandler<'a,
|
|||||||
let indexer_table_handling_config =
|
let indexer_table_handling_config =
|
||||||
TableHandlingConfig::new(ActiveRadarrBlock::Indexers.into());
|
TableHandlingConfig::new(ActiveRadarrBlock::Indexers.into());
|
||||||
|
|
||||||
if !self.handle_indexers_table_events(indexer_table_handling_config) {
|
if !handle_table(
|
||||||
|
self,
|
||||||
|
|app| &mut app.data.radarr_data.indexers,
|
||||||
|
indexer_table_handling_config,
|
||||||
|
) {
|
||||||
match self.active_radarr_block {
|
match self.active_radarr_block {
|
||||||
_ if EditIndexerHandler::accepts(self.active_radarr_block) => {
|
_ if EditIndexerHandler::accepts(self.active_radarr_block) => {
|
||||||
EditIndexerHandler::new(self.key, self.app, self.active_radarr_block, self.context)
|
EditIndexerHandler::new(self.key, self.app, self.active_radarr_block, self.context)
|
||||||
@@ -206,4 +207,12 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for IndexersHandler<'a,
|
|||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
use crate::event::Key;
|
use crate::event::Key;
|
||||||
use crate::handle_table_events;
|
|
||||||
use crate::handlers::KeyEventHandler;
|
use crate::handlers::KeyEventHandler;
|
||||||
use crate::handlers::table_handler::TableHandlingConfig;
|
use crate::handlers::table_handler::{TableHandlingConfig, handle_table};
|
||||||
use crate::models::servarr_data::modals::IndexerTestResultModalItem;
|
|
||||||
use crate::models::servarr_data::radarr::radarr_data::ActiveRadarrBlock;
|
use crate::models::servarr_data::radarr::radarr_data::ActiveRadarrBlock;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
@@ -17,27 +15,23 @@ pub(super) struct TestAllIndexersHandler<'a, 'b> {
|
|||||||
_context: Option<ActiveRadarrBlock>,
|
_context: Option<ActiveRadarrBlock>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TestAllIndexersHandler<'_, '_> {
|
impl TestAllIndexersHandler<'_, '_> {}
|
||||||
handle_table_events!(
|
|
||||||
self,
|
|
||||||
indexer_test_all_results,
|
|
||||||
self
|
|
||||||
.app
|
|
||||||
.data
|
|
||||||
.radarr_data
|
|
||||||
.indexer_test_all_results
|
|
||||||
.as_mut()
|
|
||||||
.unwrap(),
|
|
||||||
IndexerTestResultModalItem
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for TestAllIndexersHandler<'a, 'b> {
|
impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for TestAllIndexersHandler<'a, 'b> {
|
||||||
fn handle(&mut self) {
|
fn handle(&mut self) {
|
||||||
let test_all_indexers_test_results_table_handler_config =
|
let test_all_indexers_test_results_table_handler_config =
|
||||||
TableHandlingConfig::new(ActiveRadarrBlock::TestAllIndexers.into());
|
TableHandlingConfig::new(ActiveRadarrBlock::TestAllIndexers.into());
|
||||||
|
|
||||||
if !self.handle_indexer_test_all_results_table_events(
|
if !handle_table(
|
||||||
|
self,
|
||||||
|
|app| {
|
||||||
|
app
|
||||||
|
.data
|
||||||
|
.radarr_data
|
||||||
|
.indexer_test_all_results
|
||||||
|
.as_mut()
|
||||||
|
.unwrap()
|
||||||
|
},
|
||||||
test_all_indexers_test_results_table_handler_config,
|
test_all_indexers_test_results_table_handler_config,
|
||||||
) {
|
) {
|
||||||
self.handle_key_event();
|
self.handle_key_event();
|
||||||
@@ -102,4 +96,12 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for TestAllIndexersHandl
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn handle_char_key_event(&mut self) {}
|
fn handle_char_key_event(&mut self) {}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use crate::handlers::table_handler::TableHandlingConfig;
|
use crate::handlers::table_handler::{TableHandlingConfig, handle_table};
|
||||||
use crate::handlers::{KeyEventHandler, handle_prompt_toggle};
|
use crate::handlers::{KeyEventHandler, handle_prompt_toggle};
|
||||||
use crate::models::radarr_models::{
|
use crate::models::radarr_models::{
|
||||||
AddMovieBody, AddMovieOptions, AddMovieSearchResult, CollectionMovie,
|
AddMovieBody, AddMovieOptions, AddMovieSearchResult, CollectionMovie,
|
||||||
@@ -9,9 +9,7 @@ use crate::models::servarr_data::radarr::radarr_data::{
|
|||||||
};
|
};
|
||||||
use crate::models::{BlockSelectionState, Scrollable};
|
use crate::models::{BlockSelectionState, Scrollable};
|
||||||
use crate::network::radarr_network::RadarrEvent;
|
use crate::network::radarr_network::RadarrEvent;
|
||||||
use crate::{
|
use crate::{App, Key, handle_text_box_keys, handle_text_box_left_right_keys, matches_key};
|
||||||
App, Key, handle_table_events, handle_text_box_keys, handle_text_box_left_right_keys, matches_key,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[path = "add_movie_handler_tests.rs"]
|
#[path = "add_movie_handler_tests.rs"]
|
||||||
@@ -25,19 +23,6 @@ pub(super) struct AddMovieHandler<'a, 'b> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl AddMovieHandler<'_, '_> {
|
impl AddMovieHandler<'_, '_> {
|
||||||
handle_table_events!(
|
|
||||||
self,
|
|
||||||
add_movie_search_results,
|
|
||||||
self
|
|
||||||
.app
|
|
||||||
.data
|
|
||||||
.radarr_data
|
|
||||||
.add_searched_movies
|
|
||||||
.as_mut()
|
|
||||||
.expect("add_searched_movies should be initialized"),
|
|
||||||
AddMovieSearchResult
|
|
||||||
);
|
|
||||||
|
|
||||||
fn build_add_movie_body(&mut self) -> AddMovieBody {
|
fn build_add_movie_body(&mut self) -> AddMovieBody {
|
||||||
let add_movie_modal = self
|
let add_movie_modal = self
|
||||||
.app
|
.app
|
||||||
@@ -123,7 +108,18 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for AddMovieHandler<'a,
|
|||||||
let add_movie_table_handling_config =
|
let add_movie_table_handling_config =
|
||||||
TableHandlingConfig::new(ActiveRadarrBlock::AddMovieSearchResults.into());
|
TableHandlingConfig::new(ActiveRadarrBlock::AddMovieSearchResults.into());
|
||||||
|
|
||||||
if !self.handle_add_movie_search_results_table_events(add_movie_table_handling_config) {
|
if !handle_table(
|
||||||
|
self,
|
||||||
|
|app| {
|
||||||
|
app
|
||||||
|
.data
|
||||||
|
.radarr_data
|
||||||
|
.add_searched_movies
|
||||||
|
.as_mut()
|
||||||
|
.expect("add_searched_movies should be initialized")
|
||||||
|
},
|
||||||
|
add_movie_table_handling_config,
|
||||||
|
) {
|
||||||
self.handle_key_event();
|
self.handle_key_event();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -557,4 +553,12 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for AddMovieHandler<'a,
|
|||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,4 +136,12 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for DeleteMovieHandler<'
|
|||||||
self.app.pop_navigation_stack();
|
self.app.pop_navigation_stack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -392,4 +392,12 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for EditMovieHandler<'a,
|
|||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,15 +7,15 @@ use crate::handlers::radarr_handlers::library::edit_movie_handler::EditMovieHand
|
|||||||
use crate::handlers::radarr_handlers::library::movie_details_handler::MovieDetailsHandler;
|
use crate::handlers::radarr_handlers::library::movie_details_handler::MovieDetailsHandler;
|
||||||
use crate::handlers::{KeyEventHandler, handle_clear_errors, handle_prompt_toggle};
|
use crate::handlers::{KeyEventHandler, handle_clear_errors, handle_prompt_toggle};
|
||||||
|
|
||||||
use crate::handlers::table_handler::TableHandlingConfig;
|
use crate::handlers::table_handler::{TableHandlingConfig, handle_table};
|
||||||
|
use crate::matches_key;
|
||||||
use crate::models::radarr_models::Movie;
|
use crate::models::radarr_models::Movie;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::{
|
use crate::models::servarr_data::radarr::radarr_data::{
|
||||||
ActiveRadarrBlock, DELETE_MOVIE_SELECTION_BLOCKS, EDIT_MOVIE_SELECTION_BLOCKS, LIBRARY_BLOCKS,
|
ActiveRadarrBlock, DELETE_MOVIE_SELECTION_BLOCKS, EDIT_MOVIE_SELECTION_BLOCKS, LIBRARY_BLOCKS,
|
||||||
};
|
};
|
||||||
use crate::models::stateful_table::SortOption;
|
use crate::models::stateful_table::SortOption;
|
||||||
use crate::models::{BlockSelectionState, HorizontallyScrollableText};
|
use crate::models::{BlockSelectionState, HorizontallyScrollableText, Route};
|
||||||
use crate::network::radarr_network::RadarrEvent;
|
use crate::network::radarr_network::RadarrEvent;
|
||||||
use crate::{handle_table_events, matches_key};
|
|
||||||
|
|
||||||
mod add_movie_handler;
|
mod add_movie_handler;
|
||||||
mod delete_movie_handler;
|
mod delete_movie_handler;
|
||||||
@@ -34,7 +34,6 @@ pub(super) struct LibraryHandler<'a, 'b> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl LibraryHandler<'_, '_> {
|
impl LibraryHandler<'_, '_> {
|
||||||
handle_table_events!(self, movies, self.app.data.radarr_data.movies, Movie);
|
|
||||||
fn extract_movie_id(&self) -> i64 {
|
fn extract_movie_id(&self) -> i64 {
|
||||||
self.app.data.radarr_data.movies.current_selection().id
|
self.app.data.radarr_data.movies.current_selection().id
|
||||||
}
|
}
|
||||||
@@ -52,7 +51,11 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for LibraryHandler<'a, '
|
|||||||
.filter_error_block(ActiveRadarrBlock::FilterMoviesError.into())
|
.filter_error_block(ActiveRadarrBlock::FilterMoviesError.into())
|
||||||
.filter_field_fn(|movie| &movie.title.text);
|
.filter_field_fn(|movie| &movie.title.text);
|
||||||
|
|
||||||
if !self.handle_movies_table_events(movie_table_handling_config) {
|
if !handle_table(
|
||||||
|
self,
|
||||||
|
|app| &mut app.data.radarr_data.movies,
|
||||||
|
movie_table_handling_config,
|
||||||
|
) {
|
||||||
match self.active_radarr_block {
|
match self.active_radarr_block {
|
||||||
_ if AddMovieHandler::accepts(self.active_radarr_block) => {
|
_ if AddMovieHandler::accepts(self.active_radarr_block) => {
|
||||||
AddMovieHandler::new(self.key, self.app, self.active_radarr_block, self.context).handle();
|
AddMovieHandler::new(self.key, self.app, self.active_radarr_block, self.context).handle();
|
||||||
@@ -215,6 +218,14 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for LibraryHandler<'a, '
|
|||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn movies_sorting_options() -> Vec<SortOption<Movie>> {
|
fn movies_sorting_options() -> Vec<SortOption<Movie>> {
|
||||||
|
|||||||
@@ -2,11 +2,10 @@ use serde_json::Number;
|
|||||||
|
|
||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
use crate::event::Key;
|
use crate::event::Key;
|
||||||
use crate::handlers::table_handler::TableHandlingConfig;
|
use crate::handlers::table_handler::{TableHandlingConfig, handle_table};
|
||||||
use crate::handlers::{KeyEventHandler, handle_prompt_toggle};
|
use crate::handlers::{KeyEventHandler, handle_prompt_toggle};
|
||||||
use crate::models::radarr_models::{
|
use crate::matches_key;
|
||||||
Credit, MovieHistoryItem, RadarrRelease, RadarrReleaseDownloadBody,
|
use crate::models::radarr_models::{RadarrRelease, RadarrReleaseDownloadBody};
|
||||||
};
|
|
||||||
use crate::models::servarr_data::radarr::radarr_data::{
|
use crate::models::servarr_data::radarr::radarr_data::{
|
||||||
ActiveRadarrBlock, EDIT_MOVIE_SELECTION_BLOCKS, MOVIE_DETAILS_BLOCKS,
|
ActiveRadarrBlock, EDIT_MOVIE_SELECTION_BLOCKS, MOVIE_DETAILS_BLOCKS,
|
||||||
};
|
};
|
||||||
@@ -14,7 +13,6 @@ use crate::models::servarr_models::Language;
|
|||||||
use crate::models::stateful_table::SortOption;
|
use crate::models::stateful_table::SortOption;
|
||||||
use crate::models::{BlockSelectionState, Scrollable};
|
use crate::models::{BlockSelectionState, Scrollable};
|
||||||
use crate::network::radarr_network::RadarrEvent;
|
use crate::network::radarr_network::RadarrEvent;
|
||||||
use crate::{handle_table_events, matches_key};
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[path = "movie_details_handler_tests.rs"]
|
#[path = "movie_details_handler_tests.rs"]
|
||||||
@@ -28,59 +26,6 @@ pub(super) struct MovieDetailsHandler<'a, 'b> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl MovieDetailsHandler<'_, '_> {
|
impl MovieDetailsHandler<'_, '_> {
|
||||||
handle_table_events!(
|
|
||||||
self,
|
|
||||||
movie_releases,
|
|
||||||
self
|
|
||||||
.app
|
|
||||||
.data
|
|
||||||
.radarr_data
|
|
||||||
.movie_details_modal
|
|
||||||
.as_mut()
|
|
||||||
.unwrap()
|
|
||||||
.movie_releases,
|
|
||||||
RadarrRelease
|
|
||||||
);
|
|
||||||
handle_table_events!(
|
|
||||||
self,
|
|
||||||
movie_history,
|
|
||||||
self
|
|
||||||
.app
|
|
||||||
.data
|
|
||||||
.radarr_data
|
|
||||||
.movie_details_modal
|
|
||||||
.as_mut()
|
|
||||||
.unwrap()
|
|
||||||
.movie_history,
|
|
||||||
MovieHistoryItem
|
|
||||||
);
|
|
||||||
handle_table_events!(
|
|
||||||
self,
|
|
||||||
movie_cast,
|
|
||||||
self
|
|
||||||
.app
|
|
||||||
.data
|
|
||||||
.radarr_data
|
|
||||||
.movie_details_modal
|
|
||||||
.as_mut()
|
|
||||||
.unwrap()
|
|
||||||
.movie_cast,
|
|
||||||
Credit
|
|
||||||
);
|
|
||||||
handle_table_events!(
|
|
||||||
self,
|
|
||||||
movie_crew,
|
|
||||||
self
|
|
||||||
.app
|
|
||||||
.data
|
|
||||||
.radarr_data
|
|
||||||
.movie_details_modal
|
|
||||||
.as_mut()
|
|
||||||
.unwrap()
|
|
||||||
.movie_crew,
|
|
||||||
Credit
|
|
||||||
);
|
|
||||||
|
|
||||||
fn build_radarr_release_download_body(&self) -> RadarrReleaseDownloadBody {
|
fn build_radarr_release_download_body(&self) -> RadarrReleaseDownloadBody {
|
||||||
let movie_id = self.app.data.radarr_data.movies.current_selection().id;
|
let movie_id = self.app.data.radarr_data.movies.current_selection().id;
|
||||||
let (guid, indexer_id) = {
|
let (guid, indexer_id) = {
|
||||||
@@ -122,11 +67,55 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for MovieDetailsHandler<
|
|||||||
let movie_cast_table_handling_config = TableHandlingConfig::new(ActiveRadarrBlock::Cast.into());
|
let movie_cast_table_handling_config = TableHandlingConfig::new(ActiveRadarrBlock::Cast.into());
|
||||||
let movie_crew_table_handling_config = TableHandlingConfig::new(ActiveRadarrBlock::Crew.into());
|
let movie_crew_table_handling_config = TableHandlingConfig::new(ActiveRadarrBlock::Crew.into());
|
||||||
|
|
||||||
if !self.handle_movie_history_table_events(movie_history_table_handling_config)
|
if !handle_table(
|
||||||
&& !self.handle_movie_releases_table_events(movie_releases_table_handling_config)
|
self,
|
||||||
&& !self.handle_movie_cast_table_events(movie_cast_table_handling_config)
|
|app| {
|
||||||
&& !self.handle_movie_crew_table_events(movie_crew_table_handling_config)
|
&mut app
|
||||||
{
|
.data
|
||||||
|
.radarr_data
|
||||||
|
.movie_details_modal
|
||||||
|
.as_mut()
|
||||||
|
.unwrap()
|
||||||
|
.movie_history
|
||||||
|
},
|
||||||
|
movie_history_table_handling_config,
|
||||||
|
) && !handle_table(
|
||||||
|
self,
|
||||||
|
|app| {
|
||||||
|
&mut app
|
||||||
|
.data
|
||||||
|
.radarr_data
|
||||||
|
.movie_details_modal
|
||||||
|
.as_mut()
|
||||||
|
.unwrap()
|
||||||
|
.movie_releases
|
||||||
|
},
|
||||||
|
movie_releases_table_handling_config,
|
||||||
|
) && !handle_table(
|
||||||
|
self,
|
||||||
|
|app| {
|
||||||
|
&mut app
|
||||||
|
.data
|
||||||
|
.radarr_data
|
||||||
|
.movie_details_modal
|
||||||
|
.as_mut()
|
||||||
|
.unwrap()
|
||||||
|
.movie_cast
|
||||||
|
},
|
||||||
|
movie_cast_table_handling_config,
|
||||||
|
) && !handle_table(
|
||||||
|
self,
|
||||||
|
|app| {
|
||||||
|
&mut app
|
||||||
|
.data
|
||||||
|
.radarr_data
|
||||||
|
.movie_details_modal
|
||||||
|
.as_mut()
|
||||||
|
.unwrap()
|
||||||
|
.movie_crew
|
||||||
|
},
|
||||||
|
movie_crew_table_handling_config,
|
||||||
|
) {
|
||||||
self.handle_key_event();
|
self.handle_key_event();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -385,6 +374,14 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for MovieDetailsHandler<
|
|||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn releases_sorting_options() -> Vec<SortOption<RadarrRelease>> {
|
fn releases_sorting_options() -> Vec<SortOption<RadarrRelease>> {
|
||||||
|
|||||||
@@ -107,6 +107,14 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for RadarrHandler<'a, 'b
|
|||||||
fn handle_esc(&mut self) {}
|
fn handle_esc(&mut self) {}
|
||||||
|
|
||||||
fn handle_char_key_event(&mut self) {}
|
fn handle_char_key_event(&mut self) {}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_change_tab_left_right_keys(app: &mut App<'_>, key: Key) {
|
pub fn handle_change_tab_left_right_keys(app: &mut App<'_>, key: Key) {
|
||||||
|
|||||||
@@ -1,15 +1,13 @@
|
|||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
use crate::event::Key;
|
use crate::event::Key;
|
||||||
use crate::handlers::radarr_handlers::handle_change_tab_left_right_keys;
|
use crate::handlers::radarr_handlers::handle_change_tab_left_right_keys;
|
||||||
use crate::handlers::table_handler::TableHandlingConfig;
|
use crate::handlers::table_handler::{TableHandlingConfig, handle_table};
|
||||||
use crate::handlers::{KeyEventHandler, handle_clear_errors, handle_prompt_toggle};
|
use crate::handlers::{KeyEventHandler, handle_clear_errors, handle_prompt_toggle};
|
||||||
use crate::models::HorizontallyScrollableText;
|
use crate::models::HorizontallyScrollableText;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, ROOT_FOLDERS_BLOCKS};
|
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, ROOT_FOLDERS_BLOCKS};
|
||||||
use crate::models::servarr_models::{AddRootFolderBody, RootFolder};
|
use crate::models::servarr_models::AddRootFolderBody;
|
||||||
use crate::network::radarr_network::RadarrEvent;
|
use crate::network::radarr_network::RadarrEvent;
|
||||||
use crate::{
|
use crate::{handle_text_box_keys, handle_text_box_left_right_keys, matches_key};
|
||||||
handle_table_events, handle_text_box_keys, handle_text_box_left_right_keys, matches_key,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[path = "root_folders_handler_tests.rs"]
|
#[path = "root_folders_handler_tests.rs"]
|
||||||
@@ -23,13 +21,6 @@ pub(super) struct RootFoldersHandler<'a, 'b> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl RootFoldersHandler<'_, '_> {
|
impl RootFoldersHandler<'_, '_> {
|
||||||
handle_table_events!(
|
|
||||||
self,
|
|
||||||
root_folders,
|
|
||||||
self.app.data.radarr_data.root_folders,
|
|
||||||
RootFolder
|
|
||||||
);
|
|
||||||
|
|
||||||
fn build_add_root_folder_body(&mut self) -> AddRootFolderBody {
|
fn build_add_root_folder_body(&mut self) -> AddRootFolderBody {
|
||||||
let edit_root_folder = self
|
let edit_root_folder = self
|
||||||
.app
|
.app
|
||||||
@@ -60,7 +51,11 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for RootFoldersHandler<'
|
|||||||
let root_folder_table_handling_config =
|
let root_folder_table_handling_config =
|
||||||
TableHandlingConfig::new(ActiveRadarrBlock::RootFolders.into());
|
TableHandlingConfig::new(ActiveRadarrBlock::RootFolders.into());
|
||||||
|
|
||||||
if !self.handle_root_folders_table_events(root_folder_table_handling_config) {
|
if !handle_table(
|
||||||
|
self,
|
||||||
|
|app| &mut app.data.radarr_data.root_folders,
|
||||||
|
root_folder_table_handling_config,
|
||||||
|
) {
|
||||||
self.handle_key_event();
|
self.handle_key_event();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -231,4 +226,12 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for RootFoldersHandler<'
|
|||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,4 +124,12 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for SystemHandler<'a, 'b
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -196,4 +196,12 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for SystemDetailsHandler
|
|||||||
self.app.pop_navigation_stack();
|
self.app.pop_navigation_stack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
use crate::event::Key;
|
use crate::event::Key;
|
||||||
use crate::handlers::sonarr_handlers::handle_change_tab_left_right_keys;
|
use crate::handlers::sonarr_handlers::handle_change_tab_left_right_keys;
|
||||||
use crate::handlers::table_handler::TableHandlingConfig;
|
use crate::handlers::table_handler::{TableHandlingConfig, handle_table};
|
||||||
use crate::handlers::{KeyEventHandler, handle_clear_errors, handle_prompt_toggle};
|
use crate::handlers::{KeyEventHandler, handle_clear_errors, handle_prompt_toggle};
|
||||||
|
use crate::matches_key;
|
||||||
use crate::models::servarr_data::sonarr::sonarr_data::{ActiveSonarrBlock, BLOCKLIST_BLOCKS};
|
use crate::models::servarr_data::sonarr::sonarr_data::{ActiveSonarrBlock, BLOCKLIST_BLOCKS};
|
||||||
use crate::models::sonarr_models::BlocklistItem;
|
use crate::models::sonarr_models::BlocklistItem;
|
||||||
use crate::models::stateful_table::SortOption;
|
use crate::models::stateful_table::SortOption;
|
||||||
use crate::network::sonarr_network::SonarrEvent;
|
use crate::network::sonarr_network::SonarrEvent;
|
||||||
use crate::{handle_table_events, matches_key};
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[path = "blocklist_handler_tests.rs"]
|
#[path = "blocklist_handler_tests.rs"]
|
||||||
@@ -21,13 +21,6 @@ pub(super) struct BlocklistHandler<'a, 'b> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl BlocklistHandler<'_, '_> {
|
impl BlocklistHandler<'_, '_> {
|
||||||
handle_table_events!(
|
|
||||||
self,
|
|
||||||
blocklist,
|
|
||||||
self.app.data.sonarr_data.blocklist,
|
|
||||||
BlocklistItem
|
|
||||||
);
|
|
||||||
|
|
||||||
fn extract_blocklist_item_id(&self) -> i64 {
|
fn extract_blocklist_item_id(&self) -> i64 {
|
||||||
self.app.data.sonarr_data.blocklist.current_selection().id
|
self.app.data.sonarr_data.blocklist.current_selection().id
|
||||||
}
|
}
|
||||||
@@ -40,7 +33,11 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for BlocklistHandler<'a,
|
|||||||
.sorting_block(ActiveSonarrBlock::BlocklistSortPrompt.into())
|
.sorting_block(ActiveSonarrBlock::BlocklistSortPrompt.into())
|
||||||
.sort_options(blocklist_sorting_options());
|
.sort_options(blocklist_sorting_options());
|
||||||
|
|
||||||
if !self.handle_blocklist_table_events(blocklist_table_handling_config) {
|
if !handle_table(
|
||||||
|
self,
|
||||||
|
|app| &mut app.data.sonarr_data.blocklist,
|
||||||
|
blocklist_table_handling_config,
|
||||||
|
) {
|
||||||
self.handle_key_event();
|
self.handle_key_event();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -176,6 +173,14 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for BlocklistHandler<'a,
|
|||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn blocklist_sorting_options() -> Vec<SortOption<BlocklistItem>> {
|
fn blocklist_sorting_options() -> Vec<SortOption<BlocklistItem>> {
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
use crate::event::Key;
|
use crate::event::Key;
|
||||||
use crate::handlers::sonarr_handlers::handle_change_tab_left_right_keys;
|
use crate::handlers::sonarr_handlers::handle_change_tab_left_right_keys;
|
||||||
use crate::handlers::table_handler::TableHandlingConfig;
|
use crate::handlers::table_handler::{TableHandlingConfig, handle_table};
|
||||||
use crate::handlers::{KeyEventHandler, handle_clear_errors, handle_prompt_toggle};
|
use crate::handlers::{KeyEventHandler, handle_clear_errors, handle_prompt_toggle};
|
||||||
|
use crate::matches_key;
|
||||||
use crate::models::servarr_data::sonarr::sonarr_data::{ActiveSonarrBlock, DOWNLOADS_BLOCKS};
|
use crate::models::servarr_data::sonarr::sonarr_data::{ActiveSonarrBlock, DOWNLOADS_BLOCKS};
|
||||||
use crate::models::sonarr_models::DownloadRecord;
|
|
||||||
use crate::network::sonarr_network::SonarrEvent;
|
use crate::network::sonarr_network::SonarrEvent;
|
||||||
use crate::{handle_table_events, matches_key};
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[path = "downloads_handler_tests.rs"]
|
#[path = "downloads_handler_tests.rs"]
|
||||||
@@ -20,13 +19,6 @@ pub(super) struct DownloadsHandler<'a, 'b> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl DownloadsHandler<'_, '_> {
|
impl DownloadsHandler<'_, '_> {
|
||||||
handle_table_events!(
|
|
||||||
self,
|
|
||||||
downloads,
|
|
||||||
self.app.data.sonarr_data.downloads,
|
|
||||||
DownloadRecord
|
|
||||||
);
|
|
||||||
|
|
||||||
fn extract_download_id(&self) -> i64 {
|
fn extract_download_id(&self) -> i64 {
|
||||||
self.app.data.sonarr_data.downloads.current_selection().id
|
self.app.data.sonarr_data.downloads.current_selection().id
|
||||||
}
|
}
|
||||||
@@ -37,7 +29,11 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for DownloadsHandler<'a,
|
|||||||
let download_table_handling_config =
|
let download_table_handling_config =
|
||||||
TableHandlingConfig::new(ActiveSonarrBlock::Downloads.into());
|
TableHandlingConfig::new(ActiveSonarrBlock::Downloads.into());
|
||||||
|
|
||||||
if !self.handle_downloads_table_events(download_table_handling_config) {
|
if !handle_table(
|
||||||
|
self,
|
||||||
|
|app| &mut app.data.sonarr_data.downloads,
|
||||||
|
download_table_handling_config,
|
||||||
|
) {
|
||||||
self.handle_key_event();
|
self.handle_key_event();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -163,4 +159,12 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for DownloadsHandler<'a,
|
|||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
use crate::event::Key;
|
use crate::event::Key;
|
||||||
use crate::handlers::sonarr_handlers::handle_change_tab_left_right_keys;
|
use crate::handlers::sonarr_handlers::handle_change_tab_left_right_keys;
|
||||||
use crate::handlers::table_handler::TableHandlingConfig;
|
use crate::handlers::table_handler::{TableHandlingConfig, handle_table};
|
||||||
use crate::handlers::{KeyEventHandler, handle_clear_errors};
|
use crate::handlers::{KeyEventHandler, handle_clear_errors};
|
||||||
|
use crate::matches_key;
|
||||||
use crate::models::servarr_data::sonarr::sonarr_data::{ActiveSonarrBlock, HISTORY_BLOCKS};
|
use crate::models::servarr_data::sonarr::sonarr_data::{ActiveSonarrBlock, HISTORY_BLOCKS};
|
||||||
use crate::models::servarr_models::Language;
|
use crate::models::servarr_models::Language;
|
||||||
use crate::models::sonarr_models::SonarrHistoryItem;
|
use crate::models::sonarr_models::SonarrHistoryItem;
|
||||||
use crate::models::stateful_table::SortOption;
|
use crate::models::stateful_table::SortOption;
|
||||||
use crate::{handle_table_events, matches_key};
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[path = "history_handler_tests.rs"]
|
#[path = "history_handler_tests.rs"]
|
||||||
@@ -20,14 +20,7 @@ pub(super) struct HistoryHandler<'a, 'b> {
|
|||||||
_context: Option<ActiveSonarrBlock>,
|
_context: Option<ActiveSonarrBlock>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HistoryHandler<'_, '_> {
|
impl HistoryHandler<'_, '_> {}
|
||||||
handle_table_events!(
|
|
||||||
self,
|
|
||||||
history,
|
|
||||||
self.app.data.sonarr_data.history,
|
|
||||||
SonarrHistoryItem
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for HistoryHandler<'a, 'b> {
|
impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for HistoryHandler<'a, 'b> {
|
||||||
fn handle(&mut self) {
|
fn handle(&mut self) {
|
||||||
@@ -41,7 +34,11 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for HistoryHandler<'a, '
|
|||||||
.filter_error_block(ActiveSonarrBlock::FilterHistoryError.into())
|
.filter_error_block(ActiveSonarrBlock::FilterHistoryError.into())
|
||||||
.filter_field_fn(|history| &history.source_title.text);
|
.filter_field_fn(|history| &history.source_title.text);
|
||||||
|
|
||||||
if !self.handle_history_table_events(history_table_handling_config) {
|
if !handle_table(
|
||||||
|
self,
|
||||||
|
|app| &mut app.data.sonarr_data.history,
|
||||||
|
history_table_handling_config,
|
||||||
|
) {
|
||||||
self.handle_key_event();
|
self.handle_key_event();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -119,6 +116,14 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for HistoryHandler<'a, '
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(in crate::handlers::sonarr_handlers) fn history_sorting_options()
|
pub(in crate::handlers::sonarr_handlers) fn history_sorting_options()
|
||||||
|
|||||||
@@ -521,4 +521,12 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for EditIndexerHandler<'
|
|||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -197,4 +197,12 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for IndexerSettingsHandl
|
|||||||
self.app.pop_navigation_stack();
|
self.app.pop_navigation_stack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,16 +4,15 @@ use crate::handlers::sonarr_handlers::handle_change_tab_left_right_keys;
|
|||||||
use crate::handlers::sonarr_handlers::indexers::edit_indexer_handler::EditIndexerHandler;
|
use crate::handlers::sonarr_handlers::indexers::edit_indexer_handler::EditIndexerHandler;
|
||||||
use crate::handlers::sonarr_handlers::indexers::edit_indexer_settings_handler::IndexerSettingsHandler;
|
use crate::handlers::sonarr_handlers::indexers::edit_indexer_settings_handler::IndexerSettingsHandler;
|
||||||
use crate::handlers::sonarr_handlers::indexers::test_all_indexers_handler::TestAllIndexersHandler;
|
use crate::handlers::sonarr_handlers::indexers::test_all_indexers_handler::TestAllIndexersHandler;
|
||||||
use crate::handlers::table_handler::TableHandlingConfig;
|
use crate::handlers::table_handler::{TableHandlingConfig, handle_table};
|
||||||
use crate::handlers::{KeyEventHandler, handle_clear_errors, handle_prompt_toggle};
|
use crate::handlers::{KeyEventHandler, handle_clear_errors, handle_prompt_toggle};
|
||||||
|
use crate::matches_key;
|
||||||
use crate::models::BlockSelectionState;
|
use crate::models::BlockSelectionState;
|
||||||
use crate::models::servarr_data::sonarr::sonarr_data::{
|
use crate::models::servarr_data::sonarr::sonarr_data::{
|
||||||
ActiveSonarrBlock, EDIT_INDEXER_NZB_SELECTION_BLOCKS, EDIT_INDEXER_TORRENT_SELECTION_BLOCKS,
|
ActiveSonarrBlock, EDIT_INDEXER_NZB_SELECTION_BLOCKS, EDIT_INDEXER_TORRENT_SELECTION_BLOCKS,
|
||||||
INDEXER_SETTINGS_SELECTION_BLOCKS, INDEXERS_BLOCKS,
|
INDEXER_SETTINGS_SELECTION_BLOCKS, INDEXERS_BLOCKS,
|
||||||
};
|
};
|
||||||
use crate::models::servarr_models::Indexer;
|
|
||||||
use crate::network::sonarr_network::SonarrEvent;
|
use crate::network::sonarr_network::SonarrEvent;
|
||||||
use crate::{handle_table_events, matches_key};
|
|
||||||
|
|
||||||
mod edit_indexer_handler;
|
mod edit_indexer_handler;
|
||||||
mod edit_indexer_settings_handler;
|
mod edit_indexer_settings_handler;
|
||||||
@@ -31,8 +30,6 @@ pub(super) struct IndexersHandler<'a, 'b> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl IndexersHandler<'_, '_> {
|
impl IndexersHandler<'_, '_> {
|
||||||
handle_table_events!(self, indexers, self.app.data.sonarr_data.indexers, Indexer);
|
|
||||||
|
|
||||||
fn extract_indexer_id(&self) -> i64 {
|
fn extract_indexer_id(&self) -> i64 {
|
||||||
self.app.data.sonarr_data.indexers.current_selection().id
|
self.app.data.sonarr_data.indexers.current_selection().id
|
||||||
}
|
}
|
||||||
@@ -43,7 +40,11 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for IndexersHandler<'a,
|
|||||||
let indexers_table_handling_config =
|
let indexers_table_handling_config =
|
||||||
TableHandlingConfig::new(ActiveSonarrBlock::Indexers.into());
|
TableHandlingConfig::new(ActiveSonarrBlock::Indexers.into());
|
||||||
|
|
||||||
if !self.handle_indexers_table_events(indexers_table_handling_config) {
|
if !handle_table(
|
||||||
|
self,
|
||||||
|
|app| &mut app.data.sonarr_data.indexers,
|
||||||
|
indexers_table_handling_config,
|
||||||
|
) {
|
||||||
match self.active_sonarr_block {
|
match self.active_sonarr_block {
|
||||||
_ if EditIndexerHandler::accepts(self.active_sonarr_block) => {
|
_ if EditIndexerHandler::accepts(self.active_sonarr_block) => {
|
||||||
EditIndexerHandler::new(self.key, self.app, self.active_sonarr_block, self.context)
|
EditIndexerHandler::new(self.key, self.app, self.active_sonarr_block, self.context)
|
||||||
@@ -205,4 +206,12 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for IndexersHandler<'a,
|
|||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
use crate::event::Key;
|
use crate::event::Key;
|
||||||
use crate::handle_table_events;
|
|
||||||
use crate::handlers::KeyEventHandler;
|
use crate::handlers::KeyEventHandler;
|
||||||
use crate::handlers::table_handler::TableHandlingConfig;
|
use crate::handlers::table_handler::{TableHandlingConfig, handle_table};
|
||||||
use crate::models::servarr_data::modals::IndexerTestResultModalItem;
|
|
||||||
use crate::models::servarr_data::sonarr::sonarr_data::ActiveSonarrBlock;
|
use crate::models::servarr_data::sonarr::sonarr_data::ActiveSonarrBlock;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
@@ -17,29 +15,25 @@ pub(super) struct TestAllIndexersHandler<'a, 'b> {
|
|||||||
_context: Option<ActiveSonarrBlock>,
|
_context: Option<ActiveSonarrBlock>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TestAllIndexersHandler<'_, '_> {
|
impl TestAllIndexersHandler<'_, '_> {}
|
||||||
handle_table_events!(
|
|
||||||
self,
|
|
||||||
indexer_test_all_results,
|
|
||||||
self
|
|
||||||
.app
|
|
||||||
.data
|
|
||||||
.sonarr_data
|
|
||||||
.indexer_test_all_results
|
|
||||||
.as_mut()
|
|
||||||
.unwrap(),
|
|
||||||
IndexerTestResultModalItem
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for TestAllIndexersHandler<'a, 'b> {
|
impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for TestAllIndexersHandler<'a, 'b> {
|
||||||
fn handle(&mut self) {
|
fn handle(&mut self) {
|
||||||
let indexer_test_all_results_table_handling_config =
|
let indexer_test_all_results_table_handling_config =
|
||||||
TableHandlingConfig::new(ActiveSonarrBlock::TestAllIndexers.into());
|
TableHandlingConfig::new(ActiveSonarrBlock::TestAllIndexers.into());
|
||||||
|
|
||||||
if !self
|
if !handle_table(
|
||||||
.handle_indexer_test_all_results_table_events(indexer_test_all_results_table_handling_config)
|
self,
|
||||||
{
|
|app| {
|
||||||
|
app
|
||||||
|
.data
|
||||||
|
.sonarr_data
|
||||||
|
.indexer_test_all_results
|
||||||
|
.as_mut()
|
||||||
|
.unwrap()
|
||||||
|
},
|
||||||
|
indexer_test_all_results_table_handling_config,
|
||||||
|
) {
|
||||||
self.handle_key_event();
|
self.handle_key_event();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -102,4 +96,12 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for TestAllIndexersHandl
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn handle_char_key_event(&mut self) {}
|
fn handle_char_key_event(&mut self) {}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use crate::handlers::table_handler::TableHandlingConfig;
|
use crate::handlers::table_handler::{TableHandlingConfig, handle_table};
|
||||||
use crate::handlers::{KeyEventHandler, handle_prompt_toggle};
|
use crate::handlers::{KeyEventHandler, handle_prompt_toggle};
|
||||||
use crate::models::servarr_data::sonarr::modals::AddSeriesModal;
|
use crate::models::servarr_data::sonarr::modals::AddSeriesModal;
|
||||||
use crate::models::servarr_data::sonarr::sonarr_data::{
|
use crate::models::servarr_data::sonarr::sonarr_data::{
|
||||||
@@ -7,9 +7,7 @@ use crate::models::servarr_data::sonarr::sonarr_data::{
|
|||||||
use crate::models::sonarr_models::{AddSeriesBody, AddSeriesOptions, AddSeriesSearchResult};
|
use crate::models::sonarr_models::{AddSeriesBody, AddSeriesOptions, AddSeriesSearchResult};
|
||||||
use crate::models::{BlockSelectionState, Scrollable};
|
use crate::models::{BlockSelectionState, Scrollable};
|
||||||
use crate::network::sonarr_network::SonarrEvent;
|
use crate::network::sonarr_network::SonarrEvent;
|
||||||
use crate::{
|
use crate::{App, Key, handle_text_box_keys, handle_text_box_left_right_keys, matches_key};
|
||||||
App, Key, handle_table_events, handle_text_box_keys, handle_text_box_left_right_keys, matches_key,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[path = "add_series_handler_tests.rs"]
|
#[path = "add_series_handler_tests.rs"]
|
||||||
@@ -23,19 +21,6 @@ pub(super) struct AddSeriesHandler<'a, 'b> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl AddSeriesHandler<'_, '_> {
|
impl AddSeriesHandler<'_, '_> {
|
||||||
handle_table_events!(
|
|
||||||
self,
|
|
||||||
add_searched_series,
|
|
||||||
self
|
|
||||||
.app
|
|
||||||
.data
|
|
||||||
.sonarr_data
|
|
||||||
.add_searched_series
|
|
||||||
.as_mut()
|
|
||||||
.expect("add_searched_series should be initialized"),
|
|
||||||
AddSeriesSearchResult
|
|
||||||
);
|
|
||||||
|
|
||||||
fn build_add_series_body(&mut self) -> AddSeriesBody {
|
fn build_add_series_body(&mut self) -> AddSeriesBody {
|
||||||
let add_series_modal = self
|
let add_series_modal = self
|
||||||
.app
|
.app
|
||||||
@@ -117,7 +102,18 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for AddSeriesHandler<'a,
|
|||||||
let add_series_table_handling_config =
|
let add_series_table_handling_config =
|
||||||
TableHandlingConfig::new(ActiveSonarrBlock::AddSeriesSearchResults.into());
|
TableHandlingConfig::new(ActiveSonarrBlock::AddSeriesSearchResults.into());
|
||||||
|
|
||||||
if !self.handle_add_searched_series_table_events(add_series_table_handling_config) {
|
if !handle_table(
|
||||||
|
self,
|
||||||
|
|app| {
|
||||||
|
app
|
||||||
|
.data
|
||||||
|
.sonarr_data
|
||||||
|
.add_searched_series
|
||||||
|
.as_mut()
|
||||||
|
.expect("add_searched_series should be initialized")
|
||||||
|
},
|
||||||
|
add_series_table_handling_config,
|
||||||
|
) {
|
||||||
self.handle_key_event();
|
self.handle_key_event();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -624,4 +620,12 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for AddSeriesHandler<'a,
|
|||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -138,4 +138,12 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for DeleteSeriesHandler<
|
|||||||
self.app.pop_navigation_stack();
|
self.app.pop_navigation_stack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -466,4 +466,12 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for EditSeriesHandler<'a
|
|||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
use crate::event::Key;
|
use crate::event::Key;
|
||||||
use crate::handlers::sonarr_handlers::library::season_details_handler::releases_sorting_options;
|
use crate::handlers::sonarr_handlers::library::season_details_handler::releases_sorting_options;
|
||||||
use crate::handlers::table_handler::TableHandlingConfig;
|
use crate::handlers::table_handler::{TableHandlingConfig, handle_table};
|
||||||
use crate::handlers::{KeyEventHandler, handle_prompt_toggle};
|
use crate::handlers::{KeyEventHandler, handle_prompt_toggle};
|
||||||
|
use crate::matches_key;
|
||||||
use crate::models::servarr_data::sonarr::sonarr_data::{ActiveSonarrBlock, EPISODE_DETAILS_BLOCKS};
|
use crate::models::servarr_data::sonarr::sonarr_data::{ActiveSonarrBlock, EPISODE_DETAILS_BLOCKS};
|
||||||
use crate::models::sonarr_models::{SonarrHistoryItem, SonarrRelease, SonarrReleaseDownloadBody};
|
use crate::models::sonarr_models::{SonarrRelease, SonarrReleaseDownloadBody};
|
||||||
use crate::network::sonarr_network::SonarrEvent;
|
use crate::network::sonarr_network::SonarrEvent;
|
||||||
use crate::{handle_table_events, matches_key};
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[path = "episode_details_handler_tests.rs"]
|
#[path = "episode_details_handler_tests.rs"]
|
||||||
@@ -20,39 +20,6 @@ pub(super) struct EpisodeDetailsHandler<'a, 'b> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl EpisodeDetailsHandler<'_, '_> {
|
impl EpisodeDetailsHandler<'_, '_> {
|
||||||
handle_table_events!(
|
|
||||||
self,
|
|
||||||
episode_history,
|
|
||||||
self
|
|
||||||
.app
|
|
||||||
.data
|
|
||||||
.sonarr_data
|
|
||||||
.season_details_modal
|
|
||||||
.as_mut()
|
|
||||||
.expect("Season details modal is undefined")
|
|
||||||
.episode_details_modal
|
|
||||||
.as_mut()
|
|
||||||
.expect("Episode details modal is undefined")
|
|
||||||
.episode_history,
|
|
||||||
SonarrHistoryItem
|
|
||||||
);
|
|
||||||
handle_table_events!(
|
|
||||||
self,
|
|
||||||
episode_releases,
|
|
||||||
self
|
|
||||||
.app
|
|
||||||
.data
|
|
||||||
.sonarr_data
|
|
||||||
.season_details_modal
|
|
||||||
.as_mut()
|
|
||||||
.expect("Season details modal is undefined")
|
|
||||||
.episode_details_modal
|
|
||||||
.as_mut()
|
|
||||||
.expect("Episode details modal is undefined")
|
|
||||||
.episode_releases,
|
|
||||||
SonarrRelease
|
|
||||||
);
|
|
||||||
|
|
||||||
fn extract_episode_id(&self) -> i64 {
|
fn extract_episode_id(&self) -> i64 {
|
||||||
self
|
self
|
||||||
.app
|
.app
|
||||||
@@ -76,9 +43,37 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for EpisodeDetailsHandle
|
|||||||
.sorting_block(ActiveSonarrBlock::ManualEpisodeSearchSortPrompt.into())
|
.sorting_block(ActiveSonarrBlock::ManualEpisodeSearchSortPrompt.into())
|
||||||
.sort_options(releases_sorting_options());
|
.sort_options(releases_sorting_options());
|
||||||
|
|
||||||
if !self.handle_episode_history_table_events(episode_history_table_handling_config)
|
if !handle_table(
|
||||||
&& !self.handle_episode_releases_table_events(episode_releases_table_handling_config)
|
self,
|
||||||
{
|
|app| {
|
||||||
|
&mut app
|
||||||
|
.data
|
||||||
|
.sonarr_data
|
||||||
|
.season_details_modal
|
||||||
|
.as_mut()
|
||||||
|
.expect("Season details modal is undefined")
|
||||||
|
.episode_details_modal
|
||||||
|
.as_mut()
|
||||||
|
.expect("Episode details modal is undefined")
|
||||||
|
.episode_history
|
||||||
|
},
|
||||||
|
episode_history_table_handling_config,
|
||||||
|
) && !handle_table(
|
||||||
|
self,
|
||||||
|
|app| {
|
||||||
|
&mut app
|
||||||
|
.data
|
||||||
|
.sonarr_data
|
||||||
|
.season_details_modal
|
||||||
|
.as_mut()
|
||||||
|
.expect("Season details modal is undefined")
|
||||||
|
.episode_details_modal
|
||||||
|
.as_mut()
|
||||||
|
.expect("Episode details modal is undefined")
|
||||||
|
.episode_releases
|
||||||
|
},
|
||||||
|
episode_releases_table_handling_config,
|
||||||
|
) {
|
||||||
self.handle_key_event();
|
self.handle_key_event();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -370,4 +365,12 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for EpisodeDetailsHandle
|
|||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ use edit_series_handler::EditSeriesHandler;
|
|||||||
use crate::{
|
use crate::{
|
||||||
app::App,
|
app::App,
|
||||||
event::Key,
|
event::Key,
|
||||||
handle_table_events,
|
|
||||||
handlers::{KeyEventHandler, handle_clear_errors, handle_prompt_toggle},
|
handlers::{KeyEventHandler, handle_clear_errors, handle_prompt_toggle},
|
||||||
matches_key,
|
matches_key,
|
||||||
models::{
|
models::{
|
||||||
@@ -25,7 +24,7 @@ use super::handle_change_tab_left_right_keys;
|
|||||||
use crate::handlers::sonarr_handlers::library::episode_details_handler::EpisodeDetailsHandler;
|
use crate::handlers::sonarr_handlers::library::episode_details_handler::EpisodeDetailsHandler;
|
||||||
use crate::handlers::sonarr_handlers::library::season_details_handler::SeasonDetailsHandler;
|
use crate::handlers::sonarr_handlers::library::season_details_handler::SeasonDetailsHandler;
|
||||||
use crate::handlers::sonarr_handlers::library::series_details_handler::SeriesDetailsHandler;
|
use crate::handlers::sonarr_handlers::library::series_details_handler::SeriesDetailsHandler;
|
||||||
use crate::handlers::table_handler::TableHandlingConfig;
|
use crate::handlers::table_handler::{TableHandlingConfig, handle_table};
|
||||||
|
|
||||||
mod add_series_handler;
|
mod add_series_handler;
|
||||||
mod delete_series_handler;
|
mod delete_series_handler;
|
||||||
@@ -45,7 +44,6 @@ pub(super) struct LibraryHandler<'a, 'b> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl LibraryHandler<'_, '_> {
|
impl LibraryHandler<'_, '_> {
|
||||||
handle_table_events!(self, series, self.app.data.sonarr_data.series, Series);
|
|
||||||
fn extract_series_id(&self) -> i64 {
|
fn extract_series_id(&self) -> i64 {
|
||||||
self.app.data.sonarr_data.series.current_selection().id
|
self.app.data.sonarr_data.series.current_selection().id
|
||||||
}
|
}
|
||||||
@@ -63,7 +61,11 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for LibraryHandler<'a, '
|
|||||||
.filter_error_block(ActiveSonarrBlock::FilterSeriesError.into())
|
.filter_error_block(ActiveSonarrBlock::FilterSeriesError.into())
|
||||||
.filter_field_fn(|series| &series.title.text);
|
.filter_field_fn(|series| &series.title.text);
|
||||||
|
|
||||||
if !self.handle_series_table_events(series_table_handling_config) {
|
if !handle_table(
|
||||||
|
self,
|
||||||
|
|app| &mut app.data.sonarr_data.series,
|
||||||
|
series_table_handling_config,
|
||||||
|
) {
|
||||||
match self.active_sonarr_block {
|
match self.active_sonarr_block {
|
||||||
_ if AddSeriesHandler::accepts(self.active_sonarr_block) => {
|
_ if AddSeriesHandler::accepts(self.active_sonarr_block) => {
|
||||||
AddSeriesHandler::new(self.key, self.app, self.active_sonarr_block, self.context)
|
AddSeriesHandler::new(self.key, self.app, self.active_sonarr_block, self.context)
|
||||||
@@ -238,6 +240,14 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for LibraryHandler<'a, '
|
|||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn series_sorting_options() -> Vec<SortOption<Series>> {
|
fn series_sorting_options() -> Vec<SortOption<Series>> {
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
use crate::event::Key;
|
use crate::event::Key;
|
||||||
use crate::handlers::sonarr_handlers::history::history_sorting_options;
|
use crate::handlers::sonarr_handlers::history::history_sorting_options;
|
||||||
use crate::handlers::table_handler::TableHandlingConfig;
|
use crate::handlers::table_handler::{TableHandlingConfig, handle_table};
|
||||||
use crate::handlers::{KeyEventHandler, handle_prompt_toggle};
|
use crate::handlers::{KeyEventHandler, handle_prompt_toggle};
|
||||||
|
use crate::matches_key;
|
||||||
use crate::models::servarr_data::sonarr::sonarr_data::{ActiveSonarrBlock, SEASON_DETAILS_BLOCKS};
|
use crate::models::servarr_data::sonarr::sonarr_data::{ActiveSonarrBlock, SEASON_DETAILS_BLOCKS};
|
||||||
use crate::models::servarr_models::Language;
|
use crate::models::servarr_models::Language;
|
||||||
use crate::models::sonarr_models::{
|
use crate::models::sonarr_models::{
|
||||||
@@ -10,7 +11,6 @@ use crate::models::sonarr_models::{
|
|||||||
};
|
};
|
||||||
use crate::models::stateful_table::SortOption;
|
use crate::models::stateful_table::SortOption;
|
||||||
use crate::network::sonarr_network::SonarrEvent;
|
use crate::network::sonarr_network::SonarrEvent;
|
||||||
use crate::{handle_table_events, matches_key};
|
|
||||||
use serde_json::Number;
|
use serde_json::Number;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
@@ -25,46 +25,6 @@ pub(super) struct SeasonDetailsHandler<'a, 'b> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl SeasonDetailsHandler<'_, '_> {
|
impl SeasonDetailsHandler<'_, '_> {
|
||||||
handle_table_events!(
|
|
||||||
self,
|
|
||||||
episodes,
|
|
||||||
self
|
|
||||||
.app
|
|
||||||
.data
|
|
||||||
.sonarr_data
|
|
||||||
.season_details_modal
|
|
||||||
.as_mut()
|
|
||||||
.expect("Season details modal is undefined")
|
|
||||||
.episodes,
|
|
||||||
Episode
|
|
||||||
);
|
|
||||||
handle_table_events!(
|
|
||||||
self,
|
|
||||||
season_history,
|
|
||||||
self
|
|
||||||
.app
|
|
||||||
.data
|
|
||||||
.sonarr_data
|
|
||||||
.season_details_modal
|
|
||||||
.as_mut()
|
|
||||||
.expect("Season details modal is undefined")
|
|
||||||
.season_history,
|
|
||||||
SonarrHistoryItem
|
|
||||||
);
|
|
||||||
handle_table_events!(
|
|
||||||
self,
|
|
||||||
season_releases,
|
|
||||||
self
|
|
||||||
.app
|
|
||||||
.data
|
|
||||||
.sonarr_data
|
|
||||||
.season_details_modal
|
|
||||||
.as_mut()
|
|
||||||
.expect("Season details modal is undefined")
|
|
||||||
.season_releases,
|
|
||||||
SonarrRelease
|
|
||||||
);
|
|
||||||
|
|
||||||
fn extract_episode_file_id(&self) -> i64 {
|
fn extract_episode_file_id(&self) -> i64 {
|
||||||
self
|
self
|
||||||
.app
|
.app
|
||||||
@@ -126,10 +86,43 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for SeasonDetailsHandler
|
|||||||
.sorting_block(ActiveSonarrBlock::ManualSeasonSearchSortPrompt.into())
|
.sorting_block(ActiveSonarrBlock::ManualSeasonSearchSortPrompt.into())
|
||||||
.sort_options(releases_sorting_options());
|
.sort_options(releases_sorting_options());
|
||||||
|
|
||||||
if !self.handle_episodes_table_events(episodes_table_handling_config)
|
if !handle_table(
|
||||||
&& !self.handle_season_history_table_events(season_history_table_handling_config)
|
self,
|
||||||
&& !self.handle_season_releases_table_events(season_releases_table_handling_config)
|
|app| {
|
||||||
{
|
&mut app
|
||||||
|
.data
|
||||||
|
.sonarr_data
|
||||||
|
.season_details_modal
|
||||||
|
.as_mut()
|
||||||
|
.expect("Season details modal is undefined")
|
||||||
|
.episodes
|
||||||
|
},
|
||||||
|
episodes_table_handling_config,
|
||||||
|
) && !handle_table(
|
||||||
|
self,
|
||||||
|
|app| {
|
||||||
|
&mut app
|
||||||
|
.data
|
||||||
|
.sonarr_data
|
||||||
|
.season_details_modal
|
||||||
|
.as_mut()
|
||||||
|
.expect("Season details modal is undefined")
|
||||||
|
.season_history
|
||||||
|
},
|
||||||
|
season_history_table_handling_config,
|
||||||
|
) && !handle_table(
|
||||||
|
self,
|
||||||
|
|app| {
|
||||||
|
&mut app
|
||||||
|
.data
|
||||||
|
.sonarr_data
|
||||||
|
.season_details_modal
|
||||||
|
.as_mut()
|
||||||
|
.expect("Season details modal is undefined")
|
||||||
|
.season_releases
|
||||||
|
},
|
||||||
|
season_releases_table_handling_config,
|
||||||
|
) {
|
||||||
self.handle_key_event();
|
self.handle_key_event();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -460,6 +453,14 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for SeasonDetailsHandler
|
|||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(in crate::handlers::sonarr_handlers::library) fn releases_sorting_options()
|
pub(in crate::handlers::sonarr_handlers::library) fn releases_sorting_options()
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
use crate::event::Key;
|
use crate::event::Key;
|
||||||
use crate::handlers::sonarr_handlers::history::history_sorting_options;
|
use crate::handlers::sonarr_handlers::history::history_sorting_options;
|
||||||
use crate::handlers::table_handler::TableHandlingConfig;
|
use crate::handlers::table_handler::{TableHandlingConfig, handle_table};
|
||||||
use crate::handlers::{KeyEventHandler, handle_prompt_toggle};
|
use crate::handlers::{KeyEventHandler, handle_prompt_toggle};
|
||||||
|
use crate::matches_key;
|
||||||
use crate::models::BlockSelectionState;
|
use crate::models::BlockSelectionState;
|
||||||
use crate::models::servarr_data::sonarr::sonarr_data::{
|
use crate::models::servarr_data::sonarr::sonarr_data::{
|
||||||
ActiveSonarrBlock, EDIT_SERIES_SELECTION_BLOCKS, SERIES_DETAILS_BLOCKS,
|
ActiveSonarrBlock, EDIT_SERIES_SELECTION_BLOCKS, SERIES_DETAILS_BLOCKS,
|
||||||
};
|
};
|
||||||
use crate::models::sonarr_models::{Season, SonarrHistoryItem};
|
use crate::models::sonarr_models::{Season, SonarrHistoryItem};
|
||||||
use crate::network::sonarr_network::SonarrEvent;
|
use crate::network::sonarr_network::SonarrEvent;
|
||||||
use crate::{handle_table_events, matches_key};
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[path = "series_details_handler_tests.rs"]
|
#[path = "series_details_handler_tests.rs"]
|
||||||
@@ -23,20 +23,6 @@ pub(super) struct SeriesDetailsHandler<'a, 'b> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl SeriesDetailsHandler<'_, '_> {
|
impl SeriesDetailsHandler<'_, '_> {
|
||||||
handle_table_events!(self, season, self.app.data.sonarr_data.seasons, Season);
|
|
||||||
handle_table_events!(
|
|
||||||
self,
|
|
||||||
series_history,
|
|
||||||
self
|
|
||||||
.app
|
|
||||||
.data
|
|
||||||
.sonarr_data
|
|
||||||
.series_history
|
|
||||||
.as_mut()
|
|
||||||
.expect("Series history is undefined"),
|
|
||||||
SonarrHistoryItem
|
|
||||||
);
|
|
||||||
|
|
||||||
fn extract_series_id_season_number_tuple(&self) -> (i64, i64) {
|
fn extract_series_id_season_number_tuple(&self) -> (i64, i64) {
|
||||||
let series_id = self.app.data.sonarr_data.series.current_selection().id;
|
let series_id = self.app.data.sonarr_data.series.current_selection().id;
|
||||||
let season_number = self
|
let season_number = self
|
||||||
@@ -78,9 +64,22 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for SeriesDetailsHandler
|
|||||||
.filter_error_block(ActiveSonarrBlock::FilterSeriesHistoryError.into())
|
.filter_error_block(ActiveSonarrBlock::FilterSeriesHistoryError.into())
|
||||||
.filter_field_fn(|history_item: &SonarrHistoryItem| &history_item.source_title.text);
|
.filter_field_fn(|history_item: &SonarrHistoryItem| &history_item.source_title.text);
|
||||||
|
|
||||||
if !self.handle_season_table_events(season_table_handling_config)
|
if !handle_table(
|
||||||
&& !self.handle_series_history_table_events(series_history_table_handling_config)
|
self,
|
||||||
{
|
|app| &mut app.data.sonarr_data.seasons,
|
||||||
|
season_table_handling_config,
|
||||||
|
) && !handle_table(
|
||||||
|
self,
|
||||||
|
|app| {
|
||||||
|
app
|
||||||
|
.data
|
||||||
|
.sonarr_data
|
||||||
|
.series_history
|
||||||
|
.as_mut()
|
||||||
|
.expect("Series history is undefined")
|
||||||
|
},
|
||||||
|
series_history_table_handling_config,
|
||||||
|
) {
|
||||||
self.handle_key_event();
|
self.handle_key_event();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -338,4 +337,12 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for SeriesDetailsHandler
|
|||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,6 +110,14 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for SonarrHandler<'a, 'b
|
|||||||
fn handle_esc(&mut self) {}
|
fn handle_esc(&mut self) {}
|
||||||
|
|
||||||
fn handle_char_key_event(&mut self) {}
|
fn handle_char_key_event(&mut self) {}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_change_tab_left_right_keys(app: &mut App<'_>, key: Key) {
|
pub fn handle_change_tab_left_right_keys(app: &mut App<'_>, key: Key) {
|
||||||
|
|||||||
@@ -1,15 +1,13 @@
|
|||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
use crate::event::Key;
|
use crate::event::Key;
|
||||||
use crate::handlers::sonarr_handlers::handle_change_tab_left_right_keys;
|
use crate::handlers::sonarr_handlers::handle_change_tab_left_right_keys;
|
||||||
use crate::handlers::table_handler::TableHandlingConfig;
|
use crate::handlers::table_handler::{TableHandlingConfig, handle_table};
|
||||||
use crate::handlers::{KeyEventHandler, handle_clear_errors, handle_prompt_toggle};
|
use crate::handlers::{KeyEventHandler, handle_clear_errors, handle_prompt_toggle};
|
||||||
use crate::models::HorizontallyScrollableText;
|
use crate::models::HorizontallyScrollableText;
|
||||||
use crate::models::servarr_data::sonarr::sonarr_data::{ActiveSonarrBlock, ROOT_FOLDERS_BLOCKS};
|
use crate::models::servarr_data::sonarr::sonarr_data::{ActiveSonarrBlock, ROOT_FOLDERS_BLOCKS};
|
||||||
use crate::models::servarr_models::{AddRootFolderBody, RootFolder};
|
use crate::models::servarr_models::AddRootFolderBody;
|
||||||
use crate::network::sonarr_network::SonarrEvent;
|
use crate::network::sonarr_network::SonarrEvent;
|
||||||
use crate::{
|
use crate::{handle_text_box_keys, handle_text_box_left_right_keys, matches_key};
|
||||||
handle_table_events, handle_text_box_keys, handle_text_box_left_right_keys, matches_key,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[path = "root_folders_handler_tests.rs"]
|
#[path = "root_folders_handler_tests.rs"]
|
||||||
@@ -23,13 +21,6 @@ pub(super) struct RootFoldersHandler<'a, 'b> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl RootFoldersHandler<'_, '_> {
|
impl RootFoldersHandler<'_, '_> {
|
||||||
handle_table_events!(
|
|
||||||
self,
|
|
||||||
root_folders,
|
|
||||||
self.app.data.sonarr_data.root_folders,
|
|
||||||
RootFolder
|
|
||||||
);
|
|
||||||
|
|
||||||
fn build_add_root_folder_body(&mut self) -> AddRootFolderBody {
|
fn build_add_root_folder_body(&mut self) -> AddRootFolderBody {
|
||||||
let root_folder = self
|
let root_folder = self
|
||||||
.app
|
.app
|
||||||
@@ -58,7 +49,11 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for RootFoldersHandler<'
|
|||||||
let root_folders_table_handling_config =
|
let root_folders_table_handling_config =
|
||||||
TableHandlingConfig::new(ActiveSonarrBlock::RootFolders.into());
|
TableHandlingConfig::new(ActiveSonarrBlock::RootFolders.into());
|
||||||
|
|
||||||
if !self.handle_root_folders_table_events(root_folders_table_handling_config) {
|
if !handle_table(
|
||||||
|
self,
|
||||||
|
|app| &mut app.data.sonarr_data.root_folders,
|
||||||
|
root_folders_table_handling_config,
|
||||||
|
) {
|
||||||
self.handle_key_event();
|
self.handle_key_event();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -229,4 +224,12 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for RootFoldersHandler<'
|
|||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,4 +124,12 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for SystemHandler<'a, 'b
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -196,4 +196,12 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for SystemDetailsHandler
|
|||||||
self.app.pop_navigation_stack();
|
self.app.pop_navigation_stack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+635
-366
File diff suppressed because it is too large
Load Diff
@@ -3,9 +3,9 @@ mod tests {
|
|||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
use crate::app::key_binding::DEFAULT_KEYBINDINGS;
|
use crate::app::key_binding::DEFAULT_KEYBINDINGS;
|
||||||
use crate::event::Key;
|
use crate::event::Key;
|
||||||
use crate::handle_table_events;
|
|
||||||
use crate::handlers::KeyEventHandler;
|
use crate::handlers::KeyEventHandler;
|
||||||
use crate::handlers::table_handler::TableHandlingConfig;
|
use crate::handlers::table_handler::TableHandlingConfig;
|
||||||
|
use crate::handlers::table_handler::handle_table;
|
||||||
use crate::models::radarr_models::Movie;
|
use crate::models::radarr_models::Movie;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::ActiveRadarrBlock;
|
use crate::models::servarr_data::radarr::radarr_data::ActiveRadarrBlock;
|
||||||
use crate::models::servarr_models::Language;
|
use crate::models::servarr_models::Language;
|
||||||
@@ -33,13 +33,13 @@ mod tests {
|
|||||||
let minimal_movie_table_handling_config =
|
let minimal_movie_table_handling_config =
|
||||||
TableHandlingConfig::new(ActiveRadarrBlock::Movies.into());
|
TableHandlingConfig::new(ActiveRadarrBlock::Movies.into());
|
||||||
|
|
||||||
match self.active_radarr_block {
|
let config = match self.active_radarr_block {
|
||||||
ActiveRadarrBlock::MovieDetails => {
|
ActiveRadarrBlock::MovieDetails => minimal_movie_table_handling_config,
|
||||||
self.handle_movies_table_events(minimal_movie_table_handling_config);
|
_ => movie_table_handling_config,
|
||||||
}
|
};
|
||||||
_ => {
|
|
||||||
self.handle_movies_table_events(movie_table_handling_config);
|
if !handle_table(self, |app| &mut app.data.radarr_data.movies, config) {
|
||||||
}
|
self.handle_key_event();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,10 +90,14 @@ mod tests {
|
|||||||
fn handle_esc(&mut self) {}
|
fn handle_esc(&mut self) {}
|
||||||
|
|
||||||
fn handle_char_key_event(&mut self) {}
|
fn handle_char_key_event(&mut self) {}
|
||||||
}
|
|
||||||
|
|
||||||
impl TableHandlerUnit<'_, '_> {
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
handle_table_events!(self, movies, self.app.data.radarr_data.movies, Movie);
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mod test_handle_scroll_up_and_down {
|
mod test_handle_scroll_up_and_down {
|
||||||
@@ -198,6 +202,86 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_table_sort_scroll_up_with_sort_some() {
|
||||||
|
let movie_field_vec = sort_options();
|
||||||
|
let mut app = App::test_default();
|
||||||
|
app.data.radarr_data.movies.sorting(sort_options());
|
||||||
|
app.push_navigation_stack(ActiveRadarrBlock::MoviesSortPrompt.into());
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
app
|
||||||
|
.data
|
||||||
|
.radarr_data
|
||||||
|
.movies
|
||||||
|
.sort
|
||||||
|
.as_ref()
|
||||||
|
.unwrap()
|
||||||
|
.current_selection(),
|
||||||
|
&movie_field_vec[0]
|
||||||
|
);
|
||||||
|
|
||||||
|
TableHandlerUnit::new(
|
||||||
|
DEFAULT_KEYBINDINGS.up.key,
|
||||||
|
&mut app,
|
||||||
|
ActiveRadarrBlock::MoviesSortPrompt,
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
.handle();
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
app
|
||||||
|
.data
|
||||||
|
.radarr_data
|
||||||
|
.movies
|
||||||
|
.sort
|
||||||
|
.as_ref()
|
||||||
|
.unwrap()
|
||||||
|
.current_selection(),
|
||||||
|
&movie_field_vec[movie_field_vec.len() - 1]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_table_sort_scroll_down_with_sort_some() {
|
||||||
|
let movie_field_vec = sort_options();
|
||||||
|
let mut app = App::test_default();
|
||||||
|
app.data.radarr_data.movies.sorting(sort_options());
|
||||||
|
app.push_navigation_stack(ActiveRadarrBlock::MoviesSortPrompt.into());
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
app
|
||||||
|
.data
|
||||||
|
.radarr_data
|
||||||
|
.movies
|
||||||
|
.sort
|
||||||
|
.as_ref()
|
||||||
|
.unwrap()
|
||||||
|
.current_selection(),
|
||||||
|
&movie_field_vec[0]
|
||||||
|
);
|
||||||
|
|
||||||
|
TableHandlerUnit::new(
|
||||||
|
DEFAULT_KEYBINDINGS.down.key,
|
||||||
|
&mut app,
|
||||||
|
ActiveRadarrBlock::MoviesSortPrompt,
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
.handle();
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
app
|
||||||
|
.data
|
||||||
|
.radarr_data
|
||||||
|
.movies
|
||||||
|
.sort
|
||||||
|
.as_ref()
|
||||||
|
.unwrap()
|
||||||
|
.current_selection(),
|
||||||
|
&movie_field_vec[0]
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mod test_handle_home_end {
|
mod test_handle_home_end {
|
||||||
@@ -426,6 +510,70 @@ mod tests {
|
|||||||
&movie_field_vec[0]
|
&movie_field_vec[0]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_table_sort_home_with_sort_some() {
|
||||||
|
let movie_field_vec = sort_options();
|
||||||
|
let mut app = App::test_default();
|
||||||
|
app.data.radarr_data.movies.sorting(sort_options());
|
||||||
|
app.push_navigation_stack(ActiveRadarrBlock::MoviesSortPrompt.into());
|
||||||
|
|
||||||
|
TableHandlerUnit::new(
|
||||||
|
DEFAULT_KEYBINDINGS.down.key,
|
||||||
|
&mut app,
|
||||||
|
ActiveRadarrBlock::MoviesSortPrompt,
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
.handle();
|
||||||
|
|
||||||
|
TableHandlerUnit::new(
|
||||||
|
DEFAULT_KEYBINDINGS.home.key,
|
||||||
|
&mut app,
|
||||||
|
ActiveRadarrBlock::MoviesSortPrompt,
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
.handle();
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
app
|
||||||
|
.data
|
||||||
|
.radarr_data
|
||||||
|
.movies
|
||||||
|
.sort
|
||||||
|
.as_ref()
|
||||||
|
.unwrap()
|
||||||
|
.current_selection(),
|
||||||
|
&movie_field_vec[0]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_table_sort_end_with_sort_some() {
|
||||||
|
let movie_field_vec = sort_options();
|
||||||
|
let mut app = App::test_default();
|
||||||
|
app.data.radarr_data.movies.sorting(sort_options());
|
||||||
|
app.push_navigation_stack(ActiveRadarrBlock::MoviesSortPrompt.into());
|
||||||
|
|
||||||
|
TableHandlerUnit::new(
|
||||||
|
DEFAULT_KEYBINDINGS.end.key,
|
||||||
|
&mut app,
|
||||||
|
ActiveRadarrBlock::MoviesSortPrompt,
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
.handle();
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
app
|
||||||
|
.data
|
||||||
|
.radarr_data
|
||||||
|
.movies
|
||||||
|
.sort
|
||||||
|
.as_ref()
|
||||||
|
.unwrap()
|
||||||
|
.current_selection(),
|
||||||
|
&movie_field_vec[movie_field_vec.len() - 1]
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mod test_handle_pagination_scroll {
|
mod test_handle_pagination_scroll {
|
||||||
@@ -835,6 +983,30 @@ mod tests {
|
|||||||
|
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_table_block_esc_with_filter_applied() {
|
||||||
|
let mut app = App::test_default();
|
||||||
|
app.push_navigation_stack(ActiveRadarrBlock::Movies.into());
|
||||||
|
app.data.radarr_data.movies = StatefulTable {
|
||||||
|
filter: Some("Test".into()),
|
||||||
|
filtered_items: Some(Vec::new()),
|
||||||
|
filtered_state: Some(TableState::default()),
|
||||||
|
..StatefulTable::default()
|
||||||
|
};
|
||||||
|
app
|
||||||
|
.data
|
||||||
|
.radarr_data
|
||||||
|
.movies
|
||||||
|
.set_items(vec![Movie::default()]);
|
||||||
|
|
||||||
|
TableHandlerUnit::new(ESC_KEY, &mut app, ActiveRadarrBlock::Movies, None).handle();
|
||||||
|
|
||||||
|
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
||||||
|
assert_eq!(app.data.radarr_data.movies.filter, None);
|
||||||
|
assert_eq!(app.data.radarr_data.movies.filtered_items, None);
|
||||||
|
assert_eq!(app.data.radarr_data.movies.filtered_state, None);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mod test_handle_key_char {
|
mod test_handle_key_char {
|
||||||
|
|||||||
Reference in New Issue
Block a user