Added a help block to the updates popup
This commit is contained in:
+10
-3
@@ -323,7 +323,7 @@ fn draw_table<'a, B, T, F>(
|
|||||||
help,
|
help,
|
||||||
} = table_props;
|
} = table_props;
|
||||||
|
|
||||||
let content_area = draw_help(f, content_area, help);
|
let content_area = draw_help_and_get_content_rect(f, content_area, help);
|
||||||
|
|
||||||
if !content.items.is_empty() {
|
if !content.items.is_empty() {
|
||||||
let rows = content.items.iter().map(row_mapper);
|
let rows = content.items.iter().map(row_mapper);
|
||||||
@@ -592,7 +592,10 @@ pub fn draw_list_box<'a, B: Backend, T>(
|
|||||||
|
|
||||||
let (content_area, block) = if is_popup {
|
let (content_area, block) = if is_popup {
|
||||||
f.render_widget(title_block(title), area);
|
f.render_widget(title_block(title), area);
|
||||||
(draw_help(f, area, help), borderless_block())
|
(
|
||||||
|
draw_help_and_get_content_rect(f, area, help),
|
||||||
|
borderless_block(),
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
(area, title_block(title))
|
(area, title_block(title))
|
||||||
};
|
};
|
||||||
@@ -611,7 +614,11 @@ pub fn draw_list_box<'a, B: Backend, T>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_help<B: Backend>(f: &mut Frame<'_, B>, area: Rect, help: Option<&str>) -> Rect {
|
fn draw_help_and_get_content_rect<B: Backend>(
|
||||||
|
f: &mut Frame<'_, B>,
|
||||||
|
area: Rect,
|
||||||
|
help: Option<&str>,
|
||||||
|
) -> Rect {
|
||||||
if let Some(help_string) = help {
|
if let Some(help_string) = help {
|
||||||
let chunks =
|
let chunks =
|
||||||
vertical_chunks_with_margin(vec![Constraint::Min(0), Constraint::Length(2)], area, 1);
|
vertical_chunks_with_margin(vec![Constraint::Min(0), Constraint::Length(2)], area, 1);
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ use crate::ui::radarr_ui::system_ui::{
|
|||||||
};
|
};
|
||||||
use crate::ui::utils::{borderless_block, style_primary, title_block};
|
use crate::ui::utils::{borderless_block, style_primary, title_block};
|
||||||
use crate::ui::{
|
use crate::ui::{
|
||||||
draw_help, draw_large_popup_over, draw_list_box, draw_medium_popup_over, draw_prompt_box,
|
draw_help_and_get_content_rect, draw_large_popup_over, draw_list_box, draw_medium_popup_over,
|
||||||
draw_prompt_popup_over, draw_table, loading, DrawUi, ListProps, TableProps,
|
draw_prompt_box, draw_prompt_popup_over, draw_table, loading, DrawUi, ListProps, TableProps,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub(super) struct SystemDetailsUi {}
|
pub(super) struct SystemDetailsUi {}
|
||||||
@@ -72,7 +72,7 @@ fn draw_logs_popup<B: Backend>(f: &mut Frame<'_, B>, app: &mut App<'_>, area: Re
|
|||||||
title: "Log Details",
|
title: "Log Details",
|
||||||
is_loading: app.is_loading,
|
is_loading: app.is_loading,
|
||||||
is_popup: true,
|
is_popup: true,
|
||||||
help: Some("<esc> close | <↑↓←→> scroll"),
|
help: Some("<↑↓←→> scroll | <esc> close"),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -81,7 +81,8 @@ fn draw_tasks_popup<B: Backend>(f: &mut Frame<'_, B>, app: &mut App<'_>, area: R
|
|||||||
let tasks_popup_table = |f: &mut Frame<'_, B>, app: &mut App<'_>, area: Rect| {
|
let tasks_popup_table = |f: &mut Frame<'_, B>, app: &mut App<'_>, area: Rect| {
|
||||||
f.render_widget(title_block("Tasks"), area);
|
f.render_widget(title_block("Tasks"), area);
|
||||||
|
|
||||||
let context_area = draw_help(f, area, Some("<enter> start task | <esc> close"));
|
let context_area =
|
||||||
|
draw_help_and_get_content_rect(f, area, Some("<enter> start task | <esc> close"));
|
||||||
|
|
||||||
draw_table(
|
draw_table(
|
||||||
f,
|
f,
|
||||||
@@ -135,16 +136,19 @@ fn draw_start_task_prompt<B: Backend>(f: &mut Frame<'_, B>, app: &mut App<'_>, p
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn draw_updates_popup<B: Backend>(f: &mut Frame<'_, B>, app: &mut App<'_>, area: Rect) {
|
fn draw_updates_popup<B: Backend>(f: &mut Frame<'_, B>, app: &mut App<'_>, area: Rect) {
|
||||||
|
f.render_widget(title_block("Updates"), area);
|
||||||
|
|
||||||
|
let content_rect = draw_help_and_get_content_rect(f, area, Some("<↑↓> scroll | <esc> close"));
|
||||||
let updates = app.data.radarr_data.updates.get_text();
|
let updates = app.data.radarr_data.updates.get_text();
|
||||||
let block = title_block("Updates");
|
let block = borderless_block();
|
||||||
|
|
||||||
if !updates.is_empty() {
|
if !updates.is_empty() {
|
||||||
let updates_paragraph = Paragraph::new(Text::from(updates))
|
let updates_paragraph = Paragraph::new(Text::from(updates))
|
||||||
.block(block)
|
.block(block)
|
||||||
.scroll((app.data.radarr_data.updates.offset, 0));
|
.scroll((app.data.radarr_data.updates.offset, 0));
|
||||||
|
|
||||||
f.render_widget(updates_paragraph, area);
|
f.render_widget(updates_paragraph, content_rect);
|
||||||
} else {
|
} else {
|
||||||
loading(f, block, area, app.is_loading);
|
loading(f, block, content_rect, app.is_loading);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user