refactor(ui): Simplified the popup delegation so all future UI is easier to implement
This commit is contained in:
@@ -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