diff --git a/crates/project_panel/src/undo.rs b/crates/project_panel/src/undo.rs index ca4fc9ed375..787d71b9f42 100644 --- a/crates/project_panel/src/undo.rs +++ b/crates/project_panel/src/undo.rs @@ -138,7 +138,7 @@ use gpui::{AppContext, AsyncApp, SharedString, Task, WeakEntity}; use project::{ProjectPath, WorktreeId}; use std::sync::atomic::{AtomicBool, Ordering}; use std::{collections::VecDeque, sync::Arc}; -use ui::App; +use ui::{App, Severity}; use workspace::{ Workspace, notifications::{NotificationId, simple_message_notification::MessageNotification}, @@ -550,7 +550,11 @@ impl Inner { NotificationId::Named(SharedString::new_static("project_panel_undo")); workspace.show_notification(notification_id, cx, move |cx| { - cx.new(|cx| MessageNotification::new(error, cx).with_title(title)) + cx.new(|cx| { + MessageNotification::new(error, cx) + .severity(Severity::Error) + .with_title(title) + }) }) }) .ok(); diff --git a/crates/workspace/src/notifications.rs b/crates/workspace/src/notifications.rs index ffe70b8301b..b70c05024ce 100644 --- a/crates/workspace/src/notifications.rs +++ b/crates/workspace/src/notifications.rs @@ -748,6 +748,8 @@ pub mod simple_message_notification { show_suppress_button: bool, title: Option, scroll_handle: ScrollHandle, + text_to_copy: Option, + severity: Severity, } impl Focusable for MessageNotification { @@ -767,9 +769,11 @@ pub mod simple_message_notification { S: Into, { let message = message.into(); + let text_to_copy = message.clone(); Self::new_from_builder(cx, move |_, _| { Label::new(message.clone()).into_any_element() }) + .text_to_copy(text_to_copy) } pub fn new_from_builder(cx: &mut App, content: F) -> MessageNotification @@ -793,9 +797,24 @@ pub mod simple_message_notification { title: None, focus_handle: cx.focus_handle(), scroll_handle: ScrollHandle::new(), + text_to_copy: None, + severity: Severity::Info, } } + pub fn severity(mut self, severity: Severity) -> Self { + self.severity = severity; + self + } + + pub fn text_to_copy(mut self, text: S) -> Self + where + S: Into, + { + self.text_to_copy = Some(text.into()); + self + } + pub fn primary_message(mut self, message: S) -> Self where S: Into, @@ -933,6 +952,17 @@ pub mod simple_message_notification { .with_suffix( h_flex() .gap_1() + .when_some( + matches!(self.severity, Severity::Error | Severity::Warning) + .then(|| self.text_to_copy.clone()) + .flatten(), + |this, text| { + this.child( + ui::CopyButton::new("copy-notification-message", text) + .tooltip_label("Copy Message"), + ) + }, + ) .children(self.primary_message.iter().map(|message| { let mut button = Button::new(message.clone(), message.clone()) .label_size(LabelSize::Small) diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index dbb18703c53..65074e95a01 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -8326,6 +8326,7 @@ fn notify_if_database_failed(window: WindowHandle, cx: &mut Asyn |cx| { cx.new(|cx| { MessageNotification::new("Failed to load the database file.", cx) + .severity(Severity::Error) .primary_message("File an Issue") .primary_icon(IconName::Plus) .primary_on_click(|window, cx| { diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index f9c04b7c910..fcaf14a802a 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -1739,6 +1739,7 @@ fn open_log_file(workspace: &mut Workspace, window: &mut Window, cx: &mut Contex ), cx, ) + .severity(Severity::Error) }) }, ); @@ -1816,6 +1817,7 @@ fn notify_settings_errors(result: settings::SettingsParseResult, is_user: bool, show_app_notification(id, cx, move |cx| { cx.new(|cx| { MessageNotification::new(format!("Invalid user settings file\n{error}"), cx) + .severity(Severity::Error) .primary_message("Open Settings File") .primary_icon(IconName::Settings) .primary_on_click(|window, cx| { @@ -1852,6 +1854,7 @@ fn notify_settings_errors(result: settings::SettingsParseResult, is_user: bool, ), cx, ) + .severity(Severity::Error) .primary_message("Open Settings File") .primary_icon(IconName::Settings) .primary_on_click(|window, cx| { @@ -2055,6 +2058,7 @@ fn show_keymap_file_json_error( show_app_notification(notification_id, cx, move |cx| { cx.new(|cx| { MessageNotification::new(message.clone(), cx) + .severity(Severity::Error) .primary_message("Open Keymap File") .primary_icon(IconName::Settings) .primary_on_click(|window, cx| {