From 64181d4bb2071d2ff8d74ba726e89dffcb585c2c Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Fri, 21 Feb 2025 17:41:31 +0100 Subject: [PATCH] Style some more --- crates/diagnostics/src/diagnostics.rs | 35 +++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/crates/diagnostics/src/diagnostics.rs b/crates/diagnostics/src/diagnostics.rs index edede83ff0acd8..70fa68fb8a5c05 100644 --- a/crates/diagnostics/src/diagnostics.rs +++ b/crates/diagnostics/src/diagnostics.rs @@ -36,7 +36,7 @@ use std::{ }; use theme::ActiveTheme; pub use toolbar_controls::ToolbarControls; -use ui::{h_flex, prelude::*, Icon, IconName, Label}; +use ui::{h_flex, prelude::*, Icon, IconName, Label, TintColor}; use util::ResultExt; use workspace::{ item::{BreadcrumbText, Item, ItemEvent, ItemHandle, TabContentParams}, @@ -95,14 +95,39 @@ impl Render for ProjectDiagnosticsEditor { }; let child = if warning_count + self.summary.error_count == 0 { - div() + let label = if self.summary.warning_count == 0 { + SharedString::new_static("No problems in workspace") + } else { + SharedString::new_static("No errors in workspace") + }; + v_flex() + .gap_1() .key_context("EmptyPane") .bg(cx.theme().colors().editor_background) - .flex() - .items_center() .justify_center() + .items_center() .size_full() - .child(Label::new("No problems in workspace")) + .child(h_flex().items_center().child(Label::new(label))) + .when(self.summary.warning_count > 0, |this| { + let plural_suffix = if self.summary.warning_count > 1 { + "s" + } else { + "" + }; + let label = format!( + "Show {} warning{}", + self.summary.warning_count, plural_suffix + ); + this.child( + Button::new("diagnostics-show-warning-label", label) + .size(ButtonSize::Compact) + .style(ButtonStyle::Tinted(TintColor::Warning)) + .on_click(cx.listener(|this, _, window, cx| { + this.toggle_warnings(&Default::default(), window, cx); + cx.notify(); + })), + ) + }) } else { div().size_full().child(self.editor.clone()) };