fix(content): hide unavailable world actions
This commit is contained in:
1 parent
37cccc352b
commit
30a9f60830
2 files changed
+22
-6
No files matched your search
@@ -106,3 +106,10 @@ fn confirmation_metadata_is_human_readable() {
|
||||
);
|
||||
assert_eq!(confirmation_values(&[]), "Unknown");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn empty_world_picker_only_offers_exit_actions() {
|
||||
let keybinds = world_picker_keybinds(false);
|
||||
assert!(!keybinds.iter().any(|(key, _)| *key == "Enter"));
|
||||
assert!(!keybinds.iter().any(|(key, _)| *key == "j/k"));
|
||||
}
|
||||
@@ -924,16 +924,12 @@ fn render_world_picker(
|
||||
let theme = THEME.as_ref();
|
||||
let title = popup.title();
|
||||
let provider_label = popup.provider_label().to_owned();
|
||||
let keybinds = world_picker_keybinds(!popup.worlds.entries.is_empty());
|
||||
let frame_widget = crate::tui::widgets::popups::base::PopupFrame {
|
||||
title: styled_title(&title, false),
|
||||
border_color: theme.accent(),
|
||||
bg: Some(theme.surface()),
|
||||
keybinds: Some(crate::tui::widgets::popups::keybind_line(&[
|
||||
("j/k", " navigate"),
|
||||
("Enter", " continue"),
|
||||
("h", " back"),
|
||||
("Esc", " close"),
|
||||
])),
|
||||
keybinds: Some(crate::tui::widgets::popups::keybind_line(keybinds)),
|
||||
search_line: Some(
|
||||
Line::from(Span::styled(
|
||||
format!(" {provider_label} "),
|
||||
@@ -959,6 +955,19 @@ fn render_world_picker(
|
||||
);
|
||||
}
|
||||
|
||||
fn world_picker_keybinds(has_worlds: bool) -> &'static [(&'static str, &'static str)] {
|
||||
if has_worlds {
|
||||
&[
|
||||
("j/k", " navigate"),
|
||||
("Enter", " continue"),
|
||||
("h", " back"),
|
||||
("Esc", " close"),
|
||||
]
|
||||
} else {
|
||||
&[("h", " back"), ("Esc", " close")]
|
||||
}
|
||||
}
|
||||
|
||||
fn version_popup_height(
|
||||
confirming: bool,
|
||||
plan: Option<&crate::instance::content::dependencies::DependencyPlan>,
|
||||
|
||||
Reference in new issue
Block a user