diff --git a/crates/rundown-converter/src/gui.rs b/crates/rundown-converter/src/gui.rs index 62cb830..17a35d7 100644 --- a/crates/rundown-converter/src/gui.rs +++ b/crates/rundown-converter/src/gui.rs @@ -22,6 +22,7 @@ enum Update { Sheets(Vec), Analyzed(Box, Table, Box), Exported(PathBuf), + ExportFailed(String), Failed(String), } #[derive(Default, PartialEq)] @@ -161,6 +162,7 @@ struct App { tab: Tab, status: String, error: Option, + export_error: bool, rx: Option>, cancel: Arc, overwrite: bool, @@ -223,6 +225,7 @@ impl Default for App { tab: Tab::Setup, status: "Choose a spreadsheet to begin".into(), error: None, + export_error: false, rx: None, cancel: Arc::new(AtomicBool::new(false)), overwrite: false, @@ -270,6 +273,7 @@ impl App { self.show_issue_details = false; self.completed = None; self.error = None; + self.export_error = false; } fn set_input(&mut self, path: PathBuf) { self.tab = Tab::Setup; @@ -303,6 +307,7 @@ impl App { self.rx = Some(rx); self.cancel = Arc::new(AtomicBool::new(false)); self.error = None; + self.export_error = false; self.completed = None; tx } @@ -394,9 +399,17 @@ impl App { } } + fn export_failed(&mut self, message: String) { + self.error = Some(message); + self.export_error = true; + self.completed = None; + self.tab = Tab::Results; + self.status = "Export needs attention".into(); + } + fn export(&mut self) { if self.dirty { - self.error = Some("Apply & recheck your changes before exporting".into()); + self.export_failed("Apply & recheck your changes before exporting".into()); return; } let Some(a) = self.analysis.clone() else { @@ -411,7 +424,7 @@ impl App { extension.eq_ignore_ascii_case(self.export_choice.file_extension()) }) { - self.error = Some(format!( + self.export_failed(format!( "{} requires a .{} filename", self.export_choice.label(), self.export_choice.file_extension() @@ -427,7 +440,7 @@ impl App { let result = export::write(&a, &input, &output, neutral, overwrite, &cancel); let _ = tx.send(match result { Ok(()) => Update::Exported(output), - Err(e) => Update::Failed(format!("{e:#}")), + Err(e) => Update::ExportFailed(format!("{e:#}")), }); }); } @@ -492,6 +505,10 @@ impl App { self.tab = Tab::Results; self.status = "File ready".into(); } + Update::ExportFailed(e) => { + self.rx = None; + self.export_failed(e); + } Update::Failed(e) => { self.rx = None; self.error = Some(e); @@ -978,6 +995,45 @@ impl App { } } Tab::Results => { + if self.export_error { + let color = Color32::from_rgb(245, 125, 120); + review::issue_frame(color).show(ui, |ui| { + ui.label(RichText::new("! Export could not be completed").color(color).strong()); + ui.indent("export_error", |ui| { + let error = self.error.as_deref().unwrap_or_default(); + let exists = error == "Output exists; use --overwrite or choose another path"; + ui.add(egui::Label::new(if exists { "A file already exists at the selected output path." } else { error }).wrap()); + ui.strong("Next step"); + ui.add(egui::Label::new(if exists { + "Enable Replace existing output below, or change the destination, then retry." + } else { + "Resolve the problem above, check the destination, then retry." + }).wrap()); + }); + }); + ui.label(self.export_choice.label()); + ui.add( + egui::TextEdit::singleline(&mut self.output).desired_width(f32::INFINITY), + ); + ui.checkbox(&mut self.overwrite, "Replace existing output"); + ui.horizontal_wrapped(|ui| { + if ui + .add_enabled(self.export_ready(), egui::Button::new("Retry export")) + .clicked() + { + self.export(); + } + if ui + .add_enabled(self.export_ready(), egui::Button::new("Save elsewhere…")) + .clicked() + { + self.export_as(self.export_choice); + } + if self.dirty && ui.button("Review changes…").clicked() { + self.tab = Tab::Review; + } + }); + } if let Some(p) = &self.completed { ui.heading("Export ready"); ui.add(egui::Label::new(p.display().to_string()).wrap()); @@ -1004,7 +1060,7 @@ impl App { } else { "Import the .ontime.json project in Ontime. Review the schedule before running the show." }).wrap()); - } else { + } else if !self.export_error { ui.label("No export published yet."); } ui.add_space(8.0); @@ -1066,7 +1122,7 @@ impl App { }); }); egui::TopBottomPanel::bottom("action").show(ctx, |ui| { - if let Some(e) = &self.error { + if let Some(e) = &self.error && !self.export_error { let color = Color32::from_rgb(245, 125, 120); review::issue_frame(color).show(ui, |ui| { ui.label( @@ -1316,6 +1372,25 @@ mod tests { app.export(); wait(&mut app); assert!(app.error.as_ref().unwrap().contains("exists")); + assert!(app.tab == Tab::Results); + assert!(app.export_error); + assert!(!app.overwrite); + let labels = frame(&mut app, 860.0, 620.0); + for text in [ + "! Export could not be completed", + "Replace existing output", + "Retry export", + "Save elsewhere…", + ] { + assert!(labels.iter().any(|label| label == text)); + } + assert!(!labels.iter().any(|label| label.contains("--overwrite"))); + app.overwrite = true; + app.export(); + wait(&mut app); + assert!(app.error.is_none()); + assert!(!app.export_error); + assert!(app.completed.as_ref().unwrap().exists()); app.tab = Tab::Setup; app.profile = "not json".into(); app.analyze(); diff --git a/crates/rundown-converter/src/gui/review.rs b/crates/rundown-converter/src/gui/review.rs index 8f9ac79..ceadec6 100644 --- a/crates/rundown-converter/src/gui/review.rs +++ b/crates/rundown-converter/src/gui/review.rs @@ -3933,7 +3933,10 @@ mod tests { app.export(); assert!(app.rx.is_none()); assert!(app.error.as_ref().unwrap().contains("recheck")); + assert!(app.tab == Tab::Results); app.error = None; + app.export_error = false; + app.tab = Tab::Review; app.choose_issue(8); assert_eq!(app.selected_row, Some(11)); render(&mut app, &ctx, [560.0, 400.0], vec![]); diff --git a/docs/rundown-converter.md b/docs/rundown-converter.md index 3cf8c83..297d50f 100644 --- a/docs/rundown-converter.md +++ b/docs/rundown-converter.md @@ -114,8 +114,9 @@ visually distinct from labels and ordinary actions; the active tab uses the stro While scrolling is needed, the bars stay visible rather than fading away. The export confirmation wraps paths and instructions without a horizontal scrollbar; a vertical scrollbar appears only if the content exceeds the window. - If an output file already exists, **Go to output settings…** opens Setup and - focuses **Replace existing output**. Enable it explicitly or choose another filename. + Failed exports open **Results**, with the error, destination, **Replace existing + output**, **Retry export**, and **Save elsewhere…** together. Enable replacement + explicitly or choose another filename; retrying clears the error on success. Preview cells align at the top; blank title lines are omitted without changing original values in the inspector or exports. On narrow windows, timing values stack so corrections remain accessible. The table reserves space