refactor(ui): Simplified the popup delegation so all future UI is easier to implement
This commit is contained in:
@@ -128,39 +128,6 @@ pub fn draw_popup(
|
||||
popup_fn(f, app, popup_area);
|
||||
}
|
||||
|
||||
fn draw_popup_ui<T: DrawUi>(f: &mut Frame<'_>, app: &mut App<'_>, size: Size) {
|
||||
let (percent_x, percent_y) = size.to_percent();
|
||||
let popup_area = centered_rect(percent_x, percent_y, f.area());
|
||||
f.render_widget(Clear, popup_area);
|
||||
f.render_widget(background_block(), popup_area);
|
||||
T::draw(f, app, popup_area);
|
||||
}
|
||||
|
||||
pub fn draw_popup_over(
|
||||
f: &mut Frame<'_>,
|
||||
app: &mut App<'_>,
|
||||
area: Rect,
|
||||
background_fn: impl Fn(&mut Frame<'_>, &mut App<'_>, Rect),
|
||||
popup_fn: impl Fn(&mut Frame<'_>, &mut App<'_>, Rect),
|
||||
size: Size,
|
||||
) {
|
||||
background_fn(f, app, area);
|
||||
|
||||
draw_popup(f, app, popup_fn, size);
|
||||
}
|
||||
|
||||
pub fn draw_popup_over_ui<T: DrawUi>(
|
||||
f: &mut Frame<'_>,
|
||||
app: &mut App<'_>,
|
||||
area: Rect,
|
||||
background_fn: impl Fn(&mut Frame<'_>, &mut App<'_>, Rect),
|
||||
size: Size,
|
||||
) {
|
||||
background_fn(f, app, area);
|
||||
|
||||
draw_popup_ui::<T>(f, app, size);
|
||||
}
|
||||
|
||||
fn draw_tabs(f: &mut Frame<'_>, area: Rect, title: &str, tab_state: &TabState) -> Rect {
|
||||
if title.is_empty() {
|
||||
f.render_widget(layout_block(), area);
|
||||
|
||||
@@ -32,12 +32,10 @@ impl DrawUi for BlocklistUi {
|
||||
|
||||
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
if let Route::Radarr(active_radarr_block, _) = app.get_current_route() {
|
||||
draw_blocklist_table(f, app, area);
|
||||
|
||||
match active_radarr_block {
|
||||
ActiveRadarrBlock::Blocklist | ActiveRadarrBlock::BlocklistSortPrompt => {
|
||||
draw_blocklist_table(f, app, area)
|
||||
}
|
||||
ActiveRadarrBlock::BlocklistItemDetails => {
|
||||
draw_blocklist_table(f, app, area);
|
||||
draw_blocklist_item_details_popup(f, app);
|
||||
}
|
||||
ActiveRadarrBlock::DeleteBlocklistItemPrompt => {
|
||||
@@ -55,7 +53,6 @@ impl DrawUi for BlocklistUi {
|
||||
.prompt(&prompt)
|
||||
.yes_no_value(app.data.radarr_data.prompt_confirm);
|
||||
|
||||
draw_blocklist_table(f, app, area);
|
||||
f.render_widget(
|
||||
Popup::new(confirmation_prompt).size(Size::MediumPrompt),
|
||||
f.area(),
|
||||
@@ -67,7 +64,6 @@ impl DrawUi for BlocklistUi {
|
||||
.prompt("Do you want to clear your blocklist?")
|
||||
.yes_no_value(app.data.radarr_data.prompt_confirm);
|
||||
|
||||
draw_blocklist_table(f, app, area);
|
||||
f.render_widget(
|
||||
Popup::new(confirmation_prompt).size(Size::SmallPrompt),
|
||||
f.area(),
|
||||
|
||||
@@ -12,7 +12,6 @@ use crate::models::servarr_data::radarr::radarr_data::{
|
||||
ActiveRadarrBlock, COLLECTION_DETAILS_BLOCKS,
|
||||
};
|
||||
use crate::models::{EnumDisplayStyle, Route};
|
||||
use crate::ui::radarr_ui::collections::draw_collections;
|
||||
use crate::ui::styles::ManagarrStyle;
|
||||
use crate::ui::utils::{
|
||||
borderless_block, get_width_from_percentage, layout_block_top_border_with_title, title_block,
|
||||
@@ -20,7 +19,7 @@ use crate::ui::utils::{
|
||||
};
|
||||
use crate::ui::widgets::managarr_table::ManagarrTable;
|
||||
use crate::ui::widgets::popup::Size;
|
||||
use crate::ui::{draw_popup_over, DrawUi};
|
||||
use crate::ui::{draw_popup, DrawUi};
|
||||
use crate::utils::convert_runtime;
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -31,41 +30,25 @@ pub(super) struct CollectionDetailsUi;
|
||||
|
||||
impl DrawUi for CollectionDetailsUi {
|
||||
fn accepts(route: Route) -> bool {
|
||||
if let Route::Radarr(active_radarr_block, _) = route {
|
||||
if let Route::Radarr(active_radarr_block, context_option) = route {
|
||||
if let Some(context) = context_option {
|
||||
return COLLECTION_DETAILS_BLOCKS.contains(&active_radarr_block)
|
||||
&& context == ActiveRadarrBlock::CollectionDetails;
|
||||
}
|
||||
|
||||
return COLLECTION_DETAILS_BLOCKS.contains(&active_radarr_block);
|
||||
}
|
||||
|
||||
false
|
||||
}
|
||||
|
||||
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, _area: Rect) {
|
||||
if let Route::Radarr(active_radarr_block, context_option) = app.get_current_route() {
|
||||
let draw_collection_details_popup =
|
||||
|f: &mut Frame<'_>, app: &mut App<'_>, popup_area: Rect| match context_option
|
||||
.unwrap_or(active_radarr_block)
|
||||
{
|
||||
ActiveRadarrBlock::ViewMovieOverview => {
|
||||
draw_popup_over(
|
||||
f,
|
||||
app,
|
||||
popup_area,
|
||||
draw_collection_details,
|
||||
draw_movie_overview,
|
||||
Size::Small,
|
||||
);
|
||||
}
|
||||
ActiveRadarrBlock::CollectionDetails => draw_collection_details(f, app, popup_area),
|
||||
_ => (),
|
||||
};
|
||||
draw_popup(f, app, draw_collection_details, Size::Large);
|
||||
|
||||
draw_popup_over(
|
||||
f,
|
||||
app,
|
||||
area,
|
||||
draw_collections,
|
||||
draw_collection_details_popup,
|
||||
Size::Large,
|
||||
);
|
||||
if context_option.unwrap_or(active_radarr_block) == ActiveRadarrBlock::ViewMovieOverview {
|
||||
draw_popup(f, app, draw_movie_overview, Size::Small);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,5 +17,7 @@ mod tests {
|
||||
assert!(!CollectionDetailsUi::accepts(active_radarr_block.into()));
|
||||
}
|
||||
});
|
||||
|
||||
assert!(CollectionDetailsUi::accepts((ActiveRadarrBlock::CollectionDetails, Some(ActiveRadarrBlock::CollectionDetails)).into()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
use std::sync::atomic::Ordering;
|
||||
|
||||
use ratatui::layout::{Constraint, Layout, Rect};
|
||||
use ratatui::text::Text;
|
||||
use ratatui::widgets::{ListItem, Paragraph};
|
||||
use ratatui::Frame;
|
||||
use std::sync::atomic::Ordering;
|
||||
|
||||
use crate::app::context_clues::{build_context_clue_string, CONFIRMATION_PROMPT_CONTEXT_CLUES};
|
||||
use crate::app::App;
|
||||
@@ -14,7 +13,6 @@ use crate::models::servarr_data::radarr::radarr_data::{
|
||||
use crate::models::{EnumDisplayStyle, Route};
|
||||
use crate::render_selectable_input_box;
|
||||
use crate::ui::radarr_ui::collections::collection_details_ui::CollectionDetailsUi;
|
||||
use crate::ui::radarr_ui::collections::draw_collections;
|
||||
use crate::ui::styles::ManagarrStyle;
|
||||
use crate::ui::utils::{layout_paragraph_borderless, title_block_centered};
|
||||
use crate::ui::widgets::button::Button;
|
||||
@@ -22,7 +20,7 @@ use crate::ui::widgets::checkbox::Checkbox;
|
||||
use crate::ui::widgets::input_box::InputBox;
|
||||
use crate::ui::widgets::popup::{Popup, Size};
|
||||
use crate::ui::widgets::selectable_list::SelectableList;
|
||||
use crate::ui::{draw_popup, draw_popup_over, draw_popup_over_ui, DrawUi};
|
||||
use crate::ui::{draw_popup, DrawUi};
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "edit_collection_ui_tests.rs"]
|
||||
@@ -32,51 +30,42 @@ pub(super) struct EditCollectionUi;
|
||||
|
||||
impl DrawUi for EditCollectionUi {
|
||||
fn accepts(route: Route) -> bool {
|
||||
if let Route::Radarr(active_radarr_block, _) = route {
|
||||
if let Route::Radarr(active_radarr_block, context_option) = route {
|
||||
if let Some(context) = context_option {
|
||||
return EDIT_COLLECTION_BLOCKS.contains(&active_radarr_block)
|
||||
&& context == ActiveRadarrBlock::CollectionDetails;
|
||||
}
|
||||
|
||||
return EDIT_COLLECTION_BLOCKS.contains(&active_radarr_block);
|
||||
}
|
||||
|
||||
false
|
||||
}
|
||||
|
||||
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, _area: Rect) {
|
||||
if let Route::Radarr(active_radarr_block, context_option) = app.get_current_route() {
|
||||
let draw_edit_collection_prompt =
|
||||
|f: &mut Frame<'_>, app: &mut App<'_>, prompt_area: Rect| match active_radarr_block {
|
||||
ActiveRadarrBlock::EditCollectionSelectMinimumAvailability => {
|
||||
draw_edit_collection_confirmation_prompt(f, app, prompt_area);
|
||||
draw_edit_collection_select_minimum_availability_popup(f, app);
|
||||
}
|
||||
ActiveRadarrBlock::EditCollectionSelectQualityProfile => {
|
||||
draw_edit_collection_confirmation_prompt(f, app, prompt_area);
|
||||
draw_edit_collection_select_quality_profile_popup(f, app);
|
||||
}
|
||||
ActiveRadarrBlock::EditCollectionPrompt
|
||||
| ActiveRadarrBlock::EditCollectionToggleMonitored
|
||||
| ActiveRadarrBlock::EditCollectionRootFolderPathInput
|
||||
| ActiveRadarrBlock::EditCollectionToggleSearchOnAdd => {
|
||||
draw_edit_collection_confirmation_prompt(f, app, prompt_area)
|
||||
}
|
||||
_ => (),
|
||||
};
|
||||
|
||||
if let Some(context) = context_option {
|
||||
match context {
|
||||
ActiveRadarrBlock::Collections => draw_popup_over(
|
||||
f,
|
||||
app,
|
||||
area,
|
||||
draw_collections,
|
||||
draw_edit_collection_prompt,
|
||||
Size::Medium,
|
||||
),
|
||||
_ if COLLECTION_DETAILS_BLOCKS.contains(&context) => {
|
||||
draw_popup_over_ui::<CollectionDetailsUi>(f, app, area, draw_collections, Size::Large);
|
||||
draw_popup(f, app, draw_edit_collection_prompt, Size::Medium);
|
||||
}
|
||||
_ => (),
|
||||
if COLLECTION_DETAILS_BLOCKS.contains(&context) {
|
||||
draw_popup(f, app, CollectionDetailsUi::draw, Size::Large);
|
||||
}
|
||||
}
|
||||
|
||||
draw_popup(
|
||||
f,
|
||||
app,
|
||||
draw_edit_collection_confirmation_prompt,
|
||||
Size::Medium,
|
||||
);
|
||||
|
||||
match active_radarr_block {
|
||||
ActiveRadarrBlock::EditCollectionSelectMinimumAvailability => {
|
||||
draw_edit_collection_select_minimum_availability_popup(f, app);
|
||||
}
|
||||
ActiveRadarrBlock::EditCollectionSelectQualityProfile => {
|
||||
draw_edit_collection_select_quality_profile_popup(f, app);
|
||||
}
|
||||
_ => (),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@ mod tests {
|
||||
} else {
|
||||
assert!(!EditCollectionUi::accepts(active_radarr_block.into()));
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
assert!(EditCollectionUi::accepts((ActiveRadarrBlock::EditCollectionPrompt, Some(ActiveRadarrBlock::CollectionDetails)).into()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,6 @@ use ratatui::layout::{Constraint, Rect};
|
||||
use ratatui::widgets::{Cell, Row};
|
||||
use ratatui::Frame;
|
||||
|
||||
pub(super) use collection_details_ui::draw_collection_details;
|
||||
|
||||
use crate::app::App;
|
||||
use crate::models::radarr_models::Collection;
|
||||
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, COLLECTIONS_BLOCKS};
|
||||
@@ -38,37 +36,23 @@ impl DrawUi for CollectionsUi {
|
||||
|
||||
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
let route = app.get_current_route();
|
||||
let mut collections_ui_matcher = |active_radarr_block| match active_radarr_block {
|
||||
ActiveRadarrBlock::Collections
|
||||
| ActiveRadarrBlock::CollectionsSortPrompt
|
||||
| ActiveRadarrBlock::SearchCollection
|
||||
| ActiveRadarrBlock::SearchCollectionError
|
||||
| ActiveRadarrBlock::FilterCollections
|
||||
| ActiveRadarrBlock::FilterCollectionsError => draw_collections(f, app, area),
|
||||
ActiveRadarrBlock::UpdateAllCollectionsPrompt => {
|
||||
draw_collections(f, app, area);
|
||||
|
||||
match route {
|
||||
_ if CollectionDetailsUi::accepts(route) => CollectionDetailsUi::draw(f, app, area),
|
||||
_ if EditCollectionUi::accepts(route) => EditCollectionUi::draw(f, app, area),
|
||||
Route::Radarr(ActiveRadarrBlock::UpdateAllCollectionsPrompt, _) => {
|
||||
let confirmation_prompt = ConfirmationPrompt::new()
|
||||
.title("Update All Collections")
|
||||
.prompt("Do you want to update all of your collections?")
|
||||
.yes_no_value(app.data.radarr_data.prompt_confirm);
|
||||
|
||||
draw_collections(f, app, area);
|
||||
f.render_widget(
|
||||
Popup::new(confirmation_prompt).size(Size::MediumPrompt),
|
||||
f.area(),
|
||||
);
|
||||
}
|
||||
_ => (),
|
||||
};
|
||||
|
||||
match route {
|
||||
_ if CollectionDetailsUi::accepts(route) => CollectionDetailsUi::draw(f, app, area),
|
||||
_ if EditCollectionUi::accepts(route) => EditCollectionUi::draw(f, app, area),
|
||||
Route::Radarr(active_radarr_block, _)
|
||||
if COLLECTIONS_BLOCKS.contains(&active_radarr_block) =>
|
||||
{
|
||||
collections_ui_matcher(active_radarr_block)
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -123,7 +107,11 @@ pub(super) fn draw_collections(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect)
|
||||
.primary()
|
||||
};
|
||||
let collections_table = ManagarrTable::new(content, collection_row_mapping)
|
||||
.loading(app.is_loading)
|
||||
.loading(
|
||||
app.is_loading
|
||||
|| app.data.radarr_data.movies.is_empty()
|
||||
|| app.data.radarr_data.quality_profile_map.is_empty(),
|
||||
)
|
||||
.footer(collections_table_footer)
|
||||
.block(layout_block_top_border())
|
||||
.sorting(active_radarr_block == ActiveRadarrBlock::CollectionsSortPrompt)
|
||||
|
||||
@@ -31,8 +31,9 @@ impl DrawUi for DownloadsUi {
|
||||
|
||||
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
if let Route::Radarr(active_radarr_block, _) = app.get_current_route() {
|
||||
draw_downloads(f, app, area);
|
||||
|
||||
match active_radarr_block {
|
||||
ActiveRadarrBlock::Downloads => draw_downloads(f, app, area),
|
||||
ActiveRadarrBlock::DeleteDownloadPrompt => {
|
||||
let prompt = format!(
|
||||
"Do you really want to delete this download: \n{}?",
|
||||
@@ -43,7 +44,6 @@ impl DrawUi for DownloadsUi {
|
||||
.prompt(&prompt)
|
||||
.yes_no_value(app.data.radarr_data.prompt_confirm);
|
||||
|
||||
draw_downloads(f, app, area);
|
||||
f.render_widget(
|
||||
Popup::new(confirmation_prompt).size(Size::MediumPrompt),
|
||||
f.area(),
|
||||
@@ -55,7 +55,6 @@ impl DrawUi for DownloadsUi {
|
||||
.prompt("Do you want to update your downloads?")
|
||||
.yes_no_value(app.data.radarr_data.prompt_confirm);
|
||||
|
||||
draw_downloads(f, app, area);
|
||||
f.render_widget(
|
||||
Popup::new(confirmation_prompt).size(Size::MediumPrompt),
|
||||
f.area(),
|
||||
|
||||
@@ -5,7 +5,6 @@ use crate::app::App;
|
||||
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, EDIT_INDEXER_BLOCKS};
|
||||
use crate::models::Route;
|
||||
use crate::render_selectable_input_box;
|
||||
use crate::ui::radarr_ui::indexers::draw_indexers;
|
||||
use crate::ui::styles::ManagarrStyle;
|
||||
use crate::ui::utils::title_block_centered;
|
||||
use crate::ui::widgets::button::Button;
|
||||
@@ -13,7 +12,7 @@ use crate::ui::widgets::checkbox::Checkbox;
|
||||
use crate::ui::widgets::input_box::InputBox;
|
||||
use crate::ui::widgets::loading_block::LoadingBlock;
|
||||
use crate::ui::widgets::popup::Size;
|
||||
use crate::ui::{draw_popup_over, DrawUi};
|
||||
use crate::ui::{draw_popup, DrawUi};
|
||||
use ratatui::layout::{Constraint, Flex, Layout, Rect};
|
||||
use ratatui::text::Text;
|
||||
use ratatui::widgets::Paragraph;
|
||||
@@ -34,12 +33,10 @@ impl DrawUi for EditIndexerUi {
|
||||
false
|
||||
}
|
||||
|
||||
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
draw_popup_over(
|
||||
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, _area: Rect) {
|
||||
draw_popup(
|
||||
f,
|
||||
app,
|
||||
area,
|
||||
draw_indexers,
|
||||
draw_edit_indexer_prompt,
|
||||
Size::WideLargePrompt,
|
||||
);
|
||||
|
||||
@@ -12,7 +12,6 @@ use crate::models::servarr_data::radarr::radarr_data::{
|
||||
};
|
||||
use crate::models::Route;
|
||||
use crate::render_selectable_input_box;
|
||||
use crate::ui::radarr_ui::indexers::draw_indexers;
|
||||
use crate::ui::styles::ManagarrStyle;
|
||||
use crate::ui::utils::title_block_centered;
|
||||
use crate::ui::widgets::button::Button;
|
||||
@@ -20,7 +19,7 @@ use crate::ui::widgets::checkbox::Checkbox;
|
||||
use crate::ui::widgets::input_box::InputBox;
|
||||
use crate::ui::widgets::loading_block::LoadingBlock;
|
||||
use crate::ui::widgets::popup::Size;
|
||||
use crate::ui::{draw_popup_over, DrawUi};
|
||||
use crate::ui::{draw_popup, DrawUi};
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "indexer_settings_ui_tests.rs"]
|
||||
@@ -37,12 +36,10 @@ impl DrawUi for IndexerSettingsUi {
|
||||
false
|
||||
}
|
||||
|
||||
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
draw_popup_over(
|
||||
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, _area: Rect) {
|
||||
draw_popup(
|
||||
f,
|
||||
app,
|
||||
area,
|
||||
draw_indexers,
|
||||
draw_edit_indexer_settings_prompt,
|
||||
Size::WideLargePrompt,
|
||||
);
|
||||
|
||||
@@ -44,63 +44,62 @@ impl DrawUi for IndexersUi {
|
||||
|
||||
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
let route = app.get_current_route();
|
||||
let mut indexers_matchers = |active_radarr_block| match active_radarr_block {
|
||||
ActiveRadarrBlock::Indexers => draw_indexers(f, app, area),
|
||||
ActiveRadarrBlock::TestIndexer => {
|
||||
draw_indexers(f, app, area);
|
||||
if app.is_loading {
|
||||
let loading_popup = Popup::new(LoadingBlock::new(
|
||||
app.is_loading,
|
||||
title_block("Testing Indexer"),
|
||||
))
|
||||
.size(Size::LargeMessage);
|
||||
f.render_widget(loading_popup, f.area());
|
||||
} else {
|
||||
let popup = if let Some(result) = app.data.radarr_data.indexer_test_error.as_ref() {
|
||||
Popup::new(Message::new(result.clone())).size(Size::LargeMessage)
|
||||
} else {
|
||||
let message = Message::new("Indexer test succeeded!")
|
||||
.title("Success")
|
||||
.style(Style::new().success().bold());
|
||||
Popup::new(message).size(Size::Message)
|
||||
};
|
||||
|
||||
f.render_widget(popup, f.area());
|
||||
}
|
||||
}
|
||||
ActiveRadarrBlock::DeleteIndexerPrompt => {
|
||||
let prompt = format!(
|
||||
"Do you really want to delete this indexer: \n{}?",
|
||||
app
|
||||
.data
|
||||
.radarr_data
|
||||
.indexers
|
||||
.current_selection()
|
||||
.name
|
||||
.clone()
|
||||
.unwrap_or_default()
|
||||
);
|
||||
let confirmation_prompt = ConfirmationPrompt::new()
|
||||
.title("Delete Indexer")
|
||||
.prompt(&prompt)
|
||||
.yes_no_value(app.data.radarr_data.prompt_confirm);
|
||||
|
||||
draw_indexers(f, app, area);
|
||||
f.render_widget(
|
||||
Popup::new(confirmation_prompt).size(Size::MediumPrompt),
|
||||
f.area(),
|
||||
);
|
||||
}
|
||||
_ => (),
|
||||
};
|
||||
draw_indexers(f, app, area);
|
||||
|
||||
match route {
|
||||
_ if EditIndexerUi::accepts(route) => EditIndexerUi::draw(f, app, area),
|
||||
_ if IndexerSettingsUi::accepts(route) => IndexerSettingsUi::draw(f, app, area),
|
||||
_ if TestAllIndexersUi::accepts(route) => TestAllIndexersUi::draw(f, app, area),
|
||||
Route::Radarr(active_radarr_block, _) if INDEXERS_BLOCKS.contains(&active_radarr_block) => {
|
||||
indexers_matchers(active_radarr_block)
|
||||
}
|
||||
Route::Radarr(active_radarr_block, _) => match active_radarr_block {
|
||||
ActiveRadarrBlock::TestIndexer => {
|
||||
if app.is_loading || app.data.radarr_data.indexer_test_errors.is_none() {
|
||||
let loading_popup = Popup::new(LoadingBlock::new(
|
||||
app.is_loading || app.data.radarr_data.indexer_test_errors.is_none(),
|
||||
title_block("Testing Indexer"),
|
||||
))
|
||||
.size(Size::LargeMessage);
|
||||
f.render_widget(loading_popup, f.area());
|
||||
} else {
|
||||
let popup = {
|
||||
let result = app.data.radarr_data.indexer_test_errors.as_ref().expect("Test result is unpopulated");
|
||||
|
||||
if !result.is_empty() {
|
||||
Popup::new(Message::new(result.clone())).size(Size::LargeMessage)
|
||||
} else {
|
||||
let message = Message::new("Indexer test succeeded!")
|
||||
.title("Success")
|
||||
.style(Style::new().success().bold());
|
||||
Popup::new(message).size(Size::Message)
|
||||
}
|
||||
};
|
||||
|
||||
f.render_widget(popup, f.area());
|
||||
}
|
||||
}
|
||||
ActiveRadarrBlock::DeleteIndexerPrompt => {
|
||||
let prompt = format!(
|
||||
"Do you really want to delete this indexer: \n{}?",
|
||||
app
|
||||
.data
|
||||
.radarr_data
|
||||
.indexers
|
||||
.current_selection()
|
||||
.name
|
||||
.clone()
|
||||
.unwrap_or_default()
|
||||
);
|
||||
let confirmation_prompt = ConfirmationPrompt::new()
|
||||
.title("Delete Indexer")
|
||||
.prompt(&prompt)
|
||||
.yes_no_value(app.data.radarr_data.prompt_confirm);
|
||||
|
||||
f.render_widget(
|
||||
Popup::new(confirmation_prompt).size(Size::MediumPrompt),
|
||||
f.area(),
|
||||
);
|
||||
}
|
||||
_ => (),
|
||||
},
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,11 @@ use crate::app::App;
|
||||
use crate::models::servarr_data::modals::IndexerTestResultModalItem;
|
||||
use crate::models::servarr_data::radarr::radarr_data::ActiveRadarrBlock;
|
||||
use crate::models::Route;
|
||||
use crate::ui::radarr_ui::indexers::draw_indexers;
|
||||
use crate::ui::styles::ManagarrStyle;
|
||||
use crate::ui::utils::{borderless_block, get_width_from_percentage, title_block};
|
||||
use crate::ui::widgets::managarr_table::ManagarrTable;
|
||||
use crate::ui::widgets::popup::Size;
|
||||
use crate::ui::{draw_popup_over, DrawUi};
|
||||
use crate::ui::{draw_popup, DrawUi};
|
||||
use ratatui::layout::{Alignment, Constraint, Rect};
|
||||
use ratatui::widgets::{Cell, Row};
|
||||
use ratatui::Frame;
|
||||
@@ -28,26 +27,22 @@ impl DrawUi for TestAllIndexersUi {
|
||||
false
|
||||
}
|
||||
|
||||
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
draw_popup_over(
|
||||
f,
|
||||
app,
|
||||
area,
|
||||
draw_indexers,
|
||||
draw_test_all_indexers_test_results,
|
||||
Size::Large,
|
||||
);
|
||||
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, _area: Rect) {
|
||||
draw_popup(f, app, draw_test_all_indexers_test_results, Size::Large);
|
||||
}
|
||||
}
|
||||
|
||||
fn draw_test_all_indexers_test_results(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
let is_loading = app.is_loading || app.data.radarr_data.indexer_test_all_results.is_none();
|
||||
let block = title_block("Test All Indexers");
|
||||
|
||||
let current_selection =
|
||||
if let Some(test_all_results) = app.data.radarr_data.indexer_test_all_results.as_ref() {
|
||||
test_all_results.current_selection().clone()
|
||||
} else {
|
||||
IndexerTestResultModalItem::default()
|
||||
};
|
||||
f.render_widget(title_block("Test All Indexers"), area);
|
||||
f.render_widget(block, area);
|
||||
let help_footer = format!(
|
||||
"<↑↓> scroll | {}",
|
||||
build_context_clue_string(&BARE_POPUP_CONTEXT_CLUES)
|
||||
@@ -77,7 +72,7 @@ fn draw_test_all_indexers_test_results(f: &mut Frame<'_>, app: &mut App<'_>, are
|
||||
test_results_row_mapping,
|
||||
)
|
||||
.block(borderless_block())
|
||||
.loading(app.is_loading)
|
||||
.loading(is_loading)
|
||||
.footer(Some(help_footer))
|
||||
.footer_alignment(Alignment::Center)
|
||||
.margin(1)
|
||||
|
||||
@@ -13,8 +13,6 @@ use crate::models::radarr_models::AddMovieSearchResult;
|
||||
use crate::models::servarr_data::radarr::modals::AddMovieModal;
|
||||
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, ADD_MOVIE_BLOCKS};
|
||||
use crate::models::{EnumDisplayStyle, Route};
|
||||
use crate::ui::radarr_ui::collections::{draw_collection_details, draw_collections};
|
||||
use crate::ui::radarr_ui::library::draw_library;
|
||||
use crate::ui::styles::ManagarrStyle;
|
||||
use crate::ui::utils::{
|
||||
borderless_block, get_width_from_percentage, layout_block, layout_paragraph_borderless,
|
||||
@@ -26,9 +24,10 @@ use crate::ui::widgets::managarr_table::ManagarrTable;
|
||||
use crate::ui::widgets::message::Message;
|
||||
use crate::ui::widgets::popup::{Popup, Size};
|
||||
use crate::ui::widgets::selectable_list::SelectableList;
|
||||
use crate::ui::{draw_popup_over, DrawUi};
|
||||
use crate::ui::{draw_popup, DrawUi};
|
||||
use crate::utils::convert_runtime;
|
||||
use crate::{render_selectable_input_box, App};
|
||||
use crate::ui::radarr_ui::collections::CollectionsUi;
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "add_movie_ui_tests.rs"]
|
||||
@@ -47,72 +46,34 @@ impl DrawUi for AddMovieUi {
|
||||
|
||||
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
if let Route::Radarr(active_radarr_block, context_option) = app.get_current_route() {
|
||||
let draw_add_movie_search_popup =
|
||||
|f: &mut Frame<'_>, app: &mut App<'_>, area: Rect| match active_radarr_block {
|
||||
ActiveRadarrBlock::AddMovieSearchInput
|
||||
| ActiveRadarrBlock::AddMovieSearchResults
|
||||
| ActiveRadarrBlock::AddMovieEmptySearchResults => {
|
||||
draw_add_movie_search(f, app, area);
|
||||
}
|
||||
if context_option.is_some() {
|
||||
CollectionsUi::draw(f, app, area);
|
||||
draw_popup(f, app, draw_confirmation_popup, Size::Medium);
|
||||
} else {
|
||||
draw_popup(f, app, draw_add_movie_search, Size::Large);
|
||||
|
||||
match active_radarr_block {
|
||||
ActiveRadarrBlock::AddMoviePrompt
|
||||
| ActiveRadarrBlock::AddMovieSelectMonitor
|
||||
| ActiveRadarrBlock::AddMovieSelectMinimumAvailability
|
||||
| ActiveRadarrBlock::AddMovieSelectQualityProfile
|
||||
| ActiveRadarrBlock::AddMovieSelectRootFolder
|
||||
| ActiveRadarrBlock::AddMovieTagsInput => {
|
||||
if context_option.is_some() {
|
||||
draw_popup_over(
|
||||
draw_popup(
|
||||
f,
|
||||
app,
|
||||
area,
|
||||
draw_collection_details,
|
||||
draw_confirmation_popup,
|
||||
Size::Medium,
|
||||
);
|
||||
} else {
|
||||
draw_popup_over(
|
||||
f,
|
||||
app,
|
||||
area,
|
||||
draw_add_movie_search,
|
||||
draw_confirmation_popup,
|
||||
Size::Medium,
|
||||
);
|
||||
}
|
||||
}
|
||||
ActiveRadarrBlock::AddMovieAlreadyInLibrary => {
|
||||
draw_add_movie_search(f, app, area);
|
||||
f.render_widget(
|
||||
Popup::new(Message::new("This film is already in your library")).size(Size::Message),
|
||||
f.area(),
|
||||
);
|
||||
}
|
||||
_ => (),
|
||||
};
|
||||
|
||||
match active_radarr_block {
|
||||
_ if ADD_MOVIE_BLOCKS.contains(&active_radarr_block) => {
|
||||
if context_option.is_some() {
|
||||
draw_popup_over(
|
||||
f,
|
||||
app,
|
||||
area,
|
||||
draw_collections,
|
||||
draw_add_movie_search_popup,
|
||||
Size::Large,
|
||||
)
|
||||
} else {
|
||||
draw_popup_over(
|
||||
f,
|
||||
app,
|
||||
area,
|
||||
draw_library,
|
||||
draw_add_movie_search_popup,
|
||||
Size::Large,
|
||||
)
|
||||
}
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -285,26 +246,21 @@ fn draw_add_movie_search(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
|
||||
fn draw_confirmation_popup(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
if let Route::Radarr(active_radarr_block, _) = app.get_current_route() {
|
||||
draw_confirmation_prompt(f, app, area);
|
||||
|
||||
match active_radarr_block {
|
||||
ActiveRadarrBlock::AddMovieSelectMonitor => {
|
||||
draw_confirmation_prompt(f, app, area);
|
||||
draw_add_movie_select_monitor_popup(f, app);
|
||||
}
|
||||
ActiveRadarrBlock::AddMovieSelectMinimumAvailability => {
|
||||
draw_confirmation_prompt(f, app, area);
|
||||
draw_add_movie_select_minimum_availability_popup(f, app);
|
||||
}
|
||||
ActiveRadarrBlock::AddMovieSelectQualityProfile => {
|
||||
draw_confirmation_prompt(f, app, area);
|
||||
draw_add_movie_select_quality_profile_popup(f, app);
|
||||
}
|
||||
ActiveRadarrBlock::AddMovieSelectRootFolder => {
|
||||
draw_confirmation_prompt(f, app, area);
|
||||
draw_add_movie_select_root_folder_popup(f, app);
|
||||
}
|
||||
ActiveRadarrBlock::AddMoviePrompt | ActiveRadarrBlock::AddMovieTagsInput => {
|
||||
draw_confirmation_prompt(f, app, area)
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ use ratatui::Frame;
|
||||
use crate::app::App;
|
||||
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, DELETE_MOVIE_BLOCKS};
|
||||
use crate::models::Route;
|
||||
use crate::ui::radarr_ui::library::draw_library;
|
||||
use crate::ui::widgets::checkbox::Checkbox;
|
||||
use crate::ui::widgets::confirmation_prompt::ConfirmationPrompt;
|
||||
use crate::ui::widgets::popup::{Popup, Size};
|
||||
@@ -25,7 +24,7 @@ impl DrawUi for DeleteMovieUi {
|
||||
false
|
||||
}
|
||||
|
||||
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, _area: Rect) {
|
||||
if matches!(
|
||||
app.get_current_route(),
|
||||
Route::Radarr(ActiveRadarrBlock::DeleteMoviePrompt, _)
|
||||
@@ -50,7 +49,6 @@ impl DrawUi for DeleteMovieUi {
|
||||
.yes_no_highlighted(selected_block == ActiveRadarrBlock::DeleteMovieConfirmPrompt)
|
||||
.yes_no_value(app.data.radarr_data.prompt_confirm);
|
||||
|
||||
draw_library(f, app, area);
|
||||
f.render_widget(
|
||||
Popup::new(confirmation_prompt).size(Size::MediumPrompt),
|
||||
f.area(),
|
||||
|
||||
@@ -14,7 +14,6 @@ use crate::models::servarr_data::radarr::radarr_data::{
|
||||
};
|
||||
use crate::models::{EnumDisplayStyle, Route};
|
||||
use crate::render_selectable_input_box;
|
||||
use crate::ui::radarr_ui::library::draw_library;
|
||||
use crate::ui::radarr_ui::library::movie_details_ui::MovieDetailsUi;
|
||||
|
||||
use crate::ui::styles::ManagarrStyle;
|
||||
@@ -24,7 +23,7 @@ use crate::ui::widgets::checkbox::Checkbox;
|
||||
use crate::ui::widgets::input_box::InputBox;
|
||||
use crate::ui::widgets::popup::{Popup, Size};
|
||||
use crate::ui::widgets::selectable_list::SelectableList;
|
||||
use crate::ui::{draw_popup, draw_popup_over, draw_popup_over_ui, DrawUi};
|
||||
use crate::ui::{draw_popup, DrawUi};
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "edit_movie_ui_tests.rs"]
|
||||
@@ -41,46 +40,25 @@ impl DrawUi for EditMovieUi {
|
||||
false
|
||||
}
|
||||
|
||||
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, _area: Rect) {
|
||||
if let Route::Radarr(active_radarr_block, context_option) = app.get_current_route() {
|
||||
let draw_edit_movie_prompt =
|
||||
|f: &mut Frame<'_>, app: &mut App<'_>, prompt_area: Rect| match active_radarr_block {
|
||||
ActiveRadarrBlock::EditMovieSelectMinimumAvailability => {
|
||||
draw_edit_movie_confirmation_prompt(f, app, prompt_area);
|
||||
draw_edit_movie_select_minimum_availability_popup(f, app);
|
||||
}
|
||||
ActiveRadarrBlock::EditMovieSelectQualityProfile => {
|
||||
draw_edit_movie_confirmation_prompt(f, app, prompt_area);
|
||||
draw_edit_movie_select_quality_profile_popup(f, app);
|
||||
}
|
||||
ActiveRadarrBlock::EditMoviePrompt
|
||||
| ActiveRadarrBlock::EditMovieToggleMonitored
|
||||
| ActiveRadarrBlock::EditMoviePathInput
|
||||
| ActiveRadarrBlock::EditMovieTagsInput => {
|
||||
draw_edit_movie_confirmation_prompt(f, app, prompt_area)
|
||||
}
|
||||
_ => (),
|
||||
};
|
||||
|
||||
if let Some(context) = context_option {
|
||||
match context {
|
||||
ActiveRadarrBlock::Movies => {
|
||||
draw_popup_over(
|
||||
f,
|
||||
app,
|
||||
area,
|
||||
draw_library,
|
||||
draw_edit_movie_prompt,
|
||||
Size::Medium,
|
||||
);
|
||||
}
|
||||
_ if MOVIE_DETAILS_BLOCKS.contains(&context) => {
|
||||
draw_popup_over_ui::<MovieDetailsUi>(f, app, area, draw_library, Size::Large);
|
||||
draw_popup(f, app, draw_edit_movie_prompt, Size::Medium);
|
||||
}
|
||||
_ => (),
|
||||
if MOVIE_DETAILS_BLOCKS.contains(&context) {
|
||||
draw_popup(f, app, MovieDetailsUi::draw, Size::Large);
|
||||
}
|
||||
}
|
||||
|
||||
draw_popup(f, app, draw_edit_movie_confirmation_prompt, Size::Medium);
|
||||
|
||||
match active_radarr_block {
|
||||
ActiveRadarrBlock::EditMovieSelectMinimumAvailability => {
|
||||
draw_edit_movie_select_minimum_availability_popup(f, app);
|
||||
}
|
||||
ActiveRadarrBlock::EditMovieSelectQualityProfile => {
|
||||
draw_edit_movie_select_quality_profile_popup(f, app);
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,43 +44,32 @@ impl DrawUi for LibraryUi {
|
||||
|
||||
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
let route = app.get_current_route();
|
||||
let mut library_ui_matchers = |active_radarr_block: ActiveRadarrBlock| match active_radarr_block
|
||||
{
|
||||
ActiveRadarrBlock::Movies
|
||||
| ActiveRadarrBlock::MoviesSortPrompt
|
||||
| ActiveRadarrBlock::SearchMovie
|
||||
| ActiveRadarrBlock::SearchMovieError
|
||||
| ActiveRadarrBlock::FilterMovies
|
||||
| ActiveRadarrBlock::FilterMoviesError => draw_library(f, app, area),
|
||||
ActiveRadarrBlock::UpdateAllMoviesPrompt => {
|
||||
if !matches!(route, Route::Radarr(_, Some(_))) {
|
||||
draw_library(f, app, area);
|
||||
}
|
||||
|
||||
match route {
|
||||
_ if MovieDetailsUi::accepts(route) => MovieDetailsUi::draw(f, app, area),
|
||||
_ if AddMovieUi::accepts(route) => AddMovieUi::draw(f, app, area),
|
||||
_ if EditMovieUi::accepts(route) => EditMovieUi::draw(f, app, area),
|
||||
_ if DeleteMovieUi::accepts(route) => DeleteMovieUi::draw(f, app, area),
|
||||
Route::Radarr(ActiveRadarrBlock::UpdateAllMoviesPrompt, _) => {
|
||||
let confirmation_prompt = ConfirmationPrompt::new()
|
||||
.title("Update All Movies")
|
||||
.prompt("Do you want to update info and scan your disks for all of your movies?")
|
||||
.yes_no_value(app.data.radarr_data.prompt_confirm);
|
||||
|
||||
draw_library(f, app, area);
|
||||
f.render_widget(
|
||||
Popup::new(confirmation_prompt).size(Size::MediumPrompt),
|
||||
f.area(),
|
||||
);
|
||||
}
|
||||
_ => (),
|
||||
};
|
||||
|
||||
match route {
|
||||
_ if MovieDetailsUi::accepts(route) => MovieDetailsUi::draw(f, app, area),
|
||||
_ if AddMovieUi::accepts(route) => AddMovieUi::draw(f, app, area),
|
||||
_ if EditMovieUi::accepts(route) => EditMovieUi::draw(f, app, area),
|
||||
_ if DeleteMovieUi::accepts(route) => DeleteMovieUi::draw(f, app, area),
|
||||
Route::Radarr(active_radarr_block, _) if LIBRARY_BLOCKS.contains(&active_radarr_block) => {
|
||||
library_ui_matchers(active_radarr_block)
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn draw_library(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
fn draw_library(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
if let Route::Radarr(active_radarr_block, _) = app.get_current_route() {
|
||||
let current_selection = if !app.data.radarr_data.movies.items.is_empty() {
|
||||
app.data.radarr_data.movies.current_selection().clone()
|
||||
|
||||
@@ -11,14 +11,13 @@ use crate::models::radarr_models::{Credit, MovieHistoryItem, RadarrRelease};
|
||||
use crate::models::servarr_data::radarr::modals::MovieDetailsModal;
|
||||
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, MOVIE_DETAILS_BLOCKS};
|
||||
use crate::models::Route;
|
||||
use crate::ui::radarr_ui::library::draw_library;
|
||||
use crate::ui::styles::ManagarrStyle;
|
||||
use crate::ui::utils::{borderless_block, decorate_peer_style, get_width_from_percentage, layout_block_bottom_border, layout_block_top_border};
|
||||
use crate::ui::widgets::confirmation_prompt::ConfirmationPrompt;
|
||||
use crate::ui::widgets::loading_block::LoadingBlock;
|
||||
use crate::ui::widgets::managarr_table::ManagarrTable;
|
||||
use crate::ui::widgets::popup::{Popup, Size};
|
||||
use crate::ui::{draw_popup_over, draw_tabs, DrawUi};
|
||||
use crate::ui::{draw_popup, draw_tabs, DrawUi};
|
||||
use crate::utils::convert_to_gb;
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -36,7 +35,7 @@ impl DrawUi for MovieDetailsUi {
|
||||
false
|
||||
}
|
||||
|
||||
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, _area: Rect) {
|
||||
if let Route::Radarr(active_radarr_block, context_option) = app.get_current_route() {
|
||||
let draw_movie_info_popup = |f: &mut Frame<'_>, app: &mut App<'_>, popup_area: Rect| {
|
||||
let content_area = draw_tabs(
|
||||
@@ -85,11 +84,9 @@ impl DrawUi for MovieDetailsUi {
|
||||
}
|
||||
};
|
||||
|
||||
draw_popup_over(
|
||||
draw_popup(
|
||||
f,
|
||||
app,
|
||||
area,
|
||||
draw_library,
|
||||
draw_movie_info_popup,
|
||||
Size::Large,
|
||||
);
|
||||
|
||||
@@ -11,7 +11,7 @@ use crate::ui::utils::layout_block_top_border;
|
||||
use crate::ui::widgets::confirmation_prompt::ConfirmationPrompt;
|
||||
use crate::ui::widgets::managarr_table::ManagarrTable;
|
||||
use crate::ui::widgets::popup::{Popup, Size};
|
||||
use crate::ui::{draw_input_box_popup, draw_popup_over, DrawUi};
|
||||
use crate::ui::{draw_input_box_popup, draw_popup, DrawUi};
|
||||
use crate::utils::convert_to_gb;
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -31,13 +31,12 @@ impl DrawUi for RootFoldersUi {
|
||||
|
||||
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
if let Route::Radarr(active_radarr_block, _) = app.get_current_route() {
|
||||
draw_root_folders(f, app, area);
|
||||
|
||||
match active_radarr_block {
|
||||
ActiveRadarrBlock::RootFolders => draw_root_folders(f, app, area),
|
||||
ActiveRadarrBlock::AddRootFolderPrompt => draw_popup_over(
|
||||
ActiveRadarrBlock::AddRootFolderPrompt => draw_popup(
|
||||
f,
|
||||
app,
|
||||
area,
|
||||
draw_root_folders,
|
||||
draw_add_root_folder_prompt_box,
|
||||
Size::InputBox,
|
||||
),
|
||||
@@ -51,7 +50,6 @@ impl DrawUi for RootFoldersUi {
|
||||
.prompt(&prompt)
|
||||
.yes_no_value(app.data.radarr_data.prompt_confirm);
|
||||
|
||||
draw_root_folders(f, app, area);
|
||||
f.render_widget(
|
||||
Popup::new(confirmation_prompt).size(Size::MediumPrompt),
|
||||
f.area(),
|
||||
|
||||
@@ -63,18 +63,15 @@ impl DrawUi for SystemUi {
|
||||
|
||||
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
let route = app.get_current_route();
|
||||
|
||||
match route {
|
||||
_ if SystemDetailsUi::accepts(route) => SystemDetailsUi::draw(f, app, area),
|
||||
_ if matches!(route, Route::Radarr(ActiveRadarrBlock::System, _)) => {
|
||||
draw_system_ui_layout(f, app, area)
|
||||
}
|
||||
_ => (),
|
||||
draw_system_ui_layout(f, app, area);
|
||||
|
||||
if SystemDetailsUi::accepts(route) {
|
||||
SystemDetailsUi::draw(f, app, area);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn draw_system_ui_layout(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
fn draw_system_ui_layout(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
let [activities_area, logs_area, help_area] = Layout::vertical([
|
||||
Constraint::Ratio(1, 2),
|
||||
Constraint::Ratio(1, 2),
|
||||
|
||||
@@ -10,7 +10,7 @@ use crate::models::radarr_models::RadarrTask;
|
||||
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, SYSTEM_DETAILS_BLOCKS};
|
||||
use crate::models::Route;
|
||||
use crate::ui::radarr_ui::system::{
|
||||
draw_queued_events, draw_system_ui_layout, extract_task_props, TASK_TABLE_CONSTRAINTS,
|
||||
draw_queued_events, extract_task_props, TASK_TABLE_CONSTRAINTS,
|
||||
TASK_TABLE_HEADERS,
|
||||
};
|
||||
use crate::ui::styles::ManagarrStyle;
|
||||
@@ -20,7 +20,7 @@ use crate::ui::widgets::loading_block::LoadingBlock;
|
||||
use crate::ui::widgets::managarr_table::ManagarrTable;
|
||||
use crate::ui::widgets::popup::{Popup, Size};
|
||||
use crate::ui::widgets::selectable_list::SelectableList;
|
||||
use crate::ui::{draw_popup_over, DrawUi};
|
||||
use crate::ui::{draw_popup, DrawUi};
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "system_details_ui_tests.rs"]
|
||||
@@ -37,33 +37,27 @@ impl DrawUi for SystemDetailsUi {
|
||||
false
|
||||
}
|
||||
|
||||
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, _area: Rect) {
|
||||
if let Route::Radarr(active_radarr_block, _) = app.get_current_route() {
|
||||
match active_radarr_block {
|
||||
ActiveRadarrBlock::SystemLogs => {
|
||||
draw_system_ui_layout(f, app, area);
|
||||
draw_logs_popup(f, app);
|
||||
}
|
||||
ActiveRadarrBlock::SystemTasks | ActiveRadarrBlock::SystemTaskStartConfirmPrompt => {
|
||||
draw_popup_over(
|
||||
draw_popup(
|
||||
f,
|
||||
app,
|
||||
area,
|
||||
draw_system_ui_layout,
|
||||
draw_tasks_popup,
|
||||
Size::Large,
|
||||
)
|
||||
}
|
||||
ActiveRadarrBlock::SystemQueuedEvents => draw_popup_over(
|
||||
ActiveRadarrBlock::SystemQueuedEvents => draw_popup(
|
||||
f,
|
||||
app,
|
||||
area,
|
||||
draw_system_ui_layout,
|
||||
draw_queued_events,
|
||||
Size::Medium,
|
||||
),
|
||||
ActiveRadarrBlock::SystemUpdates => {
|
||||
draw_system_ui_layout(f, app, area);
|
||||
draw_updates_popup(f, app);
|
||||
}
|
||||
_ => (),
|
||||
|
||||
@@ -32,12 +32,10 @@ impl DrawUi for BlocklistUi {
|
||||
|
||||
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
if let Route::Sonarr(active_sonarr_block, _) = app.get_current_route() {
|
||||
draw_blocklist_table(f, app, area);
|
||||
|
||||
match active_sonarr_block {
|
||||
ActiveSonarrBlock::Blocklist | ActiveSonarrBlock::BlocklistSortPrompt => {
|
||||
draw_blocklist_table(f, app, area)
|
||||
}
|
||||
ActiveSonarrBlock::BlocklistItemDetails => {
|
||||
draw_blocklist_table(f, app, area);
|
||||
draw_blocklist_item_details_popup(f, app);
|
||||
}
|
||||
ActiveSonarrBlock::DeleteBlocklistItemPrompt => {
|
||||
@@ -55,7 +53,6 @@ impl DrawUi for BlocklistUi {
|
||||
.prompt(&prompt)
|
||||
.yes_no_value(app.data.sonarr_data.prompt_confirm);
|
||||
|
||||
draw_blocklist_table(f, app, area);
|
||||
f.render_widget(
|
||||
Popup::new(confirmation_prompt).size(Size::MediumPrompt),
|
||||
f.area(),
|
||||
@@ -67,7 +64,6 @@ impl DrawUi for BlocklistUi {
|
||||
.prompt("Do you want to clear your blocklist?")
|
||||
.yes_no_value(app.data.sonarr_data.prompt_confirm);
|
||||
|
||||
draw_blocklist_table(f, app, area);
|
||||
f.render_widget(
|
||||
Popup::new(confirmation_prompt).size(Size::SmallPrompt),
|
||||
f.area(),
|
||||
|
||||
@@ -31,8 +31,9 @@ impl DrawUi for DownloadsUi {
|
||||
|
||||
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
if let Route::Sonarr(active_sonarr_block, _) = app.get_current_route() {
|
||||
draw_downloads(f, app, area);
|
||||
|
||||
match active_sonarr_block {
|
||||
ActiveSonarrBlock::Downloads => draw_downloads(f, app, area),
|
||||
ActiveSonarrBlock::DeleteDownloadPrompt => {
|
||||
let prompt = format!(
|
||||
"Do you really want to delete this download: \n{}?",
|
||||
@@ -43,7 +44,6 @@ impl DrawUi for DownloadsUi {
|
||||
.prompt(&prompt)
|
||||
.yes_no_value(app.data.sonarr_data.prompt_confirm);
|
||||
|
||||
draw_downloads(f, app, area);
|
||||
f.render_widget(
|
||||
Popup::new(confirmation_prompt).size(Size::MediumPrompt),
|
||||
f.area(),
|
||||
@@ -55,7 +55,6 @@ impl DrawUi for DownloadsUi {
|
||||
.prompt("Do you want to update your downloads?")
|
||||
.yes_no_value(app.data.sonarr_data.prompt_confirm);
|
||||
|
||||
draw_downloads(f, app, area);
|
||||
f.render_widget(
|
||||
Popup::new(confirmation_prompt).size(Size::MediumPrompt),
|
||||
f.area(),
|
||||
|
||||
@@ -39,18 +39,10 @@ impl DrawUi for HistoryUi {
|
||||
|
||||
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
if let Route::Sonarr(active_sonarr_block, _) = app.get_current_route() {
|
||||
match active_sonarr_block {
|
||||
ActiveSonarrBlock::History
|
||||
| ActiveSonarrBlock::HistorySortPrompt
|
||||
| ActiveSonarrBlock::SearchHistory
|
||||
| ActiveSonarrBlock::SearchHistoryError
|
||||
| ActiveSonarrBlock::FilterHistory
|
||||
| ActiveSonarrBlock::FilterHistoryError => draw_history_table(f, app, area),
|
||||
ActiveSonarrBlock::HistoryItemDetails => {
|
||||
draw_history_table(f, app, area);
|
||||
draw_history_item_details_popup(f, app);
|
||||
}
|
||||
_ => (),
|
||||
draw_history_table(f, app, area);
|
||||
|
||||
if active_sonarr_block == ActiveSonarrBlock::HistoryItemDetails {
|
||||
draw_history_item_details_popup(f, app);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ use crate::app::App;
|
||||
use crate::models::servarr_data::sonarr::sonarr_data::{ActiveSonarrBlock, EDIT_INDEXER_BLOCKS};
|
||||
use crate::models::Route;
|
||||
use crate::render_selectable_input_box;
|
||||
use crate::ui::sonarr_ui::indexers::draw_indexers;
|
||||
use crate::ui::styles::ManagarrStyle;
|
||||
use crate::ui::utils::title_block_centered;
|
||||
use crate::ui::widgets::button::Button;
|
||||
@@ -13,7 +12,7 @@ use crate::ui::widgets::checkbox::Checkbox;
|
||||
use crate::ui::widgets::input_box::InputBox;
|
||||
use crate::ui::widgets::loading_block::LoadingBlock;
|
||||
use crate::ui::widgets::popup::Size;
|
||||
use crate::ui::{draw_popup_over, DrawUi};
|
||||
use crate::ui::{draw_popup, DrawUi};
|
||||
use ratatui::layout::{Constraint, Flex, Layout, Rect};
|
||||
use ratatui::text::Text;
|
||||
use ratatui::widgets::Paragraph;
|
||||
@@ -34,12 +33,10 @@ impl DrawUi for EditIndexerUi {
|
||||
false
|
||||
}
|
||||
|
||||
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
draw_popup_over(
|
||||
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, _area: Rect) {
|
||||
draw_popup(
|
||||
f,
|
||||
app,
|
||||
area,
|
||||
draw_indexers,
|
||||
draw_edit_indexer_prompt,
|
||||
Size::WideLargePrompt,
|
||||
);
|
||||
|
||||
@@ -10,14 +10,13 @@ use crate::models::servarr_data::sonarr::sonarr_data::{
|
||||
};
|
||||
use crate::models::Route;
|
||||
use crate::render_selectable_input_box;
|
||||
use crate::ui::sonarr_ui::indexers::draw_indexers;
|
||||
use crate::ui::styles::ManagarrStyle;
|
||||
use crate::ui::utils::title_block_centered;
|
||||
use crate::ui::widgets::button::Button;
|
||||
use crate::ui::widgets::input_box::InputBox;
|
||||
use crate::ui::widgets::loading_block::LoadingBlock;
|
||||
use crate::ui::widgets::popup::Size;
|
||||
use crate::ui::{draw_popup_over, DrawUi};
|
||||
use crate::ui::{draw_popup, DrawUi};
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "indexer_settings_ui_tests.rs"]
|
||||
@@ -34,12 +33,10 @@ impl DrawUi for IndexerSettingsUi {
|
||||
false
|
||||
}
|
||||
|
||||
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
draw_popup_over(
|
||||
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, _area: Rect) {
|
||||
draw_popup(
|
||||
f,
|
||||
app,
|
||||
area,
|
||||
draw_indexers,
|
||||
draw_edit_indexer_settings_prompt,
|
||||
Size::LargePrompt,
|
||||
);
|
||||
|
||||
@@ -44,62 +44,61 @@ impl DrawUi for IndexersUi {
|
||||
|
||||
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
let route = app.get_current_route();
|
||||
let mut indexers_matchers = |active_sonarr_block| match active_sonarr_block {
|
||||
ActiveSonarrBlock::Indexers => draw_indexers(f, app, area),
|
||||
ActiveSonarrBlock::TestIndexer => {
|
||||
draw_indexers(f, app, area);
|
||||
if app.is_loading || app.is_routing {
|
||||
let loading_popup = Popup::new(LoadingBlock::new(
|
||||
app.is_loading,
|
||||
title_block("Testing Indexer"),
|
||||
))
|
||||
.size(Size::LargeMessage);
|
||||
f.render_widget(loading_popup, f.area());
|
||||
} else {
|
||||
let popup = if let Some(result) = app.data.sonarr_data.indexer_test_error.as_ref() {
|
||||
Popup::new(Message::new(result.clone())).size(Size::LargeMessage)
|
||||
} else {
|
||||
let message = Message::new("Indexer test succeeded!")
|
||||
.title("Success")
|
||||
.style(Style::new().success().bold());
|
||||
Popup::new(message).size(Size::Message)
|
||||
};
|
||||
|
||||
f.render_widget(popup, f.area());
|
||||
}
|
||||
}
|
||||
ActiveSonarrBlock::DeleteIndexerPrompt => {
|
||||
let prompt = format!(
|
||||
"Do you really want to delete this indexer: \n{}?",
|
||||
app
|
||||
.data
|
||||
.sonarr_data
|
||||
.indexers
|
||||
.current_selection()
|
||||
.name
|
||||
.clone()
|
||||
.unwrap_or_default()
|
||||
);
|
||||
let confirmation_prompt = ConfirmationPrompt::new()
|
||||
.title("Delete Indexer")
|
||||
.prompt(&prompt)
|
||||
.yes_no_value(app.data.sonarr_data.prompt_confirm);
|
||||
|
||||
draw_indexers(f, app, area);
|
||||
f.render_widget(
|
||||
Popup::new(confirmation_prompt).size(Size::MediumPrompt),
|
||||
f.area(),
|
||||
);
|
||||
}
|
||||
_ => (),
|
||||
};
|
||||
draw_indexers(f, app, area);
|
||||
|
||||
match route {
|
||||
_ if EditIndexerUi::accepts(route) => EditIndexerUi::draw(f, app, area),
|
||||
_ if IndexerSettingsUi::accepts(route) => IndexerSettingsUi::draw(f, app, area),
|
||||
_ if TestAllIndexersUi::accepts(route) => TestAllIndexersUi::draw(f, app, area),
|
||||
Route::Sonarr(active_sonarr_block, _) if INDEXERS_BLOCKS.contains(&active_sonarr_block) => {
|
||||
indexers_matchers(active_sonarr_block)
|
||||
Route::Sonarr(active_sonarr_block, _) => match active_sonarr_block {
|
||||
ActiveSonarrBlock::TestIndexer => {
|
||||
if app.is_loading || app.data.sonarr_data.indexer_test_errors.is_none() {
|
||||
let loading_popup = Popup::new(LoadingBlock::new(
|
||||
app.is_loading || app.data.sonarr_data.indexer_test_errors.is_none(),
|
||||
title_block("Testing Indexer"),
|
||||
))
|
||||
.size(Size::LargeMessage);
|
||||
f.render_widget(loading_popup, f.area());
|
||||
} else {
|
||||
let popup = {
|
||||
let result = app.data.sonarr_data.indexer_test_errors.as_ref().expect("Test result is unpopulated");
|
||||
|
||||
if !result.is_empty() {
|
||||
Popup::new(Message::new(result.clone())).size(Size::LargeMessage)
|
||||
} else {
|
||||
let message = Message::new("Indexer test succeeded!")
|
||||
.title("Success")
|
||||
.style(Style::new().success().bold());
|
||||
Popup::new(message).size(Size::Message)
|
||||
}
|
||||
};
|
||||
|
||||
f.render_widget(popup, f.area());
|
||||
}
|
||||
}
|
||||
ActiveSonarrBlock::DeleteIndexerPrompt => {
|
||||
let prompt = format!(
|
||||
"Do you really want to delete this indexer: \n{}?",
|
||||
app
|
||||
.data
|
||||
.sonarr_data
|
||||
.indexers
|
||||
.current_selection()
|
||||
.name
|
||||
.clone()
|
||||
.unwrap_or_default()
|
||||
);
|
||||
let confirmation_prompt = ConfirmationPrompt::new()
|
||||
.title("Delete Indexer")
|
||||
.prompt(&prompt)
|
||||
.yes_no_value(app.data.sonarr_data.prompt_confirm);
|
||||
|
||||
f.render_widget(
|
||||
Popup::new(confirmation_prompt).size(Size::MediumPrompt),
|
||||
f.area(),
|
||||
);
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
|
||||
@@ -3,12 +3,11 @@ use crate::app::App;
|
||||
use crate::models::servarr_data::modals::IndexerTestResultModalItem;
|
||||
use crate::models::servarr_data::sonarr::sonarr_data::ActiveSonarrBlock;
|
||||
use crate::models::Route;
|
||||
use crate::ui::sonarr_ui::indexers::draw_indexers;
|
||||
use crate::ui::styles::ManagarrStyle;
|
||||
use crate::ui::utils::{borderless_block, get_width_from_percentage, title_block};
|
||||
use crate::ui::widgets::managarr_table::ManagarrTable;
|
||||
use crate::ui::widgets::popup::Size;
|
||||
use crate::ui::{draw_popup_over, DrawUi};
|
||||
use crate::ui::{draw_popup, DrawUi};
|
||||
use ratatui::layout::{Alignment, Constraint, Rect};
|
||||
use ratatui::widgets::{Cell, Row};
|
||||
use ratatui::Frame;
|
||||
@@ -28,12 +27,10 @@ impl DrawUi for TestAllIndexersUi {
|
||||
false
|
||||
}
|
||||
|
||||
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
draw_popup_over(
|
||||
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, _area: Rect) {
|
||||
draw_popup(
|
||||
f,
|
||||
app,
|
||||
area,
|
||||
draw_indexers,
|
||||
draw_test_all_indexers_test_results,
|
||||
Size::Large,
|
||||
);
|
||||
@@ -41,6 +38,7 @@ impl DrawUi for TestAllIndexersUi {
|
||||
}
|
||||
|
||||
fn draw_test_all_indexers_test_results(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
let is_loading = app.is_loading || app.data.sonarr_data.indexer_test_all_results.is_none();
|
||||
let current_selection =
|
||||
if let Some(test_all_results) = app.data.sonarr_data.indexer_test_all_results.as_ref() {
|
||||
test_all_results.current_selection().clone()
|
||||
@@ -77,7 +75,7 @@ fn draw_test_all_indexers_test_results(f: &mut Frame<'_>, app: &mut App<'_>, are
|
||||
test_results_row_mapping,
|
||||
)
|
||||
.block(borderless_block())
|
||||
.loading(app.is_loading)
|
||||
.loading(is_loading)
|
||||
.footer(Some(help_footer))
|
||||
.footer_alignment(Alignment::Center)
|
||||
.margin(1)
|
||||
|
||||
@@ -13,7 +13,6 @@ use crate::models::servarr_data::sonarr::modals::AddSeriesModal;
|
||||
use crate::models::servarr_data::sonarr::sonarr_data::{ActiveSonarrBlock, ADD_SERIES_BLOCKS};
|
||||
use crate::models::sonarr_models::AddSeriesSearchResult;
|
||||
use crate::models::{EnumDisplayStyle, Route};
|
||||
use crate::ui::sonarr_ui::library::draw_library;
|
||||
use crate::ui::styles::ManagarrStyle;
|
||||
use crate::ui::utils::{
|
||||
borderless_block, get_width_from_percentage, layout_block, layout_paragraph_borderless,
|
||||
@@ -26,7 +25,7 @@ use crate::ui::widgets::managarr_table::ManagarrTable;
|
||||
use crate::ui::widgets::message::Message;
|
||||
use crate::ui::widgets::popup::{Popup, Size};
|
||||
use crate::ui::widgets::selectable_list::SelectableList;
|
||||
use crate::ui::{draw_popup_over, DrawUi};
|
||||
use crate::ui::{draw_popup, DrawUi};
|
||||
use crate::{render_selectable_input_box, App};
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -44,50 +43,26 @@ impl DrawUi for AddSeriesUi {
|
||||
false
|
||||
}
|
||||
|
||||
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, _area: Rect) {
|
||||
if let Route::Sonarr(active_sonarr_block, _) = app.get_current_route() {
|
||||
let draw_add_series_search_popup =
|
||||
|f: &mut Frame<'_>, app: &mut App<'_>, area: Rect| match active_sonarr_block {
|
||||
ActiveSonarrBlock::AddSeriesSearchInput
|
||||
| ActiveSonarrBlock::AddSeriesSearchResults
|
||||
| ActiveSonarrBlock::AddSeriesEmptySearchResults => {
|
||||
draw_add_series_search(f, app, area);
|
||||
}
|
||||
ActiveSonarrBlock::AddSeriesPrompt
|
||||
| ActiveSonarrBlock::AddSeriesSelectMonitor
|
||||
| ActiveSonarrBlock::AddSeriesSelectSeriesType
|
||||
| ActiveSonarrBlock::AddSeriesSelectQualityProfile
|
||||
| ActiveSonarrBlock::AddSeriesSelectLanguageProfile
|
||||
| ActiveSonarrBlock::AddSeriesSelectRootFolder
|
||||
| ActiveSonarrBlock::AddSeriesTagsInput => {
|
||||
draw_popup_over(
|
||||
f,
|
||||
app,
|
||||
area,
|
||||
draw_add_series_search,
|
||||
draw_confirmation_popup,
|
||||
Size::Long,
|
||||
);
|
||||
}
|
||||
ActiveSonarrBlock::AddSeriesAlreadyInLibrary => {
|
||||
draw_add_series_search(f, app, area);
|
||||
f.render_widget(
|
||||
Popup::new(Message::new("This film is already in your library")).size(Size::Message),
|
||||
f.area(),
|
||||
);
|
||||
}
|
||||
_ => (),
|
||||
};
|
||||
|
||||
draw_popup(f, app, draw_add_series_search, Size::Large);
|
||||
|
||||
match active_sonarr_block {
|
||||
_ if ADD_SERIES_BLOCKS.contains(&active_sonarr_block) => draw_popup_over(
|
||||
f,
|
||||
app,
|
||||
area,
|
||||
draw_library,
|
||||
draw_add_series_search_popup,
|
||||
Size::Large,
|
||||
),
|
||||
ActiveSonarrBlock::AddSeriesPrompt
|
||||
| ActiveSonarrBlock::AddSeriesSelectMonitor
|
||||
| ActiveSonarrBlock::AddSeriesSelectSeriesType
|
||||
| ActiveSonarrBlock::AddSeriesSelectQualityProfile
|
||||
| ActiveSonarrBlock::AddSeriesSelectLanguageProfile
|
||||
| ActiveSonarrBlock::AddSeriesSelectRootFolder
|
||||
| ActiveSonarrBlock::AddSeriesTagsInput => {
|
||||
draw_popup(f, app, draw_confirmation_popup, Size::Long);
|
||||
}
|
||||
ActiveSonarrBlock::AddSeriesAlreadyInLibrary => {
|
||||
f.render_widget(
|
||||
Popup::new(Message::new("This series is already in your library")).size(Size::Message),
|
||||
f.area(),
|
||||
);
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ use ratatui::Frame;
|
||||
use crate::app::App;
|
||||
use crate::models::servarr_data::sonarr::sonarr_data::{ActiveSonarrBlock, DELETE_SERIES_BLOCKS};
|
||||
use crate::models::Route;
|
||||
use crate::ui::sonarr_ui::library::draw_library;
|
||||
use crate::ui::widgets::checkbox::Checkbox;
|
||||
use crate::ui::widgets::confirmation_prompt::ConfirmationPrompt;
|
||||
use crate::ui::widgets::popup::{Popup, Size};
|
||||
@@ -25,14 +24,14 @@ impl DrawUi for DeleteSeriesUi {
|
||||
false
|
||||
}
|
||||
|
||||
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, _area: Rect) {
|
||||
if matches!(
|
||||
app.get_current_route(),
|
||||
Route::Sonarr(ActiveSonarrBlock::DeleteSeriesPrompt, _)
|
||||
) {
|
||||
let selected_block = app.data.sonarr_data.selected_block.get_active_block();
|
||||
let prompt = format!(
|
||||
"Do you really want to delete: \n{}?",
|
||||
"Do you really want to delete the series: \n{}?",
|
||||
app.data.sonarr_data.series.current_selection().title.text
|
||||
);
|
||||
let checkboxes = vec![
|
||||
@@ -50,7 +49,6 @@ impl DrawUi for DeleteSeriesUi {
|
||||
.yes_no_highlighted(selected_block == ActiveSonarrBlock::DeleteSeriesConfirmPrompt)
|
||||
.yes_no_value(app.data.sonarr_data.prompt_confirm);
|
||||
|
||||
draw_library(f, app, area);
|
||||
f.render_widget(
|
||||
Popup::new(confirmation_prompt).size(Size::MediumPrompt),
|
||||
f.area(),
|
||||
|
||||
@@ -14,7 +14,6 @@ use crate::models::servarr_data::sonarr::sonarr_data::{
|
||||
};
|
||||
use crate::models::{EnumDisplayStyle, Route};
|
||||
use crate::render_selectable_input_box;
|
||||
use crate::ui::sonarr_ui::library::draw_library;
|
||||
|
||||
use crate::ui::styles::ManagarrStyle;
|
||||
use crate::ui::utils::{layout_paragraph_borderless, title_block_centered};
|
||||
@@ -23,7 +22,7 @@ use crate::ui::widgets::checkbox::Checkbox;
|
||||
use crate::ui::widgets::input_box::InputBox;
|
||||
use crate::ui::widgets::popup::{Popup, Size};
|
||||
use crate::ui::widgets::selectable_list::SelectableList;
|
||||
use crate::ui::{draw_popup, draw_popup_over, draw_popup_over_ui, DrawUi};
|
||||
use crate::ui::{draw_popup, DrawUi};
|
||||
|
||||
use super::series_details_ui::SeriesDetailsUi;
|
||||
|
||||
@@ -42,51 +41,33 @@ impl DrawUi for EditSeriesUi {
|
||||
false
|
||||
}
|
||||
|
||||
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, _area: Rect) {
|
||||
if let Route::Sonarr(active_sonarr_block, context_option) = app.get_current_route() {
|
||||
let draw_edit_series_prompt =
|
||||
|f: &mut Frame<'_>, app: &mut App<'_>, prompt_area: Rect| match active_sonarr_block {
|
||||
ActiveSonarrBlock::EditSeriesSelectSeriesType => {
|
||||
draw_edit_series_confirmation_prompt(f, app, prompt_area);
|
||||
draw_edit_series_select_series_type_popup(f, app);
|
||||
}
|
||||
ActiveSonarrBlock::EditSeriesSelectQualityProfile => {
|
||||
draw_edit_series_confirmation_prompt(f, app, prompt_area);
|
||||
draw_edit_series_select_quality_profile_popup(f, app);
|
||||
}
|
||||
ActiveSonarrBlock::EditSeriesSelectLanguageProfile => {
|
||||
draw_edit_series_confirmation_prompt(f, app, prompt_area);
|
||||
draw_edit_series_select_language_profile_popup(f, app);
|
||||
}
|
||||
ActiveSonarrBlock::EditSeriesPrompt
|
||||
| ActiveSonarrBlock::EditSeriesToggleMonitored
|
||||
| ActiveSonarrBlock::EditSeriesToggleSeasonFolder
|
||||
| ActiveSonarrBlock::EditSeriesPathInput
|
||||
| ActiveSonarrBlock::EditSeriesTagsInput => {
|
||||
draw_edit_series_confirmation_prompt(f, app, prompt_area)
|
||||
}
|
||||
_ => (),
|
||||
};
|
||||
|
||||
if let Some(context) = context_option {
|
||||
match context {
|
||||
ActiveSonarrBlock::Series => {
|
||||
draw_popup_over(
|
||||
f,
|
||||
app,
|
||||
area,
|
||||
draw_library,
|
||||
draw_edit_series_prompt,
|
||||
Size::Long,
|
||||
);
|
||||
}
|
||||
_ if SERIES_DETAILS_BLOCKS.contains(&context) => {
|
||||
draw_popup_over_ui::<SeriesDetailsUi>(f, app, area, draw_library, Size::Large);
|
||||
draw_popup(f, app, draw_edit_series_prompt, Size::Long);
|
||||
}
|
||||
_ => (),
|
||||
if SERIES_DETAILS_BLOCKS.contains(&context) {
|
||||
draw_popup(f, app, SeriesDetailsUi::draw, Size::Large);
|
||||
}
|
||||
}
|
||||
|
||||
let draw_edit_series_prompt =
|
||||
|f: &mut Frame<'_>, app: &mut App<'_>, prompt_area: Rect| {
|
||||
draw_edit_series_confirmation_prompt(f, app, prompt_area);
|
||||
|
||||
match active_sonarr_block {
|
||||
ActiveSonarrBlock::EditSeriesSelectSeriesType => {
|
||||
draw_edit_series_select_series_type_popup(f, app);
|
||||
}
|
||||
ActiveSonarrBlock::EditSeriesSelectQualityProfile => {
|
||||
draw_edit_series_select_quality_profile_popup(f, app);
|
||||
}
|
||||
ActiveSonarrBlock::EditSeriesSelectLanguageProfile => {
|
||||
draw_edit_series_select_language_profile_popup(f, app);
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
};
|
||||
|
||||
draw_popup(f, app, draw_edit_series_prompt, Size::Long);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,46 +54,30 @@ impl DrawUi for LibraryUi {
|
||||
|
||||
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
let route = app.get_current_route();
|
||||
let mut series_ui_matchers = |active_sonarr_block: ActiveSonarrBlock| match active_sonarr_block
|
||||
{
|
||||
ActiveSonarrBlock::Series
|
||||
| ActiveSonarrBlock::SeriesSortPrompt
|
||||
| ActiveSonarrBlock::SearchSeries
|
||||
| ActiveSonarrBlock::SearchSeriesError
|
||||
| ActiveSonarrBlock::FilterSeries
|
||||
| ActiveSonarrBlock::FilterSeriesError => draw_library(f, app, area),
|
||||
ActiveSonarrBlock::UpdateAllSeriesPrompt => {
|
||||
draw_library(f, app, area);
|
||||
|
||||
match route {
|
||||
_ if AddSeriesUi::accepts(route) => AddSeriesUi::draw(f, app, area),
|
||||
_ if DeleteSeriesUi::accepts(route) => DeleteSeriesUi::draw(f, app, area),
|
||||
_ if EditSeriesUi::accepts(route) => EditSeriesUi::draw(f, app, area),
|
||||
_ if SeriesDetailsUi::accepts(route) => SeriesDetailsUi::draw(f, app, area),
|
||||
Route::Sonarr(ActiveSonarrBlock::UpdateAllSeriesPrompt, _) => {
|
||||
let confirmation_prompt = ConfirmationPrompt::new()
|
||||
.title("Update All Series")
|
||||
.prompt("Do you want to update info and scan your disks for all of your series?")
|
||||
.yes_no_value(app.data.sonarr_data.prompt_confirm);
|
||||
|
||||
draw_library(f, app, area);
|
||||
f.render_widget(
|
||||
Popup::new(confirmation_prompt).size(Size::MediumPrompt),
|
||||
f.area(),
|
||||
);
|
||||
}
|
||||
_ => (),
|
||||
};
|
||||
|
||||
match route {
|
||||
_ if AddSeriesUi::accepts(route) => AddSeriesUi::draw(f, app, area),
|
||||
_ if DeleteSeriesUi::accepts(route) => DeleteSeriesUi::draw(f, app, area),
|
||||
_ if EditSeriesUi::accepts(route) => EditSeriesUi::draw(f, app, area),
|
||||
_ if SeriesDetailsUi::accepts(route) => {
|
||||
draw_library(f, app, area);
|
||||
SeriesDetailsUi::draw(f, app, area)
|
||||
},
|
||||
Route::Sonarr(active_sonarr_block, _) if LIBRARY_BLOCKS.contains(&active_sonarr_block) => {
|
||||
series_ui_matchers(active_sonarr_block)
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn draw_library(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
fn draw_library(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
if let Route::Sonarr(active_sonarr_block, _) = app.get_current_route() {
|
||||
let current_selection = if !app.data.sonarr_data.series.items.is_empty() {
|
||||
app.data.sonarr_data.series.current_selection().clone()
|
||||
|
||||
@@ -12,6 +12,7 @@ use crate::models::sonarr_models::{
|
||||
Season, SeasonStatistics, SonarrHistoryEventType, SonarrHistoryItem,
|
||||
};
|
||||
use crate::models::{EnumDisplayStyle, Route};
|
||||
use crate::ui::sonarr_ui::library::season_details_ui::SeasonDetailsUi;
|
||||
use crate::ui::sonarr_ui::sonarr_ui_utils::{
|
||||
create_download_failed_history_event_details,
|
||||
create_download_folder_imported_history_event_details,
|
||||
@@ -28,12 +29,9 @@ use crate::ui::widgets::loading_block::LoadingBlock;
|
||||
use crate::ui::widgets::managarr_table::ManagarrTable;
|
||||
use crate::ui::widgets::message::Message;
|
||||
use crate::ui::widgets::popup::{Popup, Size};
|
||||
use crate::ui::{draw_popup, draw_popup_over, draw_tabs, DrawUi};
|
||||
use crate::ui::sonarr_ui::library::season_details_ui::SeasonDetailsUi;
|
||||
use crate::ui::{draw_popup, draw_tabs, DrawUi};
|
||||
use crate::utils::convert_to_gb;
|
||||
|
||||
use super::draw_library;
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "series_details_ui_tests.rs"]
|
||||
mod series_details_ui_tests;
|
||||
@@ -107,28 +105,16 @@ impl DrawUi for SeriesDetailsUi {
|
||||
};
|
||||
};
|
||||
|
||||
match route {
|
||||
_ if SeasonDetailsUi::accepts(route) => {
|
||||
draw_popup(f, app, draw_series_details_popup, Size::XXLarge);
|
||||
SeasonDetailsUi::draw(f, app, area);
|
||||
},
|
||||
Route::Sonarr(active_sonarr_block, _) if SERIES_DETAILS_BLOCKS.contains(&active_sonarr_block) => {
|
||||
draw_popup_over(
|
||||
f,
|
||||
app,
|
||||
area,
|
||||
draw_library,
|
||||
draw_series_details_popup,
|
||||
Size::XXLarge,
|
||||
);
|
||||
}
|
||||
_ => (),
|
||||
draw_popup(f, app, draw_series_details_popup, Size::XXLarge);
|
||||
|
||||
if SeasonDetailsUi::accepts(route) {
|
||||
SeasonDetailsUi::draw(f, app, area);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn draw_series_description(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
fn draw_series_description(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
let current_selection = app.data.sonarr_data.series.current_selection();
|
||||
let monitored = if current_selection.monitored {
|
||||
"Yes"
|
||||
|
||||
@@ -11,7 +11,7 @@ use crate::ui::utils::layout_block_top_border;
|
||||
use crate::ui::widgets::confirmation_prompt::ConfirmationPrompt;
|
||||
use crate::ui::widgets::managarr_table::ManagarrTable;
|
||||
use crate::ui::widgets::popup::{Popup, Size};
|
||||
use crate::ui::{draw_input_box_popup, draw_popup_over, DrawUi};
|
||||
use crate::ui::{draw_input_box_popup, draw_popup, DrawUi};
|
||||
use crate::utils::convert_to_gb;
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -31,13 +31,12 @@ impl DrawUi for RootFoldersUi {
|
||||
|
||||
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
if let Route::Sonarr(active_sonarr_block, _) = app.get_current_route() {
|
||||
draw_root_folders(f, app, area);
|
||||
|
||||
match active_sonarr_block {
|
||||
ActiveSonarrBlock::RootFolders => draw_root_folders(f, app, area),
|
||||
ActiveSonarrBlock::AddRootFolderPrompt => draw_popup_over(
|
||||
ActiveSonarrBlock::AddRootFolderPrompt => draw_popup(
|
||||
f,
|
||||
app,
|
||||
area,
|
||||
draw_root_folders,
|
||||
draw_add_root_folder_prompt_box,
|
||||
Size::InputBox,
|
||||
),
|
||||
@@ -51,7 +50,6 @@ impl DrawUi for RootFoldersUi {
|
||||
.prompt(&prompt)
|
||||
.yes_no_value(app.data.sonarr_data.prompt_confirm);
|
||||
|
||||
draw_root_folders(f, app, area);
|
||||
f.render_widget(
|
||||
Popup::new(confirmation_prompt).size(Size::MediumPrompt),
|
||||
f.area(),
|
||||
|
||||
@@ -57,18 +57,15 @@ impl DrawUi for SystemUi {
|
||||
|
||||
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
let route = app.get_current_route();
|
||||
|
||||
match route {
|
||||
_ if SystemDetailsUi::accepts(route) => SystemDetailsUi::draw(f, app, area),
|
||||
_ if matches!(route, Route::Sonarr(ActiveSonarrBlock::System, _)) => {
|
||||
draw_system_ui_layout(f, app, area)
|
||||
}
|
||||
_ => (),
|
||||
draw_system_ui_layout(f, app, area);
|
||||
|
||||
if SystemDetailsUi::accepts(route) {
|
||||
SystemDetailsUi::draw(f, app, area);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn draw_system_ui_layout(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
fn draw_system_ui_layout(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
let [activities_area, logs_area, help_area] = Layout::vertical([
|
||||
Constraint::Ratio(1, 2),
|
||||
Constraint::Ratio(1, 2),
|
||||
|
||||
@@ -10,7 +10,7 @@ use crate::models::servarr_data::sonarr::sonarr_data::{ActiveSonarrBlock, SYSTEM
|
||||
use crate::models::sonarr_models::SonarrTask;
|
||||
use crate::models::Route;
|
||||
use crate::ui::sonarr_ui::system::{
|
||||
draw_queued_events, draw_system_ui_layout, extract_task_props, TASK_TABLE_CONSTRAINTS,
|
||||
draw_queued_events, extract_task_props, TASK_TABLE_CONSTRAINTS,
|
||||
TASK_TABLE_HEADERS,
|
||||
};
|
||||
use crate::ui::styles::ManagarrStyle;
|
||||
@@ -20,7 +20,7 @@ use crate::ui::widgets::loading_block::LoadingBlock;
|
||||
use crate::ui::widgets::managarr_table::ManagarrTable;
|
||||
use crate::ui::widgets::popup::{Popup, Size};
|
||||
use crate::ui::widgets::selectable_list::SelectableList;
|
||||
use crate::ui::{draw_popup_over, DrawUi};
|
||||
use crate::ui::{draw_popup, DrawUi};
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "system_details_ui_tests.rs"]
|
||||
@@ -37,33 +37,27 @@ impl DrawUi for SystemDetailsUi {
|
||||
false
|
||||
}
|
||||
|
||||
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, _area: Rect) {
|
||||
if let Route::Sonarr(active_sonarr_block, _) = app.get_current_route() {
|
||||
match active_sonarr_block {
|
||||
ActiveSonarrBlock::SystemLogs => {
|
||||
draw_system_ui_layout(f, app, area);
|
||||
draw_logs_popup(f, app);
|
||||
}
|
||||
ActiveSonarrBlock::SystemTasks | ActiveSonarrBlock::SystemTaskStartConfirmPrompt => {
|
||||
draw_popup_over(
|
||||
draw_popup(
|
||||
f,
|
||||
app,
|
||||
area,
|
||||
draw_system_ui_layout,
|
||||
draw_tasks_popup,
|
||||
Size::Large,
|
||||
)
|
||||
}
|
||||
ActiveSonarrBlock::SystemQueuedEvents => draw_popup_over(
|
||||
ActiveSonarrBlock::SystemQueuedEvents => draw_popup(
|
||||
f,
|
||||
app,
|
||||
area,
|
||||
draw_system_ui_layout,
|
||||
draw_queued_events,
|
||||
Size::Medium,
|
||||
),
|
||||
ActiveSonarrBlock::SystemUpdates => {
|
||||
draw_system_ui_layout(f, app, area);
|
||||
draw_updates_popup(f, app);
|
||||
}
|
||||
_ => (),
|
||||
@@ -158,7 +152,7 @@ fn draw_updates_popup(f: &mut Frame<'_>, app: &mut App<'_>) {
|
||||
let updates = app.data.sonarr_data.updates.get_text();
|
||||
let block = title_block("Updates");
|
||||
|
||||
if !updates.is_empty() {
|
||||
if !updates.is_empty() && !app.is_loading {
|
||||
let updates_paragraph = Paragraph::new(Text::from(updates))
|
||||
.block(borderless_block())
|
||||
.scroll((app.data.sonarr_data.updates.offset, 0));
|
||||
|
||||
Reference in New Issue
Block a user