Compare commits

...

3 Commits

Author SHA1 Message Date
a24a35aa51
ability to initiate withdrawals from the table
Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
2025-04-24 20:34:27 +03:00
aed9fae2af
highlight already withdrawn payouts because not all terminals support crossed text
Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
2025-04-24 20:04:32 +03:00
987d8e544d
pop-up overlay issue fixed on the nominator table
Signed-off-by: Uncle Stinky <uncle.stinky@ghostchain.io>
2025-04-24 19:42:09 +03:00
7 changed files with 51 additions and 10 deletions

View File

@ -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.53"
version = "0.3.56"
edition = "2021"
homepage = "https://git.ghostchain.io/ghostchain"
repository = "https://git.ghostchain.io/ghostchain/ghost-eye"

View File

@ -36,6 +36,7 @@ pub enum Action {
ClosePopup,
RotateSessionKeys,
PayoutValidatorPopup(u32, bool),
WithdrawValidatorPopup,
BalanceRequest([u8; 32], bool),
BalanceResponse([u8; 32], Option<SystemAccount>),

View File

@ -183,7 +183,10 @@ impl PartialComponent for History {
fn set_active(&mut self, current_tab: CurrentTab) {
match current_tab {
CurrentTab::History => self.is_active = true,
_ => self.is_active = false,
_ => {
self.table_state.select(None);
self.is_active = false;
}
}
}
}
@ -253,13 +256,19 @@ impl Component for History {
era_index_text = era_index_text.add_modifier(Modifier::CROSSED_OUT);
slash_text = slash_text.add_modifier(Modifier::CROSSED_OUT);
reward_text = reward_text.add_modifier(Modifier::CROSSED_OUT);
}
Row::new(vec![
Cell::from(era_index_text),
Cell::from(slash_text),
Cell::from(reward_text),
]).style(self.palette.create_highlight_style())
} else {
Row::new(vec![
Cell::from(era_index_text),
Cell::from(slash_text),
Cell::from(reward_text),
])
}
}),
[
Constraint::Length(4),
@ -267,7 +276,7 @@ impl Component for History {
Constraint::Fill(1),
],
)
.highlight_style(self.palette.create_highlight_style())
.highlight_style(self.palette.create_basic_style(true))
.column_spacing(1)
.block(Block::bordered()
.border_style(border_style)

View File

@ -244,6 +244,10 @@ impl Component for Validator {
self.previous_tab = self.current_tab;
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,
_ => {},
}

View File

@ -112,6 +112,7 @@ impl Component for PayoutPopup {
}
Ok(())
}
fn handle_key_event(&mut self, key: KeyEvent) -> Result<Option<Action>> {
if self.is_active && key.kind == KeyEventKind::Press {
match key.code {

View File

@ -11,9 +11,10 @@ use ratatui::{
},
Frame
};
use tokio::sync::mpsc::UnboundedSender;
use super::{PartialComponent, Component, CurrentTab};
use crate::types::UnlockChunk;
use crate::types::{ActionTarget, ActionLevel, UnlockChunk};
use crate::{
action::Action,
config::Config,
@ -22,6 +23,7 @@ use crate::{
pub struct Withdrawals {
is_active: bool,
action_tx: Option<UnboundedSender<Action>>,
palette: StylePalette,
scroll_state: ScrollbarState,
table_state: TableState,
@ -43,6 +45,7 @@ impl Withdrawals {
pub fn new() -> Self {
Self {
is_active: false,
action_tx: None,
scroll_state: ScrollbarState::new(0),
table_state: TableState::new(),
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) {
if self.unlockings.len() > 0 {
self.table_state.select(Some(0));
@ -143,6 +161,11 @@ impl PartialComponent 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<()> {
if let Some(style) = config.styles.get(&crate::app::Mode::Validator) {
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::Char('g') => self.first_row(),
KeyCode::Char('G') => self.last_row(),
KeyCode::Enter => self.try_open_popup(),
_ => {},
};
}

View File

@ -2,6 +2,7 @@ use std::sync::mpsc::Sender;
use color_eyre::Result;
use ratatui::{
widgets::Clear,
layout::{Alignment, Constraint, Rect},
text::Text,
widgets::{Block, Cell, Row, Table},
@ -215,6 +216,7 @@ impl Component for CurrentValidatorDetails {
.title_style(self.palette.create_title_style(false))
.title("Validator details"));
frame.render_widget(Clear, place);
frame.render_widget(table, place);
}