completely broken intro or admin
This commit is contained in:
@@ -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),
|
||||
}
|
||||
}
|
||||
|
||||
2
client/src/modes/general.rs
Normal file
2
client/src/modes/general.rs
Normal file
@@ -0,0 +1,2 @@
|
||||
// src/client/modes/general.rs
|
||||
pub mod navigation;
|
||||
0
client/src/modes/general/navigation.rs
Normal file
0
client/src/modes/general/navigation.rs
Normal file
@@ -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
|
||||
);
|
||||
|
||||
@@ -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::*;
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -30,11 +30,8 @@ pub async fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// 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<dyn std::error::Error>> {
|
||||
&mut app_state,
|
||||
total_count,
|
||||
&mut current_position,
|
||||
&mut intro_state,
|
||||
).await?;
|
||||
|
||||
app_state.current_position = current_position;
|
||||
|
||||
Reference in New Issue
Block a user