From 4ea7a24b93a535cb0d26e509a9b26363aced181b Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Thu, 16 Feb 2023 14:41:03 -0800 Subject: [PATCH] Made the 'update zed to collaborate' button clickable --- Cargo.lock | 1 + crates/collab_ui/Cargo.toml | 1 + crates/collab_ui/src/collab_titlebar_item.rs | 25 +++++++++++++------- crates/zed/src/zed.rs | 9 +++---- 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index abf9a12f0e..e45ed5c433 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1253,6 +1253,7 @@ name = "collab_ui" version = "0.1.0" dependencies = [ "anyhow", + "auto_update", "call", "client", "clock", diff --git a/crates/collab_ui/Cargo.toml b/crates/collab_ui/Cargo.toml index ac13e361fd..2dc4cc769a 100644 --- a/crates/collab_ui/Cargo.toml +++ b/crates/collab_ui/Cargo.toml @@ -22,6 +22,7 @@ test-support = [ ] [dependencies] +auto_update = { path = "../auto_update" } call = { path = "../call" } client = { path = "../client" } clock = { path = "../clock" } diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index 9f2c0fbee9..184a432ea3 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -504,7 +504,9 @@ impl CollabTitlebarItem { workspace: &ViewHandle, cx: &mut RenderContext, ) -> Option { - let theme = &cx.global::().theme; + enum ConnectionStatusButton {} + + let theme = &cx.global::().theme.clone(); match &*workspace.read(cx).client().status().borrow() { client::Status::ConnectionError | client::Status::ConnectionLost @@ -527,13 +529,20 @@ impl CollabTitlebarItem { .boxed(), ), client::Status::UpgradeRequired => Some( - Label::new( - "Please update Zed to collaborate".to_string(), - theme.workspace.titlebar.outdated_warning.text.clone(), - ) - .contained() - .with_style(theme.workspace.titlebar.outdated_warning.container) - .aligned() + MouseEventHandler::::new(0, cx, |_, _| { + Label::new( + "Please update Zed to collaborate".to_string(), + theme.workspace.titlebar.outdated_warning.text.clone(), + ) + .contained() + .with_style(theme.workspace.titlebar.outdated_warning.container) + .aligned() + .boxed() + }) + .with_cursor_style(CursorStyle::PointingHand) + .on_click(MouseButton::Left, |_, cx| { + cx.dispatch_action(auto_update::Check); + }) .boxed(), ), _ => None, diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index d6e8a1a4be..7be2818b61 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -408,17 +408,19 @@ pub fn build_window_options( } fn restart(_: &Restart, cx: &mut gpui::MutableAppContext) { - let cli_process = dbg!(cx.platform().path_for_auxiliary_executable("cli")) + let cli_process = cx + .platform() + .path_for_auxiliary_executable("cli") .log_err() .and_then(|path| { Command::new(path) - .args(["--restart-from", &format!("{}", dbg!(std::process::id()))]) + .args(["--restart-from", &format!("{}", std::process::id())]) .spawn() .log_err() }); cx.spawn(|mut cx| async move { - let did_quit = dbg!(cx.update(quit).await?); + let did_quit = cx.update(quit).await?; if !did_quit { if let Some(mut cli_process) = cli_process { cli_process.kill().log_err(); @@ -467,7 +469,6 @@ fn quit(cx: &mut gpui::MutableAppContext) -> Task> { return Ok(false); } } - dbg!("about to quit"); cx.platform().quit(); anyhow::Ok(true) })