admin panel now distinguish admin and other roles of the user
This commit is contained in:
@@ -12,6 +12,16 @@ use ratatui::{
|
||||
Frame,
|
||||
};
|
||||
|
||||
/// Renders the view specific to admin users.
|
||||
fn render_admin_panel_admin(f: &mut Frame, content_chunks: &[Rect], theme: &Theme) {
|
||||
// Admin-specific view placeholder
|
||||
let admin_message = Paragraph::new("Admin-specific view. Profile selection not applicable.")
|
||||
.style(Style::default().fg(theme.fg))
|
||||
.alignment(Alignment::Center);
|
||||
// Render only in the right pane for now, leaving left empty
|
||||
f.render_widget(admin_message, content_chunks[1]);
|
||||
}
|
||||
|
||||
pub fn render_admin_panel(
|
||||
f: &mut Frame,
|
||||
auth_state: &AuthState,
|
||||
@@ -47,6 +57,28 @@ pub fn render_admin_panel(
|
||||
.split(chunks[1]);
|
||||
|
||||
if auth_state.role.as_deref() != Some("admin") {
|
||||
render_admin_panel_non_admin(
|
||||
f,
|
||||
admin_state,
|
||||
&content_chunks,
|
||||
theme,
|
||||
profile_tree,
|
||||
selected_profile,
|
||||
);
|
||||
} else {
|
||||
render_admin_panel_admin(f, &content_chunks, theme);
|
||||
}
|
||||
}
|
||||
|
||||
/// Renders the view for non-admin users (profile list and details).
|
||||
fn render_admin_panel_non_admin(
|
||||
f: &mut Frame,
|
||||
admin_state: &AdminState,
|
||||
content_chunks: &[Rect],
|
||||
theme: &Theme,
|
||||
profile_tree: &ProfileTreeResponse,
|
||||
selected_profile: &Option<String>,
|
||||
) {
|
||||
// Profile list - Use data from admin_state
|
||||
let items: Vec<ListItem> = admin_state
|
||||
.profiles
|
||||
@@ -102,11 +134,4 @@ pub fn render_admin_panel(
|
||||
.wrap(Wrap { trim: true });
|
||||
f.render_widget(details_widget, content_chunks[1]);
|
||||
}
|
||||
} else {
|
||||
// Admin-specific view
|
||||
let admin_message = Paragraph::new("Admin-specific view. Profile selection not applicable.")
|
||||
.style(Style::default().fg(theme.fg))
|
||||
.alignment(Alignment::Center);
|
||||
f.render_widget(admin_message, content_chunks[1]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user