diff --git a/crates/ui-egui/src/backstage.rs b/crates/ui-egui/src/backstage.rs index a1605c66a4..d3fd4a4ccc 100644 --- a/crates/ui-egui/src/backstage.rs +++ b/crates/ui-egui/src/backstage.rs @@ -55,6 +55,17 @@ fn back_chevron_c(band_min_x: f32, center_y: f32, fullscreen: bool, content_left pos2(band_min_x + x, center_y) } +/// The bottom of the backstage menu: About, and the community link unless the user turned the +/// community button off — the title bar pill honors the same setting, so the menu hides the +/// link with it. +fn bottom_links(app: &WordApp) -> Vec<(&'static str, &'static str)> { + let mut links = vec![("About", "about")]; + if app.ui.show_discord { + links.push(("Discord community", "discord")); + } + links +} + /// Draws the Backstage side menu and the active page. Without a document only the Home, New, Open /// and Options pages work, and it handles Back, Escape, Save, Save As and Close routing. pub fn show(app: &mut WordApp, ui: &mut Ui) { @@ -155,7 +166,7 @@ pub fn show(app: &mut WordApp, ui: &mut Ui) { } } ui.with_layout(egui::Layout::bottom_up(egui::Align::Min), |ui| { - for (label, id) in [("About", "about"), ("Discord community", "discord")] { + for (label, id) in bottom_links(app) { let (r, resp) = ui.allocate_exact_size(vec2(200.0, 32.0), Sense::click()); resp.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, ui.is_enabled(), tl!(label))); if resp.hovered() { diff --git a/crates/ui-egui/src/tests.rs b/crates/ui-egui/src/tests.rs index c8103b6e6b..32136193d2 100644 --- a/crates/ui-egui/src/tests.rs +++ b/crates/ui-egui/src/tests.rs @@ -590,6 +590,25 @@ fn title_and_account_buttons_work() { assert!(h.query_by_label("User name:").is_some()); } +/// The Options toggle hides the community pill in the title bar; the backstage menu's +/// Discord link hides with it — one setting, everywhere the link shows. +#[test] +fn the_community_button_off_hides_the_backstage_discord_link_too() { + use egui_kittest::kittest::Queryable; + let mut a = app(); + a.run("ui.backstage", json!({"value": true})).unwrap(); + let mut h = harness(a); + h.run_steps(2); + assert!(h.query_by_label("Discord community").is_some(), "the community link shows by default"); + + let mut a = app(); + a.ui.show_discord = false; + a.run("ui.backstage", json!({"value": true})).unwrap(); + let mut h = harness(a); + h.run_steps(2); + assert!(h.query_by_label("Discord community").is_none(), "the backstage link honors the same setting"); +} + /// File › Options › Advanced › Editing: alignment guides are a UI command, on by default and /// kept between runs. #[test]