Added the ability to view Radarr updates and remapped the events queue key to 'z'
This commit is contained in:
@@ -574,7 +574,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for RadarrHandler<'a, 'b
|
||||
_ if *key == DEFAULT_KEYBINDINGS.refresh.key => {
|
||||
self.app.should_refresh = true;
|
||||
}
|
||||
_ if *key == DEFAULT_KEYBINDINGS.update.key => {
|
||||
_ if *key == DEFAULT_KEYBINDINGS.queue.key => {
|
||||
self
|
||||
.app
|
||||
.push_navigation_stack(ActiveRadarrBlock::SystemQueue.into());
|
||||
@@ -596,6 +596,11 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for RadarrHandler<'a, 'b
|
||||
.app
|
||||
.push_navigation_stack(ActiveRadarrBlock::SystemTasks.into());
|
||||
}
|
||||
_ if *key == DEFAULT_KEYBINDINGS.update.key => {
|
||||
self
|
||||
.app
|
||||
.push_navigation_stack(ActiveRadarrBlock::SystemUpdates.into());
|
||||
}
|
||||
_ => (),
|
||||
},
|
||||
ActiveRadarrBlock::AddRootFolderPrompt => {
|
||||
|
||||
@@ -23,35 +23,19 @@ mod tests {
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
use crate::models::radarr_models::ReleaseField;
|
||||
use crate::{simple_stateful_iterable_vec, test_enum_scroll, test_iterable_scroll};
|
||||
use crate::{
|
||||
simple_stateful_iterable_vec, test_enum_scroll, test_iterable_scroll,
|
||||
test_scrollable_text_scroll,
|
||||
};
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_movie_details_scroll() {
|
||||
let mut app = App::default();
|
||||
app.data.radarr_data.movie_details = ScrollableText::with_string("Test 1\nTest 2".to_owned());
|
||||
|
||||
MovieDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.up.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::MovieDetails,
|
||||
&None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.data.radarr_data.movie_details.offset, 0);
|
||||
|
||||
MovieDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.down.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::MovieDetails,
|
||||
&None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.data.radarr_data.movie_details.offset, 1);
|
||||
}
|
||||
test_scrollable_text_scroll!(
|
||||
test_movie_details_scroll,
|
||||
MovieDetailsHandler,
|
||||
movie_details,
|
||||
ActiveRadarrBlock::MovieDetails
|
||||
);
|
||||
|
||||
test_iterable_scroll!(
|
||||
test_movie_history_scroll,
|
||||
@@ -113,35 +97,17 @@ mod tests {
|
||||
use crate::models::radarr_models::ReleaseField;
|
||||
use crate::{
|
||||
extended_stateful_iterable_vec, test_enum_home_and_end, test_iterable_home_and_end,
|
||||
test_scrollable_text_home_and_end,
|
||||
};
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_movie_details_home_end() {
|
||||
let mut app = App::default();
|
||||
app.data.radarr_data.movie_details = ScrollableText::with_string("Test 1\nTest 2".to_owned());
|
||||
|
||||
MovieDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.end.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::MovieDetails,
|
||||
&None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.data.radarr_data.movie_details.offset, 1);
|
||||
|
||||
MovieDetailsHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.home.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::MovieDetails,
|
||||
&None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.data.radarr_data.movie_details.offset, 0);
|
||||
}
|
||||
test_scrollable_text_home_and_end!(
|
||||
test_movie_details_home_end,
|
||||
MovieDetailsHandler,
|
||||
movie_details,
|
||||
ActiveRadarrBlock::MovieDetails
|
||||
);
|
||||
|
||||
test_iterable_home_and_end!(
|
||||
test_movie_history_home_end,
|
||||
|
||||
@@ -921,7 +921,7 @@ mod tests {
|
||||
ActiveRadarrBlock::Collections,
|
||||
ActiveRadarrBlock::UpdateAllCollectionsPrompt
|
||||
)]
|
||||
#[case(ActiveRadarrBlock::System, ActiveRadarrBlock::SystemQueue)]
|
||||
#[case(ActiveRadarrBlock::System, ActiveRadarrBlock::SystemUpdates)]
|
||||
fn test_update_key(
|
||||
#[case] active_radarr_block: ActiveRadarrBlock,
|
||||
#[case] expected_radarr_block: ActiveRadarrBlock,
|
||||
@@ -939,6 +939,24 @@ mod tests {
|
||||
assert_eq!(app.get_current_route(), &expected_radarr_block.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_queue_key() {
|
||||
let mut app = App::default();
|
||||
|
||||
RadarrHandler::with(
|
||||
&DEFAULT_KEYBINDINGS.queue.key,
|
||||
&mut app,
|
||||
&ActiveRadarrBlock::System,
|
||||
&None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
&ActiveRadarrBlock::SystemQueue.into()
|
||||
);
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
fn test_refresh_key(
|
||||
#[values(
|
||||
@@ -1252,7 +1270,8 @@ mod tests {
|
||||
ActiveRadarrBlock::System,
|
||||
ActiveRadarrBlock::SystemLogs,
|
||||
ActiveRadarrBlock::SystemTasks,
|
||||
ActiveRadarrBlock::SystemQueue
|
||||
ActiveRadarrBlock::SystemQueue,
|
||||
ActiveRadarrBlock::SystemUpdates
|
||||
)]
|
||||
active_radarr_block: ActiveRadarrBlock,
|
||||
) {
|
||||
|
||||
@@ -40,6 +40,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for SystemDetailsHandler
|
||||
match self.active_radarr_block {
|
||||
ActiveRadarrBlock::SystemLogs => self.app.data.radarr_data.log_details.scroll_up(),
|
||||
ActiveRadarrBlock::SystemTasks => self.app.data.radarr_data.tasks.scroll_up(),
|
||||
ActiveRadarrBlock::SystemUpdates => self.app.data.radarr_data.updates.scroll_up(),
|
||||
ActiveRadarrBlock::SystemQueue => self.app.data.radarr_data.queued_events.scroll_up(),
|
||||
_ => (),
|
||||
}
|
||||
@@ -49,6 +50,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for SystemDetailsHandler
|
||||
match self.active_radarr_block {
|
||||
ActiveRadarrBlock::SystemLogs => self.app.data.radarr_data.log_details.scroll_down(),
|
||||
ActiveRadarrBlock::SystemTasks => self.app.data.radarr_data.tasks.scroll_down(),
|
||||
ActiveRadarrBlock::SystemUpdates => self.app.data.radarr_data.updates.scroll_down(),
|
||||
ActiveRadarrBlock::SystemQueue => self.app.data.radarr_data.queued_events.scroll_down(),
|
||||
_ => (),
|
||||
}
|
||||
@@ -58,6 +60,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for SystemDetailsHandler
|
||||
match self.active_radarr_block {
|
||||
ActiveRadarrBlock::SystemLogs => self.app.data.radarr_data.log_details.scroll_to_top(),
|
||||
ActiveRadarrBlock::SystemTasks => self.app.data.radarr_data.tasks.scroll_to_top(),
|
||||
ActiveRadarrBlock::SystemUpdates => self.app.data.radarr_data.updates.scroll_to_top(),
|
||||
ActiveRadarrBlock::SystemQueue => self.app.data.radarr_data.queued_events.scroll_to_top(),
|
||||
_ => (),
|
||||
}
|
||||
@@ -67,6 +70,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for SystemDetailsHandler
|
||||
match self.active_radarr_block {
|
||||
ActiveRadarrBlock::SystemLogs => self.app.data.radarr_data.log_details.scroll_to_bottom(),
|
||||
ActiveRadarrBlock::SystemTasks => self.app.data.radarr_data.tasks.scroll_to_bottom(),
|
||||
ActiveRadarrBlock::SystemUpdates => self.app.data.radarr_data.updates.scroll_to_bottom(),
|
||||
ActiveRadarrBlock::SystemQueue => self.app.data.radarr_data.queued_events.scroll_to_bottom(),
|
||||
_ => (),
|
||||
}
|
||||
@@ -126,12 +130,13 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for SystemDetailsHandler
|
||||
|
||||
fn handle_esc(&mut self) {
|
||||
match self.active_radarr_block {
|
||||
ActiveRadarrBlock::SystemLogs
|
||||
| ActiveRadarrBlock::SystemTasks
|
||||
| ActiveRadarrBlock::SystemQueue => {
|
||||
ActiveRadarrBlock::SystemLogs => {
|
||||
self.app.data.radarr_data.reset_log_details_list();
|
||||
self.app.pop_navigation_stack()
|
||||
}
|
||||
ActiveRadarrBlock::SystemQueue
|
||||
| ActiveRadarrBlock::SystemTasks
|
||||
| ActiveRadarrBlock::SystemUpdates => self.app.pop_navigation_stack(),
|
||||
ActiveRadarrBlock::SystemTaskStartConfirmPrompt => {
|
||||
self.app.pop_navigation_stack();
|
||||
self.app.data.radarr_data.prompt_confirm = false;
|
||||
|
||||
@@ -13,8 +13,8 @@ mod tests {
|
||||
mod test_handle_scroll_up_and_down {
|
||||
use rstest::rstest;
|
||||
|
||||
use crate::models::HorizontallyScrollableText;
|
||||
use crate::{simple_stateful_iterable_vec, test_iterable_scroll};
|
||||
use crate::models::{HorizontallyScrollableText, ScrollableText};
|
||||
use crate::{simple_stateful_iterable_vec, test_iterable_scroll, test_scrollable_text_scroll};
|
||||
|
||||
use super::*;
|
||||
|
||||
@@ -47,11 +47,20 @@ mod tests {
|
||||
None,
|
||||
name
|
||||
);
|
||||
|
||||
test_scrollable_text_scroll!(
|
||||
test_system_updates_scroll,
|
||||
SystemDetailsHandler,
|
||||
updates,
|
||||
ActiveRadarrBlock::SystemUpdates
|
||||
);
|
||||
}
|
||||
|
||||
mod test_handle_home_end {
|
||||
use crate::models::HorizontallyScrollableText;
|
||||
use crate::{extended_stateful_iterable_vec, test_iterable_home_and_end};
|
||||
use crate::models::{HorizontallyScrollableText, ScrollableText};
|
||||
use crate::{
|
||||
extended_stateful_iterable_vec, test_iterable_home_and_end, test_scrollable_text_home_and_end,
|
||||
};
|
||||
|
||||
use super::*;
|
||||
|
||||
@@ -84,13 +93,21 @@ mod tests {
|
||||
None,
|
||||
name
|
||||
);
|
||||
|
||||
test_scrollable_text_home_and_end!(
|
||||
test_system_updates_home_end,
|
||||
SystemDetailsHandler,
|
||||
updates,
|
||||
ActiveRadarrBlock::SystemUpdates
|
||||
);
|
||||
}
|
||||
|
||||
mod test_handle_left_right_action {
|
||||
use super::*;
|
||||
use pretty_assertions::assert_eq;
|
||||
use rstest::rstest;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_handle_log_details_left_right() {
|
||||
let active_radarr_block = ActiveRadarrBlock::SystemLogs;
|
||||
@@ -219,9 +236,10 @@ mod tests {
|
||||
}
|
||||
|
||||
mod test_handle_submit {
|
||||
use crate::network::radarr_network::RadarrEvent;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
use crate::network::radarr_network::RadarrEvent;
|
||||
|
||||
use super::*;
|
||||
|
||||
const SUBMIT_KEY: Key = DEFAULT_KEYBINDINGS.submit.key;
|
||||
@@ -294,9 +312,10 @@ mod tests {
|
||||
}
|
||||
|
||||
mod test_handle_esc {
|
||||
use crate::models::HorizontallyScrollableText;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
use crate::models::HorizontallyScrollableText;
|
||||
|
||||
use super::*;
|
||||
|
||||
const ESC_KEY: Key = DEFAULT_KEYBINDINGS.esc.key;
|
||||
@@ -354,6 +373,23 @@ mod tests {
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::System.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_esc_system_updates() {
|
||||
let mut app = App::default();
|
||||
app.push_navigation_stack(ActiveRadarrBlock::System.into());
|
||||
app.push_navigation_stack(ActiveRadarrBlock::SystemUpdates.into());
|
||||
app
|
||||
.data
|
||||
.radarr_data
|
||||
.queued_events
|
||||
.set_items(vec![QueueEvent::default()]);
|
||||
|
||||
SystemDetailsHandler::with(&ESC_KEY, &mut app, &ActiveRadarrBlock::SystemUpdates, &None)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), &ActiveRadarrBlock::System.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_system_tasks_start_task_prompt_esc() {
|
||||
let mut app = App::default();
|
||||
@@ -387,7 +423,8 @@ mod tests {
|
||||
#[values(
|
||||
ActiveRadarrBlock::SystemLogs,
|
||||
ActiveRadarrBlock::SystemTasks,
|
||||
ActiveRadarrBlock::SystemQueue
|
||||
ActiveRadarrBlock::SystemQueue,
|
||||
ActiveRadarrBlock::SystemUpdates
|
||||
)]
|
||||
active_radarr_block: ActiveRadarrBlock,
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user