mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-29 13:44:43 +00:00
Scaffold out render_project_owner
Co-Authored-By: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
This commit is contained in:
parent
e20309f560
commit
8d4652a4db
1 changed files with 68 additions and 17 deletions
|
@ -38,8 +38,8 @@ use gpui::{
|
||||||
use project::Project;
|
use project::Project;
|
||||||
use theme::ActiveTheme;
|
use theme::ActiveTheme;
|
||||||
use ui::{
|
use ui::{
|
||||||
h_stack, prelude::*, v_stack, Avatar, Button, ButtonLike, ButtonStyle2, Icon, IconButton,
|
h_stack, prelude::*, Avatar, Button, ButtonLike, ButtonStyle2, Icon, IconButton, IconElement,
|
||||||
IconElement, KeyBinding, List, ListItem, PopoverMenu, Tooltip,
|
KeyBinding, Tooltip,
|
||||||
};
|
};
|
||||||
use util::ResultExt;
|
use util::ResultExt;
|
||||||
use workspace::{notifications::NotifyResultExt, Workspace};
|
use workspace::{notifications::NotifyResultExt, Workspace};
|
||||||
|
@ -150,21 +150,24 @@ impl Render for CollabTitlebarItem {
|
||||||
.child(
|
.child(
|
||||||
h_stack()
|
h_stack()
|
||||||
.gap_1()
|
.gap_1()
|
||||||
// TODO - Add player menu
|
|
||||||
.when(is_in_room, |this| {
|
.when(is_in_room, |this| {
|
||||||
this.child(
|
this.children(self.render_project_owner(cx))
|
||||||
div()
|
|
||||||
.border()
|
|
||||||
.border_color(gpui::red())
|
|
||||||
.id("project_owner_indicator")
|
|
||||||
.child(
|
|
||||||
Button::new("project_owner", "project_owner")
|
|
||||||
.style(ButtonStyle2::Subtle)
|
|
||||||
.color(Some(Color::Player(0))),
|
|
||||||
)
|
|
||||||
.tooltip(move |cx| Tooltip::text("Toggle following", cx)),
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
// TODO - Add player menu
|
||||||
|
// .when(is_in_room, |this| {
|
||||||
|
// this.child(
|
||||||
|
// div()
|
||||||
|
// .border()
|
||||||
|
// .border_color(gpui::red())
|
||||||
|
// .id("project_owner_indicator")
|
||||||
|
// .child(
|
||||||
|
// Button::new("project_owner", "project_owner")
|
||||||
|
// .style(ButtonStyle2::Subtle)
|
||||||
|
// .color(Some(Color::Player(0))),
|
||||||
|
// )
|
||||||
|
// .tooltip(move |cx| Tooltip::text("Toggle following", cx)),
|
||||||
|
// )
|
||||||
|
// })
|
||||||
// TODO - Add project menu
|
// TODO - Add project menu
|
||||||
.child(
|
.child(
|
||||||
div()
|
div()
|
||||||
|
@ -274,14 +277,14 @@ impl Render for CollabTitlebarItem {
|
||||||
.child(
|
.child(
|
||||||
IconButton::new(
|
IconButton::new(
|
||||||
"mute-microphone",
|
"mute-microphone",
|
||||||
if is_muted.clone() {
|
if is_muted {
|
||||||
ui::Icon::MicMute
|
ui::Icon::MicMute
|
||||||
} else {
|
} else {
|
||||||
ui::Icon::Mic
|
ui::Icon::Mic
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.style(ButtonStyle2::Subtle)
|
.style(ButtonStyle2::Subtle)
|
||||||
.selected(is_muted.clone())
|
.selected(is_muted)
|
||||||
.on_click({
|
.on_click({
|
||||||
let workspace = workspace.clone();
|
let workspace = workspace.clone();
|
||||||
move |_, cx| {
|
move |_, cx| {
|
||||||
|
@ -476,6 +479,54 @@ 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_owner(&self, cx: &mut ViewContext<Self>) -> Option<impl Element> {
|
||||||
|
// TODO: We can't finish implementing this until project sharing works
|
||||||
|
// - [ ] Show the project owner when the project is remote (maybe done)
|
||||||
|
// - [x] Show the project owner when the project is local
|
||||||
|
// - [ ] Show the project owner with a lock icon when the project is local and unshared
|
||||||
|
|
||||||
|
let remote_id = self.project.read(cx).remote_id();
|
||||||
|
let is_local = remote_id.is_none();
|
||||||
|
let is_shared = self.project.read(cx).is_shared();
|
||||||
|
let (user_name, participant_index) = {
|
||||||
|
if let Some(host) = self.project.read(cx).host() {
|
||||||
|
debug_assert!(!is_local);
|
||||||
|
let (Some(host_user), Some(participant_index)) = (
|
||||||
|
self.user_store.read(cx).get_cached_user(host.user_id),
|
||||||
|
self.user_store
|
||||||
|
.read(cx)
|
||||||
|
.participant_indices()
|
||||||
|
.get(&host.user_id),
|
||||||
|
) else {
|
||||||
|
return None;
|
||||||
|
};
|
||||||
|
(host_user.github_login.clone(), participant_index.0)
|
||||||
|
} else {
|
||||||
|
debug_assert!(is_local);
|
||||||
|
let name = self
|
||||||
|
.user_store
|
||||||
|
.read(cx)
|
||||||
|
.current_user()
|
||||||
|
.map(|user| user.github_login.clone())?;
|
||||||
|
(name, 0)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Some(
|
||||||
|
Button::new(
|
||||||
|
"project_owner_trigger",
|
||||||
|
format!("{user_name} ({})", !is_shared),
|
||||||
|
)
|
||||||
|
.color(Color::Player(participant_index))
|
||||||
|
.style(ButtonStyle2::Subtle)
|
||||||
|
.into_element(),
|
||||||
|
)
|
||||||
|
|
||||||
|
// add lock if you are in a locked project
|
||||||
|
}
|
||||||
|
|
||||||
// fn collect_title_root_names(
|
// fn collect_title_root_names(
|
||||||
// &self,
|
// &self,
|
||||||
// theme: Arc<Theme>,
|
// theme: Arc<Theme>,
|
||||||
|
|
Loading…
Reference in a new issue