Made the 'update zed to collaborate' button clickable

Mikayla Maki created

Change summary

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(-)

Detailed changes

Cargo.lock 🔗

@@ -1253,6 +1253,7 @@ name = "collab_ui"
 version = "0.1.0"
 dependencies = [
  "anyhow",
+ "auto_update",
  "call",
  "client",
  "clock",

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" }

crates/collab_ui/src/collab_titlebar_item.rs 🔗

@@ -504,7 +504,9 @@ impl CollabTitlebarItem {
         workspace: &ViewHandle<Workspace>,
         cx: &mut RenderContext<Self>,
     ) -> Option<ElementBox> {
-        let theme = &cx.global::<Settings>().theme;
+        enum ConnectionStatusButton {}
+
+        let theme = &cx.global::<Settings>().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::<ConnectionStatusButton>::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,

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<Result<bool>> {
                 return Ok(false);
             }
         }
-        dbg!("about to quit");
         cx.platform().quit();
         anyhow::Ok(true)
     })