HARDEST COMMIT IN THE RECENT TIMES we fixed movement in the admin page
This commit is contained in:
@@ -28,12 +28,12 @@ pub async fn handle_navigation_event(
|
||||
|
||||
if let Some(action) = config.get_general_action(key.code, key.modifiers) {
|
||||
match action {
|
||||
"move_up" => {
|
||||
move_up(app_state, router);
|
||||
"up" => {
|
||||
up(app_state, router);
|
||||
return Ok(EventOutcome::Ok(String::new()));
|
||||
}
|
||||
"move_down" => {
|
||||
move_down(app_state, router);
|
||||
"down" => {
|
||||
down(app_state, router);
|
||||
return Ok(EventOutcome::Ok(String::new()));
|
||||
}
|
||||
"next_option" => {
|
||||
@@ -85,7 +85,7 @@ pub async fn handle_navigation_event(
|
||||
Ok(EventOutcome::Ok(String::new()))
|
||||
}
|
||||
|
||||
pub fn move_up(app_state: &mut AppState, router: &mut Router) {
|
||||
pub fn up(app_state: &mut AppState, router: &mut Router) {
|
||||
match &mut router.current {
|
||||
Page::Login(state) if app_state.ui.focus_outside_canvas => {
|
||||
if app_state.focused_button_index == 0 {
|
||||
@@ -113,7 +113,7 @@ pub fn move_up(app_state: &mut AppState, router: &mut Router) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn move_down(app_state: &mut AppState, router: &mut Router) {
|
||||
pub fn down(app_state: &mut AppState, router: &mut Router) {
|
||||
match &mut router.current {
|
||||
Page::Login(_) | Page::Register(_) if app_state.ui.focus_outside_canvas => {
|
||||
let num_general_elements = 2;
|
||||
|
||||
@@ -409,30 +409,6 @@ impl EventHandler {
|
||||
if state.handle_movement(app_state, ma) {
|
||||
return Ok(EventOutcome::Ok(String::new()));
|
||||
}
|
||||
} else {
|
||||
// Non-admin: simple profile navigation
|
||||
match ma {
|
||||
MovementAction::Up | MovementAction::Previous => {
|
||||
state.previous();
|
||||
return Ok(EventOutcome::Ok(String::new()));
|
||||
}
|
||||
MovementAction::Down | MovementAction::Next => {
|
||||
state.next();
|
||||
return Ok(EventOutcome::Ok(String::new()));
|
||||
}
|
||||
MovementAction::Select => {
|
||||
if let Some(idx) = state.get_selected_index() {
|
||||
if let Some(profile) = app_state.profile_tree.profiles.get(idx) {
|
||||
app_state.selected_profile = Some(profile.name.clone());
|
||||
return Ok(EventOutcome::Ok(format!(
|
||||
"Profile '{}' selected",
|
||||
profile.name
|
||||
)));
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
Page::Intro(state) => {
|
||||
@@ -458,29 +434,6 @@ impl EventHandler {
|
||||
) {
|
||||
return Ok(EventOutcome::Ok(self.command_message.clone()));
|
||||
}
|
||||
} else {
|
||||
// Non-admin: allow simple profile navigation
|
||||
if let Some(action) = config.get_general_action(key_event.code, key_event.modifiers) {
|
||||
match action {
|
||||
"move_up" => {
|
||||
admin_state.previous();
|
||||
return Ok(EventOutcome::Ok(String::new()));
|
||||
}
|
||||
"move_down" => {
|
||||
admin_state.next();
|
||||
return Ok(EventOutcome::Ok(String::new()));
|
||||
}
|
||||
"select" => {
|
||||
if let Some(idx) = admin_state.get_selected_index() {
|
||||
if let Some(profile) = app_state.profile_tree.profiles.get(idx) {
|
||||
app_state.selected_profile = Some(profile.name.clone());
|
||||
}
|
||||
}
|
||||
return Ok(EventOutcome::Ok("Profile selected".to_string()));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ pub fn render_admin_panel(
|
||||
/// Renders the view for non-admin users (profile list and details).
|
||||
fn render_admin_panel_non_admin(
|
||||
f: &mut Frame,
|
||||
admin_state: &AdminState,
|
||||
admin_state: &mut AdminState,
|
||||
content_chunks: &[Rect],
|
||||
theme: &Theme,
|
||||
profile_tree: &ProfileTreeResponse,
|
||||
@@ -92,7 +92,7 @@ fn render_admin_panel_non_admin(
|
||||
.block(Block::default().title("Profiles"))
|
||||
.highlight_style(Style::default().bg(theme.highlight).fg(theme.bg));
|
||||
|
||||
f.render_stateful_widget(list, content_chunks[0], &mut admin_state.profile_list_state.clone());
|
||||
f.render_stateful_widget(list, content_chunks[0], &mut admin_state.profile_list_state);
|
||||
|
||||
// Profile details - Use selection info from admin_state
|
||||
if let Some(profile) = admin_state
|
||||
|
||||
@@ -353,6 +353,9 @@ pub async fn run_ui() -> Result<()> {
|
||||
AppView::Login => router.navigate(Page::Login(login_state.clone())),
|
||||
AppView::Register => router.navigate(Page::Register(register_state.clone())),
|
||||
AppView::Admin => {
|
||||
if let Page::Admin(current) = &router.current {
|
||||
admin_state = current.clone();
|
||||
}
|
||||
info!("Active view is Admin, refreshing profile tree...");
|
||||
match grpc_client.get_profile_tree().await {
|
||||
Ok(refreshed_tree) => {
|
||||
|
||||
Reference in New Issue
Block a user