completely broken intro or admin
This commit is contained in:
@@ -82,16 +82,14 @@ impl Config {
|
|||||||
&self,
|
&self,
|
||||||
is_edit_mode: bool,
|
is_edit_mode: bool,
|
||||||
command_mode: bool,
|
command_mode: bool,
|
||||||
show_intro: bool,
|
show_general_mode: bool,
|
||||||
show_admin: bool,
|
|
||||||
key: KeyCode,
|
key: KeyCode,
|
||||||
modifiers: KeyModifiers
|
modifiers: KeyModifiers
|
||||||
) -> Option<&str> {
|
) -> Option<&str> {
|
||||||
match (show_intro, show_admin, command_mode, is_edit_mode) {
|
match (show_general_mode, command_mode, is_edit_mode) {
|
||||||
(true, _, _, _) => self.get_intro_action(key, modifiers),
|
(true, _, _) => self.get_general_action(key, modifiers),
|
||||||
(_, true, _, _) => self.get_admin_action(key, modifiers),
|
(_, true, _) => self.get_command_action_for_key(key, modifiers),
|
||||||
(_, _, true, _) => self.get_command_action_for_key(key, modifiers),
|
(_, _, true) => self.get_edit_action_for_key(key, modifiers),
|
||||||
(_, _, _, true) => self.get_edit_action_for_key(key, modifiers),
|
|
||||||
_ => self.get_read_only_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(
|
let context_action = config.get_action_for_current_context(
|
||||||
self.is_edit_mode,
|
self.is_edit_mode,
|
||||||
self.command_mode,
|
self.command_mode,
|
||||||
app_state.ui.show_intro,
|
app_state.ui.show_general_mode,
|
||||||
app_state.ui.show_admin,
|
|
||||||
key_code,
|
key_code,
|
||||||
modifiers
|
modifiers
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
// src/client/modes/mod.rs
|
// src/client/modes/mod.rs
|
||||||
pub mod handlers;
|
pub mod handlers;
|
||||||
pub mod canvas;
|
pub mod canvas;
|
||||||
|
pub mod general;
|
||||||
|
|
||||||
pub use handlers::*;
|
pub use handlers::*;
|
||||||
pub use canvas::*;
|
pub use canvas::*;
|
||||||
|
pub use general::*;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ pub struct UiState {
|
|||||||
pub is_saved: bool,
|
pub is_saved: bool,
|
||||||
pub show_intro: bool,
|
pub show_intro: bool,
|
||||||
pub show_admin: bool,
|
pub show_admin: bool,
|
||||||
|
pub show_general_mode: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct GeneralState {
|
pub struct GeneralState {
|
||||||
@@ -40,6 +41,10 @@ impl AppState {
|
|||||||
profile_tree: ProfileTreeResponse::default(),
|
profile_tree: ProfileTreeResponse::default(),
|
||||||
selected_profile: None,
|
selected_profile: None,
|
||||||
ui: UiState::default(),
|
ui: UiState::default(),
|
||||||
|
general: GeneralState {
|
||||||
|
selected_item: 0,
|
||||||
|
current_option: 0,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,6 +65,7 @@ impl Default for UiState {
|
|||||||
is_saved: false,
|
is_saved: false,
|
||||||
show_intro: true,
|
show_intro: true,
|
||||||
show_admin: false,
|
show_admin: false,
|
||||||
|
show_general_mode: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,21 +45,20 @@ pub fn render_ui(
|
|||||||
} else if app_state.ui.show_admin {
|
} else if app_state.ui.show_admin {
|
||||||
// Create temporary AdminPanelState for rendering
|
// Create temporary AdminPanelState for rendering
|
||||||
let mut admin_state = AdminPanelState::new(
|
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
|
// Fallback if admin_profiles is empty
|
||||||
app_state.profile_tree.profiles
|
app_state.profile_tree.profiles
|
||||||
.iter()
|
.iter()
|
||||||
.map(|p| p.name.clone())
|
.map(|p| p.name.clone())
|
||||||
.collect()
|
.collect()
|
||||||
} else {
|
} else {
|
||||||
app_state.admin_profiles.clone()
|
app_state.profile_tree.profiles.iter().map(|p| p.name.clone()).collect()
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// Set the selected item
|
// Set the selected item
|
||||||
if !admin_state.profiles.is_empty() {
|
if !admin_state.profiles.is_empty() {
|
||||||
let safe_index = app_state.admin_selected_item.min(admin_state.profiles.len() - 1);
|
app_state.general.selected_item.min(admin_state.profiles.len().saturating_sub(1));
|
||||||
admin_state.list_state.select(Some(safe_index));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
admin_state.render(
|
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
|
// Now create admin panel with profiles from app_state
|
||||||
if intro_state.selected_option == 1 {
|
if intro_state.selected_option == 1 {
|
||||||
app_state.ui.show_admin = true;
|
app_state.ui.show_admin = true;
|
||||||
app_state.admin_profiles = app_state.profile_tree.profiles
|
app_state.general.selected_item = 0;
|
||||||
.iter()
|
app_state.general.current_option = 0;
|
||||||
.map(|p| p.name.clone())
|
|
||||||
.collect();
|
|
||||||
app_state.admin_selected_item = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch table structure at startup (one-time)
|
// 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,
|
&mut app_state,
|
||||||
total_count,
|
total_count,
|
||||||
&mut current_position,
|
&mut current_position,
|
||||||
&mut intro_state,
|
|
||||||
).await?;
|
).await?;
|
||||||
|
|
||||||
app_state.current_position = current_position;
|
app_state.current_position = current_position;
|
||||||
|
|||||||
Reference in New Issue
Block a user