chore: reformat

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Edward Langley
2026-03-31 00:07:22 -07:00
parent 37584670eb
commit 183b2350f7
17 changed files with 1112 additions and 471 deletions

View File

@ -5,8 +5,8 @@ use ratatui::{
widgets::{Block, Borders, Clear, Widget},
};
use crate::import::wizard::{ImportWizard, WizardStep};
use crate::import::analyzer::FieldKind;
use crate::import::wizard::{ImportWizard, WizardStep};
pub struct ImportWizardWidget<'a> {
pub wizard: &'a ImportWizard,
@ -52,20 +52,31 @@ impl<'a> Widget for ImportWizardWidget<'a> {
let summary = self.wizard.pipeline.preview_summary();
buf.set_string(x, y, truncate(&summary, w), Style::default());
y += 2;
buf.set_string(x, y,
buf.set_string(
x,
y,
"Press Enter to continue\u{2026}",
Style::default().fg(Color::Yellow));
Style::default().fg(Color::Yellow),
);
}
WizardStep::SelectArrayPath => {
buf.set_string(x, y,
buf.set_string(
x,
y,
"Select the path containing records:",
Style::default().fg(Color::Yellow));
Style::default().fg(Color::Yellow),
);
y += 1;
for (i, path) in self.wizard.pipeline.array_paths.iter().enumerate() {
if y >= inner.y + inner.height { break; }
if y >= inner.y + inner.height {
break;
}
let is_sel = i == self.wizard.cursor;
let style = if is_sel {
Style::default().fg(Color::Black).bg(Color::Magenta).add_modifier(Modifier::BOLD)
Style::default()
.fg(Color::Black)
.bg(Color::Magenta)
.add_modifier(Modifier::BOLD)
} else {
Style::default()
};
@ -74,19 +85,36 @@ impl<'a> Widget for ImportWizardWidget<'a> {
y += 1;
}
y += 1;
buf.set_string(x, y, "\u{2191}\u{2193} select Enter confirm", Style::default().fg(Color::DarkGray));
buf.set_string(
x,
y,
"\u{2191}\u{2193} select Enter confirm",
Style::default().fg(Color::DarkGray),
);
}
WizardStep::ReviewProposals => {
buf.set_string(x, y,
buf.set_string(
x,
y,
"Review field proposals (Space toggle, c cycle kind):",
Style::default().fg(Color::Yellow));
Style::default().fg(Color::Yellow),
);
y += 1;
let header = format!(" {:<20} {:<22} {:<6}", "Field", "Kind", "Accept");
buf.set_string(x, y, truncate(&header, w), Style::default().fg(Color::Gray).add_modifier(Modifier::UNDERLINED));
buf.set_string(
x,
y,
truncate(&header, w),
Style::default()
.fg(Color::Gray)
.add_modifier(Modifier::UNDERLINED),
);
y += 1;
for (i, proposal) in self.wizard.pipeline.proposals.iter().enumerate() {
if y >= inner.y + inner.height - 2 { break; }
if y >= inner.y + inner.height - 2 {
break;
}
let is_sel = i == self.wizard.cursor;
let kind_color = match proposal.kind {
@ -96,14 +124,23 @@ impl<'a> Widget for ImportWizardWidget<'a> {
FieldKind::Label => Color::DarkGray,
};
let accept_str = if proposal.accepted { "[\u{2713}]" } else { "[ ]" };
let row = format!(" {:<20} {:<22} {}",
let accept_str = if proposal.accepted {
"[\u{2713}]"
} else {
"[ ]"
};
let row = format!(
" {:<20} {:<22} {}",
truncate(&proposal.field, 20),
truncate(proposal.kind_label(), 22),
accept_str);
accept_str
);
let style = if is_sel {
Style::default().fg(Color::Black).bg(Color::Cyan).add_modifier(Modifier::BOLD)
Style::default()
.fg(Color::Black)
.bg(Color::Cyan)
.add_modifier(Modifier::BOLD)
} else if proposal.accepted {
Style::default().fg(kind_color)
} else {
@ -114,23 +151,34 @@ impl<'a> Widget for ImportWizardWidget<'a> {
y += 1;
}
let hint_y = inner.y + inner.height - 1;
buf.set_string(x, hint_y, "Enter: next Space: toggle c: cycle kind Esc: cancel",
Style::default().fg(Color::DarkGray));
buf.set_string(
x,
hint_y,
"Enter: next Space: toggle c: cycle kind Esc: cancel",
Style::default().fg(Color::DarkGray),
);
}
WizardStep::NameModel => {
buf.set_string(x, y, "Model name:", Style::default().fg(Color::Yellow));
y += 1;
let name_str = format!("> {}\u{2588}", self.wizard.pipeline.model_name);
buf.set_string(x, y, truncate(&name_str, w),
Style::default().fg(Color::Green));
buf.set_string(
x,
y,
truncate(&name_str, w),
Style::default().fg(Color::Green),
);
y += 2;
buf.set_string(x, y, "Enter to import, Esc to cancel",
Style::default().fg(Color::DarkGray));
buf.set_string(
x,
y,
"Enter to import, Esc to cancel",
Style::default().fg(Color::DarkGray),
);
if let Some(msg) = &self.wizard.message {
let msg_y = inner.y + inner.height - 1;
buf.set_string(x, msg_y, truncate(msg, w),
Style::default().fg(Color::Red));
buf.set_string(x, msg_y, truncate(msg, w), Style::default().fg(Color::Red));
}
}
WizardStep::Done => {
@ -141,7 +189,11 @@ impl<'a> Widget for ImportWizardWidget<'a> {
}
fn truncate(s: &str, max: usize) -> String {
if s.len() <= max { s.to_string() }
else if max > 1 { format!("{}\u{2026}", &s[..max-1]) }
else { s[..max].to_string() }
if s.len() <= max {
s.to_string()
} else if max > 1 {
format!("{}\u{2026}", &s[..max - 1])
} else {
s[..max].to_string()
}
}