Vcs menu2 (#3648)
Header and footer are gonna be added in a separate PR as they require changes to Picker trait that I feel are separate from the contents of this PR. Release Notes: - N/A
This commit is contained in:
@@ -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