feat(handlers): Support for toggling the monitoring status of a season in the Sonarr UI
This commit is contained in:
@@ -257,6 +257,13 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for SeriesDetailsHandler
|
||||
self.app.data.sonarr_data.selected_block =
|
||||
BlockSelectionState::new(EDIT_SERIES_SELECTION_BLOCKS);
|
||||
}
|
||||
_ if key == DEFAULT_KEYBINDINGS.toggle_monitoring.key => {
|
||||
self.app.data.sonarr_data.prompt_confirm = true;
|
||||
self.app.data.sonarr_data.prompt_confirm_action =
|
||||
Some(SonarrEvent::ToggleSeasonMonitoring(None));
|
||||
|
||||
self.app.pop_and_push_navigation_stack(self.active_sonarr_block.into());
|
||||
}
|
||||
_ => (),
|
||||
},
|
||||
ActiveSonarrBlock::SeriesHistory => match self.key {
|
||||
|
||||
@@ -375,6 +375,56 @@ mod tests {
|
||||
assert!(app.data.sonarr_data.edit_series_modal.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_toggle_monitoring_key() {
|
||||
let mut app = App::default();
|
||||
let mut series_history = StatefulTable::default();
|
||||
series_history.set_items(vec![SonarrHistoryItem::default()]);
|
||||
app.data.sonarr_data.series_history = Some(series_history);
|
||||
app.push_navigation_stack(ActiveSonarrBlock::SeriesDetails.into());
|
||||
app.is_routing = false;
|
||||
|
||||
SeriesDetailsHandler::with(
|
||||
DEFAULT_KEYBINDINGS.toggle_monitoring.key,
|
||||
&mut app,
|
||||
ActiveSonarrBlock::SeriesDetails,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(
|
||||
app.get_current_route(),
|
||||
ActiveSonarrBlock::SeriesDetails.into()
|
||||
);
|
||||
assert!(app.data.sonarr_data.prompt_confirm);
|
||||
assert!(app.is_routing);
|
||||
assert_eq!(
|
||||
app.data.sonarr_data.prompt_confirm_action,
|
||||
Some(SonarrEvent::ToggleSeasonMonitoring(None))
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_toggle_monitoring_key_no_op_when_not_ready() {
|
||||
let mut app = App::default();
|
||||
app.is_loading = true;
|
||||
app.push_navigation_stack(ActiveSonarrBlock::SeriesDetails.into());
|
||||
app.is_routing = false;
|
||||
|
||||
SeriesDetailsHandler::with(
|
||||
DEFAULT_KEYBINDINGS.toggle_monitoring.key,
|
||||
&mut app,
|
||||
ActiveSonarrBlock::SeriesDetails,
|
||||
None,
|
||||
)
|
||||
.handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), ActiveSonarrBlock::SeriesDetails.into());
|
||||
assert!(!app.data.sonarr_data.prompt_confirm);
|
||||
assert!(app.data.sonarr_data.prompt_confirm_action.is_none());
|
||||
assert!(!app.is_routing);
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
fn test_auto_search_key(
|
||||
#[values(ActiveSonarrBlock::SeriesDetails, ActiveSonarrBlock::SeriesHistory)]
|
||||
|
||||
Reference in New Issue
Block a user