not working
This commit is contained in:
@@ -48,7 +48,6 @@ impl EventHandler {
|
||||
total_count: u64,
|
||||
current_position: &mut u64,
|
||||
intro_state: &mut crate::components::intro::intro::IntroState,
|
||||
admin_state: &mut crate::components::admin::admin_panel::AdminPanelState,
|
||||
) -> Result<(bool, String), Box<dyn std::error::Error>> {
|
||||
if app_state.ui.show_intro {
|
||||
if let Event::Key(key) = event {
|
||||
@@ -71,44 +70,25 @@ impl EventHandler {
|
||||
let key_code = key.code;
|
||||
let modifiers = key.modifiers;
|
||||
|
||||
// Handle admin panel first if visible
|
||||
// Handle admin panel mode
|
||||
if app_state.ui.show_admin {
|
||||
if let Some(action) = config.get_admin_action(key_code, modifiers) {
|
||||
match action {
|
||||
"move_up" => admin_state.previous(),
|
||||
"move_down" => admin_state.next(),
|
||||
"select" => {
|
||||
// Handle selection logic
|
||||
},
|
||||
"move_up" => {
|
||||
// Handle up movement using app_state directly
|
||||
app_state.admin_selected_item = app_state.admin_selected_item.saturating_sub(1);
|
||||
}
|
||||
"move_down" => {
|
||||
// Handle down movement using app_state
|
||||
app_state.admin_selected_item = app_state.admin_selected_item.saturating_add(1);
|
||||
}
|
||||
"quit" => app_state.ui.show_admin = false,
|
||||
// Handle common actions
|
||||
"save" => {
|
||||
let message = common::save(
|
||||
form_state,
|
||||
grpc_client,
|
||||
&mut app_state.ui.is_saved,
|
||||
current_position,
|
||||
total_count,
|
||||
).await?;
|
||||
return Ok((false, message));
|
||||
},
|
||||
"revert" => {
|
||||
let message = common::revert(
|
||||
form_state,
|
||||
grpc_client,
|
||||
current_position,
|
||||
total_count,
|
||||
).await?;
|
||||
return Ok((false, message));
|
||||
},
|
||||
_ => {}
|
||||
}
|
||||
return Ok((false, format!("Admin: {}", action)));
|
||||
}
|
||||
// Block other keybindings when admin panel is visible
|
||||
return Ok((false, String::new()));
|
||||
}
|
||||
|
||||
if UiStateHandler::toggle_sidebar(
|
||||
&mut app_state.ui,
|
||||
config,
|
||||
|
||||
@@ -17,6 +17,8 @@ pub struct AppState {
|
||||
pub current_position: u64,
|
||||
pub profile_tree: ProfileTreeResponse,
|
||||
pub selected_profile: Option<String>,
|
||||
pub admin_selected_item: usize, // Tracks selection in admin panel
|
||||
pub admin_profiles: Vec<String>, // Stores admin panel data
|
||||
|
||||
// UI preferences
|
||||
pub ui: UiState,
|
||||
@@ -33,6 +35,8 @@ impl AppState {
|
||||
current_position: 0,
|
||||
profile_tree: ProfileTreeResponse::default(),
|
||||
selected_profile: None,
|
||||
admin_selected_item: 0,
|
||||
admin_profiles: Vec::new(),
|
||||
ui: UiState::default(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ pub fn render_ui(
|
||||
command_message: &str,
|
||||
app_state: &AppState,
|
||||
intro_state: &intro::IntroState,
|
||||
admin_panel_state: &mut AdminPanelState,
|
||||
) {
|
||||
render_background(f, f.area(), theme);
|
||||
|
||||
|
||||
@@ -28,11 +28,14 @@ pub async fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
|
||||
app_state.profile_tree = profile_tree;
|
||||
|
||||
// Now create admin panel with profiles from app_state
|
||||
let profiles = app_state.profile_tree.profiles
|
||||
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();
|
||||
let mut admin_panel_state = AdminPanelState::new(profiles);
|
||||
app_state.admin_selected_item = 0;
|
||||
}
|
||||
|
||||
// Fetch table structure at startup (one-time)
|
||||
let table_structure = grpc_client.get_table_structure().await?;
|
||||
@@ -75,7 +78,6 @@ pub async fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
|
||||
&event_handler.command_message,
|
||||
&app_state,
|
||||
&intro_state,
|
||||
&mut admin_panel_state,
|
||||
);
|
||||
})?;
|
||||
|
||||
@@ -94,7 +96,6 @@ pub async fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
|
||||
total_count,
|
||||
&mut current_position,
|
||||
&mut intro_state,
|
||||
&mut admin_panel_state,
|
||||
).await?;
|
||||
|
||||
app_state.current_position = current_position;
|
||||
|
||||
Reference in New Issue
Block a user