moved admin now
This commit is contained in:
@@ -8,7 +8,7 @@ use crate::pages::admin_panel::add_logic;
|
||||
use crate::pages::admin_panel::add_table;
|
||||
use crate::pages::register::suggestions::RoleSuggestionsProvider;
|
||||
use crate::pages::admin::main::logic::handle_admin_navigation;
|
||||
use crate::pages::admin::admin::tui::handle_admin_selection;
|
||||
use crate::pages::admin::admin;
|
||||
use crate::modes::general::command_navigation::{
|
||||
handle_command_navigation_event, NavigationState,
|
||||
};
|
||||
@@ -332,6 +332,21 @@ impl EventHandler {
|
||||
if !outcome.get_message_if_ok().is_empty() {
|
||||
return Ok(outcome);
|
||||
}
|
||||
} else if let Page::Admin(admin_state) = &mut router.current {
|
||||
if matches!(auth_state.role, Some(UserRole::Admin)) {
|
||||
if let Event::Key(key_event) = event {
|
||||
if admin::event::handle_admin_event(
|
||||
key_event,
|
||||
config,
|
||||
app_state,
|
||||
admin_state,
|
||||
buffer_state,
|
||||
&mut self.command_message,
|
||||
)? {
|
||||
return Ok(EventOutcome::Ok(self.command_message.clone()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if toggle_sidebar(
|
||||
@@ -461,13 +476,6 @@ impl EventHandler {
|
||||
return Ok(EventOutcome::Ok(String::new()));
|
||||
}
|
||||
}
|
||||
Page::Admin(state) => {
|
||||
if matches!(auth_state.role, Some(UserRole::Admin)) {
|
||||
if state.handle_movement(app_state, ma) {
|
||||
return Ok(EventOutcome::Ok(String::new()));
|
||||
}
|
||||
}
|
||||
}
|
||||
Page::Intro(state) => {
|
||||
if state.handle_movement(ma) {
|
||||
return Ok(EventOutcome::Ok(String::new()));
|
||||
@@ -478,22 +486,6 @@ impl EventHandler {
|
||||
}
|
||||
|
||||
// Optional page-specific handlers (non-movement or rich actions)
|
||||
if let Page::Admin(admin_state) = &mut router.current {
|
||||
if matches!(auth_state.role, Some(UserRole::Admin)) {
|
||||
// Full admin navigation
|
||||
if handle_admin_navigation(
|
||||
key_event,
|
||||
config,
|
||||
app_state,
|
||||
admin_state,
|
||||
buffer_state,
|
||||
&mut self.command_message,
|
||||
) {
|
||||
return Ok(EventOutcome::Ok(self.command_message.clone()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let client_clone = self.grpc_client.clone();
|
||||
let sender_clone = self.save_logic_result_sender.clone();
|
||||
if add_logic::nav::handle_add_logic_navigation(
|
||||
@@ -606,7 +598,7 @@ impl EventHandler {
|
||||
}
|
||||
UiContext::Admin => {
|
||||
if let Page::Admin(admin_state) = &router.current {
|
||||
handle_admin_selection(
|
||||
admin::tui::handle_admin_selection(
|
||||
app_state,
|
||||
admin_state,
|
||||
);
|
||||
|
||||
@@ -14,6 +14,7 @@ use crate::pages::login::LoginFormState;
|
||||
use crate::pages::register::RegisterFormState;
|
||||
use crate::pages::admin::AdminState;
|
||||
use crate::pages::admin::AdminFocus;
|
||||
use crate::pages::admin::admin;
|
||||
use crate::pages::intro::IntroState;
|
||||
use crate::pages::forms::{FormState, FieldDefinition};
|
||||
use crate::pages::forms;
|
||||
@@ -413,33 +414,11 @@ pub async fn run_ui() -> Result<()> {
|
||||
admin_state = current.clone();
|
||||
}
|
||||
info!("Auth role at render: {:?}", auth_state.role);
|
||||
match grpc_client.get_profile_tree().await {
|
||||
Ok(refreshed_tree) => {
|
||||
app_state.profile_tree = refreshed_tree;
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to refresh profile tree for Admin panel: {}", e);
|
||||
event_handler.command_message =
|
||||
format!("Error refreshing admin data: {}", e);
|
||||
}
|
||||
}
|
||||
let profile_names = app_state.profile_tree.profiles.iter()
|
||||
.map(|p| p.name.clone())
|
||||
.collect();
|
||||
admin_state.set_profiles(profile_names);
|
||||
|
||||
if admin_state.current_focus == AdminFocus::default()
|
||||
|| !matches!(admin_state.current_focus,
|
||||
AdminFocus::InsideProfilesList |
|
||||
AdminFocus::Tables | AdminFocus::InsideTablesList |
|
||||
AdminFocus::Button1 | AdminFocus::Button2 | AdminFocus::Button3)
|
||||
{
|
||||
admin_state.current_focus = AdminFocus::ProfilesPane;
|
||||
}
|
||||
if admin_state.profile_list_state.selected().is_none()
|
||||
&& !app_state.profile_tree.profiles.is_empty()
|
||||
{
|
||||
admin_state.profile_list_state.select(Some(0));
|
||||
// Use the admin loader instead of inline logic
|
||||
if let Err(e) = admin::loader::refresh_admin_state(&mut grpc_client, &mut app_state, &mut admin_state).await {
|
||||
error!("Failed to refresh admin state: {}", e);
|
||||
event_handler.command_message = format!("Error refreshing admin data: {}", e);
|
||||
}
|
||||
|
||||
router.navigate(Page::Admin(admin_state.clone()));
|
||||
|
||||
Reference in New Issue
Block a user