diff --git a/client/src/functions/modes/navigation/admin_nav.rs b/client/src/functions/modes/navigation/admin_nav.rs index ad00f7a..dda65e4 100644 --- a/client/src/functions/modes/navigation/admin_nav.rs +++ b/client/src/functions/modes/navigation/admin_nav.rs @@ -58,33 +58,30 @@ pub fn handle_admin_navigation( *command_message = "Navigating profiles. Use Up/Down. Esc to exit.".to_string(); handled = true; } - Some("next_option") | Some("move_down") => { // move_down acts as next_option + Some("next_option") | Some("move_down") => { admin_state.current_focus = AdminFocus::Tables; *command_message = "Focus: Tables Pane".to_string(); handled = true; } - Some("previous_option") | Some("move_up") => { // move_up acts as previous_option - admin_state.current_focus = AdminFocus::Button3; // Cycle to last button - *command_message = "Focus: Button 3".to_string(); + Some("previous_option") | Some("move_up") => { + // No wrap-around: Stay on ProfilesPane if trying to go "before" it + *command_message = "At first focusable pane.".to_string(); handled = true; } - // If move_up/move_down were not explicitly for pane nav, - // they would be caught here if not handled above. - // But since we want them for pane nav, this is fine. _ => handled = false, } } AdminFocus::InsideProfilesList => { match action.as_deref() { - Some("move_up") => { // Only item navigation here + Some("move_up") => { if profile_count > 0 { list_select_previous(&mut admin_state.profile_list_state, profile_count); *command_message = "".to_string(); handled = true; } } - Some("move_down") => { // Only item navigation here + Some("move_down") => { if profile_count > 0 { list_select_next(&mut admin_state.profile_list_state, profile_count); *command_message = "".to_string(); @@ -111,12 +108,11 @@ pub fn handle_admin_navigation( ); handled = true; } - Some("exit_table_scroll") => { // 'esc' + Some("exit_table_scroll") => { admin_state.current_focus = AdminFocus::ProfilesPane; *command_message = "Focus: Profiles Pane".to_string(); handled = true; } - // next_option & previous_option are NOT handled here to enforce 'esc' first _ => handled = false, } } @@ -146,22 +142,21 @@ pub fn handle_admin_navigation( if admin_state.current_focus == AdminFocus::InsideTablesList && !admin_state.table_list_state.selected().is_none() { *command_message = "Navigating tables. Use Up/Down. Esc to exit.".to_string(); } else if admin_state.table_list_state.selected().is_none() { - // If no tables, or no profile, don't enter InsideTablesList or revert if current_profile_idx.is_none() { *command_message = "No profile selected to view tables.".to_string(); } else { *command_message = "No tables in selected profile.".to_string(); } - admin_state.current_focus = AdminFocus::Tables; // Stay on Tables pane + admin_state.current_focus = AdminFocus::Tables; } handled = true; } - Some("previous_option") | Some("move_up") => { // move_up acts as previous_option + Some("previous_option") | Some("move_up") => { admin_state.current_focus = AdminFocus::ProfilesPane; *command_message = "Focus: Profiles Pane".to_string(); handled = true; } - Some("next_option") | Some("move_down") => { // move_down acts as next_option + Some("next_option") | Some("move_down") => { admin_state.current_focus = AdminFocus::Button1; *command_message = "Focus: Add Logic Button".to_string(); handled = true; @@ -172,7 +167,7 @@ pub fn handle_admin_navigation( AdminFocus::InsideTablesList => { match action.as_deref() { - Some("move_up") => { // Only item navigation + Some("move_up") => { let current_profile_idx = admin_state.selected_profile_index .or_else(|| admin_state.profile_list_state.selected()); if let Some(p_idx) = current_profile_idx { @@ -191,7 +186,7 @@ pub fn handle_admin_navigation( handled = true; } } - Some("move_down") => { // Only item navigation + Some("move_down") => { let current_profile_idx = admin_state.selected_profile_index .or_else(|| admin_state.profile_list_state.selected()); if let Some(p_idx) = current_profile_idx { @@ -220,21 +215,18 @@ pub fn handle_admin_navigation( *command_message = format!("Table '{}' set as active.", table_name); handled = true; } - Some("exit_table_scroll") => { // 'esc' + Some("exit_table_scroll") => { admin_state.current_focus = AdminFocus::Tables; *command_message = "Focus: Tables Pane".to_string(); handled = true; } - // next_option & previous_option are NOT handled here _ => handled = false, } } - // --- Button Navigation --- - // move_up/move_down on buttons will cycle through them or to adjacent panes (Tables/Profiles) AdminFocus::Button1 => { match action.as_deref() { - Some("select") => { /* ... existing select logic ... */ + Some("select") => { let mut logic_state_profile_name = "None (Global)".to_string(); let mut selected_table_name_for_logic: Option = None; if let Some(p_idx) = admin_state.selected_profile_index { @@ -258,12 +250,12 @@ pub fn handle_admin_navigation( *command_message = "Opening Add Logic...".to_string(); handled = true; } - Some("previous_option") | Some("move_up") => { // move_up from Button1 goes to Tables Pane + Some("previous_option") | Some("move_up") => { admin_state.current_focus = AdminFocus::Tables; *command_message = "Focus: Tables Pane".to_string(); handled = true; } - Some("next_option") | Some("move_down") => { // move_down from Button1 goes to Button2 + Some("next_option") | Some("move_down") => { admin_state.current_focus = AdminFocus::Button2; *command_message = "Focus: Add Table Button".to_string(); handled = true; @@ -274,7 +266,7 @@ pub fn handle_admin_navigation( AdminFocus::Button2 => { match action.as_deref() { - Some("select") => { /* ... existing select logic ... */ + Some("select") => { if let Some(p_idx) = admin_state.selected_profile_index { if let Some(profile) = app_state.profile_tree.profiles.get(p_idx) { let selected_profile_name = profile.name.clone(); @@ -300,12 +292,12 @@ pub fn handle_admin_navigation( handled = true; } } - Some("previous_option") | Some("move_up") => { // move_up from Button2 goes to Button1 + Some("previous_option") | Some("move_up") => { admin_state.current_focus = AdminFocus::Button1; *command_message = "Focus: Add Logic Button".to_string(); handled = true; } - Some("next_option") | Some("move_down") => { // move_down from Button2 goes to Button3 + Some("next_option") | Some("move_down") => { admin_state.current_focus = AdminFocus::Button3; *command_message = "Focus: Change Table Button".to_string(); handled = true; @@ -320,14 +312,14 @@ pub fn handle_admin_navigation( *command_message = "Action: Change Table (Not Implemented)".to_string(); handled = true; } - Some("previous_option") | Some("move_up") => { // move_up from Button3 goes to Button2 + Some("previous_option") | Some("move_up") => { admin_state.current_focus = AdminFocus::Button2; *command_message = "Focus: Add Table Button".to_string(); handled = true; } - Some("next_option") | Some("move_down") => { // move_down from Button3 goes to Profiles Pane - admin_state.current_focus = AdminFocus::ProfilesPane; - *command_message = "Focus: Profiles Pane".to_string(); + Some("next_option") | Some("move_down") => { + // No wrap-around: Stay on Button3 if trying to go "after" it + *command_message = "At last focusable button.".to_string(); handled = true; } _ => handled = false,