use crate::ui::{Model, theme};
pub const NO_RUN: &str = "nobody has signed in to this row here";
pub const BY_HAND: &str = "run it by hand, on the box that holds this wall:";
pub fn render(ui: &mut egui::Ui, model: &Model, name: &str) {
if model.following().as_deref() != Some(name) {
return;
}
let Some(run) = model.signin.clone() else {
return;
};
if run.lines.is_empty() && !run.settled() {
ui.label(NO_RUN);
return;
}
for line in &run.lines {
let ink = if line.err {
theme::NOTICE
} else {
theme::tone_ink(&crate::reply::convs::Tone::Plain)
};
ui.colored_label(ink, line.text.clone());
}
if let Some(exit) = run.outcome {
ui.label(settled(exit));
}
if let Some(command) = &run.fallback {
ui.label(BY_HAND);
ui.colored_label(theme::tone_ink(&crate::reply::convs::Tone::Weak), command);
}
}
pub fn settled(exit: i32) -> String {
if exit == 0 {
"signed in".to_owned()
} else {
format!("the sign-in ended with status {exit}")
}
}
#[cfg(test)]
mod tests;