mirror of
https://github.com/zed-industries/zed.git
synced 2026-06-01 03:14:56 +07:00
Merge dde52301f9 into 09165c15dc
This commit is contained in:
commit
0c1e69486a
4 changed files with 41 additions and 2 deletions
|
|
@ -138,7 +138,7 @@ use gpui::{AppContext, AsyncApp, SharedString, Task, WeakEntity};
|
||||||
use project::{ProjectPath, WorktreeId};
|
use project::{ProjectPath, WorktreeId};
|
||||||
use std::sync::atomic::{AtomicBool, Ordering};
|
use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
use std::{collections::VecDeque, sync::Arc};
|
use std::{collections::VecDeque, sync::Arc};
|
||||||
use ui::App;
|
use ui::{App, Severity};
|
||||||
use workspace::{
|
use workspace::{
|
||||||
Workspace,
|
Workspace,
|
||||||
notifications::{NotificationId, simple_message_notification::MessageNotification},
|
notifications::{NotificationId, simple_message_notification::MessageNotification},
|
||||||
|
|
@ -550,7 +550,11 @@ impl Inner {
|
||||||
NotificationId::Named(SharedString::new_static("project_panel_undo"));
|
NotificationId::Named(SharedString::new_static("project_panel_undo"));
|
||||||
|
|
||||||
workspace.show_notification(notification_id, cx, move |cx| {
|
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();
|
.ok();
|
||||||
|
|
|
||||||
|
|
@ -748,6 +748,8 @@ pub mod simple_message_notification {
|
||||||
show_suppress_button: bool,
|
show_suppress_button: bool,
|
||||||
title: Option<SharedString>,
|
title: Option<SharedString>,
|
||||||
scroll_handle: ScrollHandle,
|
scroll_handle: ScrollHandle,
|
||||||
|
text_to_copy: Option<SharedString>,
|
||||||
|
severity: Severity,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Focusable for MessageNotification {
|
impl Focusable for MessageNotification {
|
||||||
|
|
@ -767,9 +769,11 @@ pub mod simple_message_notification {
|
||||||
S: Into<SharedString>,
|
S: Into<SharedString>,
|
||||||
{
|
{
|
||||||
let message = message.into();
|
let message = message.into();
|
||||||
|
let text_to_copy = message.clone();
|
||||||
Self::new_from_builder(cx, move |_, _| {
|
Self::new_from_builder(cx, move |_, _| {
|
||||||
Label::new(message.clone()).into_any_element()
|
Label::new(message.clone()).into_any_element()
|
||||||
})
|
})
|
||||||
|
.text_to_copy(text_to_copy)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_from_builder<F>(cx: &mut App, content: F) -> MessageNotification
|
pub fn new_from_builder<F>(cx: &mut App, content: F) -> MessageNotification
|
||||||
|
|
@ -793,9 +797,24 @@ pub mod simple_message_notification {
|
||||||
title: None,
|
title: None,
|
||||||
focus_handle: cx.focus_handle(),
|
focus_handle: cx.focus_handle(),
|
||||||
scroll_handle: ScrollHandle::new(),
|
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<S>(mut self, text: S) -> Self
|
||||||
|
where
|
||||||
|
S: Into<SharedString>,
|
||||||
|
{
|
||||||
|
self.text_to_copy = Some(text.into());
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
pub fn primary_message<S>(mut self, message: S) -> Self
|
pub fn primary_message<S>(mut self, message: S) -> Self
|
||||||
where
|
where
|
||||||
S: Into<SharedString>,
|
S: Into<SharedString>,
|
||||||
|
|
@ -933,6 +952,17 @@ pub mod simple_message_notification {
|
||||||
.with_suffix(
|
.with_suffix(
|
||||||
h_flex()
|
h_flex()
|
||||||
.gap_1()
|
.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| {
|
.children(self.primary_message.iter().map(|message| {
|
||||||
let mut button = Button::new(message.clone(), message.clone())
|
let mut button = Button::new(message.clone(), message.clone())
|
||||||
.label_size(LabelSize::Small)
|
.label_size(LabelSize::Small)
|
||||||
|
|
|
||||||
|
|
@ -8326,6 +8326,7 @@ fn notify_if_database_failed(window: WindowHandle<MultiWorkspace>, cx: &mut Asyn
|
||||||
|cx| {
|
|cx| {
|
||||||
cx.new(|cx| {
|
cx.new(|cx| {
|
||||||
MessageNotification::new("Failed to load the database file.", cx)
|
MessageNotification::new("Failed to load the database file.", cx)
|
||||||
|
.severity(Severity::Error)
|
||||||
.primary_message("File an Issue")
|
.primary_message("File an Issue")
|
||||||
.primary_icon(IconName::Plus)
|
.primary_icon(IconName::Plus)
|
||||||
.primary_on_click(|window, cx| {
|
.primary_on_click(|window, cx| {
|
||||||
|
|
|
||||||
|
|
@ -1739,6 +1739,7 @@ fn open_log_file(workspace: &mut Workspace, window: &mut Window, cx: &mut Contex
|
||||||
),
|
),
|
||||||
cx,
|
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| {
|
show_app_notification(id, cx, move |cx| {
|
||||||
cx.new(|cx| {
|
cx.new(|cx| {
|
||||||
MessageNotification::new(format!("Invalid user settings file\n{error}"), cx)
|
MessageNotification::new(format!("Invalid user settings file\n{error}"), cx)
|
||||||
|
.severity(Severity::Error)
|
||||||
.primary_message("Open Settings File")
|
.primary_message("Open Settings File")
|
||||||
.primary_icon(IconName::Settings)
|
.primary_icon(IconName::Settings)
|
||||||
.primary_on_click(|window, cx| {
|
.primary_on_click(|window, cx| {
|
||||||
|
|
@ -1852,6 +1854,7 @@ fn notify_settings_errors(result: settings::SettingsParseResult, is_user: bool,
|
||||||
),
|
),
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
|
.severity(Severity::Error)
|
||||||
.primary_message("Open Settings File")
|
.primary_message("Open Settings File")
|
||||||
.primary_icon(IconName::Settings)
|
.primary_icon(IconName::Settings)
|
||||||
.primary_on_click(|window, cx| {
|
.primary_on_click(|window, cx| {
|
||||||
|
|
@ -2055,6 +2058,7 @@ fn show_keymap_file_json_error(
|
||||||
show_app_notification(notification_id, cx, move |cx| {
|
show_app_notification(notification_id, cx, move |cx| {
|
||||||
cx.new(|cx| {
|
cx.new(|cx| {
|
||||||
MessageNotification::new(message.clone(), cx)
|
MessageNotification::new(message.clone(), cx)
|
||||||
|
.severity(Severity::Error)
|
||||||
.primary_message("Open Keymap File")
|
.primary_message("Open Keymap File")
|
||||||
.primary_icon(IconName::Settings)
|
.primary_icon(IconName::Settings)
|
||||||
.primary_on_click(|window, cx| {
|
.primary_on_click(|window, cx| {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue