going directly into adminstate from appstate for the admin page. DESTROYED

This commit is contained in:
filipriec
2025-04-14 11:24:56 +02:00
parent 1927d1fa4d
commit 2d724876eb
10 changed files with 100 additions and 33 deletions

View File

@@ -6,9 +6,11 @@ use crate::state::app::state::AppState;
use crate::state::pages::form::FormState;
use crate::state::pages::auth::LoginState;
use crate::state::pages::auth::RegisterState;
use crate::state::pages::admin::AdminState;
use crate::state::pages::canvas_state::CanvasState;
use crate::ui::handlers::context::UiContext;
use crate::modes::handlers::event::EventOutcome;
use crate::functions::modes::navigation::admin_nav;
pub async fn handle_navigation_event(
key: KeyEvent,
@@ -17,6 +19,7 @@ pub async fn handle_navigation_event(
app_state: &mut AppState,
login_state: &mut LoginState,
register_state: &mut RegisterState,
admin_state: &mut AdminState,
command_mode: &mut bool,
command_input: &mut String,
command_message: &mut String,
@@ -24,11 +27,11 @@ 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, login_state, register_state);
move_up(app_state, login_state, register_state, admin_state);
return Ok(EventOutcome::Ok(String::new()));
}
"move_down" => {
move_down(app_state);
move_down(app_state, admin_state);
return Ok(EventOutcome::Ok(String::new()));
}
"next_option" => {
@@ -80,7 +83,7 @@ pub async fn handle_navigation_event(
Ok(EventOutcome::Ok(String::new()))
}
pub fn move_up(app_state: &mut AppState, login_state: &mut LoginState, register_state: &mut RegisterState) {
pub fn move_up(app_state: &mut AppState, login_state: &mut LoginState, register_state: &mut RegisterState, admin_state: &mut AdminState) {
if app_state.ui.focus_outside_canvas && app_state.ui.show_login || app_state.ui.show_register{
if app_state.general.selected_item == 0 {
app_state.ui.focus_outside_canvas = false;
@@ -97,22 +100,11 @@ pub fn move_up(app_state: &mut AppState, login_state: &mut LoginState, register_
} else if app_state.ui.show_intro {
app_state.ui.intro_state.previous_option();
} else if app_state.ui.show_admin {
// Assuming profile_tree.profiles is the list we're navigating
let profile_count = app_state.profile_tree.profiles.len();
if profile_count == 0 {
return;
}
// Use general state for tracking selection in admin panel
if app_state.general.selected_item == 0 {
app_state.general.selected_item = profile_count - 1;
} else {
app_state.general.selected_item = app_state.general.selected_item.saturating_sub(1);
}
admin_nav::move_admin_list_up(app_state, admin_state);
}
}
pub fn move_down(app_state: &mut AppState) {
pub fn move_down(app_state: &mut AppState, admin_state: &mut AdminState) {
if app_state.ui.focus_outside_canvas && app_state.ui.show_login || app_state.ui.show_register {
let num_general_elements = 2;
if app_state.general.selected_item < num_general_elements - 1 {
@@ -127,7 +119,7 @@ pub fn move_down(app_state: &mut AppState) {
return;
}
app_state.general.selected_item = (app_state.general.selected_item + 1) % profile_count;
admin_nav::move_admin_list_down(app_state, admin_state);
}
}