ability to initiate withdrawals from the table
Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
This commit is contained in:
parent
aed9fae2af
commit
a24a35aa51
@ -2,7 +2,7 @@
|
|||||||
name = "ghost-eye"
|
name = "ghost-eye"
|
||||||
authors = ["str3tch <stretch@ghostchain.io>"]
|
authors = ["str3tch <stretch@ghostchain.io>"]
|
||||||
description = "Application for interacting with Casper/Ghost nodes that are exposing RPC only to the localhost"
|
description = "Application for interacting with Casper/Ghost nodes that are exposing RPC only to the localhost"
|
||||||
version = "0.3.55"
|
version = "0.3.56"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
homepage = "https://git.ghostchain.io/ghostchain"
|
homepage = "https://git.ghostchain.io/ghostchain"
|
||||||
repository = "https://git.ghostchain.io/ghostchain/ghost-eye"
|
repository = "https://git.ghostchain.io/ghostchain/ghost-eye"
|
||||||
|
@ -36,6 +36,7 @@ pub enum Action {
|
|||||||
ClosePopup,
|
ClosePopup,
|
||||||
RotateSessionKeys,
|
RotateSessionKeys,
|
||||||
PayoutValidatorPopup(u32, bool),
|
PayoutValidatorPopup(u32, bool),
|
||||||
|
WithdrawValidatorPopup,
|
||||||
|
|
||||||
BalanceRequest([u8; 32], bool),
|
BalanceRequest([u8; 32], bool),
|
||||||
BalanceResponse([u8; 32], Option<SystemAccount>),
|
BalanceResponse([u8; 32], Option<SystemAccount>),
|
||||||
|
@ -244,6 +244,10 @@ impl Component for Validator {
|
|||||||
self.previous_tab = self.current_tab;
|
self.previous_tab = self.current_tab;
|
||||||
self.current_tab = CurrentTab::PayoutPopup;
|
self.current_tab = CurrentTab::PayoutPopup;
|
||||||
}
|
}
|
||||||
|
Action::WithdrawValidatorPopup => {
|
||||||
|
self.previous_tab = self.current_tab;
|
||||||
|
self.current_tab = CurrentTab::WithdrawPopup;
|
||||||
|
},
|
||||||
Action::ClosePopup => self.current_tab = self.previous_tab,
|
Action::ClosePopup => self.current_tab = self.previous_tab,
|
||||||
_ => {},
|
_ => {},
|
||||||
}
|
}
|
||||||
|
@ -112,6 +112,7 @@ impl Component for PayoutPopup {
|
|||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_key_event(&mut self, key: KeyEvent) -> Result<Option<Action>> {
|
fn handle_key_event(&mut self, key: KeyEvent) -> Result<Option<Action>> {
|
||||||
if self.is_active && key.kind == KeyEventKind::Press {
|
if self.is_active && key.kind == KeyEventKind::Press {
|
||||||
match key.code {
|
match key.code {
|
||||||
|
@ -11,9 +11,10 @@ use ratatui::{
|
|||||||
},
|
},
|
||||||
Frame
|
Frame
|
||||||
};
|
};
|
||||||
|
use tokio::sync::mpsc::UnboundedSender;
|
||||||
|
|
||||||
use super::{PartialComponent, Component, CurrentTab};
|
use super::{PartialComponent, Component, CurrentTab};
|
||||||
use crate::types::UnlockChunk;
|
use crate::types::{ActionTarget, ActionLevel, UnlockChunk};
|
||||||
use crate::{
|
use crate::{
|
||||||
action::Action,
|
action::Action,
|
||||||
config::Config,
|
config::Config,
|
||||||
@ -22,6 +23,7 @@ use crate::{
|
|||||||
|
|
||||||
pub struct Withdrawals {
|
pub struct Withdrawals {
|
||||||
is_active: bool,
|
is_active: bool,
|
||||||
|
action_tx: Option<UnboundedSender<Action>>,
|
||||||
palette: StylePalette,
|
palette: StylePalette,
|
||||||
scroll_state: ScrollbarState,
|
scroll_state: ScrollbarState,
|
||||||
table_state: TableState,
|
table_state: TableState,
|
||||||
@ -43,6 +45,7 @@ impl Withdrawals {
|
|||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
is_active: false,
|
is_active: false,
|
||||||
|
action_tx: None,
|
||||||
scroll_state: ScrollbarState::new(0),
|
scroll_state: ScrollbarState::new(0),
|
||||||
table_state: TableState::new(),
|
table_state: TableState::new(),
|
||||||
palette: StylePalette::default(),
|
palette: StylePalette::default(),
|
||||||
@ -52,6 +55,21 @@ impl Withdrawals {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn try_open_popup(&mut self) {
|
||||||
|
if let Some(action_tx) = &self.action_tx {
|
||||||
|
if let Some(index) = self.table_state.selected() {
|
||||||
|
if index == 0 && self.unlockings[0].era > self.current_era {
|
||||||
|
let _ = action_tx.send(Action::WithdrawValidatorPopup);
|
||||||
|
} else {
|
||||||
|
let _ = action_tx.send(Action::EventLog(
|
||||||
|
"Nothing to be witdrawn yet on the selected unlocking".to_string(),
|
||||||
|
ActionLevel::Info,
|
||||||
|
ActionTarget::ValidatorLog));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn first_row(&mut self) {
|
fn first_row(&mut self) {
|
||||||
if self.unlockings.len() > 0 {
|
if self.unlockings.len() > 0 {
|
||||||
self.table_state.select(Some(0));
|
self.table_state.select(Some(0));
|
||||||
@ -143,6 +161,11 @@ impl PartialComponent for Withdrawals {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Component for Withdrawals {
|
impl Component for Withdrawals {
|
||||||
|
fn register_action_handler(&mut self, tx: UnboundedSender<Action>) -> Result<()> {
|
||||||
|
self.action_tx = Some(tx);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn register_config_handler(&mut self, config: Config) -> Result<()> {
|
fn register_config_handler(&mut self, config: Config) -> Result<()> {
|
||||||
if let Some(style) = config.styles.get(&crate::app::Mode::Validator) {
|
if let Some(style) = config.styles.get(&crate::app::Mode::Validator) {
|
||||||
self.palette.with_normal_style(style.get("normal_style").copied());
|
self.palette.with_normal_style(style.get("normal_style").copied());
|
||||||
@ -175,6 +198,7 @@ impl Component for Withdrawals {
|
|||||||
KeyCode::Down | KeyCode::Char('j') => self.next_row(),
|
KeyCode::Down | KeyCode::Char('j') => self.next_row(),
|
||||||
KeyCode::Char('g') => self.first_row(),
|
KeyCode::Char('g') => self.first_row(),
|
||||||
KeyCode::Char('G') => self.last_row(),
|
KeyCode::Char('G') => self.last_row(),
|
||||||
|
KeyCode::Enter => self.try_open_popup(),
|
||||||
_ => {},
|
_ => {},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user