Skip to content

Commit

Permalink
Update Rust crate ratatui to 0.27.0 (#5850)
Browse files Browse the repository at this point in the history
  • Loading branch information
oxide-renovate[bot] authored Jul 6, 2024
1 parent ac85000 commit 14e3a8b
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 37 deletions.
57 changes: 35 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ rand = "0.8.5"
rand_core = "0.6.4"
rand_distr = "0.4.3"
rand_seeder = "0.2.3"
ratatui = "0.26.2"
ratatui = "0.27.0"
rayon = "1.10"
rcgen = "0.12.1"
reedline = "0.31.0"
Expand Down Expand Up @@ -510,7 +510,7 @@ trust-dns-server = "0.22"
trybuild = "1.0.91"
tufaceous = { path = "tufaceous" }
tufaceous-lib = { path = "tufaceous-lib" }
tui-tree-widget = "0.19.0"
tui-tree-widget = "0.21.0"
typed-rng = { path = "typed-rng" }
unicode-width = "0.1.11"
update-common = { path = "update-common" }
Expand Down
25 changes: 14 additions & 11 deletions wicket/src/ui/panes/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ pub struct UpdatePane {
impl UpdatePane {
pub fn new(log: &Logger) -> UpdatePane {
let log = log.new(o!("component" => "UpdatePane"));
let mut tree_state = TreeState::default();
let tree_state = TreeState::default();
let items = ALL_COMPONENT_IDS
.iter()
.enumerate()
Expand All @@ -187,7 +187,8 @@ impl UpdatePane {
.expect("no children so no duplicate identifiers")
})
.collect::<Vec<_>>();
tree_state.select_first(&items);
// `ensure_selection_matches_rack_state` will perform the initial
// selection on the update tree.

UpdatePane {
log,
Expand Down Expand Up @@ -1319,12 +1320,14 @@ impl UpdatePane {
}

// When we switch panes, we may have moved around in the rack. We want to
// ensure that the currently selected rack component in the update tree
// ensure that the currently selected rack component in the update tree
// matches what was selected in the rack or inventory views. We already do
// the converse when on this pane and move around the tree.
fn ensure_selection_matches_rack_state(&mut self, state: &State) {
let selected = self.tree_state.selected();
if state.rack_state.selected != ALL_COMPONENT_IDS[selected[0]] {
let tree_selected = self.tree_state.selected();
let should_reselect = tree_selected.is_empty()
|| state.rack_state.selected != ALL_COMPONENT_IDS[tree_selected[0]];
if should_reselect {
let index = ALL_COMPONENT_IDS
.iter()
.position(|&id| id == state.rack_state.selected)
Expand Down Expand Up @@ -1377,7 +1380,7 @@ impl UpdatePane {
self.update_items(state);

// Draw the contents
let tree = Tree::new(self.items.clone())
let tree = Tree::new(&self.items)
.expect("tree does not have duplicate identifiers")
.block(block.clone().borders(Borders::LEFT | Borders::RIGHT))
.style(style::plain_text())
Expand Down Expand Up @@ -2486,21 +2489,21 @@ impl Control for UpdatePane {

match cmd {
Cmd::Up => {
self.tree_state.key_up(&self.items);
self.tree_state.key_up();
let selected = self.tree_state.selected();
state.rack_state.selected = ALL_COMPONENT_IDS[selected[0]];
Some(Action::Redraw)
}
Cmd::Down => {
self.tree_state.key_down(&self.items);
self.tree_state.key_down();
let selected = self.tree_state.selected();
state.rack_state.selected = ALL_COMPONENT_IDS[selected[0]];
Some(Action::Redraw)
}
Cmd::Collapse | Cmd::Left => {
// We always want something selected. If we close the root,
// we want to re-open it.
let selected = self.tree_state.selected();
let selected = self.tree_state.selected().to_vec();
self.tree_state.key_left();
if self.tree_state.selected().is_empty() {
self.tree_state.select(selected);
Expand All @@ -2523,12 +2526,12 @@ impl Control for UpdatePane {
Some(Action::Redraw)
}
Cmd::GotoTop => {
self.tree_state.select_first(&self.items);
self.tree_state.select_first();
state.rack_state.selected = ALL_COMPONENT_IDS[0];
Some(Action::Redraw)
}
Cmd::GotoBottom => {
self.tree_state.select_last(&self.items);
self.tree_state.select_last();
state.rack_state.selected =
ALL_COMPONENT_IDS[ALL_COMPONENT_IDS.len() - 1];
Some(Action::Redraw)
Expand Down
2 changes: 0 additions & 2 deletions workspace-hack/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ sha2 = { version = "0.10.8", features = ["oid"] }
similar = { version = "2.5.0", features = ["inline", "unicode"] }
slog = { version = "2.7.0", features = ["dynamic-keys", "max_level_trace", "release_max_level_debug", "release_max_level_trace"] }
smallvec = { version = "1.13.2", default-features = false, features = ["const_new"] }
socket2 = { version = "0.5.7", default-features = false, features = ["all"] }
spin = { version = "0.9.8" }
string_cache = { version = "0.8.7" }
subtle = { version = "2.5.0" }
Expand Down Expand Up @@ -203,7 +202,6 @@ sha2 = { version = "0.10.8", features = ["oid"] }
similar = { version = "2.5.0", features = ["inline", "unicode"] }
slog = { version = "2.7.0", features = ["dynamic-keys", "max_level_trace", "release_max_level_debug", "release_max_level_trace"] }
smallvec = { version = "1.13.2", default-features = false, features = ["const_new"] }
socket2 = { version = "0.5.7", default-features = false, features = ["all"] }
spin = { version = "0.9.8" }
string_cache = { version = "0.8.7" }
subtle = { version = "2.5.0" }
Expand Down

0 comments on commit 14e3a8b

Please sign in to comment.