admin panel keyindings
This commit is contained in:
@@ -48,6 +48,7 @@ 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 {
|
||||
@@ -70,6 +71,44 @@ impl EventHandler {
|
||||
let key_code = key.code;
|
||||
let modifiers = key.modifiers;
|
||||
|
||||
// Handle admin panel first if visible
|
||||
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
|
||||
},
|
||||
"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,
|
||||
|
||||
Reference in New Issue
Block a user