mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-09 12:01:58 +00:00
Show dev server in the titlebar for remote projects (#11276)
Co-Authored-By: Mikayla <mikayla@zed.dev> Release Notes: - Show server name in the titlebar for remote projects Co-authored-by: Mikayla <mikayla@zed.dev>
This commit is contained in:
parent
74f8ef0364
commit
eb0f1e71f7
6 changed files with 53 additions and 5 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -2359,6 +2359,7 @@ dependencies = [
|
||||||
"pretty_assertions",
|
"pretty_assertions",
|
||||||
"project",
|
"project",
|
||||||
"recent_projects",
|
"recent_projects",
|
||||||
|
"remote_projects",
|
||||||
"rich_text",
|
"rich_text",
|
||||||
"rpc",
|
"rpc",
|
||||||
"schemars",
|
"schemars",
|
||||||
|
|
|
@ -50,6 +50,7 @@ parking_lot.workspace = true
|
||||||
picker.workspace = true
|
picker.workspace = true
|
||||||
project.workspace = true
|
project.workspace = true
|
||||||
recent_projects.workspace = true
|
recent_projects.workspace = true
|
||||||
|
remote_projects.workspace = true
|
||||||
rich_text.workspace = true
|
rich_text.workspace = true
|
||||||
rpc.workspace = true
|
rpc.workspace = true
|
||||||
schemars.workspace = true
|
schemars.workspace = true
|
||||||
|
|
|
@ -9,12 +9,12 @@ use gpui::{
|
||||||
};
|
};
|
||||||
use project::{Project, RepositoryEntry};
|
use project::{Project, RepositoryEntry};
|
||||||
use recent_projects::RecentProjects;
|
use recent_projects::RecentProjects;
|
||||||
use rpc::proto;
|
use rpc::proto::{self, DevServerStatus};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use theme::ActiveTheme;
|
use theme::ActiveTheme;
|
||||||
use ui::{
|
use ui::{
|
||||||
h_flex, popover_menu, prelude::*, Avatar, AvatarAudioStatusIndicator, Button, ButtonLike,
|
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 util::ResultExt;
|
||||||
use vcs_menu::{build_branch_list, BranchList, OpenRecent as ToggleVcsMenu};
|
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
|
// resolve if you are in a room -> render_project_owner
|
||||||
// render_project_owner -> resolve if you are in a room -> Option<foo>
|
// 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 = self.project.read(cx).host()?;
|
||||||
let host_user = self.user_store.read(cx).get_cached_user(host.user_id)?;
|
let host_user = self.user_store.read(cx).get_cached_user(host.user_id)?;
|
||||||
let participant_index = self
|
let participant_index = self
|
||||||
|
@ -406,7 +440,8 @@ impl CollabTitlebarItem {
|
||||||
})
|
})
|
||||||
.log_err();
|
.log_err();
|
||||||
})
|
})
|
||||||
}),
|
})
|
||||||
|
.into_any_element(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ use picker::{
|
||||||
highlighted_match_with_paths::{HighlightedMatchWithPaths, HighlightedText},
|
highlighted_match_with_paths::{HighlightedMatchWithPaths, HighlightedText},
|
||||||
Picker, PickerDelegate,
|
Picker, PickerDelegate,
|
||||||
};
|
};
|
||||||
use remote_projects::RemoteProjects;
|
pub use remote_projects::RemoteProjects;
|
||||||
use rpc::proto::DevServerStatus;
|
use rpc::proto::DevServerStatus;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::{
|
use std::{
|
||||||
|
|
|
@ -60,6 +60,12 @@ impl RemoteProjects {
|
||||||
.detach();
|
.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 {
|
pub fn new(cx: &mut ViewContext<Self>) -> Self {
|
||||||
let remote_project_path_input = cx.new_view(|cx| TextField::new(cx, "", "Project path"));
|
let remote_project_path_input = cx.new_view(|cx| TextField::new(cx, "", "Project path"));
|
||||||
let dev_server_name_input =
|
let dev_server_name_input =
|
||||||
|
|
|
@ -114,6 +114,11 @@ impl Store {
|
||||||
self.remote_projects.get(&id)
|
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(
|
async fn handle_remote_projects_update(
|
||||||
this: Model<Self>,
|
this: Model<Self>,
|
||||||
envelope: TypedEnvelope<proto::RemoteProjectsUpdate>,
|
envelope: TypedEnvelope<proto::RemoteProjectsUpdate>,
|
||||||
|
|
Loading…
Reference in a new issue