Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Show dev server in the titlebar for remote projects (#11276)
Conrad Irwineb0f1e71f788
diff --git a/Cargo.lock b/Cargo.lockindex 12ebae98f63..7a7b5bb5c1a 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -2359,6 +2359,7 @@ dependencies = ["pretty_assertions","project","recent_projects",+ "remote_projects","rich_text","rpc","schemars",diff --git a/crates/collab_ui/Cargo.toml b/crates/collab_ui/Cargo.tomlindex ff78b508531..f5f25ce2318 100644--- a/crates/collab_ui/Cargo.toml+++ b/crates/collab_ui/Cargo.toml@@ -50,6 +50,7 @@ parking_lot.workspace = truepicker.workspace = trueproject.workspace = truerecent_projects.workspace = true+remote_projects.workspace = truerich_text.workspace = truerpc.workspace = trueschemars.workspace = truediff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rsindex 5f9ee3a013e..23876f0ca1f 100644--- a/crates/collab_ui/src/collab_titlebar_item.rs+++ b/crates/collab_ui/src/collab_titlebar_item.rs@@ -9,12 +9,12 @@ use gpui::{};use project::{Project, RepositoryEntry};use recent_projects::RecentProjects;-use rpc::proto;+use rpc::proto::{self, DevServerStatus};use std::sync::Arc;use theme::ActiveTheme;use ui::{h_flex, popover_menu, prelude::*, Avatar, AvatarAudioStatusIndicator, Button, ButtonLike,- ButtonStyle, ContextMenu, Icon, IconButton, IconName, TintColor, TitleBar, Tooltip,+ ButtonStyle, ContextMenu, Icon, IconButton, IconName, Indicator, TintColor, TitleBar, Tooltip,};use util::ResultExt;use vcs_menu::{build_branch_list, BranchList, OpenRecent as ToggleVcsMenu};@@ -375,7 +375,41 @@ impl CollabTitlebarItem {// resolve if you are in a room -> render_project_owner// render_project_owner -> resolve if you are in a room -> Option<foo>- pub fn render_project_host(&self, cx: &mut ViewContext<Self>) -> Option<impl IntoElement> {+ pub fn render_project_host(&self, cx: &mut ViewContext<Self>) -> Option<AnyElement> {+ if let Some(dev_server) =+ self.project+ .read(cx)+ .remote_project_id()+ .and_then(|remote_project_id| {+ remote_projects::Store::global(cx)+ .read(cx)+ .dev_server_for_project(remote_project_id)+ })+ {+ return Some(+ ButtonLike::new("dev_server_trigger")+ .child(Indicator::dot().color(+ if dev_server.status == DevServerStatus::Online {+ Color::Created+ } else {+ Color::Disabled+ },+ ))+ .child(+ Label::new(dev_server.name.clone())+ .size(LabelSize::Small)+ .line_height_style(LineHeightStyle::UiLabel),+ )+ .tooltip(move |cx| Tooltip::text("Project is hosted on a dev server", cx))+ .on_click(cx.listener(|this, _, cx| {+ if let Some(workspace) = this.workspace.upgrade() {+ recent_projects::RemoteProjects::open(workspace, cx)+ }+ }))+ .into_any_element(),+ );+ }+let host = self.project.read(cx).host()?;let host_user = self.user_store.read(cx).get_cached_user(host.user_id)?;let participant_index = self@@ -406,7 +440,8 @@ impl CollabTitlebarItem {}).log_err();})- }),+ })+ .into_any_element(),)}diff --git a/crates/recent_projects/src/recent_projects.rs b/crates/recent_projects/src/recent_projects.rsindex 813f95e2126..8b26d71c581 100644--- a/crates/recent_projects/src/recent_projects.rs+++ b/crates/recent_projects/src/recent_projects.rs@@ -11,7 +11,7 @@ use picker::{highlighted_match_with_paths::{HighlightedMatchWithPaths, HighlightedText},Picker, PickerDelegate,};-use remote_projects::RemoteProjects;+pub use remote_projects::RemoteProjects;use rpc::proto::DevServerStatus;use serde::Deserialize;use std::{diff --git a/crates/recent_projects/src/remote_projects.rs b/crates/recent_projects/src/remote_projects.rsindex 61900efef77..86a2495e4ba 100644--- a/crates/recent_projects/src/remote_projects.rs+++ b/crates/recent_projects/src/remote_projects.rs@@ -60,6 +60,12 @@ impl RemoteProjects {.detach();}+ pub fn open(workspace: View<Workspace>, cx: &mut WindowContext) {+ workspace.update(cx, |workspace, cx| {+ workspace.toggle_modal(cx, |cx| Self::new(cx))+ })+ }+pub fn new(cx: &mut ViewContext<Self>) -> Self {let remote_project_path_input = cx.new_view(|cx| TextField::new(cx, "", "Project path"));let dev_server_name_input =diff --git a/crates/remote_projects/src/remote_projects.rs b/crates/remote_projects/src/remote_projects.rsindex 5e62d5c32ef..93450ef837c 100644--- a/crates/remote_projects/src/remote_projects.rs+++ b/crates/remote_projects/src/remote_projects.rs@@ -114,6 +114,11 @@ impl Store {self.remote_projects.get(&id)}+ pub fn dev_server_for_project(&self, id: RemoteProjectId) -> Option<&DevServer> {+ self.remote_project(id)+ .and_then(|project| self.dev_server(project.dev_server_id))+ }+async fn handle_remote_projects_update(this: Model<Self>,envelope: TypedEnvelope<proto::RemoteProjectsUpdate>,