Skip to content

DesignCraft: An open-source page and layout design editor written by scratch in pure Rust

fix(ui): the status bar's error count opens the Preflight panel

pepenba0b0ec1104d
diff --git a/crates/ui-egui/src/chrome.rs b/crates/ui-egui/src/chrome.rs
index 439fb3932..5855b3f9a 100644
--- a/crates/ui-egui/src/chrome.rs
+++ b/crates/ui-egui/src/chrome.rs
@@ -709,22 +709,21 @@ pub fn status_bar(app: &mut DesignApp, ui: &mut egui::Ui) {
4.0,
if errors == 0 { Color32::from_rgb(60, 200, 90) } else { Color32::from_rgb(235, 50, 50) },
);
- crate::rtl::label(
- ui,
- egui::RichText::new(if errors == 0 {
- format!("{} ▾", crate::i18n::tr(&app.ui.language, "No errors"))
- } else {
- format!(
- "{} ▾",
- crate::i18n::count_label(
- &app.ui.language,
- if errors == 1 && app.ui.language != "uk" { "error" } else { "errors" },
- errors
- )
- )
- })
- .font(small.clone()),
- );
+ let count = if errors == 0 {
+ format!("{} ▾", crate::i18n::tr(&app.ui.language, "No errors"))
+ } else {
+ format!(
+ "{} ▾",
+ crate::i18n::count_label(&app.ui.language, if errors == 1 && app.ui.language != "uk" { "error" } else { "errors" }, errors)
+ )
+ };
+ // As in InDesign, the count opens a menu that leads to the Preflight panel.
+ crate::menus::menu_button(ui, egui::RichText::new(count).font(small.clone()), |ui| {
+ if ui.button(crate::i18n::tr(&app.ui.language, "Preflight Panel…")).clicked() {
+ let _ = app.run("window.panel", json!({"panel": "preflight"}));
+ ui.close();
+ }
+ });
ui.add_space(12.0);
ui.label(egui::RichText::new(&app.ui.status).font(small).color(t.text_dim));
});
@@ -899,6 +898,22 @@ mod tests {
h.get_by_label(label).rect()
}
+ /// The status bar's preflight count is a menu; its Preflight Panel entry shows the panel.
+ #[test]
+ fn status_bar_error_count_opens_the_preflight_panel() {
+ let mut app = app();
+ app.run("file.new", serde_json::json!({})).unwrap();
+ app.ui.dock_tab = "properties".into();
+ let mut h = test_window::open(app, vec2(1200.0, 700.0));
+ h.get_by_label("No errors ▾").click();
+ h.run_steps(3);
+ h.get_by_label("Preflight Panel…").click();
+ h.run_steps(3);
+ // Preflight is not a dock tab: `window.panel` shows it as its own panel.
+ assert_eq!(h.state().app.ui.open_panel.as_deref(), Some("preflight"));
+ h.get_by_label("Preflight");
+ }
+
/// A very long document name made its tab grow past the window, hiding the close button
/// and the tabs after it (#603).
#[test]
diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rs
index a35261d59..229ced6eb 100644
--- a/crates/ui-egui/src/menus.rs
+++ b/crates/ui-egui/src/menus.rs
@@ -162,7 +162,7 @@ pub const UI_COMMANDS: &[(&str, &str, Option<&str>, &str)] = &[
"window.panel",
"Show Panel",
None,
- "{panel: properties|pages|layers|swatches|paragraphStyles|characterStyles|stroke|character|paragraph|textWrap|links|table}",
+ "{panel: properties|pages|layers|swatches|paragraphStyles|characterStyles|stroke|character|paragraph|textWrap|links|table|preflight}",
),
("window.floatPanel", "Float Panel", None, "{panel, x?, y?} — the panel in its own movable window"),
(