moved admin now
This commit is contained in:
@@ -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