remove redundant selectability for session keys in validators tab
Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
This commit is contained in:
parent
08e0f3d576
commit
9d346172b6
@ -2,7 +2,7 @@
|
||||
name = "ghost-eye"
|
||||
authors = ["str3tch <stretch@ghostchain.io>"]
|
||||
description = "Application for interacting with Casper/Ghost nodes that are exposing RPC only to the localhost"
|
||||
version = "0.3.32"
|
||||
version = "0.3.33"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
|
@ -52,7 +52,6 @@ use withdraw_popup::WithdrawPopup;
|
||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||
pub enum CurrentTab {
|
||||
Nothing,
|
||||
StashInfo,
|
||||
ListenAddresses,
|
||||
NominatorsByValidator,
|
||||
History,
|
||||
@ -118,15 +117,13 @@ impl Validator {
|
||||
CurrentTab::Withdrawals => self.current_tab = CurrentTab::History,
|
||||
CurrentTab::History => self.current_tab = CurrentTab::NominatorsByValidator,
|
||||
CurrentTab::NominatorsByValidator => self.current_tab = CurrentTab::ListenAddresses,
|
||||
CurrentTab::ListenAddresses => self.current_tab = CurrentTab::StashInfo,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
fn move_right(&mut self) {
|
||||
match self.current_tab {
|
||||
CurrentTab::Nothing => self.current_tab = CurrentTab::StashInfo,
|
||||
CurrentTab::StashInfo => self.current_tab = CurrentTab::ListenAddresses,
|
||||
CurrentTab::Nothing => self.current_tab = CurrentTab::ListenAddresses,
|
||||
CurrentTab::ListenAddresses => self.current_tab = CurrentTab::NominatorsByValidator,
|
||||
CurrentTab::NominatorsByValidator => self.current_tab = CurrentTab::History,
|
||||
CurrentTab::History => self.current_tab = CurrentTab::Withdrawals,
|
||||
@ -267,7 +264,7 @@ impl Component for Validator {
|
||||
match action {
|
||||
Action::SetActiveScreen(Mode::Validator) => {
|
||||
self.is_active = true;
|
||||
self.current_tab = CurrentTab::StashInfo;
|
||||
self.current_tab = CurrentTab::ListenAddresses;
|
||||
}
|
||||
Action::PayoutValidatorPopup(_, _) => {
|
||||
self.previous_tab = self.current_tab;
|
||||
|
@ -3,16 +3,12 @@ use std::fs::File;
|
||||
use std::io::{Write, BufRead, BufReader};
|
||||
|
||||
use color_eyre::Result;
|
||||
use crossterm::event::{KeyCode, KeyEvent};
|
||||
use ratatui::layout::{Constraint, Margin};
|
||||
use ratatui::layout::Constraint;
|
||||
use ratatui::style::{Modifier, Stylize};
|
||||
use ratatui::{
|
||||
text::Text,
|
||||
layout::{Alignment, Rect},
|
||||
widgets::{
|
||||
Block, Cell, Row, Table, TableState, Scrollbar,
|
||||
ScrollbarOrientation, ScrollbarState,
|
||||
},
|
||||
widgets::{Block, Cell, Row, Table},
|
||||
Frame
|
||||
};
|
||||
|
||||
@ -42,8 +38,6 @@ pub struct StashInfo {
|
||||
action_tx: Option<UnboundedSender<Action>>,
|
||||
network_tx: Option<Sender<Action>>,
|
||||
palette: StylePalette,
|
||||
scroll_state: ScrollbarState,
|
||||
table_state: TableState,
|
||||
stash_pair: Option<PairSigner<CasperConfig, Pair>>,
|
||||
stash_address: String,
|
||||
session_keys: std::collections::HashMap<String, SessionKeyInfo>,
|
||||
@ -63,8 +57,6 @@ impl StashInfo {
|
||||
is_active: false,
|
||||
action_tx: None,
|
||||
network_tx: None,
|
||||
scroll_state: ScrollbarState::new(0),
|
||||
table_state: TableState::new(),
|
||||
palette: StylePalette::default(),
|
||||
stash_address: String::new(),
|
||||
stash_pair: None,
|
||||
@ -81,51 +73,6 @@ impl StashInfo {
|
||||
}
|
||||
}
|
||||
|
||||
fn first_row(&mut self) {
|
||||
if self.session_keys.len() > 0 {
|
||||
self.table_state.select(Some(0));
|
||||
self.scroll_state = self.scroll_state.position(0);
|
||||
}
|
||||
}
|
||||
|
||||
fn next_row(&mut self) {
|
||||
let i = match self.table_state.selected() {
|
||||
Some(i) => {
|
||||
if i >= self.session_keys.len() - 1 {
|
||||
i
|
||||
} else {
|
||||
i + 1
|
||||
}
|
||||
},
|
||||
None => 0,
|
||||
};
|
||||
self.table_state.select(Some(i));
|
||||
self.scroll_state = self.scroll_state.position(i);
|
||||
}
|
||||
|
||||
fn last_row(&mut self) {
|
||||
if self.session_keys.len() > 0 {
|
||||
let last = self.session_keys.len() - 1;
|
||||
self.table_state.select(Some(last));
|
||||
self.scroll_state = self.scroll_state.position(last);
|
||||
}
|
||||
}
|
||||
|
||||
fn previous_row(&mut self) {
|
||||
let i = match self.table_state.selected() {
|
||||
Some(i) => {
|
||||
if i == 0 {
|
||||
0
|
||||
} else {
|
||||
i - 1
|
||||
}
|
||||
},
|
||||
None => 0
|
||||
};
|
||||
self.table_state.select(Some(i));
|
||||
self.scroll_state = self.scroll_state.position(i);
|
||||
}
|
||||
|
||||
fn read_or_create_stash(&mut self) -> Result<()> {
|
||||
match File::open(&self.stash_filepath) {
|
||||
Ok(file) => {
|
||||
@ -230,16 +177,7 @@ impl StashInfo {
|
||||
}
|
||||
|
||||
impl PartialComponent for StashInfo {
|
||||
fn set_active(&mut self, current_tab: CurrentTab) {
|
||||
match current_tab {
|
||||
CurrentTab::StashInfo => self.is_active = true,
|
||||
_ => {
|
||||
self.is_active = false;
|
||||
self.table_state.select(None);
|
||||
self.scroll_state = self.scroll_state.position(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
fn set_active(&mut self, _current_tab: CurrentTab) { }
|
||||
}
|
||||
|
||||
impl Component for StashInfo {
|
||||
@ -276,19 +214,6 @@ impl Component for StashInfo {
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
fn handle_key_event(&mut self, key: KeyEvent) -> Result<Option<Action>> {
|
||||
if self.is_active {
|
||||
match key.code {
|
||||
KeyCode::Up | KeyCode::Char('k') => self.previous_row(),
|
||||
KeyCode::Down | KeyCode::Char('j') => self.next_row(),
|
||||
KeyCode::Char('g') => self.first_row(),
|
||||
KeyCode::Char('G') => self.last_row(),
|
||||
_ => {},
|
||||
};
|
||||
}
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
fn draw(&mut self, frame: &mut Frame, area: Rect) -> Result<()> {
|
||||
let [place, _] = super::validator_session_and_listen_layout(area);
|
||||
let (border_style, border_type) = self.palette.create_border_style(self.is_active);
|
||||
@ -340,19 +265,7 @@ impl Component for StashInfo {
|
||||
.title_style(self.palette.create_title_style(false))
|
||||
.title(self.stash_address.clone()));
|
||||
|
||||
let scrollbar = Scrollbar::default()
|
||||
.orientation(ScrollbarOrientation::VerticalRight)
|
||||
.begin_symbol(None)
|
||||
.end_symbol(None)
|
||||
.style(self.palette.create_scrollbar_style());
|
||||
|
||||
frame.render_stateful_widget(table, place, &mut self.table_state);
|
||||
frame.render_stateful_widget(
|
||||
scrollbar,
|
||||
place.inner(Margin { vertical: 1, horizontal: 1 }),
|
||||
&mut self.scroll_state,
|
||||
);
|
||||
|
||||
frame.render_widget(table, place);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user