fix(tui): guard contextual content actions
This commit is contained in:
1 parent
59707b77d2
commit
70286ed9b8
7 files changed
+114
-2
No files matched your search
@@ -222,7 +222,12 @@ pub fn render(frame: &mut Frame, area: Rect, focused: FocusedArea, state: &mut A
|
||||
|
||||
let keybind_line = if focused == FocusedArea::Account {
|
||||
Some(super::popups::keybind_line_fitted(
|
||||
&[("⏎", " select"), ("a", " add"), ("d", " del")],
|
||||
&[
|
||||
("⏎", " select"),
|
||||
("a", " add"),
|
||||
("d", " del"),
|
||||
("Esc", " back"),
|
||||
],
|
||||
area.width.saturating_sub(2),
|
||||
))
|
||||
} else {
|
||||
|
||||
@@ -1125,6 +1125,11 @@ impl ContentListState {
|
||||
self.entries.get(*index)
|
||||
}
|
||||
|
||||
pub fn selected_has_provider_project(&self) -> bool {
|
||||
self.selected_entry()
|
||||
.is_some_and(|entry| entry.provider_project.is_some())
|
||||
}
|
||||
|
||||
fn restore_selected_file_stem(&mut self, file_stem: Option<&str>) {
|
||||
let filtered = self.filtered_indices();
|
||||
self.list_state.selected = file_stem
|
||||
|
||||
@@ -301,6 +301,15 @@ pub fn render(
|
||||
_ => worlds_state.entries.iter(),
|
||||
}
|
||||
.any(|entry| entry.title_suffix.as_deref() == Some("Update"));
|
||||
let can_change_version = match tab {
|
||||
ContentTab::Mods => mods_state.selected_has_provider_project(),
|
||||
ContentTab::ResourcePacks => resource_packs_state.selected_has_provider_project(),
|
||||
ContentTab::Shaders => shaders_state.selected_has_provider_project(),
|
||||
ContentTab::Worlds if open_world_datapacks.is_some() => {
|
||||
world_datapacks_state.selected_has_provider_project()
|
||||
}
|
||||
_ => false,
|
||||
};
|
||||
|
||||
// keybinds change depending on which tab is active and whether
|
||||
// the content panel or instances panel has focus
|
||||
@@ -428,6 +437,12 @@ pub fn render(
|
||||
if is_focused && mode == ContentMode::Installed && !has_updates {
|
||||
keybinds.retain(|(key, _)| *key != "u");
|
||||
}
|
||||
if is_focused && mode == ContentMode::Installed && !can_change_version {
|
||||
keybinds.retain(|(key, _)| *key != "v");
|
||||
}
|
||||
if is_focused && !keybinds.iter().any(|(key, _)| key.contains("Esc")) {
|
||||
keybinds.push(("Esc", " back"));
|
||||
}
|
||||
// The main panel footer stays on its border; lower-priority hints are omitted when narrow.
|
||||
block = block.title_bottom(crate::tui::widgets::popups::keybind_line_fitted(
|
||||
&keybinds,
|
||||
|
||||
@@ -218,12 +218,14 @@ pub fn render(
|
||||
("d", " del"),
|
||||
("j/k", " move"),
|
||||
("h/l", " tab"),
|
||||
("Esc", " back"),
|
||||
],
|
||||
SettingsPane::Info => &[
|
||||
("e", " inst"),
|
||||
("g", " global"),
|
||||
("d", " desk"),
|
||||
("h/l", " tab"),
|
||||
("Esc", " back"),
|
||||
],
|
||||
};
|
||||
Some(super::popups::keybind_line_fitted(
|
||||
|
||||
Reference in new issue
Block a user