Merge remote-tracking branch 'origin/main' into perf-2
This commit is contained in:
@@ -21,10 +21,7 @@ use settings::{Settings, SettingsStore};
|
||||
use std::sync::Arc;
|
||||
use theme::ActiveTheme as _;
|
||||
use time::{OffsetDateTime, UtcOffset};
|
||||
use ui::{
|
||||
h_stack, prelude::WindowContext, v_stack, Avatar, Button, ButtonCommon as _, Clickable, Icon,
|
||||
IconButton, Label, Tooltip,
|
||||
};
|
||||
use ui::{prelude::*, Avatar, Button, Icon, IconButton, Label, Tooltip};
|
||||
use util::{ResultExt, TryFutureExt};
|
||||
use workspace::{
|
||||
dock::{DockPosition, Panel, PanelEvent},
|
||||
@@ -382,13 +379,18 @@ impl ChatPanel {
|
||||
.child(text.element("body".into(), cx))
|
||||
.child(
|
||||
div()
|
||||
.invisible()
|
||||
.absolute()
|
||||
.top_1()
|
||||
.right_2()
|
||||
.w_8()
|
||||
.group_hover("", |this| this.visible())
|
||||
.child(render_remove(message_id_to_remove, cx)),
|
||||
.visible_on_hover("")
|
||||
.children(message_id_to_remove.map(|message_id| {
|
||||
IconButton::new(("remove", message_id), Icon::XCircle).on_click(
|
||||
cx.listener(move |this, _, cx| {
|
||||
this.remove_message(message_id, cx);
|
||||
}),
|
||||
)
|
||||
})),
|
||||
)
|
||||
.into_any()
|
||||
}
|
||||
@@ -528,18 +530,6 @@ impl ChatPanel {
|
||||
}
|
||||
}
|
||||
|
||||
fn render_remove(message_id_to_remove: Option<u64>, cx: &mut ViewContext<ChatPanel>) -> AnyElement {
|
||||
if let Some(message_id) = message_id_to_remove {
|
||||
IconButton::new(("remove", message_id), Icon::XCircle)
|
||||
.on_click(cx.listener(move |this, _, cx| {
|
||||
this.remove_message(message_id, cx);
|
||||
}))
|
||||
.into_any_element()
|
||||
} else {
|
||||
div().into_any_element()
|
||||
}
|
||||
}
|
||||
|
||||
impl EventEmitter<Event> for ChatPanel {}
|
||||
|
||||
impl Render for ChatPanel {
|
||||
|
||||
@@ -175,12 +175,12 @@ use editor::Editor;
|
||||
use feature_flags::{ChannelsAlpha, FeatureFlagAppExt, FeatureFlagViewExt};
|
||||
use fuzzy::{match_strings, StringMatchCandidate};
|
||||
use gpui::{
|
||||
actions, canvas, div, img, impl_actions, overlay, point, prelude::*, px, rems, serde_json,
|
||||
size, Action, AppContext, AsyncWindowContext, Bounds, ClipboardItem, DismissEvent, Div,
|
||||
EventEmitter, FocusHandle, Focusable, FocusableView, Hsla, InteractiveElement, IntoElement,
|
||||
Length, Model, MouseDownEvent, ParentElement, Pixels, Point, PromptLevel, Quad, Render,
|
||||
RenderOnce, ScrollHandle, SharedString, Size, Stateful, Styled, Subscription, Task, View,
|
||||
ViewContext, VisualContext, WeakView,
|
||||
actions, canvas, div, fill, img, impl_actions, overlay, point, prelude::*, px, rems,
|
||||
serde_json, size, Action, AnyElement, AppContext, AsyncWindowContext, Bounds, ClipboardItem,
|
||||
DismissEvent, Div, EventEmitter, FocusHandle, Focusable, FocusableView, Hsla,
|
||||
InteractiveElement, IntoElement, Length, Model, MouseDownEvent, ParentElement, Pixels, Point,
|
||||
PromptLevel, Quad, Render, RenderOnce, ScrollHandle, SharedString, Size, Stateful, Styled,
|
||||
Subscription, Task, View, ViewContext, VisualContext, WeakView,
|
||||
};
|
||||
use project::{Fs, Project};
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
@@ -402,7 +402,7 @@ impl CollabPanel {
|
||||
|
||||
let filter_editor = cx.build_view(|cx| {
|
||||
let mut editor = Editor::single_line(cx);
|
||||
editor.set_placeholder_text("Filter channels, contacts", cx);
|
||||
editor.set_placeholder_text("Filter...", cx);
|
||||
editor
|
||||
});
|
||||
|
||||
@@ -1156,25 +1156,21 @@ impl CollabPanel {
|
||||
let tooltip = format!("Follow {}", user.github_login);
|
||||
|
||||
ListItem::new(SharedString::from(user.github_login.clone()))
|
||||
.left_child(Avatar::new(user.avatar_uri.clone()))
|
||||
.child(
|
||||
h_stack()
|
||||
.w_full()
|
||||
.justify_between()
|
||||
.child(Label::new(user.github_login.clone()))
|
||||
.child(if is_pending {
|
||||
Label::new("Calling").color(Color::Muted).into_any_element()
|
||||
} else if is_current_user {
|
||||
IconButton::new("leave-call", Icon::ArrowRight)
|
||||
.on_click(cx.listener(move |this, _, cx| {
|
||||
Self::leave_call(cx);
|
||||
}))
|
||||
.tooltip(|cx| Tooltip::text("Leave Call", cx))
|
||||
.into_any_element()
|
||||
} else {
|
||||
div().into_any_element()
|
||||
}),
|
||||
)
|
||||
.start_slot(Avatar::new(user.avatar_uri.clone()))
|
||||
.child(Label::new(user.github_login.clone()))
|
||||
.end_slot(if is_pending {
|
||||
Label::new("Calling").color(Color::Muted).into_any_element()
|
||||
} else if is_current_user {
|
||||
IconButton::new("leave-call", Icon::Exit)
|
||||
.style(ButtonStyle::Subtle)
|
||||
.on_click(cx.listener(move |this, _, cx| {
|
||||
Self::leave_call(cx);
|
||||
}))
|
||||
.tooltip(|cx| Tooltip::text("Leave Call", cx))
|
||||
.into_any_element()
|
||||
} else {
|
||||
div().into_any_element()
|
||||
})
|
||||
.when_some(peer_id, |this, peer_id| {
|
||||
this.tooltip(move |cx| Tooltip::text(tooltip.clone(), cx))
|
||||
.on_click(cx.listener(move |this, _, cx| {
|
||||
@@ -1212,8 +1208,12 @@ impl CollabPanel {
|
||||
.detach_and_log_err(cx);
|
||||
});
|
||||
}))
|
||||
.left_child(render_tree_branch(is_last, cx))
|
||||
.child(IconButton::new(0, Icon::Folder))
|
||||
.start_slot(
|
||||
h_stack()
|
||||
.gap_1()
|
||||
.child(render_tree_branch(is_last, cx))
|
||||
.child(IconButton::new(0, Icon::Folder)),
|
||||
)
|
||||
.child(Label::new(project_name.clone()))
|
||||
.tooltip(move |cx| Tooltip::text(format!("Open {}", project_name), cx))
|
||||
|
||||
@@ -1305,8 +1305,12 @@ impl CollabPanel {
|
||||
let id = peer_id.map_or(usize::MAX, |id| id.as_u64() as usize);
|
||||
|
||||
ListItem::new(("screen", id))
|
||||
.left_child(render_tree_branch(is_last, cx))
|
||||
.child(IconButton::new(0, Icon::Screen))
|
||||
.start_slot(
|
||||
h_stack()
|
||||
.gap_1()
|
||||
.child(render_tree_branch(is_last, cx))
|
||||
.child(IconButton::new(0, Icon::Screen)),
|
||||
)
|
||||
.child(Label::new("Screen"))
|
||||
.when_some(peer_id, |this, _| {
|
||||
this.on_click(cx.listener(move |this, _, cx| {
|
||||
@@ -1372,9 +1376,13 @@ impl CollabPanel {
|
||||
.on_click(cx.listener(move |this, _, cx| {
|
||||
this.open_channel_notes(channel_id, cx);
|
||||
}))
|
||||
.left_child(render_tree_branch(false, cx))
|
||||
.child(IconButton::new(0, Icon::File))
|
||||
.child(Label::new("notes"))
|
||||
.start_slot(
|
||||
h_stack()
|
||||
.gap_1()
|
||||
.child(render_tree_branch(false, cx))
|
||||
.child(IconButton::new(0, Icon::File)),
|
||||
)
|
||||
.child(div().h_7().w_full().child(Label::new("notes")))
|
||||
.tooltip(move |cx| Tooltip::text("Open Channel Notes", cx))
|
||||
}
|
||||
|
||||
@@ -1387,8 +1395,12 @@ impl CollabPanel {
|
||||
.on_click(cx.listener(move |this, _, cx| {
|
||||
this.join_channel_chat(channel_id, cx);
|
||||
}))
|
||||
.left_child(render_tree_branch(true, cx))
|
||||
.child(IconButton::new(0, Icon::MessageBubbles))
|
||||
.start_slot(
|
||||
h_stack()
|
||||
.gap_1()
|
||||
.child(render_tree_branch(false, cx))
|
||||
.child(IconButton::new(0, Icon::MessageBubbles)),
|
||||
)
|
||||
.child(Label::new("chat"))
|
||||
.tooltip(move |cx| Tooltip::text("Open Chat", cx))
|
||||
}
|
||||
@@ -2149,11 +2161,6 @@ impl CollabPanel {
|
||||
fn render_signed_in(&mut self, cx: &mut ViewContext<Self>) -> Div {
|
||||
v_stack()
|
||||
.size_full()
|
||||
.child(
|
||||
div()
|
||||
.p_2()
|
||||
.child(div().rounded(px(2.0)).child(self.filter_editor.clone())),
|
||||
)
|
||||
.child(
|
||||
v_stack()
|
||||
.size_full()
|
||||
@@ -2223,6 +2230,14 @@ impl CollabPanel {
|
||||
}
|
||||
})),
|
||||
)
|
||||
.child(
|
||||
div().p_2().child(
|
||||
div()
|
||||
.border_primary(cx)
|
||||
.border_t()
|
||||
.child(self.filter_editor.clone()),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
fn render_header(
|
||||
@@ -2275,21 +2290,27 @@ impl CollabPanel {
|
||||
Section::ActiveCall => channel_link.map(|channel_link| {
|
||||
let channel_link_copy = channel_link.clone();
|
||||
IconButton::new("channel-link", Icon::Copy)
|
||||
.icon_size(IconSize::Small)
|
||||
.size(ButtonSize::None)
|
||||
.visible_on_hover("section-header")
|
||||
.on_click(move |_, cx| {
|
||||
let item = ClipboardItem::new(channel_link_copy.clone());
|
||||
cx.write_to_clipboard(item)
|
||||
})
|
||||
.tooltip(|cx| Tooltip::text("Copy channel link", cx))
|
||||
.into_any_element()
|
||||
}),
|
||||
Section::Contacts => Some(
|
||||
IconButton::new("add-contact", Icon::Plus)
|
||||
.on_click(cx.listener(|this, _, cx| this.toggle_contact_finder(cx)))
|
||||
.tooltip(|cx| Tooltip::text("Search for new contact", cx)),
|
||||
.tooltip(|cx| Tooltip::text("Search for new contact", cx))
|
||||
.into_any_element(),
|
||||
),
|
||||
Section::Channels => Some(
|
||||
IconButton::new("add-channel", Icon::Plus)
|
||||
.on_click(cx.listener(|this, _, cx| this.new_root_channel(cx)))
|
||||
.tooltip(|cx| Tooltip::text("Create a channel", cx)),
|
||||
.tooltip(|cx| Tooltip::text("Create a channel", cx))
|
||||
.into_any_element(),
|
||||
),
|
||||
_ => None,
|
||||
};
|
||||
@@ -2304,25 +2325,18 @@ impl CollabPanel {
|
||||
|
||||
h_stack()
|
||||
.w_full()
|
||||
.map(|el| {
|
||||
if can_collapse {
|
||||
el.child(
|
||||
ListItem::new(text.clone())
|
||||
.child(div().w_full().child(Label::new(text)))
|
||||
.selected(is_selected)
|
||||
.toggle(Some(!is_collapsed))
|
||||
.on_click(cx.listener(move |this, _, cx| {
|
||||
this.toggle_section_expanded(section, cx)
|
||||
})),
|
||||
)
|
||||
} else {
|
||||
el.child(
|
||||
ListHeader::new(text)
|
||||
.when_some(button, |el, button| el.meta(button))
|
||||
.selected(is_selected),
|
||||
)
|
||||
}
|
||||
})
|
||||
.group("section-header")
|
||||
.child(
|
||||
ListHeader::new(text)
|
||||
.toggle(if can_collapse {
|
||||
Some(!is_collapsed)
|
||||
} else {
|
||||
None
|
||||
})
|
||||
.inset(true)
|
||||
.end_slot::<AnyElement>(button)
|
||||
.selected(is_selected),
|
||||
)
|
||||
.when(section == Section::Channels, |el| {
|
||||
el.drag_over::<DraggedChannelView>(|style| {
|
||||
style.bg(cx.theme().colors().ghost_element_hover)
|
||||
@@ -2363,25 +2377,20 @@ impl CollabPanel {
|
||||
})
|
||||
.when(!calling, |el| {
|
||||
el.child(
|
||||
div()
|
||||
.id("remove_contact")
|
||||
.invisible()
|
||||
.group_hover("", |style| style.visible())
|
||||
.child(
|
||||
IconButton::new("remove_contact", Icon::Close)
|
||||
.icon_color(Color::Muted)
|
||||
.tooltip(|cx| Tooltip::text("Remove Contact", cx))
|
||||
.on_click(cx.listener({
|
||||
let github_login = github_login.clone();
|
||||
move |this, _, cx| {
|
||||
this.remove_contact(user_id, &github_login, cx);
|
||||
}
|
||||
})),
|
||||
),
|
||||
IconButton::new("remove_contact", Icon::Close)
|
||||
.icon_color(Color::Muted)
|
||||
.visible_on_hover("")
|
||||
.tooltip(|cx| Tooltip::text("Remove Contact", cx))
|
||||
.on_click(cx.listener({
|
||||
let github_login = github_login.clone();
|
||||
move |this, _, cx| {
|
||||
this.remove_contact(user_id, &github_login, cx);
|
||||
}
|
||||
})),
|
||||
)
|
||||
}),
|
||||
)
|
||||
.left_child(
|
||||
.start_slot(
|
||||
// todo!() handle contacts with no avatar
|
||||
Avatar::new(contact.user.avatar_uri.clone())
|
||||
.availability_indicator(if online { Some(!busy) } else { None }),
|
||||
@@ -2460,7 +2469,7 @@ impl CollabPanel {
|
||||
.child(Label::new(github_login.clone()))
|
||||
.child(h_stack().children(controls)),
|
||||
)
|
||||
.left_avatar(user.avatar_uri.clone())
|
||||
.start_slot(Avatar::new(user.avatar_uri.clone()))
|
||||
}
|
||||
|
||||
fn render_contact_placeholder(
|
||||
@@ -2541,6 +2550,8 @@ impl CollabPanel {
|
||||
div()
|
||||
.id(channel_id as usize)
|
||||
.group("")
|
||||
.flex()
|
||||
.w_full()
|
||||
.on_drag({
|
||||
let channel = channel.clone();
|
||||
move |cx| {
|
||||
@@ -2566,67 +2577,10 @@ impl CollabPanel {
|
||||
)
|
||||
.child(
|
||||
ListItem::new(channel_id as usize)
|
||||
.indent_level(depth)
|
||||
// Offset the indent depth by one to give us room to show the disclosure.
|
||||
.indent_level(depth + 1)
|
||||
.indent_step_size(cx.rem_size() * 14.0 / 16.0) // @todo()! @nate this is to step over the disclosure toggle
|
||||
.left_icon(if is_public { Icon::Public } else { Icon::Hash })
|
||||
.selected(is_selected || is_active)
|
||||
.child(
|
||||
h_stack()
|
||||
.w_full()
|
||||
.justify_between()
|
||||
.child(
|
||||
h_stack()
|
||||
.id(channel_id as usize)
|
||||
.child(Label::new(channel.name.clone()))
|
||||
.children(face_pile.map(|face_pile| face_pile.render(cx))),
|
||||
)
|
||||
.child(
|
||||
h_stack()
|
||||
.child(
|
||||
div()
|
||||
.id("channel_chat")
|
||||
.when(!has_messages_notification, |el| el.invisible())
|
||||
.group_hover("", |style| style.visible())
|
||||
.child(
|
||||
IconButton::new(
|
||||
"channel_chat",
|
||||
Icon::MessageBubbles,
|
||||
)
|
||||
.icon_color(if has_messages_notification {
|
||||
Color::Default
|
||||
} else {
|
||||
Color::Muted
|
||||
})
|
||||
.on_click(cx.listener(move |this, _, cx| {
|
||||
this.join_channel_chat(channel_id, cx)
|
||||
}))
|
||||
.tooltip(|cx| {
|
||||
Tooltip::text("Open channel chat", cx)
|
||||
}),
|
||||
),
|
||||
)
|
||||
.child(
|
||||
div()
|
||||
.id("channel_notes")
|
||||
.when(!has_notes_notification, |el| el.invisible())
|
||||
.group_hover("", |style| style.visible())
|
||||
.child(
|
||||
IconButton::new("channel_notes", Icon::File)
|
||||
.icon_color(if has_notes_notification {
|
||||
Color::Default
|
||||
} else {
|
||||
Color::Muted
|
||||
})
|
||||
.on_click(cx.listener(move |this, _, cx| {
|
||||
this.open_channel_notes(channel_id, cx)
|
||||
}))
|
||||
.tooltip(|cx| {
|
||||
Tooltip::text("Open channel notes", cx)
|
||||
}),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
.toggle(disclosed)
|
||||
.on_toggle(
|
||||
cx.listener(move |this, _, cx| {
|
||||
@@ -2646,7 +2600,49 @@ impl CollabPanel {
|
||||
move |this, event: &MouseDownEvent, cx| {
|
||||
this.deploy_channel_context_menu(event.position, channel_id, ix, cx)
|
||||
},
|
||||
)),
|
||||
))
|
||||
.start_slot(
|
||||
IconElement::new(if is_public { Icon::Public } else { Icon::Hash })
|
||||
.size(IconSize::Small)
|
||||
.color(Color::Muted),
|
||||
)
|
||||
.child(
|
||||
h_stack()
|
||||
.id(channel_id as usize)
|
||||
.child(Label::new(channel.name.clone()))
|
||||
.children(face_pile.map(|face_pile| face_pile.render(cx))),
|
||||
)
|
||||
.end_slot(
|
||||
h_stack()
|
||||
.child(
|
||||
IconButton::new("channel_chat", Icon::MessageBubbles)
|
||||
.icon_color(if has_messages_notification {
|
||||
Color::Default
|
||||
} else {
|
||||
Color::Muted
|
||||
})
|
||||
.when(!has_messages_notification, |this| {
|
||||
this.visible_on_hover("")
|
||||
})
|
||||
.on_click(cx.listener(move |this, _, cx| {
|
||||
this.join_channel_chat(channel_id, cx)
|
||||
}))
|
||||
.tooltip(|cx| Tooltip::text("Open channel chat", cx)),
|
||||
)
|
||||
.child(
|
||||
IconButton::new("channel_notes", Icon::File)
|
||||
.icon_color(if has_notes_notification {
|
||||
Color::Default
|
||||
} else {
|
||||
Color::Muted
|
||||
})
|
||||
.when(!has_notes_notification, |this| this.visible_on_hover(""))
|
||||
.on_click(cx.listener(move |this, _, cx| {
|
||||
this.open_channel_notes(channel_id, cx)
|
||||
}))
|
||||
.tooltip(|cx| Tooltip::text("Open channel notes", cx)),
|
||||
),
|
||||
),
|
||||
)
|
||||
.tooltip(|cx| Tooltip::text("Join channel", cx))
|
||||
|
||||
@@ -2962,7 +2958,11 @@ impl CollabPanel {
|
||||
let item = ListItem::new("channel-editor")
|
||||
.inset(false)
|
||||
.indent_level(depth)
|
||||
.left_icon(Icon::Hash);
|
||||
.start_slot(
|
||||
IconElement::new(Icon::Hash)
|
||||
.size(IconSize::Small)
|
||||
.color(Color::Muted),
|
||||
);
|
||||
|
||||
if let Some(pending_name) = self
|
||||
.channel_editing_state
|
||||
@@ -2994,7 +2994,7 @@ fn render_tree_branch(is_last: bool, cx: &mut WindowContext) -> impl IntoElement
|
||||
let right = bounds.right();
|
||||
let top = bounds.top();
|
||||
|
||||
cx.paint_quad(
|
||||
cx.paint_quad(fill(
|
||||
Bounds::from_corners(
|
||||
point(start_x, top),
|
||||
point(
|
||||
@@ -3002,18 +3002,12 @@ fn render_tree_branch(is_last: bool, cx: &mut WindowContext) -> impl IntoElement
|
||||
if is_last { start_y } else { bounds.bottom() },
|
||||
),
|
||||
),
|
||||
Default::default(),
|
||||
color,
|
||||
Default::default(),
|
||||
Hsla::transparent_black(),
|
||||
);
|
||||
cx.paint_quad(
|
||||
));
|
||||
cx.paint_quad(fill(
|
||||
Bounds::from_corners(point(start_x, start_y), point(right, start_y + thickness)),
|
||||
Default::default(),
|
||||
color,
|
||||
Default::default(),
|
||||
Hsla::transparent_black(),
|
||||
);
|
||||
));
|
||||
})
|
||||
.w(width)
|
||||
.h(line_height)
|
||||
|
||||
@@ -2,10 +2,10 @@ use crate::face_pile::FacePile;
|
||||
use call::{ActiveCall, ParticipantLocation, Room};
|
||||
use client::{proto::PeerId, Client, ParticipantIndex, User, UserStore};
|
||||
use gpui::{
|
||||
actions, canvas, div, overlay, point, px, rems, AppContext, DismissEvent, Div, Element,
|
||||
FocusableView, Hsla, InteractiveElement, IntoElement, Model, ParentElement, Path, Render,
|
||||
Stateful, StatefulInteractiveElement, Styled, Subscription, ViewContext, VisualContext,
|
||||
WeakView, WindowBounds,
|
||||
actions, canvas, div, overlay, point, px, rems, AnyElement, AppContext, DismissEvent, Div,
|
||||
Element, FocusableView, Hsla, InteractiveElement, IntoElement, Model, ParentElement, Path,
|
||||
Render, Stateful, StatefulInteractiveElement, Styled, Subscription, View, ViewContext,
|
||||
VisualContext, WeakView, WindowBounds,
|
||||
};
|
||||
use project::{Project, RepositoryEntry};
|
||||
use recent_projects::RecentProjects;
|
||||
@@ -13,9 +13,10 @@ use std::sync::Arc;
|
||||
use theme::{ActiveTheme, PlayerColors};
|
||||
use ui::{
|
||||
h_stack, popover_menu, prelude::*, Avatar, Button, ButtonLike, ButtonStyle, ContextMenu, Icon,
|
||||
IconButton, IconElement, KeyBinding, Tooltip,
|
||||
IconButton, IconElement, Tooltip,
|
||||
};
|
||||
use util::ResultExt;
|
||||
use vcs_menu::{build_branch_list, BranchList, OpenRecent as ToggleVcsMenu};
|
||||
use workspace::{notifications::NotifyResultExt, Workspace, WORKSPACE_DB};
|
||||
|
||||
const MAX_PROJECT_NAME_LENGTH: usize = 40;
|
||||
@@ -50,7 +51,7 @@ pub struct CollabTitlebarItem {
|
||||
user_store: Model<UserStore>,
|
||||
client: Arc<Client>,
|
||||
workspace: WeakView<Workspace>,
|
||||
//branch_popover: Option<ViewHandle<BranchList>>,
|
||||
branch_popover: Option<View<BranchList>>,
|
||||
project_popover: Option<recent_projects::RecentProjects>,
|
||||
//user_menu: ViewHandle<ContextMenu>,
|
||||
_subscriptions: Vec<Subscription>,
|
||||
@@ -329,7 +330,7 @@ impl CollabTitlebarItem {
|
||||
// menu.set_position_mode(OverlayPositionMode::Local);
|
||||
// menu
|
||||
// }),
|
||||
// branch_popover: None,
|
||||
branch_popover: None,
|
||||
project_popover: None,
|
||||
_subscriptions: subscriptions,
|
||||
}
|
||||
@@ -408,23 +409,25 @@ impl CollabTitlebarItem {
|
||||
.map(|branch| util::truncate_and_trailoff(&branch, MAX_BRANCH_NAME_LENGTH))?;
|
||||
|
||||
Some(
|
||||
div().border().border_color(gpui::red()).child(
|
||||
Button::new("project_branch_trigger", branch_name)
|
||||
.style(ButtonStyle::Subtle)
|
||||
.tooltip(move |cx| {
|
||||
cx.build_view(|_| {
|
||||
Tooltip::new("Recent Branches")
|
||||
.key_binding(KeyBinding::new(gpui::KeyBinding::new(
|
||||
"cmd-b",
|
||||
// todo!() Replace with real action.
|
||||
gpui::NoAction,
|
||||
None,
|
||||
)))
|
||||
.meta("Local branches only")
|
||||
div()
|
||||
.border()
|
||||
.border_color(gpui::red())
|
||||
.child(
|
||||
Button::new("project_branch_trigger", branch_name)
|
||||
.style(ButtonStyle::Subtle)
|
||||
.tooltip(move |cx| {
|
||||
Tooltip::with_meta(
|
||||
"Recent Branches",
|
||||
Some(&ToggleVcsMenu),
|
||||
"Local branches only",
|
||||
cx,
|
||||
)
|
||||
})
|
||||
.into()
|
||||
}),
|
||||
),
|
||||
.on_click(
|
||||
cx.listener(|this, _, cx| this.toggle_vcs_menu(&ToggleVcsMenu, cx)),
|
||||
),
|
||||
)
|
||||
.children(self.render_branches_popover_host()),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -503,131 +506,34 @@ impl CollabTitlebarItem {
|
||||
.log_err();
|
||||
}
|
||||
|
||||
// pub fn toggle_user_menu(&mut self, _: &ToggleUserMenu, cx: &mut ViewContext<Self>) {
|
||||
// self.user_menu.update(cx, |user_menu, cx| {
|
||||
// let items = if let Some(_) = self.user_store.read(cx).current_user() {
|
||||
// vec![
|
||||
// ContextMenuItem::action("Settings", zed_actions::OpenSettings),
|
||||
// ContextMenuItem::action("Theme", theme_selector::Toggle),
|
||||
// ContextMenuItem::separator(),
|
||||
// ContextMenuItem::action(
|
||||
// "Share Feedback",
|
||||
// feedback::feedback_editor::GiveFeedback,
|
||||
// ),
|
||||
// ContextMenuItem::action("Sign Out", SignOut),
|
||||
// ]
|
||||
// } else {
|
||||
// vec![
|
||||
// ContextMenuItem::action("Settings", zed_actions::OpenSettings),
|
||||
// ContextMenuItem::action("Theme", theme_selector::Toggle),
|
||||
// ContextMenuItem::separator(),
|
||||
// ContextMenuItem::action(
|
||||
// "Share Feedback",
|
||||
// feedback::feedback_editor::GiveFeedback,
|
||||
// ),
|
||||
// ]
|
||||
// };
|
||||
// user_menu.toggle(Default::default(), AnchorCorner::TopRight, items, cx);
|
||||
// });
|
||||
// }
|
||||
fn render_branches_popover_host<'a>(&'a self) -> Option<AnyElement> {
|
||||
self.branch_popover.as_ref().map(|child| {
|
||||
overlay()
|
||||
.child(div().min_w_64().child(child.clone()))
|
||||
.into_any()
|
||||
})
|
||||
}
|
||||
|
||||
// fn render_branches_popover_host<'a>(
|
||||
// &'a self,
|
||||
// _theme: &'a theme::Titlebar,
|
||||
// cx: &'a mut ViewContext<Self>,
|
||||
// ) -> Option<AnyElement<Self>> {
|
||||
// self.branch_popover.as_ref().map(|child| {
|
||||
// let theme = theme::current(cx).clone();
|
||||
// let child = ChildView::new(child, cx);
|
||||
// let child = MouseEventHandler::new::<BranchList, _>(0, cx, |_, _| {
|
||||
// child
|
||||
// .flex(1., true)
|
||||
// .contained()
|
||||
// .constrained()
|
||||
// .with_width(theme.titlebar.menu.width)
|
||||
// .with_height(theme.titlebar.menu.height)
|
||||
// })
|
||||
// .on_click(MouseButton::Left, |_, _, _| {})
|
||||
// .on_down_out(MouseButton::Left, move |_, this, cx| {
|
||||
// this.branch_popover.take();
|
||||
// cx.emit(());
|
||||
// cx.notify();
|
||||
// })
|
||||
// .contained()
|
||||
// .into_any();
|
||||
pub fn toggle_vcs_menu(&mut self, _: &ToggleVcsMenu, cx: &mut ViewContext<Self>) {
|
||||
if self.branch_popover.take().is_none() {
|
||||
if let Some(workspace) = self.workspace.upgrade() {
|
||||
let Some(view) = build_branch_list(workspace, cx).log_err() else {
|
||||
return;
|
||||
};
|
||||
cx.subscribe(&view, |this, _, _, cx| {
|
||||
this.branch_popover = None;
|
||||
cx.notify();
|
||||
})
|
||||
.detach();
|
||||
self.project_popover.take();
|
||||
let focus_handle = view.focus_handle(cx);
|
||||
cx.focus(&focus_handle);
|
||||
self.branch_popover = Some(view);
|
||||
}
|
||||
}
|
||||
|
||||
// Overlay::new(child)
|
||||
// .with_fit_mode(OverlayFitMode::SwitchAnchor)
|
||||
// .with_anchor_corner(AnchorCorner::TopLeft)
|
||||
// .with_z_index(999)
|
||||
// .aligned()
|
||||
// .bottom()
|
||||
// .left()
|
||||
// .into_any()
|
||||
// })
|
||||
// }
|
||||
|
||||
// fn render_project_popover_host<'a>(
|
||||
// &'a self,
|
||||
// _theme: &'a theme::Titlebar,
|
||||
// cx: &'a mut ViewContext<Self>,
|
||||
// ) -> Option<AnyElement<Self>> {
|
||||
// self.project_popover.as_ref().map(|child| {
|
||||
// let theme = theme::current(cx).clone();
|
||||
// let child = ChildView::new(child, cx);
|
||||
// let child = MouseEventHandler::new::<RecentProjects, _>(0, cx, |_, _| {
|
||||
// child
|
||||
// .flex(1., true)
|
||||
// .contained()
|
||||
// .constrained()
|
||||
// .with_width(theme.titlebar.menu.width)
|
||||
// .with_height(theme.titlebar.menu.height)
|
||||
// })
|
||||
// .on_click(MouseButton::Left, |_, _, _| {})
|
||||
// .on_down_out(MouseButton::Left, move |_, this, cx| {
|
||||
// this.project_popover.take();
|
||||
// cx.emit(());
|
||||
// cx.notify();
|
||||
// })
|
||||
// .into_any();
|
||||
|
||||
// Overlay::new(child)
|
||||
// .with_fit_mode(OverlayFitMode::SwitchAnchor)
|
||||
// .with_anchor_corner(AnchorCorner::TopLeft)
|
||||
// .with_z_index(999)
|
||||
// .aligned()
|
||||
// .bottom()
|
||||
// .left()
|
||||
// .into_any()
|
||||
// })
|
||||
// }
|
||||
|
||||
// pub fn toggle_vcs_menu(&mut self, _: &ToggleVcsMenu, cx: &mut ViewContext<Self>) {
|
||||
// if self.branch_popover.take().is_none() {
|
||||
// if let Some(workspace) = self.workspace.upgrade(cx) {
|
||||
// let Some(view) =
|
||||
// cx.add_option_view(|cx| build_branch_list(workspace, cx).log_err())
|
||||
// else {
|
||||
// return;
|
||||
// };
|
||||
// cx.subscribe(&view, |this, _, event, cx| {
|
||||
// match event {
|
||||
// PickerEvent::Dismiss => {
|
||||
// this.branch_popover = None;
|
||||
// }
|
||||
// }
|
||||
|
||||
// cx.notify();
|
||||
// })
|
||||
// .detach();
|
||||
// self.project_popover.take();
|
||||
// cx.focus(&view);
|
||||
// self.branch_popover = Some(view);
|
||||
// }
|
||||
// }
|
||||
|
||||
// cx.notify();
|
||||
// }
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
pub fn toggle_project_menu(&mut self, _: &ToggleProjectMenu, cx: &mut ViewContext<Self>) {
|
||||
let workspace = self.workspace.clone();
|
||||
|
||||
@@ -34,7 +34,7 @@ pub fn init(app_state: &Arc<AppState>, cx: &mut AppContext) {
|
||||
ChatPanelSettings::register(cx);
|
||||
NotificationPanelSettings::register(cx);
|
||||
|
||||
// vcs_menu::init(cx);
|
||||
vcs_menu::init(cx);
|
||||
collab_titlebar_item::init(cx);
|
||||
collab_panel::init(cx);
|
||||
channel_view::init(cx);
|
||||
|
||||
Reference in New Issue
Block a user