Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
ui: Make `Callout` constructors more flexible (#29895)
Marshall Bowers3e2abbf53b5c
diff --git a/crates/agent/src/message_editor.rs b/crates/agent/src/message_editor.rsindex 3e4e1ce9f6f..5c88769f992 100644--- a/crates/agent/src/message_editor.rs+++ b/crates/agent/src/message_editor.rs@@ -1093,10 +1093,10 @@ impl MessageEditor {Some(div().child(ui::Callout::multi_line(- title.into(),- message.into(),+ title,+ message,icon,- "Start New Thread".into(),+ "Start New Thread",Box::new(cx.listener(|this, _, window, cx| {let from_thread_id = Some(this.thread.read(cx).id().clone());window.dispatch_action(Box::new(NewThread { from_thread_id }), cx);diff --git a/crates/agent/src/ui/preview/usage_callouts.rs b/crates/agent/src/ui/preview/usage_callouts.rsindex 17ef7914b60..6ebe0fdd88e 100644--- a/crates/agent/src/ui/preview/usage_callouts.rs+++ b/crates/agent/src/ui/preview/usage_callouts.rs@@ -93,10 +93,10 @@ impl RenderOnce for UsageCallout {};Callout::multi_line(- title.into(),- message.into(),+ title,+ message,icon,- button_text.into(),+ button_text,Box::new(move |_, _, cx| {cx.open_url(url);}),diff --git a/crates/ui/src/components/callout.rs b/crates/ui/src/components/callout.rsindex fc2d122486e..9e632ce8336 100644--- a/crates/ui/src/components/callout.rs+++ b/crates/ui/src/components/callout.rs@@ -1,6 +1,7 @@-use crate::prelude::*;use gpui::ClickEvent;+use crate::prelude::*;+#[derive(IntoElement, RegisterComponent)]pub struct Callout {title: SharedString,@@ -13,33 +14,33 @@ pub struct Callout {impl Callout {pub fn single_line(- title: SharedString,+ title: impl Into<SharedString>,icon: Icon,- cta_label: SharedString,+ cta_label: impl Into<SharedString>,cta_action: Box<dyn Fn(&ClickEvent, &mut Window, &mut App) + 'static>,) -> Self {Self {- title,+ title: title.into(),message: None,icon,- cta_label,+ cta_label: cta_label.into(),cta_action,line_height: None,}}pub fn multi_line(- title: SharedString,- message: SharedString,+ title: impl Into<SharedString>,+ message: impl Into<SharedString>,icon: Icon,- cta_label: SharedString,+ cta_label: impl Into<SharedString>,cta_action: Box<dyn Fn(&ClickEvent, &mut Window, &mut App) + 'static>,) -> Self {Self {- title,- message: Some(message),+ title: title.into(),+ message: Some(message.into()),icon,- cta_label,+ cta_label: cta_label.into(),cta_action,line_height: None,}@@ -127,11 +128,11 @@ impl Component for Callout {single_example("Single Line",Callout::single_line(- "Your settings contain deprecated values, please update them.".into(),+ "Your settings contain deprecated values, please update them.",Icon::new(IconName::Warning).color(Color::Warning).size(IconSize::Small),- "Backup & Update".into(),+ "Backup & Update",Box::new(|_, _, _| {}),).into_any_element(),@@ -140,12 +141,12 @@ impl Component for Callout {single_example("Multi Line",Callout::multi_line(- "Thread reached the token limit".into(),- "Start a new thread from a summary to continue the conversation.".into(),+ "Thread reached the token limit",+ "Start a new thread from a summary to continue the conversation.",Icon::new(IconName::X).color(Color::Error).size(IconSize::Small),- "Start New Thread".into(),+ "Start New Thread",Box::new(|_, _, _| {}),).into_any_element(),