Move install_cli function to a seperate crate
Add install cli button to welcome experience Add toast pop ups for CLI installation status
This commit is contained in:
parent
1f6bd0ea77
commit
8db7e17ac5
12 changed files with 142 additions and 64 deletions
|
@ -122,6 +122,8 @@ impl Workspace {
|
|||
|
||||
pub mod simple_message_notification {
|
||||
|
||||
use std::borrow::Cow;
|
||||
|
||||
use gpui::{
|
||||
actions,
|
||||
elements::{Flex, MouseEventHandler, Padding, ParentElement, Svg, Text},
|
||||
|
@ -153,9 +155,9 @@ pub mod simple_message_notification {
|
|||
}
|
||||
|
||||
pub struct MessageNotification {
|
||||
message: String,
|
||||
message: Cow<'static, str>,
|
||||
click_action: Option<Box<dyn Action>>,
|
||||
click_message: Option<String>,
|
||||
click_message: Option<Cow<'static, str>>,
|
||||
}
|
||||
|
||||
pub enum MessageNotificationEvent {
|
||||
|
@ -167,23 +169,23 @@ pub mod simple_message_notification {
|
|||
}
|
||||
|
||||
impl MessageNotification {
|
||||
pub fn new_message<S: AsRef<str>>(message: S) -> MessageNotification {
|
||||
pub fn new_message<S: Into<Cow<'static, str>>>(message: S) -> MessageNotification {
|
||||
Self {
|
||||
message: message.as_ref().to_string(),
|
||||
message: message.into(),
|
||||
click_action: None,
|
||||
click_message: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new<S1: AsRef<str>, A: Action, S2: AsRef<str>>(
|
||||
pub fn new<S1: Into<Cow<'static, str>>, A: Action, S2: Into<Cow<'static, str>>>(
|
||||
message: S1,
|
||||
click_action: A,
|
||||
click_message: S2,
|
||||
) -> Self {
|
||||
Self {
|
||||
message: message.as_ref().to_string(),
|
||||
message: message.into(),
|
||||
click_action: Some(Box::new(click_action) as Box<dyn Action>),
|
||||
click_message: Some(click_message.as_ref().to_string()),
|
||||
click_message: Some(click_message.into()),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -210,6 +212,8 @@ pub mod simple_message_notification {
|
|||
let click_message = self.click_message.as_ref().map(|message| message.clone());
|
||||
let message = self.message.clone();
|
||||
|
||||
let has_click_action = click_action.is_some();
|
||||
|
||||
MouseEventHandler::<MessageNotificationTag>::new(0, cx, |state, cx| {
|
||||
Flex::column()
|
||||
.with_child(
|
||||
|
@ -243,6 +247,7 @@ pub mod simple_message_notification {
|
|||
.on_click(MouseButton::Left, move |_, cx| {
|
||||
cx.dispatch_action(CancelMessageNotification)
|
||||
})
|
||||
.with_cursor_style(CursorStyle::PointingHand)
|
||||
.aligned()
|
||||
.constrained()
|
||||
.with_height(
|
||||
|
@ -272,12 +277,19 @@ pub mod simple_message_notification {
|
|||
.contained()
|
||||
.boxed()
|
||||
})
|
||||
.with_cursor_style(CursorStyle::PointingHand)
|
||||
// Since we're not using a proper overlay, we have to capture these extra events
|
||||
.on_down(MouseButton::Left, |_, _| {})
|
||||
.on_up(MouseButton::Left, |_, _| {})
|
||||
.on_click(MouseButton::Left, move |_, cx| {
|
||||
if let Some(click_action) = click_action.as_ref() {
|
||||
cx.dispatch_any_action(click_action.boxed_clone())
|
||||
}
|
||||
})
|
||||
.with_cursor_style(if has_click_action {
|
||||
CursorStyle::PointingHand
|
||||
} else {
|
||||
CursorStyle::Arrow
|
||||
})
|
||||
.boxed()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue