diff --git a/client/src/config/binds/config.rs b/client/src/config/binds/config.rs index 9a034f8..4cadf4f 100644 --- a/client/src/config/binds/config.rs +++ b/client/src/config/binds/config.rs @@ -82,16 +82,14 @@ impl Config { &self, is_edit_mode: bool, command_mode: bool, - show_intro: bool, - show_admin: bool, + show_general_mode: bool, key: KeyCode, modifiers: KeyModifiers ) -> Option<&str> { - match (show_intro, show_admin, command_mode, is_edit_mode) { - (true, _, _, _) => self.get_intro_action(key, modifiers), - (_, true, _, _) => self.get_admin_action(key, modifiers), - (_, _, true, _) => self.get_command_action_for_key(key, modifiers), - (_, _, _, true) => self.get_edit_action_for_key(key, modifiers), + match (show_general_mode, command_mode, is_edit_mode) { + (true, _, _) => self.get_general_action(key, modifiers), + (_, true, _) => self.get_command_action_for_key(key, modifiers), + (_, _, true) => self.get_edit_action_for_key(key, modifiers), _ => self.get_read_only_action_for_key(key, modifiers), } } diff --git a/client/src/modes/general.rs b/client/src/modes/general.rs new file mode 100644 index 0000000..aa1c875 --- /dev/null +++ b/client/src/modes/general.rs @@ -0,0 +1,2 @@ +// src/client/modes/general.rs +pub mod navigation; diff --git a/client/src/modes/general/navigation.rs b/client/src/modes/general/navigation.rs new file mode 100644 index 0000000..e69de29 diff --git a/client/src/modes/handlers/event.rs b/client/src/modes/handlers/event.rs index 42a506a..bc4f1b9 100644 --- a/client/src/modes/handlers/event.rs +++ b/client/src/modes/handlers/event.rs @@ -170,8 +170,7 @@ impl EventHandler { let context_action = config.get_action_for_current_context( self.is_edit_mode, self.command_mode, - app_state.ui.show_intro, - app_state.ui.show_admin, + app_state.ui.show_general_mode, key_code, modifiers ); diff --git a/client/src/modes/mod.rs b/client/src/modes/mod.rs index 5c80154..b9611f5 100644 --- a/client/src/modes/mod.rs +++ b/client/src/modes/mod.rs @@ -1,6 +1,8 @@ // src/client/modes/mod.rs pub mod handlers; pub mod canvas; +pub mod general; pub use handlers::*; pub use canvas::*; +pub use general::*; diff --git a/client/src/state/state.rs b/client/src/state/state.rs index a250b7b..892017f 100644 --- a/client/src/state/state.rs +++ b/client/src/state/state.rs @@ -8,6 +8,7 @@ pub struct UiState { pub is_saved: bool, pub show_intro: bool, pub show_admin: bool, + pub show_general_mode: bool, } pub struct GeneralState { @@ -40,6 +41,10 @@ impl AppState { profile_tree: ProfileTreeResponse::default(), selected_profile: None, ui: UiState::default(), + general: GeneralState { + selected_item: 0, + current_option: 0, + }, }) } @@ -60,6 +65,7 @@ impl Default for UiState { is_saved: false, show_intro: true, show_admin: false, + show_general_mode: false, } } } diff --git a/client/src/ui/handlers/render.rs b/client/src/ui/handlers/render.rs index ed7eac0..2ce2100 100644 --- a/client/src/ui/handlers/render.rs +++ b/client/src/ui/handlers/render.rs @@ -45,21 +45,20 @@ pub fn render_ui( } else if app_state.ui.show_admin { // Create temporary AdminPanelState for rendering let mut admin_state = AdminPanelState::new( - if app_state.admin_profiles.is_empty() { + if app_state.profile_tree.profiles.is_empty() { // Fallback if admin_profiles is empty app_state.profile_tree.profiles .iter() .map(|p| p.name.clone()) .collect() } else { - app_state.admin_profiles.clone() + app_state.profile_tree.profiles.iter().map(|p| p.name.clone()).collect() } ); // Set the selected item if !admin_state.profiles.is_empty() { - let safe_index = app_state.admin_selected_item.min(admin_state.profiles.len() - 1); - admin_state.list_state.select(Some(safe_index)); + app_state.general.selected_item.min(admin_state.profiles.len().saturating_sub(1)); } admin_state.render( diff --git a/client/src/ui/handlers/ui.rs b/client/src/ui/handlers/ui.rs index 8e1afc0..0871063 100644 --- a/client/src/ui/handlers/ui.rs +++ b/client/src/ui/handlers/ui.rs @@ -30,11 +30,8 @@ pub async fn run_ui() -> Result<(), Box> { // Now create admin panel with profiles from app_state if intro_state.selected_option == 1 { app_state.ui.show_admin = true; - app_state.admin_profiles = app_state.profile_tree.profiles - .iter() - .map(|p| p.name.clone()) - .collect(); - app_state.admin_selected_item = 0; + app_state.general.selected_item = 0; + app_state.general.current_option = 0; } // Fetch table structure at startup (one-time) @@ -95,7 +92,6 @@ pub async fn run_ui() -> Result<(), Box> { &mut app_state, total_count, &mut current_position, - &mut intro_state, ).await?; app_state.current_position = current_position;