the profile name is now passed from admin panel to the add table page
This commit is contained in:
@@ -113,11 +113,11 @@ pub fn render_add_table(
|
||||
// --- Top Info Rendering (Wide - 2 lines) ---
|
||||
let profile_text = Paragraph::new(vec![
|
||||
Line::from(Span::styled(
|
||||
format!("profile: {}", add_table_state.profile_name),
|
||||
format!("Profile: {}", add_table_state.profile_name),
|
||||
theme.fg,
|
||||
)),
|
||||
Line::from(Span::styled(
|
||||
format!("table name: {}", add_table_state.table_name),
|
||||
format!("Table name: {}", add_table_state.table_name),
|
||||
theme.fg,
|
||||
)),
|
||||
])
|
||||
@@ -169,14 +169,14 @@ pub fn render_add_table(
|
||||
.split(top_info_area);
|
||||
|
||||
let profile_text = Paragraph::new(Span::styled(
|
||||
format!("profile: {}", add_table_state.profile_name),
|
||||
format!("Profile: {}", add_table_state.profile_name),
|
||||
theme.fg,
|
||||
))
|
||||
.alignment(Alignment::Left);
|
||||
f.render_widget(profile_text, top_info_chunks[0]);
|
||||
|
||||
let table_name_text = Paragraph::new(Span::styled(
|
||||
format!("table: {}", add_table_state.table_name),
|
||||
format!("Table: {}", add_table_state.table_name),
|
||||
theme.fg,
|
||||
))
|
||||
.alignment(Alignment::Left);
|
||||
|
||||
@@ -8,6 +8,7 @@ use crate::state::{
|
||||
use crossterm::event::{KeyCode, KeyEvent, KeyModifiers};
|
||||
use crate::state::app::buffer::AppView;
|
||||
use crate::state::app::buffer::BufferState;
|
||||
use crate::state::pages::add_table::AddTableState;
|
||||
|
||||
/// Handles navigation events specifically for the Admin Panel view.
|
||||
/// Returns true if the event was handled, false otherwise.
|
||||
@@ -160,9 +161,37 @@ pub fn handle_admin_navigation(
|
||||
// TODO: Trigger action for Button 1
|
||||
}
|
||||
AdminFocus::Button2 => {
|
||||
// --- Prepare AddTableState based on persistent selections ---
|
||||
if let Some(p_idx) = admin_state.selected_profile_index {
|
||||
if let Some(profile) = app_state.profile_tree.profiles.get(p_idx) {
|
||||
let selected_profile_name = profile.name.clone();
|
||||
|
||||
|
||||
// Create and populate the new AddTableState
|
||||
let new_add_table_state = AddTableState {
|
||||
profile_name: selected_profile_name,
|
||||
// Reset other fields to defaults for a fresh start
|
||||
..AddTableState::default()
|
||||
};
|
||||
|
||||
// Assign the prepared state
|
||||
admin_state.add_table_state = new_add_table_state;
|
||||
|
||||
// Switch view
|
||||
buffer_state.update_history(AppView::AddTable);
|
||||
app_state.ui.focus_outside_canvas = false;
|
||||
*command_message = "Navigating to Add Table page...".to_string();
|
||||
*command_message = format!(
|
||||
"Navigating to Add Table for profile '{}'...",
|
||||
admin_state.add_table_state.profile_name
|
||||
);
|
||||
|
||||
} else {
|
||||
*command_message = "Error: Selected profile index out of bounds.".to_string();
|
||||
}
|
||||
} else {
|
||||
*command_message = "Please select a profile ([*]) first.".to_string();
|
||||
}
|
||||
// --- End preparation ---
|
||||
}
|
||||
AdminFocus::Button3 => {
|
||||
*command_message = "Action: Change Table (Not Implemented)".to_string();
|
||||
|
||||
Reference in New Issue
Block a user